Files
speckle-server/packages/server/modules/gatekeeper/services/readOnly.ts
T
Gergő Jedlicska f501cc4ad5 gergo/web 2888 workspace project cancreate (#4294)
* WIP can create project

* WIP can create project more work

* complete body, stencil tests

* feat(shared): move workspace plan types into shared

* test progress wip

* feat(shared): add more logic to canCreateWorkspaceProject

* a few more tests, as a treat

* chore(authz): round out tests

* fixed loaders, new GQL checks, dataLoaders in auth loaders

* fix(authz): get workspace limits loader

* chore(authz): update loaders

* frontend fixed up to snuff

* fix(authz): fix workspace plans for tests

* fix(authz): classic

* fix(authz): 0 counts

---------

Co-authored-by: Chuck Driesler <chuck@speckle.systems>
Co-authored-by: Kristaps Fabians Geikins <fabis94@live.com>
2025-04-01 16:38:20 +01:00

26 lines
1.1 KiB
TypeScript

import { GetWorkspacePlan } from '@/modules/gatekeeper/domain/billing'
import { GetWorkspacePlanByProjectId } from '@/modules/gatekeeper/domain/operations'
import { Workspace } from '@/modules/workspacesCore/domain/types'
import { isWorkspacePlanStatusReadOnly } from '@speckle/shared'
export const isWorkspaceReadOnlyFactory =
({ getWorkspacePlan }: { getWorkspacePlan: GetWorkspacePlan }) =>
async ({ workspaceId }: { workspaceId: Workspace['id'] }) => {
const workspacePlan = await getWorkspacePlan({ workspaceId })
// Should never happen
if (!workspacePlan) return true
return isWorkspacePlanStatusReadOnly(workspacePlan.status)
}
export const isProjectReadOnlyFactory =
({
getWorkspacePlanByProjectId
}: {
getWorkspacePlanByProjectId: GetWorkspacePlanByProjectId
}) =>
async ({ projectId }: { projectId: string }) => {
const workspacePlan = await getWorkspacePlanByProjectId({ projectId })
if (!workspacePlan) return false // The project is not in a workspace
return isWorkspacePlanStatusReadOnly(workspacePlan.status)
}