Let members view a workspace's dashboard, editing still for managers only
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -4,18 +4,17 @@ import grabWorkspaceActivity from "@/src/functions/backend/db/workspaces/grab-wo
|
||||
import grabWorkspaceBots from "@/src/functions/backend/db/workspaces/grab-workspace-bots";
|
||||
import grabWorkspaceComputers from "@/src/functions/backend/db/workspaces/grab-workspace-computers";
|
||||
import { AdminHomePath } from "@/src/dict/admin-sections-dict";
|
||||
import canManageCrew from "@/src/utils/rbac/can-manage-crew";
|
||||
import type { PagePropsType, PageQueryObject } from "@/src/types";
|
||||
import type { BunextPageServerFn } from "@moduletrace/bunext/types";
|
||||
|
||||
/**
|
||||
* A workspace's dashboard: its picture, context, latest activity, bots and
|
||||
* computers, all read-only. Editing lives under Settings. Only super admins
|
||||
* and admins see it; a member opens its first bot instead.
|
||||
* computers, all read-only. Everyone who reaches the workspace sees it; editing lives
|
||||
* under Settings, for super admins and admins only.
|
||||
*/
|
||||
export const server: BunextPageServerFn<PagePropsType> = async (params) => {
|
||||
const query: PageQueryObject = params.query;
|
||||
const { user, user_types } = await userAuth({ req: params.req });
|
||||
const { user } = await userAuth({ req: params.req });
|
||||
|
||||
if (!user?.id) {
|
||||
return { redirect: { destination: "/auth/login" } };
|
||||
@@ -32,33 +31,6 @@ export const server: BunextPageServerFn<PagePropsType> = async (params) => {
|
||||
|
||||
const workspace_id = Number(workspace.id);
|
||||
|
||||
/**
|
||||
* Members don't manage it: they go straight to its first bot.
|
||||
*/
|
||||
if (!canManageCrew({ user_types })) {
|
||||
const workspace_bots = await grabWorkspaceBots({
|
||||
user_id: user.id,
|
||||
workspace_id,
|
||||
});
|
||||
|
||||
if (workspace_bots[0]?.id) {
|
||||
return {
|
||||
redirect: {
|
||||
destination: `/admin/workspaces/${workspace_id}/bots/${workspace_bots[0].id}`,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
props: {
|
||||
workspaces,
|
||||
workspace,
|
||||
bots: workspace_bots,
|
||||
workspace_bots,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const [workspace_bots, workspace_computers, workspace_activity] =
|
||||
await Promise.all([
|
||||
grabWorkspaceBots({ user_id: user.id, workspace_id }),
|
||||
|
||||
Reference in New Issue
Block a user