Skip to content

Commit

Permalink
Merge pull request #44845 from nextcloud/backport/44834/stable29
Browse files Browse the repository at this point in the history
  • Loading branch information
Altahrim authored Apr 17, 2024
2 parents e31e542 + 3a8a0d1 commit 38bd20b
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 20 deletions.
3 changes: 2 additions & 1 deletion apps/files/src/actions/downloadAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
8 changes: 3 additions & 5 deletions apps/files/src/components/FileEntry/FileEntryActions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -105,21 +105,19 @@ import NcActionSeparator from '@nextcloud/vue/dist/Components/NcActionSeparator.
import NcIconSvgWrapper from '@nextcloud/vue/dist/Components/NcIconSvgWrapper.js'
import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js'
import ArrowLeftIcon from 'vue-material-design-icons/ArrowLeft.vue'
import ChevronRightIcon from 'vue-material-design-icons/ChevronRight.vue'
import Vue from 'vue'
import Vue, { defineComponent } from 'vue'
import CustomElementRender from '../CustomElementRender.vue'
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,
Expand Down Expand Up @@ -337,7 +335,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()
}
Expand Down
6 changes: 6 additions & 0 deletions apps/files/src/newMenu/newFolder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) }))
Expand Down
14 changes: 11 additions & 3 deletions apps/files/src/newMenu/newFromTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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,
})
Expand All @@ -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,
Expand Down
16 changes: 15 additions & 1 deletion apps/files/src/views/TemplatePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
},
Expand Down Expand Up @@ -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,
},
Expand Down
3 changes: 0 additions & 3 deletions dist/2382-2382.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/2382-2382.js.map

This file was deleted.

Loading

0 comments on commit 38bd20b

Please sign in to comment.