fix Vencord context menu entries having no icon (#4518)
This commit is contained in:
parent
30ba4da010
commit
79759ffa7e
13 changed files with 45 additions and 0 deletions
17
packages/discord-types/src/menu.d.ts
vendored
17
packages/discord-types/src/menu.d.ts
vendored
|
|
@ -2,6 +2,22 @@ import type { ComponentType, CSSProperties, ForwardRefRenderFunction, MouseEvent
|
|||
|
||||
type RC<C> = ComponentType<PropsWithChildren<C & Record<string, any>>>;
|
||||
|
||||
type LeadingAccessory =
|
||||
| {
|
||||
type: "icon";
|
||||
icon: ComponentType<any>;
|
||||
}
|
||||
| {
|
||||
type: "emoji";
|
||||
emojiId?: string;
|
||||
src?: string;
|
||||
animated?: boolean;
|
||||
}
|
||||
| {
|
||||
type: "image";
|
||||
src: string;
|
||||
};
|
||||
|
||||
export interface Menu {
|
||||
Menu: RC<{
|
||||
navId: string;
|
||||
|
|
@ -20,6 +36,7 @@ export interface Menu {
|
|||
label: ReactNode;
|
||||
action?(e: MouseEvent): void;
|
||||
icon?: ComponentType<any>;
|
||||
leadingAccessory?: LeadingAccessory;
|
||||
|
||||
color?: string;
|
||||
render?: ComponentType<any>;
|
||||
|
|
|
|||
|
|
@ -90,6 +90,7 @@ export function buildExtraRoleContextMenuItems(role: Role, guild: Guild, popoutR
|
|||
GuildSettingsActions.selectRole(role.id);
|
||||
}}
|
||||
icon={PencilIcon}
|
||||
leadingAccessory={{ type: "icon", icon: PencilIcon }}
|
||||
/>
|
||||
),
|
||||
role.colorString && (
|
||||
|
|
@ -99,6 +100,7 @@ export function buildExtraRoleContextMenuItems(role: Role, guild: Guild, popoutR
|
|||
label="Copy Role Color"
|
||||
action={() => copyToClipboard(role.colorString!)}
|
||||
icon={AppearanceIcon}
|
||||
leadingAccessory={{ type: "icon", icon: AppearanceIcon }}
|
||||
/>
|
||||
)
|
||||
].filter(isTruthy);
|
||||
|
|
@ -117,6 +119,7 @@ export function buildExtraRoleContextMenuItems(role: Role, guild: Guild, popoutR
|
|||
});
|
||||
}}
|
||||
icon={ImageIcon}
|
||||
leadingAccessory={{ type: "icon", icon: ImageIcon }}
|
||||
/>
|
||||
),
|
||||
popoutRef && (
|
||||
|
|
@ -185,6 +188,7 @@ export function openRoleContextMenu(event: React.MouseEvent<HTMLElement>, { guil
|
|||
id="vc-better-role-context-copy-role-id"
|
||||
label={getIntlMessage("COPY_ID_ROLE")}
|
||||
icon={CopyIdIcon}
|
||||
leadingAccessory={{ type: "icon", icon: CopyIdIcon }}
|
||||
action={() => copyToClipboard(role.id)}
|
||||
/>
|
||||
</Menu.Menu>
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ export const addViewStreamContext: NavContextMenuPatchCallback = (children, { us
|
|||
label="View Stream Preview"
|
||||
id="view-stream-preview"
|
||||
icon={ScreenshareIcon}
|
||||
leadingAccessory={{ type: "icon", icon: ScreenshareIcon }}
|
||||
action={() => stream && handleViewPreview(stream)}
|
||||
disabled={!stream}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ const UserContextMenuPatch: NavContextMenuPatchCallback = (children, { user }: U
|
|||
label="Copy User URL"
|
||||
action={() => copyToClipboard(`<https://discord.com/users/${user.id}>`)}
|
||||
icon={LinkIcon}
|
||||
leadingAccessory={{ type: "icon", icon: LinkIcon }}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ export default function DecorationContextMenu({ decoration }: { decoration: Deco
|
|||
id={cl("decoration-context-menu-copy-hash")}
|
||||
label="Copy Decoration Hash"
|
||||
icon={CopyIcon}
|
||||
leadingAccessory={{ type: "icon", icon: CopyIcon }}
|
||||
action={() => copyToClipboard(decoration.hash)}
|
||||
/>
|
||||
{decoration.authorId === UserStore.getCurrentUser().id &&
|
||||
|
|
@ -31,6 +32,7 @@ export default function DecorationContextMenu({ decoration }: { decoration: Deco
|
|||
label="Delete Decoration"
|
||||
color="danger"
|
||||
icon={DeleteIcon}
|
||||
leadingAccessory={{ type: "icon", icon: DeleteIcon }}
|
||||
action={() => openModal(props => (
|
||||
<ConfirmModal
|
||||
{...props}
|
||||
|
|
|
|||
|
|
@ -89,6 +89,7 @@ const makeContextMenuPatch: (shouldAddIcon: boolean) => NavContextMenuPatchCallb
|
|||
label="Apply NewGuildSettings"
|
||||
id="vc-newguildsettings-apply"
|
||||
icon={shouldAddIcon ? CogWheel : void 0}
|
||||
leadingAccessory={shouldAddIcon ? { type: "icon", icon: CogWheel } : void 0}
|
||||
action={() => applyDefaultSettings(guild.id)}
|
||||
/>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -230,6 +230,7 @@ function RoleContextMenu({ guild, roleId, onClose }: { guild: Guild; roleId: str
|
|||
id={cl("copy-role-id")}
|
||||
label={getIntlMessage("COPY_ID_ROLE")}
|
||||
icon={CopyIdIcon}
|
||||
leadingAccessory={{ type: "icon", icon: CopyIdIcon }}
|
||||
action={() => copyToClipboard(roleId)}
|
||||
/>
|
||||
|
||||
|
|
@ -240,6 +241,7 @@ function RoleContextMenu({ guild, roleId, onClose }: { guild: Guild; roleId: str
|
|||
id={cl("view-as-role")}
|
||||
label={getIntlMessage("VIEW_AS_ROLE")}
|
||||
icon={ViewAsRoleIcon}
|
||||
leadingAccessory={{ type: "icon", icon: ViewAsRoleIcon }}
|
||||
action={() => {
|
||||
onClose();
|
||||
FluxDispatcher.dispatch({
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ const guildPopoutPatch: NavContextMenuPatchCallback = (children, { guild }: { gu
|
|||
label="View Reviews"
|
||||
id="vc-rdb-server-reviews"
|
||||
icon={OpenExternalIcon}
|
||||
leadingAccessory={{ type: "icon", icon: OpenExternalIcon }}
|
||||
action={() => openReviewsModal(guild.id, guild.name, ReviewType.Server)}
|
||||
/>
|
||||
);
|
||||
|
|
@ -62,6 +63,7 @@ const userContextPatch: NavContextMenuPatchCallback = (children, { user }: { use
|
|||
label="View Reviews"
|
||||
id="vc-rdb-user-reviews"
|
||||
icon={OpenExternalIcon}
|
||||
leadingAccessory={{ type: "icon", icon: OpenExternalIcon }}
|
||||
action={() => openReviewsModal(user.id, user.username, ReviewType.User)}
|
||||
/>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -84,18 +84,21 @@ function CopyContextMenu({ name, type, path }: { type: string; name: string; pat
|
|||
label={`Copy ${type} Name`}
|
||||
action={() => copyWithToast(name)}
|
||||
icon={CopyIcon}
|
||||
leadingAccessory={{ type: "icon", icon: CopyIcon }}
|
||||
/>
|
||||
<Menu.MenuItem
|
||||
id="vc-spotify-copy-link"
|
||||
label={`Copy ${type} Link`}
|
||||
action={() => copyWithToast("https://open.spotify.com" + path)}
|
||||
icon={LinkIcon}
|
||||
leadingAccessory={{ type: "icon", icon: LinkIcon }}
|
||||
/>
|
||||
<Menu.MenuItem
|
||||
id="vc-spotify-open"
|
||||
label={`Open ${type} in Spotify`}
|
||||
action={() => SpotifyStore.openExternal(path)}
|
||||
icon={OpenExternalIcon}
|
||||
leadingAccessory={{ type: "icon", icon: OpenExternalIcon }}
|
||||
/>
|
||||
</Menu.Menu>
|
||||
);
|
||||
|
|
@ -225,6 +228,7 @@ function AlbumContextMenu({ track }: { track: Track; }) {
|
|||
label="Open Album"
|
||||
action={() => SpotifyStore.openExternal(`/album/${track.album.id}`)}
|
||||
icon={OpenExternalIcon}
|
||||
leadingAccessory={{ type: "icon", icon: OpenExternalIcon }}
|
||||
/>
|
||||
<Menu.MenuItem
|
||||
key="view-cover"
|
||||
|
|
@ -233,6 +237,7 @@ function AlbumContextMenu({ track }: { track: Track; }) {
|
|||
// trolley
|
||||
action={() => openImageModal(track.album.image)}
|
||||
icon={ImageIcon}
|
||||
leadingAccessory={{ type: "icon", icon: ImageIcon }}
|
||||
/>
|
||||
<Menu.MenuControlItem
|
||||
id="spotify-volume"
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ const messageCtxPatch: NavContextMenuPatchCallback = (children, { message }: { m
|
|||
id="vc-trans"
|
||||
label="Translate"
|
||||
icon={TranslateIcon}
|
||||
leadingAccessory={{ type: "icon", icon: TranslateIcon }}
|
||||
action={async () => {
|
||||
const trans = await translate("received", content);
|
||||
handleTranslate(message.id, trans);
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ const messageContextMenuPatch: NavContextMenuPatchCallback = (
|
|||
label={isEmbedSuppressed ? "Unsuppress Embeds" : "Suppress Embeds"}
|
||||
color={isEmbedSuppressed ? undefined : "danger"}
|
||||
icon={isEmbedSuppressed ? ImageVisible : ImageInvisible}
|
||||
leadingAccessory={{ type: "icon", icon: isEmbedSuppressed ? ImageVisible : ImageInvisible }}
|
||||
action={() =>
|
||||
RestAPI.patch({
|
||||
url: Constants.Endpoints.MESSAGE(channel.id, messageId),
|
||||
|
|
|
|||
|
|
@ -117,6 +117,7 @@ const UserContext: NavContextMenuPatchCallback = (children, { user, guildId }: U
|
|||
label="View Avatar"
|
||||
action={() => openAvatar(IconUtils.getUserAvatarURL(user, true))}
|
||||
icon={ImageIcon}
|
||||
leadingAccessory={{ type: "icon", icon: ImageIcon }}
|
||||
/>
|
||||
{memberAvatar && (
|
||||
<Menu.MenuItem
|
||||
|
|
@ -129,6 +130,7 @@ const UserContext: NavContextMenuPatchCallback = (children, { user, guildId }: U
|
|||
canAnimate: true
|
||||
}))}
|
||||
icon={ImageIcon}
|
||||
leadingAccessory={{ type: "icon", icon: ImageIcon }}
|
||||
/>
|
||||
)}
|
||||
{avatarDecoration && (
|
||||
|
|
@ -141,6 +143,7 @@ const UserContext: NavContextMenuPatchCallback = (children, { user, guildId }: U
|
|||
canAnimate: true
|
||||
})!)}
|
||||
icon={ImageIcon}
|
||||
leadingAccessory={{ type: "icon", icon: ImageIcon }}
|
||||
/>
|
||||
)}
|
||||
</Menu.MenuGroup>
|
||||
|
|
@ -167,6 +170,7 @@ const GuildContext: NavContextMenuPatchCallback = (children, { guild }: GuildCon
|
|||
})!)
|
||||
}
|
||||
icon={ImageIcon}
|
||||
leadingAccessory={{ type: "icon", icon: ImageIcon }}
|
||||
/>
|
||||
) : null}
|
||||
{banner ? (
|
||||
|
|
@ -177,6 +181,7 @@ const GuildContext: NavContextMenuPatchCallback = (children, { guild }: GuildCon
|
|||
openBanner(IconUtils.getGuildBannerURL(guild, true)!)
|
||||
}
|
||||
icon={ImageIcon}
|
||||
leadingAccessory={{ type: "icon", icon: ImageIcon }}
|
||||
/>
|
||||
) : null}
|
||||
</Menu.MenuGroup>
|
||||
|
|
@ -195,6 +200,7 @@ const GroupDMContext: NavContextMenuPatchCallback = (children, { channel }: Grou
|
|||
openAvatar(IconUtils.getChannelIconURL(channel)!)
|
||||
}
|
||||
icon={ImageIcon}
|
||||
leadingAccessory={{ type: "icon", icon: ImageIcon }}
|
||||
/>
|
||||
</Menu.MenuGroup>
|
||||
));
|
||||
|
|
|
|||
|
|
@ -151,6 +151,7 @@ function MakeContextCallback(name: "Guild" | "Role" | "User" | "Channel" | "Mess
|
|||
label="View Raw"
|
||||
action={action}
|
||||
icon={CopyRawIcon}
|
||||
leadingAccessory={{ type: "icon", icon: CopyRawIcon }}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
|
@ -169,6 +170,7 @@ const devContextCallback: NavContextMenuPatchCallback = (children, { id }: { id:
|
|||
label="View Raw"
|
||||
action={() => openViewRawModal(JSON.stringify(role, null, 4), "Role")}
|
||||
icon={CopyRawIcon}
|
||||
leadingAccessory={{ type: "icon", icon: CopyRawIcon }}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue