From 2440a06536dd2b8053359999bb61d495220cbf9c Mon Sep 17 00:00:00 2001 From: Aaron Liu Date: Fri, 23 May 2025 18:20:05 +0800 Subject: [PATCH] fix(dashboard): remove default shortcut setting --- src/component/Admin/Common/SharesInput.tsx | 122 ------------------ src/component/Admin/Settings/Settings.tsx | 1 - .../Settings/UserSession/UserSession.tsx | 7 +- 3 files changed, 2 insertions(+), 128 deletions(-) diff --git a/src/component/Admin/Common/SharesInput.tsx b/src/component/Admin/Common/SharesInput.tsx index f58f6b1..7c52cf4 100644 --- a/src/component/Admin/Common/SharesInput.tsx +++ b/src/component/Admin/Common/SharesInput.tsx @@ -9,141 +9,19 @@ import FileTypeIcon from "../../FileManager/Explorer/FileTypeIcon.tsx"; import LinkDismiss from "../../Icons/LinkDismiss.tsx"; export interface SharesInputProps { - value: number[]; - onChange: (value: number[]) => void; } const SharesInput = (props: SharesInputProps) => { const theme = useTheme(); const { t } = useTranslation(); const [options, setOptions] = useState([]); - const [idShareMap, setIdShareMap] = useState>({}); - const [loading, setLoading] = useState(false); - const [inputValue, setInputValue] = useState(""); - const dispatch = useAppDispatch(); - - useEffect(() => { - if (props.value.length > 0) { - fetch({ input: props.value.join(",") }); - } - }, []); - - const fetch = useMemo( - () => - debounce((request: { input: string }) => { - setLoading(true); - dispatch( - getShareList({ - page: 1, - page_size: 50, - order_by: "", - order_direction: "desc", - conditions: { - share_id: request.input, - }, - }), - ) - .then((results) => { - setOptions(results?.shares?.map((share) => share.id) ?? []); - setIdShareMap((origin) => ({ - ...origin, - ...results?.shares?.reduce( - (acc, share) => { - acc[share.id] = share; - return acc; - }, - {} as Record, - ), - })); - }) - .finally(() => { - setLoading(false); - }); - }, 400), - [dispatch], - ); - - useEffect(() => { - let active = true; - - if (inputValue === "") { - setOptions([]); - return undefined; - } - - fetch({ input: inputValue }); - - return () => { - active = false; - }; - }, [inputValue, fetch]); - - const handleChange = (_event: React.SyntheticEvent, value: number[]) => { - props.onChange(value); - }; return ( { - if (newValue) { - console.log(newValue); - props.onChange(newValue as number[]); - } - }} - onInputChange={(_event, newInputValue) => { - setInputValue(newInputValue); - }} - noOptionsText={t("application:modals.noResults")} - renderTags={(value: readonly unknown[], getTagProps) => - value.map((option: unknown, index: number) => { - const { key, ...tagProps } = getTagProps({ index }); - const share = idShareMap[option as number]; - return ( - - ) : ( - - ) - } - size="small" - label={share?.edges?.file?.name ?? t("application:share.expiredLink")} - key={key} - {...tagProps} - /> - ); - }) - } - renderOption={(props, option) => { - const share = idShareMap[option as number]; - return ( -
  • - - {share ? ( - - ) : ( - - )} - theme.typography.body2.fontSize, - width: "100%", - ml: 2, - }} - > - {share?.edges?.file?.name ?? t("application:share.expiredLink")} - - -
  • - ); - }} renderInput={(params) => ( { "avatar_size", "avatar_size_l", "gravatar_server", - "default_symbolics", ]} > diff --git a/src/component/Admin/Settings/UserSession/UserSession.tsx b/src/component/Admin/Settings/UserSession/UserSession.tsx index 3a780bf..e43e9ba 100644 --- a/src/component/Admin/Settings/UserSession/UserSession.tsx +++ b/src/component/Admin/Settings/UserSession/UserSession.tsx @@ -108,12 +108,9 @@ const UserSession = () => { {t("settings.defaultGroupDes")} - + - setSettings({ default_symbolics: JSON.stringify(shares) })} - /> +