a6287fc06d
* init db migration * WIP store view * create service call * WIP insertion * insert sort of works * moving code arounmd * creation tests * avoid duplicate entries * fixes from main * basic group retrieval works * group filtering works * WIP view listing * filter by acl * fixes + WIP single group retrieval * wip pivot * more pivot query fixes * tests fixed after pivot * views list tests * fixing test command * business plan only checks * more tests for coverage * .dts import fix * cli fix * anutha one * auth policy tests for business plan access * WIP saved views panel base * BE listing adjustments * WIP group rendering * group render done * WIP post create cache updates * listing fine? * my vs theirs * auto open * minor fixes * click load omg * nicely loading views * type fix * less spammy loading * another type fix: * more lint fix * test fix * codecov disable * moar coverage * fix sidebar flashin * more test coverage * more test cvoverage * minor adfjustments * adj * saved view wipe fixes * CSR viewer * more improvements * extra feature flag checks * lint fix * feature flags fix * more test fixes
76 lines
1.9 KiB
TypeScript
76 lines
1.9 KiB
TypeScript
import { graphql } from '~/lib/common/generated/gql/gql'
|
|
import { useQuery } from '@vue/apollo-composable'
|
|
import { workspaceLimitsQuery } from '~/lib/workspaces/graphql/queries'
|
|
import { WorkspacePlanConfigs, type MaybeNullOrUndefined } from '@speckle/shared'
|
|
import type { WorkspacePlanLimits_WorkspaceFragment } from '~/lib/common/generated/gql/graphql'
|
|
import { useFeatureFlags } from '~/lib/common/composables/env'
|
|
|
|
graphql(`
|
|
fragment WorkspacePlanLimits_Workspace on Workspace {
|
|
id
|
|
slug
|
|
plan {
|
|
name
|
|
}
|
|
}
|
|
`)
|
|
|
|
export const useWorkspaceLimits = (params: {
|
|
slug: MaybeRef<MaybeNullOrUndefined<string>>
|
|
workspace?: MaybeRef<MaybeNullOrUndefined<WorkspacePlanLimits_WorkspaceFragment>>
|
|
}) => {
|
|
const { slug } = params
|
|
|
|
const featureFlags = useFeatureFlags()
|
|
const { result } = useQuery(
|
|
workspaceLimitsQuery,
|
|
() => ({
|
|
slug: unref(slug) || ''
|
|
}),
|
|
() => ({
|
|
enabled: !!unref(slug)?.length
|
|
})
|
|
)
|
|
|
|
const workspace = computed(
|
|
() => unref(params.workspace) || result.value?.workspaceBySlug
|
|
)
|
|
|
|
// Plan limits
|
|
const limits = computed(() => {
|
|
const planName = workspace.value?.plan?.name
|
|
if (!planName)
|
|
return {
|
|
projectCount: 0,
|
|
modelCount: 0,
|
|
versionsHistory: null,
|
|
commentHistory: null
|
|
}
|
|
|
|
const planConfig = WorkspacePlanConfigs({ featureFlags })[planName]
|
|
return planConfig?.limits
|
|
})
|
|
|
|
const versionLimitFormatted = computed(() => {
|
|
const versionsHistory = limits.value?.versionsHistory
|
|
if (!versionsHistory) return 'Unlimited'
|
|
|
|
const { value, unit } = versionsHistory
|
|
return `${value} ${unit}`
|
|
})
|
|
|
|
const commentLimitFormatted = computed(() => {
|
|
const commentHistory = limits.value?.commentHistory
|
|
if (!commentHistory) return 'Unlimited'
|
|
|
|
const { value, unit } = commentHistory
|
|
return `${value} ${unit}`
|
|
})
|
|
|
|
return {
|
|
limits,
|
|
versionLimitFormatted,
|
|
commentLimitFormatted
|
|
}
|
|
}
|