diff --git a/packages/app/src/components/workspace-setting/workspace-setting.tsx b/packages/app/src/components/workspace-setting/workspace-setting.tsx
index d04885b131..b479b6144a 100644
--- a/packages/app/src/components/workspace-setting/workspace-setting.tsx
+++ b/packages/app/src/components/workspace-setting/workspace-setting.tsx
@@ -42,6 +42,7 @@ import {
Workspace,
Member,
removeMember,
+ updateWorkspace,
} from '@pathfinder/data-services';
import { Avatar } from '@mui/material';
import { Menu, MenuItem } from '@/ui/menu';
@@ -158,7 +159,9 @@ export const WorkspaceSetting = ({
{activeTab === ActiveTab.members && workspace && (
)}
- {activeTab === ActiveTab.publish && }
+ {activeTab === ActiveTab.publish && (
+
+ )}
@@ -286,31 +289,69 @@ const MembersPage = ({ workspace }: { workspace: Workspace }) => {
);
};
-const PublishPage = () => {
+const PublishPage = ({ workspace }: { workspace: Workspace }) => {
+ const { refreshWorkspacesMeta } = useAppState();
+ const shareUrl = window.location.host + '/workspace/' + workspace.id;
+ const togglePublic = (flag: boolean) => {
+ updateWorkspace({
+ id: workspace.id,
+ public: flag,
+ }).then(data => {
+ refreshWorkspacesMeta();
+ toast('Updated');
+ });
+ };
+ const copyUrl = () => {
+ navigator.clipboard.writeText(shareUrl);
+ toast('Copied');
+ };
return (
-
- After publishing to the web, everyone can view the content of this
- workspace through the link.
-
- Share with link
-
-
-
-
- Copy Link
-
-
-
+ {workspace.public ? (
+
+ After publishing to the web, everyone can view the content of this
+ workspace through the link.
+
+ ) : (
+ <>
+
+ The current workspace has been published to the web, everyone can
+ view the contents of this workspace through the link.
+
+ Share with link
+
+
+
+
+ Copy Link
+
+
+
+ >
+ )}
-
- Publish to web
-
+ {!workspace.public ? (
+ {
+ togglePublic(true);
+ }}
+ type="primary"
+ shape="circle"
+ >
+ Publish to web
+
+ ) : (
+ {
+ togglePublic(false);
+ }}
+ type="primary"
+ shape="circle"
+ >
+ Stop publishing
+
+ )}
);
};