From 36947a3711b31903bcc24bb2857d50bf68799eda Mon Sep 17 00:00:00 2001 From: steven Date: Tue, 4 Oct 2022 19:52:09 +0800 Subject: [PATCH] feat: add empty placeholder --- web/src/components/CreateWorkspaceDialog.tsx | 9 +++-- web/src/components/Header.tsx | 7 ++++ web/src/components/common/Dropdown.tsx | 2 +- web/src/pages/Home.tsx | 29 ++++++++++++--- web/src/pages/WorkspaceDetail.tsx | 39 +++++++++++++++++--- 5 files changed, 70 insertions(+), 16 deletions(-) diff --git a/web/src/components/CreateWorkspaceDialog.tsx b/web/src/components/CreateWorkspaceDialog.tsx index 44ea268..b773f9a 100644 --- a/web/src/components/CreateWorkspaceDialog.tsx +++ b/web/src/components/CreateWorkspaceDialog.tsx @@ -8,7 +8,7 @@ import toastHelper from "./Toast"; interface Props { workspaceId?: WorkspaceId; onClose: () => void; - onConfirm?: () => void; + onConfirm?: (workspace: Workspace) => void; } interface State { @@ -67,19 +67,20 @@ const CreateWorkspaceDialog: React.FC = (props: Props) => { requestState.setLoading(); try { + let workspace; if (workspaceId) { - await workspaceService.patchWorkspace({ + workspace = await workspaceService.patchWorkspace({ id: workspaceId, ...state.workspaceCreate, }); } else { - await workspaceService.createWorkspace({ + workspace = await workspaceService.createWorkspace({ ...state.workspaceCreate, }); } if (onConfirm) { - onConfirm(); + onConfirm(workspace); } else { onClose(); } diff --git a/web/src/components/Header.tsx b/web/src/components/Header.tsx index c8acd4b..c1d4283 100644 --- a/web/src/components/Header.tsx +++ b/web/src/components/Header.tsx @@ -122,6 +122,13 @@ const Header: React.FC = () => { showCreateWorkspaceDialog: false, }); }} + onConfirm={(workspace: Workspace) => { + setState({ + ...state, + showCreateWorkspaceDialog: false, + }); + navigate(`/${workspace.name}`); + }} /> )} diff --git a/web/src/components/common/Dropdown.tsx b/web/src/components/common/Dropdown.tsx index 477e1fe..0a9ba3f 100644 --- a/web/src/components/common/Dropdown.tsx +++ b/web/src/components/common/Dropdown.tsx @@ -37,7 +37,7 @@ const Dropdown: React.FC = (props: Props) => { {trigger ? ( trigger ) : ( - )} diff --git a/web/src/pages/Home.tsx b/web/src/pages/Home.tsx index 2b14359..507d52a 100644 --- a/web/src/pages/Home.tsx +++ b/web/src/pages/Home.tsx @@ -27,6 +27,11 @@ const Home: React.FC = () => { } Promise.all([workspaceService.fetchWorkspaceList()]).finally(() => { + const workspaceList = workspaceService.getState().workspaceList; + if (workspaceList.length > 0) { + navigate(`/${workspaceList[0].name}`); + return; + } loadingState.setFinish(); }); }, []); @@ -45,18 +50,23 @@ const Home: React.FC = () => {
Workspace List -
{loadingState.isLoading ? (
loading
+ ) : workspaceList.length === 0 ? ( +
+ +

Oops, no workspace.

+ +
) : ( )} @@ -71,6 +81,13 @@ const Home: React.FC = () => { showCreateWorkspaceDialog: false, }); }} + onConfirm={(workspace: Workspace) => { + setState({ + ...state, + showCreateWorkspaceDialog: false, + }); + navigate(`/${workspace.name}`); + }} /> )} diff --git a/web/src/pages/WorkspaceDetail.tsx b/web/src/pages/WorkspaceDetail.tsx index 39f57cc..0f58fb5 100644 --- a/web/src/pages/WorkspaceDetail.tsx +++ b/web/src/pages/WorkspaceDetail.tsx @@ -76,14 +76,29 @@ const WorkspaceDetail: React.FC = () => {
-
- +
+ Shortcuts - + Members - + Setting
@@ -123,7 +138,21 @@ const WorkspaceDetail: React.FC = () => {
) : ( <> - {location.hash === "#shortcuts" && } + {location.hash === "#shortcuts" && + (shortcutList.length === 0 ? ( +
+ +

Oops, no shortcut.

+ +
+ ) : ( + + ))} {location.hash === "#members" && } {location.hash === "#setting" && }