From 746f706a82de5a53eb5edd4d42a9ba4337978546 Mon Sep 17 00:00:00 2001 From: KaWaite Date: Mon, 11 Oct 2021 15:37:03 +0900 Subject: [PATCH 1/5] fix dataset modal bug --- .../EarthEditor/DatasetPane/DatasetModal/hooks.ts | 10 ++++++++++ .../EarthEditor/DatasetPane/DatasetModal/index.tsx | 7 ++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/components/molecules/EarthEditor/DatasetPane/DatasetModal/hooks.ts b/src/components/molecules/EarthEditor/DatasetPane/DatasetModal/hooks.ts index 02c289156..f27118730 100644 --- a/src/components/molecules/EarthEditor/DatasetPane/DatasetModal/hooks.ts +++ b/src/components/molecules/EarthEditor/DatasetPane/DatasetModal/hooks.ts @@ -13,6 +13,7 @@ export default ( sheetName: string, schemeId: string | null, ) => Promise, + onClose?: () => void, ) => { const [url, onUrlChange] = useState(); const [csv, changeCsv] = useState(); @@ -44,6 +45,14 @@ export default ( setDataType(type); }, []); + const handleClose = useCallback(() => { + changeCsv(undefined); + changeSheet(undefined); + onUrlChange(undefined); + setDataType(undefined); + onClose?.(); + }, [onClose]); + const onSheetSelect = useCallback(sheet => { changeSheet(sheet); }, []); @@ -70,5 +79,6 @@ export default ( onReturn, onSheetSelect, handleImport, + handleClose, }; }; diff --git a/src/components/molecules/EarthEditor/DatasetPane/DatasetModal/index.tsx b/src/components/molecules/EarthEditor/DatasetPane/DatasetModal/index.tsx index 25e68cd28..59dbe43dc 100644 --- a/src/components/molecules/EarthEditor/DatasetPane/DatasetModal/index.tsx +++ b/src/components/molecules/EarthEditor/DatasetPane/DatasetModal/index.tsx @@ -45,7 +45,8 @@ const DatasetModal: React.FC = ({ onSheetSelect, handleImport, handleClick, - } = useHooks(handleDatasetAdd, handleGoogleSheetDatasetAdd); + handleClose, + } = useHooks(handleDatasetAdd, handleGoogleSheetDatasetAdd, onClose); const primaryButtonText = useMemo(() => { if (syncLoading) { @@ -60,7 +61,7 @@ const DatasetModal: React.FC = ({ = ({
diff --git a/src/components/molecules/Visualizer/Widget/Button/index.tsx b/src/components/molecules/Visualizer/Widget/Button/index.tsx index d44476712..b95b5b873 100644 --- a/src/components/molecules/Visualizer/Widget/Button/index.tsx +++ b/src/components/molecules/Visualizer/Widget/Button/index.tsx @@ -10,25 +10,24 @@ export type Props = WidgetProps; export type Button = ButtonType; export type MenuItem = MenuItemType; export type Property = { - default: Button; + default?: Button; menu?: MenuItem[]; }; const Menu = ({ widget, sceneProperty }: Props): JSX.Element | null => { - const { default: button, menu: menuItems } = (widget?.property as Property | undefined) ?? {}; + const { default: button, menu: menuItems } = (widget.property as Property) ?? {}; - return button ? ( + return ( - ) : null; + ); }; const Wrapper = styled.div` diff --git a/src/components/molecules/Visualizer/Widget/Storytelling/index.tsx b/src/components/molecules/Visualizer/Widget/Storytelling/index.tsx index bb41627f3..49e9e62bb 100644 --- a/src/components/molecules/Visualizer/Widget/Storytelling/index.tsx +++ b/src/components/molecules/Visualizer/Widget/Storytelling/index.tsx @@ -52,7 +52,7 @@ const Storytelling = ({ openMenu(false); }); - return stories?.length > 0 ? ( + return (
- {typeof selected === "undefined" ? "-" : selected.index + 1} / {stories.length} + {typeof selected === "undefined" ? "-" : selected.index + 1} /{" "} + {stories.length > 0 ? stories.length : "-"}
- ) : null; + ); }; const Widget = styled.div<{ From 62708466824dced73d132a191b187bc24b13ec6b Mon Sep 17 00:00:00 2001 From: KaWaite Date: Mon, 11 Oct 2021 17:15:57 +0900 Subject: [PATCH 3/5] fix: modal not closing on proj creation --- .../molecules/Common/ProjectCreationModal/index.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/molecules/Common/ProjectCreationModal/index.tsx b/src/components/molecules/Common/ProjectCreationModal/index.tsx index 72c114037..5f5c73953 100644 --- a/src/components/molecules/Common/ProjectCreationModal/index.tsx +++ b/src/components/molecules/Common/ProjectCreationModal/index.tsx @@ -44,12 +44,12 @@ const ProjectCreationModal: React.FC = ({ const [openAssets, setOpenAssets] = useState(false); const formik = useFormik({ initialValues, - onSubmit: useCallback( - async (data: FormValues) => { - await onSubmit?.(data); - }, - [onSubmit], - ), + onSubmit: async (data: FormValues, { setStatus, resetForm }) => { + await onSubmit?.(data); + onClose?.(); + resetForm({}); + setStatus({ success: true }); + }, }); const handleClose = useCallback(() => { From 501356be8e330492cb544888e90770ee29a44399 Mon Sep 17 00:00:00 2001 From: KaWaite Date: Mon, 11 Oct 2021 17:20:57 +0900 Subject: [PATCH 4/5] fix: clearing workspace modal after creation --- .../Common/WorkspaceCreationModal/index.tsx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/components/molecules/Common/WorkspaceCreationModal/index.tsx b/src/components/molecules/Common/WorkspaceCreationModal/index.tsx index c400a35a3..2ffda97ec 100644 --- a/src/components/molecules/Common/WorkspaceCreationModal/index.tsx +++ b/src/components/molecules/Common/WorkspaceCreationModal/index.tsx @@ -29,13 +29,12 @@ const WorkspaceCreationModal: React.FC = ({ open, onClose, onSubmit }) => const intl = useIntl(); const formik = useFormik({ initialValues, - onSubmit: useCallback( - async (data: FormValues) => { - await onSubmit?.(data); - onClose?.(true); - }, - [onClose, onSubmit], - ), + onSubmit: async (data: FormValues, { setStatus, resetForm }) => { + await onSubmit?.(data); + onClose?.(true); + resetForm({}); + setStatus({ success: true }); + }, }); const handleClose = useCallback(() => { From ff9cc363b9813cb3f3a5c35791d59853700a9ab3 Mon Sep 17 00:00:00 2001 From: KaWaite Date: Mon, 11 Oct 2021 17:38:44 +0900 Subject: [PATCH 5/5] fix add/delete member bug --- src/components/organisms/Settings/Workspace/hooks.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/organisms/Settings/Workspace/hooks.ts b/src/components/organisms/Settings/Workspace/hooks.ts index 3fd6a04a4..c84e35a64 100644 --- a/src/components/organisms/Settings/Workspace/hooks.ts +++ b/src/components/organisms/Settings/Workspace/hooks.ts @@ -137,6 +137,7 @@ export default (params: Params) => { if (!teamId) return; const result = await addMemberToTeamMutation({ variables: { userId, teamId, role: Role.Reader }, + refetchQueries: ["teams"], }); if (result.errors || !result.data?.addMemberToTeam) { setNotification({ @@ -184,7 +185,10 @@ export default (params: Params) => { const removeMemberFromTeam = useCallback( async (userId: string) => { if (!teamId) return; - const result = await removeMemberFromTeamMutation({ variables: { teamId, userId } }); + const result = await removeMemberFromTeamMutation({ + variables: { teamId, userId }, + refetchQueries: ["teams"], + }); if (result.errors || !result.data?.removeMemberFromTeam) { setNotification({ type: "error",