From f276c979fab41c2803f78d691898f061a2511e19 Mon Sep 17 00:00:00 2001 From: Steven Date: Sat, 31 Aug 2024 22:54:30 +0800 Subject: [PATCH] chore: update visibility checkbox --- frontend/locales/en.json | 2 +- frontend/locales/zh.json | 2 +- .../src/components/CreateCollectionDrawer.tsx | 35 +++++++-------- .../src/components/CreateShortcutDrawer.tsx | 44 ++++++------------- 4 files changed, 30 insertions(+), 53 deletions(-) diff --git a/frontend/locales/en.json b/frontend/locales/en.json index 133b636..f80a9f2 100644 --- a/frontend/locales/en.json +++ b/frontend/locales/en.json @@ -42,7 +42,7 @@ }, "public": { "self": "Public", - "description": "Visible to everyone on the internet" + "description": "Public on the internet" } } }, diff --git a/frontend/locales/zh.json b/frontend/locales/zh.json index 91259dc..46bf297 100644 --- a/frontend/locales/zh.json +++ b/frontend/locales/zh.json @@ -39,7 +39,7 @@ }, "public": { "self": "公开的", - "description": "对任何人可见" + "description": "公开至互联网" } } }, diff --git a/frontend/web/src/components/CreateCollectionDrawer.tsx b/frontend/web/src/components/CreateCollectionDrawer.tsx index 7e729cf..ce9a8ba 100644 --- a/frontend/web/src/components/CreateCollectionDrawer.tsx +++ b/frontend/web/src/components/CreateCollectionDrawer.tsx @@ -1,4 +1,4 @@ -import { Button, DialogActions, DialogContent, DialogTitle, Drawer, Input, ModalClose, Radio, RadioGroup } from "@mui/joy"; +import { Button, Checkbox, DialogActions, DialogContent, DialogTitle, Divider, Drawer, Input, ModalClose } from "@mui/joy"; import { isUndefined } from "lodash-es"; import { useEffect, useState } from "react"; import { toast } from "react-hot-toast"; @@ -107,14 +107,6 @@ const CreateCollectionDrawer: React.FC = (props: Props) => { }); }; - const handleVisibilityInputChange = (e: React.ChangeEvent) => { - setPartialState({ - collectionCreate: Object.assign(state.collectionCreate, { - visibility: e.target.value, - }), - }); - }; - const handleDescriptionInputChange = (e: React.ChangeEvent) => { setPartialState({ collectionCreate: Object.assign(state.collectionCreate, { @@ -209,18 +201,21 @@ const CreateCollectionDrawer: React.FC = (props: Props) => {
- Visibility -
- - - - -
-

- {t(`shortcut.visibility.${state.collectionCreate.visibility.toLowerCase()}.description`)} -

+ + setPartialState({ + collectionCreate: Object.assign(state.collectionCreate, { + visibility: e.target.checked ? Visibility.PUBLIC : Visibility.WORKSPACE, + }), + }) + } + />
-
+ +

Shortcuts ({selectedShortcuts.length}) diff --git a/frontend/web/src/components/CreateShortcutDrawer.tsx b/frontend/web/src/components/CreateShortcutDrawer.tsx index 7869fee..28f82b4 100644 --- a/frontend/web/src/components/CreateShortcutDrawer.tsx +++ b/frontend/web/src/components/CreateShortcutDrawer.tsx @@ -1,16 +1,4 @@ -import { - Button, - DialogActions, - DialogContent, - DialogTitle, - Divider, - Drawer, - Input, - ModalClose, - Radio, - RadioGroup, - Textarea, -} from "@mui/joy"; +import { Button, Checkbox, DialogActions, DialogContent, DialogTitle, Divider, Drawer, Input, ModalClose, Textarea } from "@mui/joy"; import classnames from "classnames"; import { isUndefined, uniq } from "lodash-es"; import { useEffect, useState } from "react"; @@ -124,14 +112,6 @@ const CreateShortcutDrawer: React.FC = (props: Props) => { }); }; - const handleVisibilityInputChange = (e: React.ChangeEvent) => { - setPartialState({ - shortcutCreate: Object.assign(state.shortcutCreate, { - visibility: e.target.value, - }), - }); - }; - const handleDescriptionInputChange = (e: React.ChangeEvent) => { setPartialState({ shortcutCreate: Object.assign(state.shortcutCreate, { @@ -291,16 +271,18 @@ const CreateShortcutDrawer: React.FC = (props: Props) => { )}

- Visibility -
- - - - -
-

- {t(`shortcut.visibility.${state.shortcutCreate.visibility.toLowerCase()}.description`)} -

+ + setPartialState({ + shortcutCreate: Object.assign(state.shortcutCreate, { + visibility: e.target.checked ? Visibility.PUBLIC : Visibility.WORKSPACE, + }), + }) + } + />
More