2020-03-12 14:29:21 +01:00
|
|
|
<template>
|
2020-02-18 08:57:00 +01:00
|
|
|
<aside class="section container">
|
|
|
|
<h1 class="title">{{ $t("Settings") }}</h1>
|
|
|
|
<div class="columns">
|
|
|
|
<SettingsMenu class="column is-one-quarter-desktop" :menu="menu" />
|
|
|
|
<div class="column">
|
|
|
|
<nav class="breadcrumb" aria-label="breadcrumbs">
|
|
|
|
<ul>
|
|
|
|
<li
|
|
|
|
v-for="route in routes.get($route.name)"
|
|
|
|
:class="{ 'is-active': route.to.name === $route.name }"
|
|
|
|
:key="route.to.name"
|
|
|
|
>
|
|
|
|
<router-link :to="{ name: route.to.name }">{{ route.title }}</router-link>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</nav>
|
|
|
|
<router-view />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</aside>
|
2020-03-12 14:29:21 +01:00
|
|
|
</template>
|
|
|
|
<script lang="ts">
|
2020-02-18 08:57:00 +01:00
|
|
|
import { Component, Vue, Watch } from "vue-property-decorator";
|
|
|
|
import { Route } from "vue-router";
|
|
|
|
import SettingsMenu from "../components/Settings/SettingsMenu.vue";
|
|
|
|
import RouteName from "../router/name";
|
|
|
|
import { ISettingMenuSection } from "../types/setting-menu.model";
|
|
|
|
import { IPerson, Person } from "../types/actor";
|
|
|
|
import { IDENTITIES } from "../graphql/actor";
|
2020-03-12 14:29:21 +01:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
components: { SettingsMenu },
|
|
|
|
apollo: {
|
|
|
|
identities: {
|
|
|
|
query: IDENTITIES,
|
2020-02-18 08:57:00 +01:00
|
|
|
update: (data) => data.identities.map((identity: IPerson) => new Person(identity)),
|
2020-03-12 14:29:21 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
export default class Settings extends Vue {
|
|
|
|
RouteName = RouteName;
|
|
|
|
|
|
|
|
menu: ISettingMenuSection[] = [];
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2020-03-12 14:29:21 +01:00
|
|
|
identities!: IPerson[];
|
2020-02-18 08:57:00 +01:00
|
|
|
|
2020-03-12 14:29:21 +01:00
|
|
|
newIdentity!: ISettingMenuSection;
|
|
|
|
|
|
|
|
mounted() {
|
|
|
|
this.newIdentity = {
|
2020-02-18 08:57:00 +01:00
|
|
|
title: this.$t("New profile") as string,
|
2020-03-12 14:29:21 +01:00
|
|
|
to: { name: RouteName.CREATE_IDENTITY } as Route,
|
|
|
|
};
|
|
|
|
this.menu = [
|
|
|
|
{
|
2020-02-18 08:57:00 +01:00
|
|
|
title: this.$t("Account") as string,
|
2020-03-12 14:29:21 +01:00
|
|
|
to: { name: RouteName.ACCOUNT_SETTINGS } as Route,
|
|
|
|
items: [
|
|
|
|
{
|
2020-02-18 08:57:00 +01:00
|
|
|
title: this.$t("General") as string,
|
2020-03-12 14:29:21 +01:00
|
|
|
to: { name: RouteName.ACCOUNT_SETTINGS_GENERAL } as Route,
|
|
|
|
},
|
|
|
|
{
|
2020-02-18 08:57:00 +01:00
|
|
|
title: this.$t("Preferences") as string,
|
2020-03-12 14:29:21 +01:00
|
|
|
to: { name: RouteName.PREFERENCES } as Route,
|
|
|
|
},
|
|
|
|
{
|
2020-02-18 08:57:00 +01:00
|
|
|
title: this.$t("Notifications") as string,
|
2020-03-12 14:29:21 +01:00
|
|
|
to: { name: RouteName.NOTIFICATIONS } as Route,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
2020-02-18 08:57:00 +01:00
|
|
|
title: this.$t("Profiles") as string,
|
2020-03-12 14:29:21 +01:00
|
|
|
to: { name: RouteName.IDENTITIES } as Route,
|
|
|
|
items: [this.newIdentity],
|
|
|
|
},
|
|
|
|
{
|
2020-02-18 08:57:00 +01:00
|
|
|
title: this.$t("Moderation") as string,
|
2020-03-12 14:29:21 +01:00
|
|
|
to: { name: RouteName.MODERATION } as Route,
|
|
|
|
items: [
|
|
|
|
{
|
2020-02-18 08:57:00 +01:00
|
|
|
title: this.$t("Reports") as string,
|
2020-03-12 14:29:21 +01:00
|
|
|
to: { name: RouteName.REPORTS } as Route,
|
|
|
|
items: [
|
|
|
|
{
|
2020-02-18 08:57:00 +01:00
|
|
|
title: this.$t("Report") as string,
|
2020-03-12 14:29:21 +01:00
|
|
|
to: { name: RouteName.REPORT } as Route,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
2020-02-18 08:57:00 +01:00
|
|
|
title: this.$t("Moderation log") as string,
|
2020-03-12 14:29:21 +01:00
|
|
|
to: { name: RouteName.REPORT_LOGS } as Route,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
2020-02-18 08:57:00 +01:00
|
|
|
title: this.$t("Admin") as string,
|
2020-03-12 14:29:21 +01:00
|
|
|
to: { name: RouteName.ADMIN } as Route,
|
|
|
|
items: [
|
|
|
|
{
|
2020-02-18 08:57:00 +01:00
|
|
|
title: this.$t("Dashboard") as string,
|
2020-03-12 14:29:21 +01:00
|
|
|
to: { name: RouteName.ADMIN_DASHBOARD } as Route,
|
|
|
|
},
|
|
|
|
{
|
2020-02-18 08:57:00 +01:00
|
|
|
title: this.$t("Instance settings") as string,
|
2020-03-12 14:29:21 +01:00
|
|
|
to: { name: RouteName.ADMIN_SETTINGS } as Route,
|
|
|
|
},
|
|
|
|
{
|
2020-02-18 08:57:00 +01:00
|
|
|
title: this.$t("Federation") as string,
|
2020-03-12 14:29:21 +01:00
|
|
|
to: { name: RouteName.RELAYS } as Route,
|
|
|
|
items: [
|
|
|
|
{
|
2020-02-18 08:57:00 +01:00
|
|
|
title: this.$t("Followings") as string,
|
2020-03-12 14:29:21 +01:00
|
|
|
to: { name: RouteName.RELAY_FOLLOWINGS } as Route,
|
|
|
|
},
|
|
|
|
{
|
2020-02-18 08:57:00 +01:00
|
|
|
title: this.$t("Followers") as string,
|
2020-03-12 14:29:21 +01:00
|
|
|
to: { name: RouteName.RELAY_FOLLOWERS } as Route,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2020-06-11 19:13:21 +02:00
|
|
|
{
|
|
|
|
title: this.$t("Users") as string,
|
|
|
|
to: { name: RouteName.USERS } as Route,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: this.$t("Profiles") as string,
|
|
|
|
to: { name: RouteName.PROFILES } as Route,
|
|
|
|
},
|
2020-03-12 14:29:21 +01:00
|
|
|
],
|
|
|
|
},
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
@Watch("identities")
|
|
|
|
updateIdentities(identities: IPerson[]) {
|
2020-03-12 14:29:21 +01:00
|
|
|
if (!identities) return;
|
|
|
|
if (!this.menu[1].items) return;
|
|
|
|
this.menu[1].items = [];
|
2020-02-18 08:57:00 +01:00
|
|
|
this.menu[1].items.push(
|
|
|
|
...identities.map((identity: IPerson) => ({
|
|
|
|
to: ({
|
|
|
|
name: RouteName.UPDATE_IDENTITY,
|
|
|
|
params: { identityName: identity.preferredUsername },
|
|
|
|
} as unknown) as Route,
|
2020-03-12 14:29:21 +01:00
|
|
|
title: `@${identity.preferredUsername}`,
|
2020-02-18 08:57:00 +01:00
|
|
|
}))
|
|
|
|
);
|
2020-03-12 14:29:21 +01:00
|
|
|
this.menu[1].items.push(this.newIdentity);
|
|
|
|
}
|
|
|
|
|
|
|
|
get routes(): Map<string, Route[]> {
|
|
|
|
return this.getPath(this.menu);
|
|
|
|
}
|
|
|
|
|
|
|
|
getPath(object: ISettingMenuSection[]) {
|
2020-02-18 08:57:00 +01:00
|
|
|
function iter(menu: ISettingMenuSection[] | ISettingMenuSection, acc: ISettingMenuSection[]) {
|
2020-03-12 14:29:21 +01:00
|
|
|
if (Array.isArray(menu)) {
|
|
|
|
return menu.forEach((item: ISettingMenuSection) => {
|
|
|
|
iter(item, acc.concat(item));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if (menu.items && menu.items.length > 0) {
|
|
|
|
return menu.items.forEach((item: ISettingMenuSection) => {
|
|
|
|
iter(item, acc.concat(item));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
result.set(menu.to.name, acc);
|
|
|
|
}
|
|
|
|
|
|
|
|
const result = new Map();
|
|
|
|
iter(object, []);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2020-02-18 08:57:00 +01:00
|
|
|
aside.section {
|
|
|
|
padding-top: 1rem;
|
|
|
|
}
|
|
|
|
</style>
|