mirror of
https://github.com/usememos/memos.git
synced 2025-03-19 20:20:06 +01:00
chore: add my account entry in user dropdown (#1187)
This commit is contained in:
parent
977e7f55e5
commit
ae61ade2b1
@ -13,21 +13,23 @@ import StorageSection from "./Settings/StorageSection";
|
|||||||
import SSOSection from "./Settings/SSOSection";
|
import SSOSection from "./Settings/SSOSection";
|
||||||
import "../less/setting-dialog.less";
|
import "../less/setting-dialog.less";
|
||||||
|
|
||||||
type Props = DialogProps;
|
|
||||||
|
|
||||||
type SettingSection = "my-account" | "preference" | "member" | "system" | "storage" | "sso";
|
type SettingSection = "my-account" | "preference" | "member" | "system" | "storage" | "sso";
|
||||||
|
|
||||||
|
interface Props extends DialogProps {
|
||||||
|
selectedSection?: SettingSection;
|
||||||
|
}
|
||||||
|
|
||||||
interface State {
|
interface State {
|
||||||
selectedSection: SettingSection;
|
selectedSection: SettingSection;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SettingDialog: React.FC<Props> = (props: Props) => {
|
const SettingDialog: React.FC<Props> = (props: Props) => {
|
||||||
const { destroy } = props;
|
const { destroy, selectedSection } = props;
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const user = userStore.state.user;
|
const user = userStore.state.user;
|
||||||
const [state, setState] = useState<State>({
|
const [state, setState] = useState<State>({
|
||||||
selectedSection: "my-account",
|
selectedSection: selectedSection || "my-account",
|
||||||
});
|
});
|
||||||
const isHost = user?.role === "HOST";
|
const isHost = user?.role === "HOST";
|
||||||
|
|
||||||
@ -128,13 +130,15 @@ const SettingDialog: React.FC<Props> = (props: Props) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function showSettingDialog(): void {
|
export default function showSettingDialog(selectedSection?: SettingSection): void {
|
||||||
generateDialog(
|
generateDialog(
|
||||||
{
|
{
|
||||||
className: "setting-dialog",
|
className: "setting-dialog",
|
||||||
dialogName: "setting-dialog",
|
dialogName: "setting-dialog",
|
||||||
},
|
},
|
||||||
SettingDialog,
|
SettingDialog,
|
||||||
{}
|
{
|
||||||
|
selectedSection,
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import Dropdown from "./common/Dropdown";
|
|||||||
import showArchivedMemoDialog from "./ArchivedMemoDialog";
|
import showArchivedMemoDialog from "./ArchivedMemoDialog";
|
||||||
import showAboutSiteDialog from "./AboutSiteDialog";
|
import showAboutSiteDialog from "./AboutSiteDialog";
|
||||||
import UserAvatar from "./UserAvatar";
|
import UserAvatar from "./UserAvatar";
|
||||||
|
import showSettingDialog from "./SettingDialog";
|
||||||
|
|
||||||
const UserBanner = () => {
|
const UserBanner = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@ -44,6 +45,10 @@ const UserBanner = () => {
|
|||||||
});
|
});
|
||||||
}, [memos]);
|
}, [memos]);
|
||||||
|
|
||||||
|
const handleMyAccountClick = () => {
|
||||||
|
showSettingDialog("my-account");
|
||||||
|
};
|
||||||
|
|
||||||
const handleArchivedBtnClick = () => {
|
const handleArchivedBtnClick = () => {
|
||||||
showArchivedMemoDialog();
|
showArchivedMemoDialog();
|
||||||
};
|
};
|
||||||
@ -77,6 +82,12 @@ const UserBanner = () => {
|
|||||||
<>
|
<>
|
||||||
{!userStore.isVisitorMode() && (
|
{!userStore.isVisitorMode() && (
|
||||||
<>
|
<>
|
||||||
|
<button
|
||||||
|
className="w-full px-3 truncate text-left leading-10 cursor-pointer rounded dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-zinc-800"
|
||||||
|
onClick={handleMyAccountClick}
|
||||||
|
>
|
||||||
|
<span className="mr-1">🤠</span> {t("setting.my-account")}
|
||||||
|
</button>
|
||||||
<button
|
<button
|
||||||
className="w-full px-3 truncate text-left leading-10 cursor-pointer rounded dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-zinc-800"
|
className="w-full px-3 truncate text-left leading-10 cursor-pointer rounded dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-zinc-800"
|
||||||
onClick={handleArchivedBtnClick}
|
onClick={handleArchivedBtnClick}
|
||||||
@ -89,7 +100,7 @@ const UserBanner = () => {
|
|||||||
className="w-full px-3 truncate text-left leading-10 cursor-pointer rounded dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-zinc-800"
|
className="w-full px-3 truncate text-left leading-10 cursor-pointer rounded dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-zinc-800"
|
||||||
onClick={handleAboutBtnClick}
|
onClick={handleAboutBtnClick}
|
||||||
>
|
>
|
||||||
<span className="mr-1">🤠</span> {t("common.about")}
|
<span className="mr-1">🏂</span> {t("common.about")}
|
||||||
</button>
|
</button>
|
||||||
{!userStore.isVisitorMode() && (
|
{!userStore.isVisitorMode() && (
|
||||||
<button
|
<button
|
||||||
|
Loading…
x
Reference in New Issue
Block a user