mirror of
https://github.com/hcengineering/platform.git
synced 2025-06-02 13:52:40 +00:00
ezqms-1029: fix permissions check for creating project doc from context menu (#6282)
Signed-off-by: Alexey Zinoviev <alexey.zinoviev@xored.com>
This commit is contained in:
parent
f09afc7eb3
commit
afd682ed9b
@ -39,7 +39,8 @@
|
|||||||
setCurrentProject,
|
setCurrentProject,
|
||||||
getProjectDocsHierarchy,
|
getProjectDocsHierarchy,
|
||||||
isEditableProject,
|
isEditableProject,
|
||||||
createDocument
|
createDocument,
|
||||||
|
canCreateChildDocument
|
||||||
} from '../../utils'
|
} from '../../utils'
|
||||||
|
|
||||||
import documents from '../../plugin'
|
import documents from '../../plugin'
|
||||||
@ -129,17 +130,19 @@
|
|||||||
async function getSpaceActions (space: DocumentSpace): Promise<Action[]> {
|
async function getSpaceActions (space: DocumentSpace): Promise<Action[]> {
|
||||||
const actions = await getActions(space)
|
const actions = await getActions(space)
|
||||||
|
|
||||||
const action: Action = {
|
if (
|
||||||
|
spaceType?.projects === true &&
|
||||||
|
(await isEditableProject(project)) &&
|
||||||
|
(await canCreateChildDocument(space, true))
|
||||||
|
) {
|
||||||
|
actions.push({
|
||||||
icon: documents.icon.NewDocument,
|
icon: documents.icon.NewDocument,
|
||||||
label: documents.string.CreateDocument,
|
label: documents.string.CreateDocument,
|
||||||
group: 'create',
|
group: 'create',
|
||||||
action: async () => {
|
action: async () => {
|
||||||
await createDocument(space)
|
await createDocument(space)
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
if (spaceType?.projects === true && (await isEditableProject(project))) {
|
|
||||||
actions.push(action)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return orderActions(actions)
|
return orderActions(actions)
|
||||||
|
@ -605,7 +605,8 @@ export async function canCreateChildTemplate (
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function canCreateChildDocument (
|
export async function canCreateChildDocument (
|
||||||
doc?: Document | Document[] | DocumentSpace | DocumentSpace[] | ProjectDocument | ProjectDocument[]
|
doc?: Document | Document[] | DocumentSpace | DocumentSpace[] | ProjectDocument | ProjectDocument[],
|
||||||
|
includeProjects = false
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
if (doc === null || doc === undefined) {
|
if (doc === null || doc === undefined) {
|
||||||
return false
|
return false
|
||||||
@ -625,7 +626,7 @@ export async function canCreateChildDocument (
|
|||||||
|
|
||||||
if (isSpace(hierarchy, doc)) {
|
if (isSpace(hierarchy, doc)) {
|
||||||
const spaceType = await client.findOne(documents.class.DocumentSpaceType, { _id: doc.type })
|
const spaceType = await client.findOne(documents.class.DocumentSpaceType, { _id: doc.type })
|
||||||
return spaceType?.projects !== true
|
return includeProjects || spaceType?.projects !== true
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isProjectDocument(hierarchy, doc)) {
|
if (isProjectDocument(hierarchy, doc)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user