mirror of
https://github.com/nextcloud/server.git
synced 2026-06-09 00:32:29 -04:00
Merge pull request #44844 from nextcloud/backport/44834/stable28
[stable28] fix(files): Inherit some node attributes when creating new nodes to preserve shared state
This commit is contained in:
commit
cfd7e99240
14 changed files with 51 additions and 21 deletions
|
|
@ -48,7 +48,8 @@ const isDownloadable = function(node: Node) {
|
|||
|
||||
// If the mount type is a share, ensure it got download permissions.
|
||||
if (node.attributes['mount-type'] === 'shared') {
|
||||
const downloadAttribute = JSON.parse(node.attributes['share-attributes']).find((attribute: { scope: string; key: string }) => attribute.scope === 'permissions' && attribute.key === 'download')
|
||||
const shareAttributes = JSON.parse(node.attributes['share-attributes'] ?? 'null')
|
||||
const downloadAttribute = shareAttributes?.find?.((attribute: { scope: string; key: string }) => attribute.scope === 'permissions' && attribute.key === 'download')
|
||||
if (downloadAttribute !== undefined && downloadAttribute.enabled === false) {
|
||||
return false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,13 +93,15 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { DefaultType, FileAction, Node, NodeStatus, View, getFileActions } from '@nextcloud/files'
|
||||
import type { FileAction, Node, View } from '@nextcloud/files'
|
||||
import type { PropType } from 'vue'
|
||||
|
||||
import { showError, showSuccess } from '@nextcloud/dialogs'
|
||||
import { DefaultType, NodeStatus, getFileActions } from '@nextcloud/files'
|
||||
import { translate as t } from '@nextcloud/l10n'
|
||||
import Vue, { PropType } from 'vue'
|
||||
import Vue, { defineComponent } from 'vue'
|
||||
|
||||
import ArrowLeftIcon from 'vue-material-design-icons/ArrowLeft.vue'
|
||||
import ChevronRightIcon from 'vue-material-design-icons/ChevronRight.vue'
|
||||
import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
|
||||
import NcActions from '@nextcloud/vue/dist/Components/NcActions.js'
|
||||
import NcActionSeparator from '@nextcloud/vue/dist/Components/NcActionSeparator.js'
|
||||
|
|
@ -112,12 +114,11 @@ import logger from '../../logger.js'
|
|||
// The registered actions list
|
||||
const actions = getFileActions()
|
||||
|
||||
export default Vue.extend({
|
||||
export default defineComponent({
|
||||
name: 'FileEntryActions',
|
||||
|
||||
components: {
|
||||
ArrowLeftIcon,
|
||||
ChevronRightIcon,
|
||||
CustomElementRender,
|
||||
NcActionButton,
|
||||
NcActions,
|
||||
|
|
@ -335,7 +336,7 @@ export default Vue.extend({
|
|||
// Focus the previous menu action button
|
||||
this.$nextTick(() => {
|
||||
// Focus the action button
|
||||
const menuAction = this.$refs[`action-${action.id}`][0]
|
||||
const menuAction = this.$refs[`action-${action.id}`]?.[0]
|
||||
if (menuAction) {
|
||||
menuAction.$el.querySelector('button')?.focus()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,6 +74,12 @@ export const entry = {
|
|||
owner: getCurrentUser()?.uid || null,
|
||||
permissions: Permission.ALL,
|
||||
root: context?.root || '/files/' + getCurrentUser()?.uid,
|
||||
// Include mount-type from parent folder as this is inherited
|
||||
attributes: {
|
||||
'mount-type': context.attributes?.['mount-type'],
|
||||
'owner-id': context.attributes?.['owner-id'],
|
||||
'owner-display-name': context.attributes?.['owner-display-name'],
|
||||
},
|
||||
})
|
||||
|
||||
showSuccess(t('files', 'Created new folder "{name}"', { name: basename(source) }))
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ import Vue, { defineAsyncComponent } from 'vue'
|
|||
const TemplatePickerVue = defineAsyncComponent(() => import('../views/TemplatePicker.vue'))
|
||||
let TemplatePicker: ComponentInstance & { open: (n: string, t: TemplateFile) => void } | null = null
|
||||
|
||||
const getTemplatePicker = async () => {
|
||||
const getTemplatePicker = async (context: Folder) => {
|
||||
if (TemplatePicker === null) {
|
||||
// Create document root
|
||||
const mountingPoint = document.createElement('div')
|
||||
|
|
@ -45,7 +45,15 @@ const getTemplatePicker = async () => {
|
|||
|
||||
// Init vue app
|
||||
TemplatePicker = new Vue({
|
||||
render: (h) => h(TemplatePickerVue, { ref: 'picker' }),
|
||||
render: (h) => h(
|
||||
TemplatePickerVue,
|
||||
{
|
||||
ref: 'picker',
|
||||
props: {
|
||||
parent: context,
|
||||
},
|
||||
},
|
||||
),
|
||||
methods: { open(...args) { this.$refs.picker.open(...args) } },
|
||||
el: mountingPoint,
|
||||
})
|
||||
|
|
@ -71,7 +79,7 @@ export function registerTemplateEntries() {
|
|||
},
|
||||
order: 11,
|
||||
async handler(context: Folder, content: Node[]) {
|
||||
const templatePicker = getTemplatePicker()
|
||||
const templatePicker = getTemplatePicker(context)
|
||||
const name = await newNodeName(`${provider.label}${provider.extension}`, content, {
|
||||
label: t('files', 'Filename'),
|
||||
name: provider.label,
|
||||
|
|
|
|||
|
|
@ -90,6 +90,16 @@ export default defineComponent({
|
|||
TemplatePreview,
|
||||
},
|
||||
|
||||
props: {
|
||||
/**
|
||||
* The parent folder where to create the node
|
||||
*/
|
||||
parent: {
|
||||
type: Object,
|
||||
default: () => null,
|
||||
},
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
// Check empty template by default
|
||||
|
|
@ -109,7 +119,7 @@ export default defineComponent({
|
|||
nameWithoutExt() {
|
||||
// Strip extension from name if defined
|
||||
return !this.extension
|
||||
? this.name
|
||||
? this.name!
|
||||
: this.name!.slice(0, 0 - this.extension.length)
|
||||
},
|
||||
|
||||
|
|
@ -236,6 +246,10 @@ export default defineComponent({
|
|||
size: fileInfo.size,
|
||||
permissions: fileInfo.permissions,
|
||||
attributes: {
|
||||
// Inherit some attributes from parent folder like the mount type and real owner
|
||||
'mount-type': this.parent?.attributes?.['mount-type'],
|
||||
'owner-id': this.parent?.attributes?.['owner-id'],
|
||||
'owner-display-name': this.parent?.attributes?.['owner-display-name'],
|
||||
...fileInfo,
|
||||
'has-preview': fileInfo.hasPreview,
|
||||
},
|
||||
|
|
|
|||
3
dist/2379-2379.js
vendored
3
dist/2379-2379.js
vendored
File diff suppressed because one or more lines are too long
1
dist/2379-2379.js.map
vendored
1
dist/2379-2379.js.map
vendored
File diff suppressed because one or more lines are too long
3
dist/5929-5929.js
vendored
Normal file
3
dist/5929-5929.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/5929-5929.js.map
vendored
Normal file
1
dist/5929-5929.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
4
dist/files-init.js
vendored
4
dist/files-init.js
vendored
File diff suppressed because one or more lines are too long
2
dist/files-init.js.map
vendored
2
dist/files-init.js.map
vendored
File diff suppressed because one or more lines are too long
4
dist/files-main.js
vendored
4
dist/files-main.js
vendored
File diff suppressed because one or more lines are too long
2
dist/files-main.js.map
vendored
2
dist/files-main.js.map
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue