ProfileSets: Move to settings tab
This commit is contained in:
parent
8492c8d0ad
commit
7e126aa1c2
4 changed files with 115 additions and 24 deletions
|
|
@ -186,8 +186,6 @@ export function PresetManager({ section, guildId }: PresetManagerProps) {
|
|||
>
|
||||
Random
|
||||
</Button>
|
||||
</div>
|
||||
<div className={cl("import")}>
|
||||
<Button
|
||||
size="small"
|
||||
variant="secondary"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* Vencord, a Discord client mod
|
||||
* Copyright (c) 2026 Vendicated and contributors
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import { Button } from "@components/Button";
|
||||
import { HeadingPrimary } from "@components/Heading";
|
||||
import { SettingsTab, wrapTab } from "@components/settings";
|
||||
import { GuildStore, React, SearchableSelect, SelectedGuildStore, useStateFromStores } from "@webpack/common";
|
||||
|
||||
import { cl } from "../index";
|
||||
import { PresetSection } from "../utils/storage";
|
||||
import { PresetManager } from "./presetManager";
|
||||
|
||||
function ProfileSetsTab() {
|
||||
const [section, setSection] = React.useState<PresetSection>("main");
|
||||
const lastSelectedGuildId = useStateFromStores(
|
||||
[SelectedGuildStore],
|
||||
() => SelectedGuildStore.getLastSelectedGuildId() ?? SelectedGuildStore.getGuildId()
|
||||
);
|
||||
|
||||
const guildOptions = React.useMemo(
|
||||
() => GuildStore.getGuildsArray()
|
||||
.map(guild => ({ label: guild.name, value: guild.id }))
|
||||
.sort((a, b) => a.label.localeCompare(b.label)),
|
||||
[]
|
||||
);
|
||||
|
||||
const [guildId, setGuildId] = React.useState<string | undefined>(lastSelectedGuildId ?? guildOptions[0]?.value);
|
||||
|
||||
return (
|
||||
<SettingsTab>
|
||||
<HeadingPrimary className={cl("tab-heading")}>Profile Sets</HeadingPrimary>
|
||||
|
||||
<div className={cl("section-switch")}>
|
||||
<Button
|
||||
size="small"
|
||||
variant={section === "main" ? "primary" : "secondary"}
|
||||
onClick={() => setSection("main")}
|
||||
>
|
||||
Main Profile
|
||||
</Button>
|
||||
<Button
|
||||
size="small"
|
||||
variant={section === "server" ? "primary" : "secondary"}
|
||||
onClick={() => setSection("server")}
|
||||
>
|
||||
Server Profiles
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{section === "server" && (
|
||||
<div className={cl("guild-picker")}>
|
||||
<SearchableSelect
|
||||
options={guildOptions}
|
||||
value={guildId}
|
||||
placeholder="Select a server"
|
||||
clearable={false}
|
||||
closeOnSelect={true}
|
||||
onChange={v => setGuildId(v as string)}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{section === "server" && !guildId ? (
|
||||
<p className={cl("empty-state")}>You are not in any servers yet.</p>
|
||||
) : (
|
||||
<PresetManager section={section} guildId={section === "server" ? guildId : undefined} />
|
||||
)}
|
||||
</SettingsTab>
|
||||
);
|
||||
}
|
||||
|
||||
export default wrapTab(ProfileSetsTab, "Profile Sets");
|
||||
|
|
@ -7,13 +7,15 @@
|
|||
import "./styles.css";
|
||||
|
||||
import { definePluginSettings } from "@api/Settings";
|
||||
import { UserIcon } from "@components/Icons";
|
||||
import SettingsPlugin from "@plugins/_core/settings";
|
||||
import { EquicordDevs } from "@utils/constants";
|
||||
import { classNameFactory } from "@utils/css";
|
||||
import { removeFromArray } from "@utils/misc";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { React } from "@webpack/common";
|
||||
import { SettingsRouter } from "@webpack/common";
|
||||
|
||||
import { PresetManager } from "./components/presetManager";
|
||||
import { loadPresets, PresetSection } from "./utils/storage";
|
||||
import { loadPresets } from "./utils/storage";
|
||||
|
||||
export const cl = classNameFactory("vc-profile-presets-");
|
||||
export const settings = definePluginSettings({
|
||||
|
|
@ -28,30 +30,27 @@ export const settings = definePluginSettings({
|
|||
|
||||
export default definePlugin({
|
||||
name: "ProfileSets",
|
||||
description: "Allows you to save and load different profile presets, via the Profile Section in Settings.",
|
||||
description: "Allows you to save and load different profile presets.",
|
||||
tags: ["Appearance", "Customisation", "Utility"],
|
||||
authors: [EquicordDevs.omaw, EquicordDevs.justjxke],
|
||||
settings,
|
||||
patches: [
|
||||
{
|
||||
find: "DefaultCustomizationSections: user cannot be undefined",
|
||||
replacement: {
|
||||
match: /return.{0,50}children:\[(?=.{0,50},\{placeholder:)/,
|
||||
replace: "$&$self.renderPresetSection(\"main\"),"
|
||||
}
|
||||
toolboxActions: {
|
||||
"Open Profile Sets": () => {
|
||||
SettingsRouter.openUserSettings("equicord_profile_sets_panel");
|
||||
},
|
||||
{
|
||||
find: "USER_SETTINGS_GUILD_PROFILE)",
|
||||
replacement: {
|
||||
match: /guildId:(\i\.id),onChange:(\i)\}\)(?=.{0,25}profilePreviewTitle:)/,
|
||||
replace: 'guildId:$1,onChange:$2}),$self.renderPresetSection("server",$1)'
|
||||
}
|
||||
}
|
||||
],
|
||||
},
|
||||
|
||||
start() {
|
||||
loadPresets("main");
|
||||
SettingsPlugin.customEntries.push({
|
||||
key: "equicord_profile_sets",
|
||||
title: "Profile Sets",
|
||||
Component: require("./components/profileSetsTab").default,
|
||||
Icon: UserIcon
|
||||
});
|
||||
},
|
||||
|
||||
stop() {
|
||||
removeFromArray(SettingsPlugin.customEntries, e => e.key === "equicord_profile_sets");
|
||||
},
|
||||
renderPresetSection(section: PresetSection, guildId?: string) {
|
||||
return <PresetManager section={section} guildId={guildId} />;
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,3 +1,22 @@
|
|||
.vc-profile-presets-tab-heading {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.vc-profile-presets-section-switch {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.vc-profile-presets-guild-picker {
|
||||
max-width: 300px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.vc-profile-presets-empty-state {
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.vc-profile-presets-section {
|
||||
margin-bottom: 20px;
|
||||
padding: 0;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue