feat(workspaces): toggle embedded viewer branding (#4762)
* feat(viewer): embedded viewer option to hide speckle branding * chore(viewer): can edit embed options policy * chore(embeds): tests for new policy and gql
This commit is contained in:
@@ -30,6 +30,14 @@ export default {
|
||||
workspaceId: parent.workspaceId
|
||||
})
|
||||
return Authz.toGraphqlResult(canMoveProjectToWorkspace)
|
||||
},
|
||||
canEditEmbedOptions: async (parent, _args, ctx) => {
|
||||
const canEditEmbedOptions =
|
||||
await ctx.authPolicies.workspace.canUpdateEmbedOptions({
|
||||
userId: ctx.userId,
|
||||
workspaceId: parent.workspaceId
|
||||
})
|
||||
return Authz.toGraphqlResult(canEditEmbedOptions)
|
||||
}
|
||||
}
|
||||
} as Resolvers
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
countInvitableCollaboratorsByProjectIdFactory,
|
||||
getInvitableCollaboratorsByProjectIdFactory
|
||||
} from '@/modules/workspaces/repositories/users'
|
||||
import { getWorkspaceFactory } from '@/modules/workspaces/repositories/workspaces'
|
||||
import { getMoveProjectToWorkspaceDryRunFactory } from '@/modules/workspaces/services/projects'
|
||||
|
||||
const { FF_WORKSPACES_MODULE_ENABLED } = getFeatureFlags()
|
||||
@@ -61,6 +62,21 @@ export default FF_WORKSPACES_MODULE_ENABLED
|
||||
})({ projectId, workspaceId })
|
||||
|
||||
return addedToWorkspace
|
||||
},
|
||||
embedOptions: async (parent) => {
|
||||
const { workspaceId } = parent
|
||||
|
||||
if (!workspaceId) {
|
||||
return {
|
||||
hideSpeckleBranding: false
|
||||
}
|
||||
}
|
||||
|
||||
const workspace = await getWorkspaceFactory({ db })({ workspaceId })
|
||||
|
||||
return {
|
||||
hideSpeckleBranding: workspace?.isEmbedSpeckleBrandingHidden ?? false
|
||||
}
|
||||
}
|
||||
},
|
||||
ProjectMoveToWorkspaceDryRun: {
|
||||
|
||||
@@ -1042,6 +1042,44 @@ export = FF_WORKSPACES_MODULE_ENABLED
|
||||
)
|
||||
return true
|
||||
},
|
||||
updateEmbedOptions: async (parent, args, context) => {
|
||||
const { workspaceId, hideSpeckleBranding } = args.input
|
||||
|
||||
const logger = context.log.child({ workspaceId })
|
||||
|
||||
return await asOperation(
|
||||
async ({ db, emit }) => {
|
||||
const workspace = await updateWorkspaceFactory({
|
||||
validateSlug: validateSlugFactory({
|
||||
getWorkspaceBySlug: getWorkspaceBySlugFactory({ db })
|
||||
}),
|
||||
getWorkspace: getWorkspaceWithDomainsFactory({ db }),
|
||||
getWorkspaceSsoProviderRecord: getWorkspaceSsoProviderFactory({
|
||||
db,
|
||||
decrypt: getDecryptor()
|
||||
}),
|
||||
upsertWorkspace: upsertWorkspaceFactory({ db }),
|
||||
emitWorkspaceEvent: emit
|
||||
})({
|
||||
workspaceId,
|
||||
workspaceInput: {
|
||||
isEmbedSpeckleBrandingHidden: hideSpeckleBranding
|
||||
}
|
||||
})
|
||||
|
||||
return {
|
||||
hideSpeckleBranding: workspace.isEmbedSpeckleBrandingHidden
|
||||
}
|
||||
},
|
||||
{
|
||||
logger,
|
||||
name: 'updateWorkspaceEmbedOptions',
|
||||
description:
|
||||
'Update workspace-level configuration for the embedded viewer',
|
||||
transaction: true
|
||||
}
|
||||
)
|
||||
},
|
||||
invites: () => ({}),
|
||||
projects: () => ({}),
|
||||
dismiss: async (_parent, args, ctx) => {
|
||||
@@ -1652,6 +1690,11 @@ export = FF_WORKSPACES_MODULE_ENABLED
|
||||
return await getWorkspaceSsoProviderRecordFactory({ db })({
|
||||
workspaceId: parent.id
|
||||
})
|
||||
},
|
||||
embedOptions: async (parent) => {
|
||||
return {
|
||||
hideSpeckleBranding: parent.isEmbedSpeckleBrandingHidden
|
||||
}
|
||||
}
|
||||
},
|
||||
WorkspaceSso: {
|
||||
|
||||
Reference in New Issue
Block a user