EZQMS-729: Restrict spaces operations (#5500)

This commit is contained in:
Alexey Zinoviev
2024-05-04 20:49:24 +07:00
committed by GitHub
parent ad59463057
commit 4bc1534ee0
57 changed files with 873 additions and 114 deletions
+45 -13
View File
@@ -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
}
})