Skip to content

Commit

Permalink
コントロールパネルの権限強化
Browse files Browse the repository at this point in the history
  • Loading branch information
nanasina8 committed Dec 24, 2024
1 parent 9ae8d3c commit a9ca058
Show file tree
Hide file tree
Showing 4 changed files with 182 additions and 157 deletions.
3 changes: 2 additions & 1 deletion packages/frontend/src/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ const accountData = miLocalStorage.getItem('account');

// TODO: 外部からはreadonlyに
export const $i = accountData ? reactive(JSON.parse(accountData) as Account) : null;

export const iAmCustomEmojisManager = $i != null && ($i.isAdmin === true || $i.isModerator === true || $i.policies.canManageCustomEmojis === true);
export const iAmAvatarDecorationsManager = $i != null && ($i.isAdmin === true || $i.isModerator === true || $i.policies.canManageAvatarDecorations === true);
export const iAmModerator = $i != null && ($i.isAdmin === true || $i.isModerator === true);
export const iAmAdmin = $i != null && $i.isAdmin;

Expand Down
268 changes: 145 additions & 123 deletions packages/frontend/src/pages/admin/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import { i18n } from '@/i18n.js';
import { instance } from '@/instance.js';
import * as os from '@/os.js';
import { lookupUser, lookupUserByEmail, lookupFile } from '@/scripts/admin-lookup.js';
import { $i } from '@/account.js';
import { lookup } from '@/scripts/lookup.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { PageMetadata, definePageMetadata, provideMetadataReceiver, provideReactiveMetadata } from '@/scripts/page-metadata.js';
Expand Down Expand Up @@ -183,133 +184,154 @@ const menuDef = computed<ISuperMenuDefinitions>(() => [{
}] : [])],
}, {
title: i18n.ts.administration,
items: [{
icon: 'ti ti-dashboard',
text: i18n.ts.dashboard,
to: '/admin/overview',
active: currentPage.value?.route.name === 'overview',
}, {
icon: 'ti ti-users',
text: i18n.ts.users,
to: '/admin/users',
active: currentPage.value?.route.name === 'users',
}, {
icon: 'ti ti-user-plus',
text: i18n.ts.invite,
to: '/admin/invites',
active: currentPage.value?.route.name === 'invites',
}, {
icon: 'ti ti-badges',
text: i18n.ts.roles,
to: '/admin/roles',
active: currentPage.value?.route.name === 'roles',
}, {
icon: 'ti ti-icons',
text: i18n.ts.customEmojis,
to: '/admin/emojis',
active: currentPage.value?.route.name === 'emojis',
}, {
icon: 'ti ti-sparkles',
text: i18n.ts.avatarDecorations,
to: '/admin/avatar-decorations',
active: currentPage.value?.route.name === 'avatarDecorations',
}, {
icon: 'ti ti-whirl',
text: i18n.ts.federation,
to: '/admin/federation',
active: currentPage.value?.route.name === 'federation',
}, {
icon: 'ti ti-clock-play',
text: i18n.ts.jobQueue,
to: '/admin/queue',
active: currentPage.value?.route.name === 'queue',
}, {
icon: 'ti ti-cloud',
text: i18n.ts.files,
to: '/admin/files',
active: currentPage.value?.route.name === 'files',
}, {
icon: 'ti ti-speakerphone',
text: i18n.ts.announcements,
to: '/admin/announcements',
active: currentPage.value?.route.name === 'announcements',
}, {
icon: 'ti ti-ad',
text: i18n.ts.ads,
to: '/admin/ads',
active: currentPage.value?.route.name === 'ads',
}, {
icon: 'ti ti-exclamation-circle',
text: i18n.ts.abuseReports,
to: '/admin/abuses',
active: currentPage.value?.route.name === 'abuses',
}, {
icon: 'ti ti-list-search',
text: i18n.ts.moderationLogs,
to: '/admin/modlog',
active: currentPage.value?.route.name === 'modlog',
}],
items: [
...($i?.isAdmin || $i?.isModerator ? [
{
icon: 'ti ti-dashboard',
text: i18n.ts.dashboard,
to: '/admin/overview',
active: currentPage.value?.route.name === 'overview',
}, {
icon: 'ti ti-users',
text: i18n.ts.users,
to: '/admin/users',
active: currentPage.value?.route.name === 'users',
}, {
icon: 'ti ti-user-plus',
text: i18n.ts.invite,
to: '/admin/invites',
active: currentPage.value?.route.name === 'invites',
}, {
icon: 'ti ti-badges',
text: i18n.ts.roles,
to: '/admin/roles',
active: currentPage.value?.route.name === 'roles',
},
] : []),
...($i?.isAdmin || $i?.isModerator || $i?.policies.canManageCustomEmojis ? [
{
icon: 'ti ti-icons',
text: i18n.ts.customEmojis,
to: '/admin/emojis',
active: currentPage.value?.route.name === 'emojis',
},
] : []),
...($i?.isAdmin || $i?.isModerator || $i?.policies.canManageAvatarDecorations ? [
{
icon: 'ti ti-sparkles',
text: i18n.ts.avatarDecorations,
to: '/admin/avatar-decorations',
active: currentPage.value?.route.name === 'avatarDecorations',
},
] : []),
...($i?.isAdmin || $i?.isModerator ? [
{

icon: 'ti ti-whirl',
text: i18n.ts.federation,
to: '/admin/federation',
active: currentPage.value?.route.name === 'federation',
}, {
icon: 'ti ti-clock-play',
text: i18n.ts.jobQueue,
to: '/admin/queue',
active: currentPage.value?.route.name === 'queue',
}, {
icon: 'ti ti-cloud',
text: i18n.ts.files,
to: '/admin/files',
active: currentPage.value?.route.name === 'files',
}, {
icon: 'ti ti-speakerphone',
text: i18n.ts.announcements,
to: '/admin/announcements',
active: currentPage.value?.route.name === 'announcements',
}, {
icon: 'ti ti-ad',
text: i18n.ts.ads,
to: '/admin/ads',
active: currentPage.value?.route.name === 'ads',
}, {
icon: 'ti ti-exclamation-circle',
text: i18n.ts.abuseReports,
to: '/admin/abuses',
active: currentPage.value?.route.name === 'abuses',
}, {
icon: 'ti ti-list-search',
text: i18n.ts.moderationLogs,
to: '/admin/modlog',
active: currentPage.value?.route.name === 'modlog',
}] : []),
],
}, {
title: i18n.ts.settings,
items: [{
icon: 'ti ti-settings',
text: i18n.ts.general,
to: '/admin/settings',
active: currentPage.value?.route.name === 'settings',
}, {
icon: 'ti ti-paint',
text: i18n.ts.branding,
to: '/admin/branding',
active: currentPage.value?.route.name === 'branding',
}, {
icon: 'ti ti-shield',
text: i18n.ts.moderation,
to: '/admin/moderation',
active: currentPage.value?.route.name === 'moderation',
}, {
icon: 'ti ti-mail',
text: i18n.ts.emailServer,
to: '/admin/email-settings',
active: currentPage.value?.route.name === 'email-settings',
}, {
icon: 'ti ti-cloud',
text: i18n.ts.objectStorage,
to: '/admin/object-storage',
active: currentPage.value?.route.name === 'object-storage',
}, {
icon: 'ti ti-lock',
text: i18n.ts.security,
to: '/admin/security',
active: currentPage.value?.route.name === 'security',
}, {
icon: 'ti ti-planet',
text: i18n.ts.relays,
to: '/admin/relays',
active: currentPage.value?.route.name === 'relays',
}, {
icon: 'ti ti-link',
text: i18n.ts.externalServices,
to: '/admin/external-services',
active: currentPage.value?.route.name === 'external-services',
}, {
icon: 'ti ti-webhook',
text: 'Webhook',
to: '/admin/system-webhook',
active: currentPage.value?.route.name === 'system-webhook',
}, {
icon: 'ti ti-bolt',
text: i18n.ts.performance,
to: '/admin/performance',
active: currentPage.value?.route.name === 'performance',
}],
items: [
...($i?.isAdmin ? [
{
icon: 'ti ti-settings',
text: i18n.ts.general,
to: '/admin/settings',
active: currentPage.value?.route.name === 'settings',
}, {
icon: 'ti ti-paint',
text: i18n.ts.branding,
to: '/admin/branding',
active: currentPage.value?.route.name === 'branding',
}, {
icon: 'ti ti-shield',
text: i18n.ts.moderation,
to: '/admin/moderation',
active: currentPage.value?.route.name === 'moderation',
}, {
icon: 'ti ti-mail',
text: i18n.ts.emailServer,
to: '/admin/email-settings',
active: currentPage.value?.route.name === 'email-settings',
}, {
icon: 'ti ti-cloud',
text: i18n.ts.objectStorage,
to: '/admin/object-storage',
active: currentPage.value?.route.name === 'object-storage',
}, {
icon: 'ti ti-lock',
text: i18n.ts.security,
to: '/admin/security',
active: currentPage.value?.route.name === 'security',
}, {
icon: 'ti ti-planet',
text: i18n.ts.relays,
to: '/admin/relays',
active: currentPage.value?.route.name === 'relays',
}, {
icon: 'ti ti-link',
text: i18n.ts.externalServices,
to: '/admin/external-services',
active: currentPage.value?.route.name === 'external-services',
}, {
icon: 'ti ti-webhook',
text: 'Webhook',
to: '/admin/system-webhook',
active: currentPage.value?.route.name === 'system-webhook',
}, {
icon: 'ti ti-bolt',
text: i18n.ts.performance,
to: '/admin/performance',
active: currentPage.value?.route.name === 'performance',
},
] : []),
],
}, {
title: i18n.ts.info,
items: [{
icon: 'ti ti-database',
text: i18n.ts.database,
to: '/admin/database',
active: currentPage.value?.route.name === 'database',
}],
items: [
...($i?.isAdmin ? [
{
icon: 'ti ti-database',
text: i18n.ts.database,
to: '/admin/database',
active: currentPage.value?.route.name === 'database',
},
] : []),
],
}]);

function invite() {
Expand Down
Loading

0 comments on commit a9ca058

Please sign in to comment.