mirror of
https://github.com/aykhans/slash-e.git
synced 2025-04-20 22:07:15 +00:00
fix: default value of visibility selector
This commit is contained in:
parent
817e7ff87a
commit
50f3134bfa
@ -1,4 +1,4 @@
|
|||||||
import { Button, Input, Select, Textarea, Option, Switch, Link } from "@mui/joy";
|
import { Button, Input, Link, Option, Select, Switch, Textarea } from "@mui/joy";
|
||||||
import { isEqual } from "lodash-es";
|
import { isEqual } from "lodash-es";
|
||||||
import { useRef, useState } from "react";
|
import { useRef, useState } from "react";
|
||||||
import toast from "react-hot-toast";
|
import toast from "react-hot-toast";
|
||||||
@ -8,6 +8,13 @@ import { useWorkspaceStore } from "@/stores";
|
|||||||
import { Visibility } from "@/types/proto/api/v1/common";
|
import { Visibility } from "@/types/proto/api/v1/common";
|
||||||
import { WorkspaceSetting } from "@/types/proto/api/v1/workspace_service";
|
import { WorkspaceSetting } from "@/types/proto/api/v1/workspace_service";
|
||||||
|
|
||||||
|
const getDefaultVisibility = (visibility?: Visibility) => {
|
||||||
|
if (!visibility || [Visibility.VISIBILITY_UNSPECIFIED, Visibility.UNRECOGNIZED].includes(visibility)) {
|
||||||
|
return Visibility.PRIVATE;
|
||||||
|
}
|
||||||
|
return visibility;
|
||||||
|
};
|
||||||
|
|
||||||
const WorkspaceSection = () => {
|
const WorkspaceSection = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const workspaceStore = useWorkspaceStore();
|
const workspaceStore = useWorkspaceStore();
|
||||||
@ -101,8 +108,36 @@ const WorkspaceSection = () => {
|
|||||||
onChange={(event) => handleInstanceUrlChange(event.target.value)}
|
onChange={(event) => handleInstanceUrlChange(event.target.value)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="w-full flex flex-row justify-between items-center">
|
||||||
|
<div className="w-full flex flex-col justify-start items-start">
|
||||||
|
<p className="font-medium dark:text-gray-400">{t("settings.workspace.enable-user-signup.self")}</p>
|
||||||
|
<p className="text-sm text-gray-500">{t("settings.workspace.enable-user-signup.description")}</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<Switch
|
||||||
|
size="lg"
|
||||||
|
checked={workspaceSetting.enableSignup}
|
||||||
|
onChange={(event) => handleEnableSignUpChange(event.target.checked)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="w-full flex flex-row justify-between items-center">
|
||||||
|
<div className="w-full flex flex-col justify-start items-start">
|
||||||
|
<p className="font-medium dark:text-gray-400">{t("settings.workspace.default-visibility")}</p>
|
||||||
|
<p className="text-sm text-gray-500 leading-tight">The default visibility of new shortcuts/collections.</p>
|
||||||
|
</div>
|
||||||
|
<Select
|
||||||
|
className="w-36"
|
||||||
|
defaultValue={getDefaultVisibility(workspaceSetting.defaultVisibility)}
|
||||||
|
onChange={(_, value) => handleDefaultVisibilityChange(value as Visibility)}
|
||||||
|
>
|
||||||
|
<Option value={Visibility.PRIVATE}>{t(`shortcut.visibility.private.self`)}</Option>
|
||||||
|
<Option value={Visibility.WORKSPACE}>{t(`shortcut.visibility.workspace.self`)}</Option>
|
||||||
|
<Option value={Visibility.PUBLIC}>{t(`shortcut.visibility.public.self`)}</Option>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
<div className="w-full flex flex-col justify-start items-start">
|
<div className="w-full flex flex-col justify-start items-start">
|
||||||
<p className="font-medium dark:text-gray-400">Favicon Provider</p>
|
<p className="font-medium dark:text-gray-400">Favicon provider</p>
|
||||||
<p className="text-sm text-gray-500">
|
<p className="text-sm text-gray-500">
|
||||||
e.g.{" "}
|
e.g.{" "}
|
||||||
<Link className="!text-sm" href="https://github.com/yourselfhosted/favicons" target="_blank">
|
<Link className="!text-sm" href="https://github.com/yourselfhosted/favicons" target="_blank">
|
||||||
@ -127,34 +162,8 @@ const WorkspaceSection = () => {
|
|||||||
onChange={(event) => handleCustomStyleChange(event.target.value)}
|
onChange={(event) => handleCustomStyleChange(event.target.value)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="w-full flex flex-row justify-between items-center">
|
|
||||||
<div className="w-full flex flex-col justify-start items-start">
|
|
||||||
<p className="font-medium">{t("settings.workspace.enable-user-signup.self")}</p>
|
|
||||||
<p className="text-gray-500">{t("settings.workspace.enable-user-signup.description")}</p>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<Switch
|
|
||||||
size="lg"
|
|
||||||
checked={workspaceSetting.enableSignup}
|
|
||||||
onChange={(event) => handleEnableSignUpChange(event.target.checked)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="w-full flex flex-row justify-between items-center">
|
|
||||||
<div className="flex flex-row justify-start items-center gap-x-1">
|
|
||||||
<span className="font-medium dark:text-gray-400">{t("settings.workspace.default-visibility")}</span>
|
|
||||||
</div>
|
|
||||||
<Select
|
|
||||||
defaultValue={workspaceSetting.defaultVisibility || Visibility.PRIVATE}
|
|
||||||
onChange={(_, value) => handleDefaultVisibilityChange(value as Visibility)}
|
|
||||||
>
|
|
||||||
<Option value={Visibility.PRIVATE}>{t(`shortcut.visibility.private.self`)}</Option>
|
|
||||||
<Option value={Visibility.WORKSPACE}>{t(`shortcut.visibility.workspace.self`)}</Option>
|
|
||||||
<Option value={Visibility.PUBLIC}>{t(`shortcut.visibility.public.self`)}</Option>
|
|
||||||
</Select>
|
|
||||||
</div>
|
|
||||||
<div>
|
<div>
|
||||||
<Button variant="outlined" color="neutral" disabled={!allowSave} onClick={handleSaveWorkspaceSetting}>
|
<Button color="primary" disabled={!allowSave} onClick={handleSaveWorkspaceSetting}>
|
||||||
{t("common.save")}
|
{t("common.save")}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -8,7 +8,7 @@ import { useUserStore, useWorkspaceStore } from "@/stores";
|
|||||||
import { stringifyPlanType } from "@/stores/subscription";
|
import { stringifyPlanType } from "@/stores/subscription";
|
||||||
import { Role } from "@/types/proto/api/v1/user_service";
|
import { Role } from "@/types/proto/api/v1/user_service";
|
||||||
|
|
||||||
const WorkspaceSetting: React.FC = () => {
|
const WorkspaceSetting = () => {
|
||||||
const workspaceStore = useWorkspaceStore();
|
const workspaceStore = useWorkspaceStore();
|
||||||
const currentUser = useUserStore().getCurrentUser();
|
const currentUser = useUserStore().getCurrentUser();
|
||||||
const isAdmin = currentUser.role === Role.ADMIN;
|
const isAdmin = currentUser.role === Role.ADMIN;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user