mirror of
https://github.com/hcengineering/platform.git
synced 2025-06-08 08:51:12 +00:00
Remove team (#2625)
Signed-off-by: Vyacheslav Tumanov <me@slavatumanov.me>
This commit is contained in:
parent
6450ebe66d
commit
93305b512a
@ -36,4 +36,8 @@ export function createModel (builder: Builder): void {
|
|||||||
builder.createDoc(serverCore.class.Trigger, core.space.Model, {
|
builder.createDoc(serverCore.class.Trigger, core.space.Model, {
|
||||||
trigger: serverTracker.trigger.OnProjectRemove
|
trigger: serverTracker.trigger.OnProjectRemove
|
||||||
})
|
})
|
||||||
|
|
||||||
|
builder.createDoc(serverCore.class.Trigger, core.space.Model, {
|
||||||
|
trigger: serverTracker.trigger.OnTeamDelete
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@ -1085,6 +1085,26 @@ export function createModel (builder: Builder): void {
|
|||||||
tracker.action.EditTeam
|
tracker.action.EditTeam
|
||||||
)
|
)
|
||||||
|
|
||||||
|
createAction(
|
||||||
|
builder,
|
||||||
|
{
|
||||||
|
action: tracker.actionImpl.DeleteTeam,
|
||||||
|
label: tracker.string.DeleteTeam,
|
||||||
|
icon: view.icon.Delete,
|
||||||
|
input: 'focus',
|
||||||
|
category: tracker.category.Tracker,
|
||||||
|
target: tracker.class.Team,
|
||||||
|
query: {
|
||||||
|
archived: false
|
||||||
|
},
|
||||||
|
context: {
|
||||||
|
mode: ['context', 'browser'],
|
||||||
|
group: 'edit'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
tracker.action.DeleteTeam
|
||||||
|
)
|
||||||
|
|
||||||
builder.createDoc(
|
builder.createDoc(
|
||||||
view.class.ActionCategory,
|
view.class.ActionCategory,
|
||||||
core.space.Model,
|
core.space.Model,
|
||||||
|
@ -58,11 +58,13 @@ export default mergeIds(trackerId, tracker, {
|
|||||||
CopyToClipboard: '' as ViewAction,
|
CopyToClipboard: '' as ViewAction,
|
||||||
EditWorkflowStatuses: '' as ViewAction,
|
EditWorkflowStatuses: '' as ViewAction,
|
||||||
EditTeam: '' as ViewAction,
|
EditTeam: '' as ViewAction,
|
||||||
|
DeleteTeam: '' as ViewAction,
|
||||||
DeleteSprint: '' as ViewAction
|
DeleteSprint: '' as ViewAction
|
||||||
},
|
},
|
||||||
action: {
|
action: {
|
||||||
NewRelatedIssue: '' as Ref<Action<Doc, Record<string, any>>>,
|
NewRelatedIssue: '' as Ref<Action<Doc, Record<string, any>>>,
|
||||||
DeleteSprint: '' as Ref<Action<Doc, Record<string, any>>>,
|
DeleteSprint: '' as Ref<Action<Doc, Record<string, any>>>,
|
||||||
|
DeleteTeam: '' as Ref<Action<Doc, Record<string, any>>>,
|
||||||
SetSprintLead: '' as Ref<Action<Doc, Record<string, any>>>
|
SetSprintLead: '' as Ref<Action<Doc, Record<string, any>>>
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -177,6 +177,9 @@
|
|||||||
"EditIssue": "Edit {title}",
|
"EditIssue": "Edit {title}",
|
||||||
"EditWorkflowStatuses": "Edit issue statuses",
|
"EditWorkflowStatuses": "Edit issue statuses",
|
||||||
"EditTeam": "Edit team",
|
"EditTeam": "Edit team",
|
||||||
|
"DeleteTeam": "Delete team",
|
||||||
|
"DeleteTeamName": "Delete team {name}?",
|
||||||
|
"TeamHasIssues": "There are existing issues in this team, are you sure that you want to delete? Both the team and the issues will be deleted.",
|
||||||
"ManageWorkflowStatuses": "Manage issue statuses within team",
|
"ManageWorkflowStatuses": "Manage issue statuses within team",
|
||||||
"AddWorkflowStatus": "Add issue status",
|
"AddWorkflowStatus": "Add issue status",
|
||||||
"EditWorkflowStatus": "Edit issue status",
|
"EditWorkflowStatus": "Edit issue status",
|
||||||
|
@ -177,6 +177,9 @@
|
|||||||
"EditIssue": "Редактирование {title}",
|
"EditIssue": "Редактирование {title}",
|
||||||
"EditWorkflowStatuses": "Редактировать статусы задач",
|
"EditWorkflowStatuses": "Редактировать статусы задач",
|
||||||
"EditTeam": "Редактировать команду",
|
"EditTeam": "Редактировать команду",
|
||||||
|
"DeleteTeam": "Удалить команду",
|
||||||
|
"DeleteTeamName": "Удалить команду {name}?",
|
||||||
|
"TeamHasIssues": "Для данной команды существуют задачи, уверены, что хотите удалить? Задачи и команда будут удалены.",
|
||||||
"ManageWorkflowStatuses": "Управлять статусами задач для команды",
|
"ManageWorkflowStatuses": "Управлять статусами задач для команды",
|
||||||
"AddWorkflowStatus": "Добавить статус задачи",
|
"AddWorkflowStatus": "Добавить статус задачи",
|
||||||
"EditWorkflowStatus": "Редактировать статус задачи",
|
"EditWorkflowStatus": "Редактировать статус задачи",
|
||||||
|
@ -119,7 +119,8 @@ import {
|
|||||||
getAllStatuses,
|
getAllStatuses,
|
||||||
getAllPriority,
|
getAllPriority,
|
||||||
getAllProjects,
|
getAllProjects,
|
||||||
getAllSprints
|
getAllSprints,
|
||||||
|
removeTeam
|
||||||
} from './utils'
|
} from './utils'
|
||||||
import { deleteObject } from '@hcengineering/view-resources/src/utils'
|
import { deleteObject } from '@hcengineering/view-resources/src/utils'
|
||||||
|
|
||||||
@ -201,6 +202,31 @@ async function editTeam (team: Team | undefined): Promise<void> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function deleteTeam (team: Team | undefined): Promise<void> {
|
||||||
|
if (team !== undefined) {
|
||||||
|
const client = getClient()
|
||||||
|
const anyIssue = await client.findOne(tracker.class.Issue, { space: team._id })
|
||||||
|
if (anyIssue !== undefined) {
|
||||||
|
showPopup(
|
||||||
|
MessageBox,
|
||||||
|
{
|
||||||
|
label: tracker.string.DeleteTeamName,
|
||||||
|
labelProps: { name: team.name },
|
||||||
|
message: tracker.string.TeamHasIssues
|
||||||
|
},
|
||||||
|
undefined,
|
||||||
|
(result?: boolean) => {
|
||||||
|
if (result === true) {
|
||||||
|
void removeTeam(team)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
await removeTeam(team)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function moveAndDeleteSprints (client: TxOperations, oldSprints: Sprint[], newSprint?: Sprint): Promise<void> {
|
async function moveAndDeleteSprints (client: TxOperations, oldSprints: Sprint[], newSprint?: Sprint): Promise<void> {
|
||||||
const noSprintLabel = await translate(tracker.string.NoSprint, {})
|
const noSprintLabel = await translate(tracker.string.NoSprint, {})
|
||||||
|
|
||||||
@ -412,7 +438,8 @@ export default async (): Promise<Resources> => ({
|
|||||||
actionImpl: {
|
actionImpl: {
|
||||||
EditWorkflowStatuses: editWorkflowStatuses,
|
EditWorkflowStatuses: editWorkflowStatuses,
|
||||||
EditTeam: editTeam,
|
EditTeam: editTeam,
|
||||||
DeleteSprint: deleteSprint
|
DeleteSprint: deleteSprint,
|
||||||
|
DeleteTeam: deleteTeam
|
||||||
},
|
},
|
||||||
resolver: {
|
resolver: {
|
||||||
Location: resolveLocation
|
Location: resolveLocation
|
||||||
|
@ -96,6 +96,9 @@ export default mergeIds(trackerId, tracker, {
|
|||||||
IssueStatuses: '' as IntlString,
|
IssueStatuses: '' as IntlString,
|
||||||
EditWorkflowStatuses: '' as IntlString,
|
EditWorkflowStatuses: '' as IntlString,
|
||||||
EditTeam: '' as IntlString,
|
EditTeam: '' as IntlString,
|
||||||
|
DeleteTeam: '' as IntlString,
|
||||||
|
DeleteTeamName: '' as IntlString,
|
||||||
|
TeamHasIssues: '' as IntlString,
|
||||||
ManageWorkflowStatuses: '' as IntlString,
|
ManageWorkflowStatuses: '' as IntlString,
|
||||||
AddWorkflowStatus: '' as IntlString,
|
AddWorkflowStatus: '' as IntlString,
|
||||||
EditWorkflowStatus: '' as IntlString,
|
EditWorkflowStatus: '' as IntlString,
|
||||||
|
@ -30,7 +30,7 @@ import core, {
|
|||||||
} from '@hcengineering/core'
|
} from '@hcengineering/core'
|
||||||
import { TypeState } from '@hcengineering/kanban'
|
import { TypeState } from '@hcengineering/kanban'
|
||||||
import { Asset, IntlString, translate } from '@hcengineering/platform'
|
import { Asset, IntlString, translate } from '@hcengineering/platform'
|
||||||
import { createQuery } from '@hcengineering/presentation'
|
import { createQuery, getClient } from '@hcengineering/presentation'
|
||||||
import {
|
import {
|
||||||
Issue,
|
Issue,
|
||||||
IssuePriority,
|
IssuePriority,
|
||||||
@ -650,3 +650,8 @@ export async function getPreviousAssignees (
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function removeTeam (teamToDelete: Team): Promise<void> {
|
||||||
|
const client = getClient()
|
||||||
|
await client.removeDoc(tracker.class.Team, core.space.Space, teamToDelete._id)
|
||||||
|
}
|
||||||
|
@ -36,7 +36,7 @@ import { getMetadata } from '@hcengineering/platform'
|
|||||||
import { Resource } from '@hcengineering/platform/lib/platform'
|
import { Resource } from '@hcengineering/platform/lib/platform'
|
||||||
import { TriggerControl } from '@hcengineering/server-core'
|
import { TriggerControl } from '@hcengineering/server-core'
|
||||||
import { addAssigneeNotification } from '@hcengineering/server-task-resources'
|
import { addAssigneeNotification } from '@hcengineering/server-task-resources'
|
||||||
import tracker, { Issue, IssueParentInfo, Project, TimeSpendReport, trackerId } from '@hcengineering/tracker'
|
import tracker, { Issue, IssueParentInfo, Project, Team, TimeSpendReport, trackerId } from '@hcengineering/tracker'
|
||||||
|
|
||||||
async function updateSubIssues (
|
async function updateSubIssues (
|
||||||
updateTx: TxUpdateDoc<Issue>,
|
updateTx: TxUpdateDoc<Issue>,
|
||||||
@ -96,6 +96,32 @@ export async function addTrackerAssigneeNotification (
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
export async function OnTeamDelete (tx: Tx, control: TriggerControl): Promise<Tx[]> {
|
||||||
|
const actualTx = TxProcessor.extractTx(tx)
|
||||||
|
if (actualTx._class !== core.class.TxRemoveDoc) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
|
||||||
|
const ctx = actualTx as TxRemoveDoc<Team>
|
||||||
|
|
||||||
|
if (ctx.objectClass !== tracker.class.Team) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
const issues = await control.findAll(tracker.class.Issue, {
|
||||||
|
space: ctx.objectId
|
||||||
|
})
|
||||||
|
|
||||||
|
const res: Tx[] = []
|
||||||
|
issues.forEach((issue) => {
|
||||||
|
res.push(control.txFactory.createTxRemoveDoc(issue._class, issue.space, issue._id))
|
||||||
|
})
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
@ -202,7 +228,8 @@ export default async () => ({
|
|||||||
},
|
},
|
||||||
trigger: {
|
trigger: {
|
||||||
OnIssueUpdate,
|
OnIssueUpdate,
|
||||||
OnProjectRemove
|
OnProjectRemove,
|
||||||
|
OnTeamDelete
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ export default plugin(serverTrackerId, {
|
|||||||
},
|
},
|
||||||
trigger: {
|
trigger: {
|
||||||
OnIssueUpdate: '' as Resource<TriggerFunc>,
|
OnIssueUpdate: '' as Resource<TriggerFunc>,
|
||||||
OnProjectRemove: '' as Resource<TriggerFunc>
|
OnProjectRemove: '' as Resource<TriggerFunc>,
|
||||||
|
OnTeamDelete: '' as Resource<TriggerFunc>
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user