mirror of
https://github.com/hcengineering/platform.git
synced 2026-08-21 20:02:22 +02:00
* Configure who should be able to send invitation link Signed-off-by: Artem Savchenko <armisav@gmail.com> * Add user role select Signed-off-by: Artem Savchenko <armisav@gmail.com> * Limit default user roles Signed-off-by: Artem Savchenko <armisav@gmail.com> --------- Signed-off-by: Artem Savchenko <armisav@gmail.com>
377 lines
11 KiB
TypeScript
377 lines
11 KiB
TypeScript
//
|
|
// Copyright © 2020, 2021 Anticrm Platform Contributors.
|
|
//
|
|
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License. You may
|
|
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
//
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
//
|
|
|
|
import type {
|
|
AccountRole,
|
|
Blob,
|
|
Class,
|
|
Configuration,
|
|
Doc,
|
|
Mixin,
|
|
Ref,
|
|
AccountUuid,
|
|
Domain,
|
|
IntegrationKind
|
|
} from '@hcengineering/core'
|
|
import type { Metadata, Plugin } from '@hcengineering/platform'
|
|
import { Asset, IntlString, Resource, plugin } from '@hcengineering/platform'
|
|
import { TemplateField, TemplateFieldCategory } from '@hcengineering/templates'
|
|
import { Action, AnyComponent } from '@hcengineering/ui'
|
|
import { type Integration as AccountIntegration } from '@hcengineering/account-client'
|
|
|
|
import { SpaceTypeCreator, SpaceTypeEditor } from './spaceTypeEditor'
|
|
|
|
export * from './spaceTypeEditor'
|
|
export * from './utils'
|
|
export * from './analytics'
|
|
|
|
export const DOMAIN_SETTING = 'setting' as Domain
|
|
|
|
/**
|
|
* @public
|
|
*/
|
|
export type Handler = Resource<(integration: AccountIntegration) => Promise<void>>
|
|
|
|
/**
|
|
* @public
|
|
*/
|
|
export interface IntegrationType extends Doc {
|
|
label: IntlString
|
|
description: IntlString
|
|
descriptionComponent?: AnyComponent
|
|
stateComponent?: AnyComponent
|
|
icon: AnyComponent
|
|
allowMultiple: boolean
|
|
kind: IntegrationKind
|
|
|
|
createComponent?: AnyComponent
|
|
onDisconnect?: Handler
|
|
onDisconnectAll?: Handler // Disconnect for all workspaces
|
|
reconnectComponent?: AnyComponent
|
|
configureComponent?: AnyComponent
|
|
|
|
getActions?: Resource<(integration?: AccountIntegration) => Promise<Action[]>>
|
|
}
|
|
|
|
/**
|
|
* @public
|
|
*/
|
|
export interface Integration extends Doc {
|
|
type: Ref<IntegrationType>
|
|
disabled: boolean
|
|
value: string
|
|
error?: IntlString | null
|
|
shared?: AccountUuid[]
|
|
}
|
|
|
|
/**
|
|
* @public
|
|
*/
|
|
export interface Editable extends Class<Doc> {
|
|
value: boolean // true is editable, false is not
|
|
}
|
|
|
|
/**
|
|
* @public
|
|
*
|
|
* Mixin to allow delete of Custom classes.
|
|
*/
|
|
export interface UserMixin extends Class<Doc> {}
|
|
|
|
/**
|
|
* @public
|
|
*/
|
|
export interface SettingsCategory extends Doc {
|
|
name: string
|
|
label: IntlString
|
|
icon: Asset
|
|
component: AnyComponent
|
|
props?: Record<string, any>
|
|
|
|
// If defined, will pass kind with key to component
|
|
extraComponents?: Record<string, AnyComponent>
|
|
|
|
group?: string
|
|
|
|
// If defined, will sort using order.
|
|
order?: number
|
|
role: AccountRole
|
|
|
|
// A feature to be used with hides
|
|
feature?: string
|
|
|
|
expandable?: boolean
|
|
adminOnly?: boolean
|
|
}
|
|
|
|
/**
|
|
* @public
|
|
*/
|
|
export interface InviteSettings extends Configuration {
|
|
expirationTime: number
|
|
emailMask: string
|
|
limit: number
|
|
defaultInviteRole: AccountRole
|
|
inviteLinkGeneratorRoles: AccountRole[]
|
|
}
|
|
|
|
/**
|
|
* Stable capability IDs for role-based permissions.
|
|
* Used with RoleCapabilitySettings to define which AccountRoles can perform which actions.
|
|
* @public
|
|
*/
|
|
export const RoleCapability = {
|
|
GenerateInviteLink: 'setting:capability:GenerateInviteLink',
|
|
ManageInviteSettings: 'setting:capability:ManageInviteSettings'
|
|
} as const
|
|
|
|
/**
|
|
* @public
|
|
*/
|
|
export type RoleCapabilityId = (typeof RoleCapability)[keyof typeof RoleCapability]
|
|
|
|
/**
|
|
* Workspace-level config: which AccountRoles have which capabilities.
|
|
* Maps capability ID -> list of roles that have it (account has capability if hasAccountRole(account, role) for any role in the list).
|
|
* @public
|
|
*/
|
|
export interface RoleCapabilitySettings extends Configuration {
|
|
/** capabilityId -> roles that are allowed (e.g. [User, Maintainer, Owner]) */
|
|
roleByCapability: Record<string, AccountRole[]>
|
|
}
|
|
|
|
/**
|
|
* @public
|
|
*/
|
|
export interface OfficeSettings extends Configuration {
|
|
defaultStartWithTranscription: boolean
|
|
defaultStartWithRecording: boolean
|
|
}
|
|
|
|
/**
|
|
* @public
|
|
*/
|
|
export interface WorkspaceSetting extends Doc {
|
|
icon?: Ref<Blob> | null
|
|
}
|
|
|
|
export enum IntegrationError {
|
|
EMAIL_IS_ALREADY_USED = 'EMAIL_IS_ALREADY_USED'
|
|
}
|
|
|
|
/**
|
|
* @public
|
|
*/
|
|
export const settingId = 'setting' as Plugin
|
|
|
|
export default plugin(settingId, {
|
|
ids: {
|
|
SettingApp: '' as Ref<Doc>,
|
|
Profile: '' as Ref<Doc>,
|
|
Password: '' as Ref<Doc>,
|
|
Setting: '' as Ref<Doc>,
|
|
Integrations: '' as Ref<Doc>,
|
|
Relations: '' as Ref<Doc>,
|
|
Support: '' as Ref<Doc>,
|
|
Privacy: '' as Ref<Doc>,
|
|
Terms: '' as Ref<Doc>,
|
|
ClassSetting: '' as Ref<Doc>,
|
|
General: '' as Ref<Doc>,
|
|
Owners: '' as Ref<Doc>,
|
|
InviteSettings: '' as Ref<Doc>,
|
|
RoleCapabilitySettings: '' as Ref<Doc>,
|
|
WorkspaceSetting: '' as Ref<Doc>,
|
|
ManageSpaces: '' as Ref<Doc>,
|
|
Spaces: '' as Ref<Doc>,
|
|
Backup: '' as Ref<Doc>,
|
|
Export: '' as Ref<Doc>,
|
|
OfficeSettings: '' as Ref<Doc>,
|
|
DisablePermissionsConfiguration: '' as Ref<Configuration>,
|
|
Mailboxes: '' as Ref<Doc>
|
|
},
|
|
mixin: {
|
|
Editable: '' as Ref<Mixin<Editable>>,
|
|
UserMixin: '' as Ref<Mixin<UserMixin>>,
|
|
SpaceTypeEditor: '' as Ref<Mixin<SpaceTypeEditor>>,
|
|
SpaceTypeCreator: '' as Ref<Mixin<SpaceTypeCreator>>
|
|
},
|
|
class: {
|
|
SettingsCategory: '' as Ref<Class<SettingsCategory>>,
|
|
WorkspaceSettingCategory: '' as Ref<Class<SettingsCategory>>,
|
|
Integration: '' as Ref<Class<Integration>>,
|
|
IntegrationType: '' as Ref<Class<IntegrationType>>,
|
|
InviteSettings: '' as Ref<Class<InviteSettings>>,
|
|
RoleCapabilitySettings: '' as Ref<Class<RoleCapabilitySettings>>,
|
|
OfficeSettings: '' as Ref<Class<OfficeSettings>>,
|
|
WorkspaceSetting: '' as Ref<Class<WorkspaceSetting>>
|
|
},
|
|
component: {
|
|
Settings: '' as AnyComponent,
|
|
Profile: '' as AnyComponent,
|
|
Password: '' as AnyComponent,
|
|
WorkspaceSettings: '' as AnyComponent,
|
|
Integrations: '' as AnyComponent,
|
|
Support: '' as AnyComponent,
|
|
Privacy: '' as AnyComponent,
|
|
Terms: '' as AnyComponent,
|
|
ClassSetting: '' as AnyComponent,
|
|
PermissionPresenter: '' as AnyComponent,
|
|
AttributePermissionPresenter: '' as AnyComponent,
|
|
ClassPermissionPresenter: '' as AnyComponent,
|
|
SpaceTypeDescriptorPresenter: '' as AnyComponent,
|
|
SpaceTypeGeneralSectionEditor: '' as AnyComponent,
|
|
SpaceTypePropertiesSectionEditor: '' as AnyComponent,
|
|
SpaceTypeRolesSectionEditor: '' as AnyComponent,
|
|
RoleEditor: '' as AnyComponent,
|
|
RoleAssignmentEditor: '' as AnyComponent,
|
|
RelationSetting: '' as AnyComponent,
|
|
Backup: '' as AnyComponent,
|
|
CreateAttributePopup: '' as AnyComponent,
|
|
CreateRelation: '' as AnyComponent,
|
|
EditRelation: '' as AnyComponent,
|
|
Mailboxes: '' as AnyComponent,
|
|
AddEmailSocialId: '' as AnyComponent,
|
|
OfficeSettings: '' as AnyComponent,
|
|
UserRoleSelect: '' as AnyComponent
|
|
},
|
|
string: {
|
|
Settings: '' as IntlString,
|
|
Setting: '' as IntlString,
|
|
Spaces: '' as IntlString,
|
|
WorkspaceSettings: '' as IntlString,
|
|
Integrations: '' as IntlString,
|
|
Support: '' as IntlString,
|
|
Privacy: '' as IntlString,
|
|
Terms: '' as IntlString,
|
|
Categories: '' as IntlString,
|
|
Delete: '' as IntlString,
|
|
Disconnect: '' as IntlString,
|
|
DisconnectAll: '' as IntlString,
|
|
Add: '' as IntlString,
|
|
Proceed: '' as IntlString,
|
|
SendConfirmation: '' as IntlString,
|
|
NewEmail: '' as IntlString,
|
|
AccountSettings: '' as IntlString,
|
|
ChangePassword: '' as IntlString,
|
|
Saving: '' as IntlString,
|
|
Saved: '' as IntlString,
|
|
Signout: '' as IntlString,
|
|
InviteWorkspace: '' as IntlString,
|
|
SelectWorkspace: '' as IntlString,
|
|
Reconnect: '' as IntlString,
|
|
ClassSetting: '' as IntlString,
|
|
Classes: '' as IntlString,
|
|
Owners: '' as IntlString,
|
|
Configure: '' as IntlString,
|
|
InviteSettings: '' as IntlString,
|
|
RoleCapabilitySettings: '' as IntlString,
|
|
DefaultInviteRoleForJoin: '' as IntlString,
|
|
InviteLinkGeneratorRoles: '' as IntlString,
|
|
General: '' as IntlString,
|
|
Properties: '' as IntlString,
|
|
TaskTypes: '' as IntlString,
|
|
Automations: '' as IntlString,
|
|
Collections: '' as IntlString,
|
|
SpaceTypes: '' as IntlString,
|
|
Roles: '' as IntlString,
|
|
OwnerOrMaintainerRequired: '' as IntlString,
|
|
Backup: '' as IntlString,
|
|
BackupLast: '' as IntlString,
|
|
BackupTotalSnapshots: '' as IntlString,
|
|
BackupTotalFiles: '' as IntlString,
|
|
BackupSize: '' as IntlString,
|
|
BackupLinkInfo: '' as IntlString,
|
|
BackupBearerTokenInfo: '' as IntlString,
|
|
BackupSnapshots: '' as IntlString,
|
|
BackupFileDownload: '' as IntlString,
|
|
BackupFiles: '' as IntlString,
|
|
BackupNoBackup: '' as IntlString,
|
|
NonBackupedBlobs: '' as IntlString,
|
|
AddAttribute: '' as IntlString,
|
|
Mailboxes: '' as IntlString,
|
|
CreateMailbox: '' as IntlString,
|
|
CreateMailboxPlaceholder: '' as IntlString,
|
|
MailboxNoDomains: '' as IntlString,
|
|
MailboxLimitReached: '' as IntlString,
|
|
OfficeSettings: '' as IntlString,
|
|
OfficeDefaultSettings: '' as IntlString,
|
|
DefaultStartWithTranscription: '' as IntlString,
|
|
DefaultStartWithRecording: '' as IntlString,
|
|
MailboxErrorInvalidName: '' as IntlString,
|
|
MailboxErrorDomainNotFound: '' as IntlString,
|
|
MailboxErrorNameRulesViolated: '' as IntlString,
|
|
MailboxErrorMailboxExists: '' as IntlString,
|
|
MailboxErrorMailboxCountLimit: '' as IntlString,
|
|
DeleteMailbox: '' as IntlString,
|
|
MailboxDeleteConfirmation: '' as IntlString,
|
|
IntegrationFailed: '' as IntlString,
|
|
IntegrationError: '' as IntlString,
|
|
EmailIsUsed: '' as IntlString,
|
|
Customize: '' as IntlString,
|
|
CodeSent: '' as IntlString,
|
|
SendAgain: '' as IntlString,
|
|
SendAgainIn: '' as IntlString,
|
|
AllIntegrations: '' as IntlString,
|
|
ConnectedIntegrations: '' as IntlString,
|
|
AvailableIntegrations: '' as IntlString,
|
|
Connect: '' as IntlString,
|
|
Integrate: '' as IntlString,
|
|
FailedToLoadIntegrations: '' as IntlString,
|
|
FailedToDisconnect: '' as IntlString,
|
|
ServiceIsUnavailable: '' as IntlString,
|
|
Integrated: '' as IntlString,
|
|
Connected: '' as IntlString,
|
|
Disconnected: '' as IntlString,
|
|
Available: '' as IntlString,
|
|
NotConnectedIntegration: '' as IntlString,
|
|
IntegrationIsUnstable: '' as IntlString
|
|
},
|
|
icon: {
|
|
AccountSettings: '' as Asset,
|
|
Owners: '' as Asset,
|
|
Password: '' as Asset,
|
|
Setting: '' as Asset,
|
|
Integrations: '' as Asset,
|
|
Support: '' as Asset,
|
|
Privacy: '' as Asset,
|
|
Terms: '' as Asset,
|
|
Signout: '' as Asset,
|
|
SelectWorkspace: '' as Asset,
|
|
Clazz: '' as Asset,
|
|
Enums: '' as Asset,
|
|
InviteSettings: '' as Asset,
|
|
InviteWorkspace: '' as Asset,
|
|
Views: '' as Asset,
|
|
Relations: '' as Asset,
|
|
Mailbox: '' as Asset,
|
|
OfficeSettings: '' as Asset
|
|
},
|
|
templateFieldCategory: {
|
|
Integration: '' as Ref<TemplateFieldCategory>
|
|
},
|
|
templateField: {
|
|
OwnerFirstName: '' as Ref<TemplateField>,
|
|
OwnerLastName: '' as Ref<TemplateField>,
|
|
OwnerPosition: '' as Ref<TemplateField>,
|
|
Value: '' as Ref<TemplateField>
|
|
},
|
|
metadata: {
|
|
BackupUrl: '' as Metadata<string>
|
|
},
|
|
function: {
|
|
HasRoleCapability: '' as Resource<(capabilityId: RoleCapabilityId | string) => Promise<boolean>>
|
|
}
|
|
})
|