Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(files): Replace deprecated Types enum for share types #49300

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions apps/files/src/views/FilesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
type="tertiary"
@click="openSharingSidebar">
<template #icon>
<LinkIcon v-if="shareButtonType === Type.SHARE_TYPE_LINK" />
<LinkIcon v-if="shareButtonType === ShareType.Link" />
<AccountPlusIcon v-else :size="20" />
</template>
</NcButton>
Expand Down Expand Up @@ -141,7 +141,7 @@
</template>

<script lang="ts">
import type { ContentsWithRoot, INode } from '@nextcloud/files'
import type { ContentsWithRoot, Folder, INode } from '@nextcloud/files'
import type { Upload } from '@nextcloud/upload'
import type { CancelablePromise } from 'cancelable-promise'
import type { ComponentPublicInstance } from 'vue'
Expand All @@ -150,11 +150,11 @@ import type { UserConfig } from '../types.ts'

import { getCapabilities } from '@nextcloud/capabilities'
import { emit, subscribe, unsubscribe } from '@nextcloud/event-bus'
import { Folder, Node, Permission, sortNodes, getFileListActions } from '@nextcloud/files'
import { Node, Permission, sortNodes, getFileListActions } from '@nextcloud/files'
import { translate as t } from '@nextcloud/l10n'
import { join, dirname, normalize } from 'path'
import { showError, showWarning } from '@nextcloud/dialogs'
import { Type } from '@nextcloud/sharing'
import { ShareType } from '@nextcloud/sharing'
import { UploadPicker, UploadStatus } from '@nextcloud/upload'
import { loadState } from '@nextcloud/initial-state'
import { defineComponent } from 'vue'
Expand Down Expand Up @@ -261,7 +261,7 @@ export default defineComponent({
// non reactive data
enableGridView,
forbiddenCharacters,
Type,
ShareType,
}
},

Expand Down Expand Up @@ -391,22 +391,22 @@ export default defineComponent({
return t('files', 'Share')
}

if (this.shareButtonType === Type.SHARE_TYPE_LINK) {
if (this.shareButtonType === ShareType.Link) {
return t('files', 'Shared by link')
}
return t('files', 'Shared')
},
shareButtonType(): Type | null {
shareButtonType(): ShareType | null {
if (!this.shareTypesAttributes) {
return null
}

// If all types are links, show the link icon
if (this.shareTypesAttributes.some(type => type === Type.SHARE_TYPE_LINK)) {
return Type.SHARE_TYPE_LINK
if (this.shareTypesAttributes.some(type => type === ShareType.Link)) {
return ShareType.Link
}

return Type.SHARE_TYPE_USER
return ShareType.User
},

gridViewButtonLabel() {
Expand Down Expand Up @@ -454,7 +454,11 @@ export default defineComponent({
if (action.enabled === undefined) {
return true
}
return action.enabled(this.currentView, this.dirContents, { folder: this.currentFolder })
return action.enabled(
this.currentView!,
this.dirContents,
{ folder: this.currentFolder! },
)
})
.toSorted((a, b) => a.order - b.order)
return enabledActions
Expand Down
Loading