mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-10 11:47:42 +02:00
EZQMS-729: Restrict spaces operations (#5500)
This commit is contained in:
@@ -179,6 +179,37 @@ export async function OnComponentRemove (tx: Tx, control: TriggerControl): Promi
|
||||
return res
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export async function OnWorkspaceOwnerAdded (tx: Tx, control: TriggerControl): Promise<Tx[]> {
|
||||
const targetProject = (
|
||||
await control.findAll(tracker.class.Project, {
|
||||
_id: tracker.project.DefaultProject
|
||||
})
|
||||
)[0]
|
||||
|
||||
if (targetProject === undefined) {
|
||||
return []
|
||||
}
|
||||
|
||||
const res: Tx[] = []
|
||||
const actualTx = tx as TxUpdateDoc<PersonAccount>
|
||||
|
||||
if (
|
||||
targetProject.owners === undefined ||
|
||||
targetProject.owners.length === 0 ||
|
||||
targetProject.owners[0] === core.account.System
|
||||
) {
|
||||
const updTx = control.txFactory.createTxUpdateDoc(tracker.class.Project, targetProject.space, targetProject._id, {
|
||||
owners: [actualTx.objectId]
|
||||
})
|
||||
res.push(updTx)
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
@@ -245,19 +276,6 @@ export async function OnIssueUpdate (tx: Tx, control: TriggerControl): Promise<T
|
||||
return []
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
||||
export default async () => ({
|
||||
function: {
|
||||
IssueHTMLPresenter: issueHTMLPresenter,
|
||||
IssueTextPresenter: issueTextPresenter,
|
||||
IssueNotificationContentProvider: getIssueNotificationContent
|
||||
},
|
||||
trigger: {
|
||||
OnIssueUpdate,
|
||||
OnComponentRemove
|
||||
}
|
||||
})
|
||||
|
||||
async function doTimeReportUpdate (cud: TxCUD<TimeSpendReport>, tx: Tx, control: TriggerControl): Promise<Tx[]> {
|
||||
const parentTx = tx as TxCollectionCUD<Issue, TimeSpendReport>
|
||||
switch (cud._class) {
|
||||
@@ -465,3 +483,17 @@ function updateIssueParentEstimations (
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
||||
export default async () => ({
|
||||
function: {
|
||||
IssueHTMLPresenter: issueHTMLPresenter,
|
||||
IssueTextPresenter: issueTextPresenter,
|
||||
IssueNotificationContentProvider: getIssueNotificationContent
|
||||
},
|
||||
trigger: {
|
||||
OnIssueUpdate,
|
||||
OnComponentRemove,
|
||||
OnWorkspaceOwnerAdded
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user