mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-21 03:56:23 +08:00
refactor(workspace): rename workspaceId
This commit is contained in:
@@ -21,7 +21,7 @@ export function LigoVirgoRoutes() {
|
||||
/>
|
||||
<Route path="/ui" element={<UIPage />} />
|
||||
<Route
|
||||
path="/:workspace_id/*"
|
||||
path="/:workspaceId/*"
|
||||
element={
|
||||
<RoutePrivate>
|
||||
<WorkspaceContainer />
|
||||
|
||||
@@ -5,22 +5,22 @@ import { useNavigate, useParams } from 'react-router-dom';
|
||||
|
||||
export function WorkspaceHome() {
|
||||
const navigate = useNavigate();
|
||||
const { workspace_id } = useParams();
|
||||
const { workspaceId } = useParams();
|
||||
const { user } = useUserAndSpaces();
|
||||
|
||||
useEffect(() => {
|
||||
const navigateToUserInitialPage = async () => {
|
||||
const [recentPages, userInitialPageId] = await Promise.all([
|
||||
services.api.userConfig.getRecentPages(workspace_id, user.id),
|
||||
services.api.userConfig.getRecentPages(workspaceId, user.id),
|
||||
services.api.userConfig.getUserInitialPage(
|
||||
workspace_id,
|
||||
workspaceId,
|
||||
user.id
|
||||
),
|
||||
]);
|
||||
// if recent pages if null, run initialize task
|
||||
if (recentPages.length === 0) {
|
||||
await services.api.editorBlock.copyTemplateToPage(
|
||||
workspace_id,
|
||||
workspaceId,
|
||||
userInitialPageId,
|
||||
TemplateFactory.generatePageTemplateByGroupKeys({
|
||||
name: '👋 Get Started with AFFiNE',
|
||||
@@ -33,11 +33,11 @@ export function WorkspaceHome() {
|
||||
);
|
||||
}
|
||||
if (userInitialPageId) {
|
||||
navigate(`/${workspace_id}/${userInitialPageId}`);
|
||||
navigate(`/${workspaceId}/${userInitialPageId}`);
|
||||
}
|
||||
};
|
||||
navigateToUserInitialPage();
|
||||
}, [navigate, user.id, workspace_id]);
|
||||
}, [navigate, user.id, workspaceId]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -7,14 +7,8 @@ import { WorkspaceHome } from './Home';
|
||||
import Pages from './pages';
|
||||
|
||||
export function WorkspaceContainer() {
|
||||
const { workspace_id } = useParams();
|
||||
const { workspaceId } = useParams();
|
||||
const { user, currentSpaceId } = useUserAndSpaces();
|
||||
if (
|
||||
user &&
|
||||
![currentSpaceId, 'affine2vin277tcmafwq'].includes(workspace_id)
|
||||
) {
|
||||
// return <Navigate to={`/${currentSpaceId}`} replace={true} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<Routes>
|
||||
@@ -22,11 +16,11 @@ export function WorkspaceContainer() {
|
||||
<Route path="/pages" element={<Pages />} />
|
||||
<Route
|
||||
path="/:page_id/edgeless"
|
||||
element={<Edgeless workspace={workspace_id} />}
|
||||
element={<Edgeless workspace={workspaceId} />}
|
||||
/>
|
||||
<Route
|
||||
path="/:page_id"
|
||||
element={<Page workspace={workspace_id} />}
|
||||
element={<Page workspace={workspaceId} />}
|
||||
/>
|
||||
<Route path="/" element={<WorkspaceHome />} />
|
||||
</Route>
|
||||
|
||||
@@ -38,7 +38,7 @@ export type CollapsiblePageTreeProps = {
|
||||
export function CollapsiblePageTree(props: CollapsiblePageTreeProps) {
|
||||
const { className, style, children, title, initialOpen = true } = props;
|
||||
const navigate = useNavigate();
|
||||
const { workspace_id, page_id } = useParams();
|
||||
const { workspaceId, page_id } = useParams();
|
||||
|
||||
const { handleAddPage } = usePageTree();
|
||||
const { addPageToday } = useCalendarHeatmap();
|
||||
@@ -48,16 +48,16 @@ export function CollapsiblePageTree(props: CollapsiblePageTreeProps) {
|
||||
const create_page = useCallback(async () => {
|
||||
if (page_id) {
|
||||
const newPage = await services.api.editorBlock.create({
|
||||
workspace: workspace_id,
|
||||
workspace: workspaceId,
|
||||
type: 'page' as const,
|
||||
});
|
||||
|
||||
await handleAddPage(newPage.id);
|
||||
addPageToday();
|
||||
|
||||
navigate(`/${workspace_id}/${newPage.id}`);
|
||||
navigate(`/${workspaceId}/${newPage.id}`);
|
||||
}
|
||||
}, [addPageToday, handleAddPage, navigate, page_id, workspace_id]);
|
||||
}, [addPageToday, handleAddPage, navigate, page_id, workspaceId]);
|
||||
|
||||
const [newPageBtnVisible, setNewPageBtnVisible] = useState<boolean>(false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user