diff --git a/frontend/web/src/components/CreateCollectionDrawer.tsx b/frontend/web/src/components/CreateCollectionDrawer.tsx index 2cd71f9..9317b5b 100644 --- a/frontend/web/src/components/CreateCollectionDrawer.tsx +++ b/frontend/web/src/components/CreateCollectionDrawer.tsx @@ -10,6 +10,7 @@ import { Visibility } from "@/types/proto/api/v2/common"; import { convertVisibilityFromPb } from "@/utils/visibility"; import useLoading from "../hooks/useLoading"; import Icon from "./Icon"; +import ResourceNameInput from "./ResourceNameInput"; import ShortcutView from "./ShortcutView"; interface Props { @@ -33,8 +34,9 @@ const CreateCollectionDrawer: React.FC = (props: Props) => { }), }); const [selectedShortcuts, setSelectedShortcuts] = useState([]); - const requestState = useLoading(false); const isCreating = isUndefined(collectionId); + const loadingState = useLoading(!isCreating); + const requestState = useLoading(false); const unselectedShortcuts = shortcutList .filter((shortcut) => { if (state.collectionCreate.visibility === Visibility.PUBLIC) { @@ -63,11 +65,16 @@ const CreateCollectionDrawer: React.FC = (props: Props) => { .map((shortcutId) => shortcutList.find((shortcut) => shortcut.id === shortcutId)) .filter(Boolean) as Shortcut[] ); + loadingState.setFinish(); } } })(); }, [collectionId]); + if (loadingState.isLoading) { + return null; + } + const setPartialState = (partialState: Partial) => { setState({ ...state, @@ -75,10 +82,10 @@ const CreateCollectionDrawer: React.FC = (props: Props) => { }); }; - const handleNameInputChange = (e: React.ChangeEvent) => { + const handleNameChange = (name: string) => { setPartialState({ collectionCreate: Object.assign(state.collectionCreate, { - name: e.target.value.replace(/\s+/g, "-"), + name: name.replace(/\s+/g, "-"), }), }); }; @@ -154,20 +161,7 @@ const CreateCollectionDrawer: React.FC = (props: Props) => {
-
- - Name * - -
- -
-
+
Title * diff --git a/frontend/web/src/components/CreateShortcutDrawer.tsx b/frontend/web/src/components/CreateShortcutDrawer.tsx index 8e481bb..e10cd2f 100644 --- a/frontend/web/src/components/CreateShortcutDrawer.tsx +++ b/frontend/web/src/components/CreateShortcutDrawer.tsx @@ -20,7 +20,7 @@ import { useAppSelector } from "@/stores"; import useLoading from "../hooks/useLoading"; import { shortcutService } from "../services"; import Icon from "./Icon"; -import ShortcutNameInput from "./ShortcutNameInput"; +import ResourceNameInput from "./ResourceNameInput"; interface Props { shortcutId?: ShortcutId; @@ -84,7 +84,7 @@ const CreateShortcutDrawer: React.FC = (props: Props) => { }, [shortcutId]); if (loadingState.isLoading) { - return; + return null; } const setPartialState = (partialState: Partial) => { @@ -222,7 +222,7 @@ const CreateShortcutDrawer: React.FC = (props: Props) => {
- +
Link * diff --git a/frontend/web/src/components/ShortcutNameInput.tsx b/frontend/web/src/components/ResourceNameInput.tsx similarity index 85% rename from frontend/web/src/components/ShortcutNameInput.tsx rename to frontend/web/src/components/ResourceNameInput.tsx index 9b88e4f..c77a572 100644 --- a/frontend/web/src/components/ShortcutNameInput.tsx +++ b/frontend/web/src/components/ResourceNameInput.tsx @@ -9,7 +9,7 @@ interface Props { onChange: (name: string) => void; } -const ShortcutNameInput = (props: Props) => { +const ResourceNameInput = (props: Props) => { const { name, onChange } = props; const [modified, setModified] = useState(false); const [editingName, setEditingName] = useState(name || generateRandomString().toLowerCase()); @@ -49,17 +49,11 @@ const ShortcutNameInput = (props: Props) => {
{modified && (
- +
)}
); }; -export default ShortcutNameInput; +export default ResourceNameInput;