Skip to content

Commit 38bd20b

Browse files
authored
Merge pull request #44845 from nextcloud/backport/44834/stable29
2 parents e31e542 + 3a8a0d1 commit 38bd20b

File tree

14 files changed

+47
-20
lines changed

14 files changed

+47
-20
lines changed

apps/files/src/actions/downloadAction.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ const isDownloadable = function(node: Node) {
4848

4949
// If the mount type is a share, ensure it got download permissions.
5050
if (node.attributes['mount-type'] === 'shared') {
51-
const downloadAttribute = JSON.parse(node.attributes['share-attributes']).find((attribute: { scope: string; key: string }) => attribute.scope === 'permissions' && attribute.key === 'download')
51+
const shareAttributes = JSON.parse(node.attributes['share-attributes'] ?? 'null')
52+
const downloadAttribute = shareAttributes?.find?.((attribute: { scope: string; key: string }) => attribute.scope === 'permissions' && attribute.key === 'download')
5253
if (downloadAttribute !== undefined && downloadAttribute.enabled === false) {
5354
return false
5455
}

apps/files/src/components/FileEntry/FileEntryActions.vue

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,21 +105,19 @@ import NcActionSeparator from '@nextcloud/vue/dist/Components/NcActionSeparator.
105105
import NcIconSvgWrapper from '@nextcloud/vue/dist/Components/NcIconSvgWrapper.js'
106106
import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js'
107107
import ArrowLeftIcon from 'vue-material-design-icons/ArrowLeft.vue'
108-
import ChevronRightIcon from 'vue-material-design-icons/ChevronRight.vue'
109-
import Vue from 'vue'
108+
import Vue, { defineComponent } from 'vue'
110109
111110
import CustomElementRender from '../CustomElementRender.vue'
112111
import logger from '../../logger.js'
113112
114113
// The registered actions list
115114
const actions = getFileActions()
116115
117-
export default Vue.extend({
116+
export default defineComponent({
118117
name: 'FileEntryActions',
119118
120119
components: {
121120
ArrowLeftIcon,
122-
ChevronRightIcon,
123121
CustomElementRender,
124122
NcActionButton,
125123
NcActions,
@@ -337,7 +335,7 @@ export default Vue.extend({
337335
// Focus the previous menu action button
338336
this.$nextTick(() => {
339337
// Focus the action button
340-
const menuAction = this.$refs[`action-${action.id}`][0]
338+
const menuAction = this.$refs[`action-${action.id}`]?.[0]
341339
if (menuAction) {
342340
menuAction.$el.querySelector('button')?.focus()
343341
}

apps/files/src/newMenu/newFolder.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ export const entry = {
7474
owner: getCurrentUser()?.uid || null,
7575
permissions: Permission.ALL,
7676
root: context?.root || '/files/' + getCurrentUser()?.uid,
77+
// Include mount-type from parent folder as this is inherited
78+
attributes: {
79+
'mount-type': context.attributes?.['mount-type'],
80+
'owner-id': context.attributes?.['owner-id'],
81+
'owner-display-name': context.attributes?.['owner-display-name'],
82+
},
7783
})
7884

7985
showSuccess(t('files', 'Created new folder "{name}"', { name: basename(source) }))

apps/files/src/newMenu/newFromTemplate.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import Vue, { defineAsyncComponent } from 'vue'
3636
const TemplatePickerVue = defineAsyncComponent(() => import('../views/TemplatePicker.vue'))
3737
let TemplatePicker: ComponentInstance & { open: (n: string, t: TemplateFile) => void } | null = null
3838

39-
const getTemplatePicker = async () => {
39+
const getTemplatePicker = async (context: Folder) => {
4040
if (TemplatePicker === null) {
4141
// Create document root
4242
const mountingPoint = document.createElement('div')
@@ -45,7 +45,15 @@ const getTemplatePicker = async () => {
4545

4646
// Init vue app
4747
TemplatePicker = new Vue({
48-
render: (h) => h(TemplatePickerVue, { ref: 'picker' }),
48+
render: (h) => h(
49+
TemplatePickerVue,
50+
{
51+
ref: 'picker',
52+
props: {
53+
parent: context,
54+
},
55+
},
56+
),
4957
methods: { open(...args) { this.$refs.picker.open(...args) } },
5058
el: mountingPoint,
5159
})
@@ -71,7 +79,7 @@ export function registerTemplateEntries() {
7179
},
7280
order: 11,
7381
async handler(context: Folder, content: Node[]) {
74-
const templatePicker = getTemplatePicker()
82+
const templatePicker = getTemplatePicker(context)
7583
const name = await newNodeName(`${provider.label}${provider.extension}`, content, {
7684
label: t('files', 'Filename'),
7785
name: provider.label,

apps/files/src/views/TemplatePicker.vue

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,16 @@ export default defineComponent({
9090
TemplatePreview,
9191
},
9292
93+
props: {
94+
/**
95+
* The parent folder where to create the node
96+
*/
97+
parent: {
98+
type: Object,
99+
default: () => null,
100+
},
101+
},
102+
93103
data() {
94104
return {
95105
// Check empty template by default
@@ -109,7 +119,7 @@ export default defineComponent({
109119
nameWithoutExt() {
110120
// Strip extension from name if defined
111121
return !this.extension
112-
? this.name
122+
? this.name!
113123
: this.name!.slice(0, 0 - this.extension.length)
114124
},
115125
@@ -236,6 +246,10 @@ export default defineComponent({
236246
size: fileInfo.size,
237247
permissions: fileInfo.permissions,
238248
attributes: {
249+
// Inherit some attributes from parent folder like the mount type and real owner
250+
'mount-type': this.parent?.attributes?.['mount-type'],
251+
'owner-id': this.parent?.attributes?.['owner-id'],
252+
'owner-display-name': this.parent?.attributes?.['owner-display-name'],
239253
...fileInfo,
240254
'has-preview': fileInfo.hasPreview,
241255
},

dist/2382-2382.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

dist/2382-2382.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)