merge: upstream

This commit is contained in:
Mar0xy 2023-10-31 19:33:24 +01:00
commit 4dd23a3793
No known key found for this signature in database
GPG key ID: 56569BBE47D2C828
217 changed files with 6773 additions and 2275 deletions

View file

@ -3,12 +3,42 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
import type { MenuItem } from '@/types/menu.js';
import * as os from '@/os.js';
import { instance } from '@/instance.js';
import { host } from '@/config.js';
import { i18n } from '@/i18n.js';
import { $i } from '@/account.js';
function toolsMenuItems(): MenuItem[] {
return [{
type: 'link',
to: '/scratchpad',
text: i18n.ts.scratchpad,
icon: 'ph-terminal-window ph-bold ph-lg-2',
}, {
type: 'link',
to: '/api-console',
text: 'API Console',
icon: 'ph-terminal-window ph-bold ph-lg-2',
}, {
type: 'link',
to: '/clicker',
text: '🍪👈',
icon: 'ph-cookie ph-bold pg-lg',
}, ($i && ($i.isAdmin || $i.policies.canManageCustomEmojis)) ? {
type: 'link',
to: '/custom-emojis-manager',
text: i18n.ts.manageCustomEmojis,
icon: 'ph-smiley ph-bold pg-lg',
} : undefined, ($i && ($i.isAdmin || $i.policies.canManageAvatarDecorations)) ? {
type: 'link',
to: '/avatar-decorations',
text: i18n.ts.manageAvatarDecorations,
icon: 'ph-sparkle ph-bold pg-lg',
} : undefined];
}
export function openInstanceMenu(ev: MouseEvent) {
os.popupMenu([{
text: instance.name ?? host,
@ -46,28 +76,8 @@ export function openInstanceMenu(ev: MouseEvent) {
} : undefined, {
type: 'parent',
text: i18n.ts.tools,
icon: 'ph-wrench ph-bold ph-lg',
children: [{
type: 'link',
to: '/scratchpad',
text: i18n.ts.scratchpad,
icon: 'ph-terminal-window ph-bold ph-lg-2',
}, {
type: 'link',
to: '/api-console',
text: 'API Console',
icon: 'ph-terminal-window ph-bold ph-lg-2',
}, {
type: 'link',
to: '/clicker',
text: '🍪👈',
icon: 'ph-cookie ph-bold pg-lg',
}, ($i && ($i.isAdmin || $i.policies.canManageCustomEmojis)) ? {
type: 'link',
to: '/custom-emojis-manager',
text: i18n.ts.manageCustomEmojis,
icon: 'ph-smiley ph-bold pg-lg',
} : undefined],
icon: 'ph-toolbox ph-bold ph-lg',
children: toolsMenuItems(),
}, null, (instance.impressumUrl) ? {
text: i18n.ts.impressum,
icon: 'ph-newspaper-clipping ph-bold pg-lg',
@ -100,3 +110,9 @@ export function openInstanceMenu(ev: MouseEvent) {
align: 'left',
});
}
export function openToolsMenu(ev: MouseEvent) {
os.popupMenu(toolsMenuItems(), ev.currentTarget ?? ev.target, {
align: 'left',
});
}