Chunter: Remove attachments only for creator (#1552)

Signed-off-by: Denis Bunakalya <denis.bunakalya@xored.com>
This commit is contained in:
Denis Bunakalya 2022-04-28 21:15:24 +03:00 committed by GitHub
parent d64c009366
commit 260d8d95fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 82 additions and 28 deletions

View File

@ -43,6 +43,7 @@
"FileBrowserTypeFilterVideos": "Videos",
"FileBrowserTypeFilterPDFs": "PDFs",
"AddAttachmentToSaved": "Add attachment to saved",
"RemoveAttachmentFromSaved": "Remove attachment from saved"
"RemoveAttachmentFromSaved": "Remove attachment from saved",
"DeleteFile": "Delete file"
}
}
}

View File

@ -43,6 +43,7 @@
"FileBrowserTypeFilterVideos": "Видео",
"FileBrowserTypeFilterPDFs": "PDF-файлы",
"AddAttachmentToSaved": "Добавить вложение в сохраненные",
"RemoveAttachmentFromSaved": "Удалить вложение из сохраненных"
"RemoveAttachmentFromSaved": "Удалить вложение из сохраненных",
"DeleteFile": "Удалить файл"
}
}
}

View File

@ -13,22 +13,39 @@
// limitations under the License.
-->
<script lang="ts">
import { Attachment } from '@anticrm/attachment'
import { Doc } from '@anticrm/core'
import { getFileUrl } from '@anticrm/presentation'
import { Icon, IconMoreV, showPopup } from '@anticrm/ui'
import { Menu } from '@anticrm/view-resources'
import attachment, { Attachment } from '@anticrm/attachment'
import { Doc, getCurrentAccount } from '@anticrm/core'
import { getFileUrl, getClient } from '@anticrm/presentation'
import { Icon, IconMoreV, showPopup, Menu } from '@anticrm/ui'
import FileDownload from './icons/FileDownload.svelte'
import { AttachmentGalleryPresenter } from '..'
export let attachments: Attachment[]
let selectedFileNumber: number | undefined
const myAccId = getCurrentAccount()._id
const client = getClient()
const showFileMenu = async (ev: MouseEvent, object: Doc, fileNumber: number): Promise<void> => {
selectedFileNumber = fileNumber
showPopup(Menu, { object }, ev.target as HTMLElement, () => {
selectedFileNumber = undefined
})
showPopup(
Menu,
{
actions: [
...(myAccId === object.modifiedBy
? [
{
label: attachment.string.DeleteFile,
action: async () => await client.removeDoc(object._class, object.space, object._id)
}
]
: [])
]
},
ev.target as HTMLElement,
() => {
selectedFileNumber = undefined
}
)
}
</script>

View File

@ -13,22 +13,39 @@
// limitations under the License.
-->
<script lang="ts">
import { Attachment } from '@anticrm/attachment'
import { Doc } from '@anticrm/core'
import { getFileUrl } from '@anticrm/presentation'
import { Icon, IconMoreV, showPopup } from '@anticrm/ui'
import { Menu } from '@anticrm/view-resources'
import attachment, { Attachment } from '@anticrm/attachment'
import { Doc, getCurrentAccount } from '@anticrm/core'
import { getFileUrl, getClient } from '@anticrm/presentation'
import { Icon, IconMoreV, showPopup, Menu } from '@anticrm/ui'
import FileDownload from './icons/FileDownload.svelte'
import { AttachmentPresenter } from '..'
export let attachments: Attachment[]
let selectedFileNumber: number | undefined
const myAccId = getCurrentAccount()._id
const client = getClient()
const showFileMenu = async (ev: MouseEvent, object: Doc, fileNumber: number): Promise<void> => {
selectedFileNumber = fileNumber
showPopup(Menu, { object }, ev.target as HTMLElement, () => {
selectedFileNumber = undefined
})
showPopup(
Menu,
{
actions: [
...(myAccId === object.modifiedBy
? [
{
label: attachment.string.DeleteFile,
action: async () => await client.removeDoc(object._class, object.space, object._id)
}
]
: [])
]
},
ev.target as HTMLElement,
() => {
selectedFileNumber = undefined
}
)
}
</script>

View File

@ -83,6 +83,7 @@ export default plugin(attachmentId, {
FileBrowserTypeFilterImages: '' as IntlString,
FileBrowserTypeFilterAudio: '' as IntlString,
FileBrowserTypeFilterVideos: '' as IntlString,
FileBrowserTypeFilterPDFs: '' as IntlString
FileBrowserTypeFilterPDFs: '' as IntlString,
DeleteFile: '' as IntlString
}
})

View File

@ -17,12 +17,13 @@
import attachment, { Attachment } from '@anticrm/attachment'
import { AttachmentPresenter, FileDownload } from '@anticrm/attachment-resources'
import { ChunterSpace } from '@anticrm/chunter'
import { Doc, SortingOrder } from '@anticrm/core'
import { createQuery, getFileUrl } from '@anticrm/presentation'
import { Menu } from '@anticrm/view-resources'
import { getCurrentLocation, showPopup, IconMoreV, Label, navigate, Icon } from '@anticrm/ui'
import { Doc, SortingOrder, getCurrentAccount } from '@anticrm/core'
import { createQuery, getFileUrl, getClient } from '@anticrm/presentation'
import { getCurrentLocation, showPopup, IconMoreV, Label, navigate, Icon, Menu } from '@anticrm/ui'
export let channel: ChunterSpace | undefined
const myAccId = getCurrentAccount()._id
const client = getClient()
const query = createQuery()
let visibleAttachments: Attachment[] | undefined
@ -33,9 +34,25 @@
const showMenu = async (ev: MouseEvent, object: Doc, rowNumber: number): Promise<void> => {
selectedRowNumber = rowNumber
showPopup(Menu, { object }, ev.target as HTMLElement, () => {
selectedRowNumber = undefined
})
showPopup(
Menu,
{
actions: [
...(myAccId === object.modifiedBy
? [
{
label: attachment.string.DeleteFile,
action: async () => await client.removeDoc(object._class, object.space, object._id)
}
]
: [])
]
},
ev.target as HTMLElement,
() => {
selectedRowNumber = undefined
}
)
}
$: channel &&