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

feat(files): add folder icon overlay #40209

Merged
merged 1 commit into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
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
71 changes: 64 additions & 7 deletions apps/files/src/components/FileEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@
<td class="files-list__row-name" data-cy-files-list-row-name>
<!-- Icon or preview -->
<span class="files-list__row-icon" @click="execDefaultAction">
<FolderIcon v-if="source.type === 'folder'" />
<template v-if="source.type === 'folder'">
<FolderIcon />
<OverlayIcon :is="folderOverlay"
v-if="folderOverlay"
class="files-list__row-icon-overlay" />
</template>

<!-- Decorative image, should not be aria documented -->
<span v-else-if="previewUrl && !backgroundFailed"
Expand Down Expand Up @@ -167,27 +172,33 @@

<script lang='ts'>
import type { PropType } from 'vue'
import type { Node } from '@nextcloud/files'

import { CancelablePromise } from 'cancelable-promise'
import { debounce } from 'debounce'
import { emit } from '@nextcloud/event-bus'
import { extname } from 'path'
import { generateUrl } from '@nextcloud/router'
import { getFileActions, DefaultType, FileType, formatFileSize, Permission, Folder, File } from '@nextcloud/files'
import { getFileActions, DefaultType, FileType, formatFileSize, Permission, Folder, File, Node } from '@nextcloud/files'
import { Type as ShareType } from '@nextcloud/sharing'
import { showError, showSuccess } from '@nextcloud/dialogs'
import { translate } from '@nextcloud/l10n'
import { vOnClickOutside } from '@vueuse/components'
import axios from '@nextcloud/axios'
import moment from '@nextcloud/moment'
import Vue from 'vue'

import AccountGroupIcon from 'vue-material-design-icons/AccountGroup.vue'
import FileIcon from 'vue-material-design-icons/File.vue'
import FolderIcon from 'vue-material-design-icons/Folder.vue'
import moment from '@nextcloud/moment'
import KeyIcon from 'vue-material-design-icons/Key.vue'
import LinkIcon from 'vue-material-design-icons/Link.vue'
import NetworkIcon from 'vue-material-design-icons/Network.vue'
import AccountPlusIcon from 'vue-material-design-icons/AccountPlus.vue'
import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
import NcActions from '@nextcloud/vue/dist/Components/NcActions.js'
import NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadioSwitch.js'
import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js'
import NcTextField from '@nextcloud/vue/dist/Components/NcTextField.js'
import Vue from 'vue'

import { action as sidebarAction } from '../actions/sidebarAction.ts'
import { hashCode } from '../utils/hashUtils.ts'
Expand All @@ -212,16 +223,21 @@ export default Vue.extend({
name: 'FileEntry',

components: {
AccountGroupIcon,
AccountPlusIcon,
CustomElementRender,
CustomSvgIconRender,
FavoriteIcon,
FileIcon,
FolderIcon,
KeyIcon,
LinkIcon,
NcActionButton,
NcActions,
NcCheckboxRadioSwitch,
NcLoadingIcon,
NcTextField,
NetworkIcon,
},

props: {
Expand Down Expand Up @@ -356,6 +372,38 @@ export default Vue.extend({
return ''
},

folderOverlay() {
if (this.source.type !== FileType.Folder) {
return null
}

// Encrypted folders
if (this.source?.attributes?.['is-encrypted'] === 1) {
return KeyIcon
}

// Link and mail shared folders
const shareTypes = Object.values(this.source?.attributes?.['share-types'] || {}).flat() as number[]
if (shareTypes.some(type => type === ShareType.SHARE_TYPE_LINK || type === ShareType.SHARE_TYPE_EMAIL)) {
return LinkIcon
}

// Shared folders
if (shareTypes.length > 0) {
return AccountPlusIcon
}

switch (this.source?.attributes?.['mount-type']) {
case 'external':
case 'external-session':
return NetworkIcon
case 'group':
return AccountGroupIcon
}

return null
},

linkTo() {
if (this.source.attributes.failed) {
return {
Expand Down Expand Up @@ -871,12 +919,21 @@ export default Vue.extend({
/* Hover effect on tbody lines only */
tr {
&:hover,
&:focus,
&:visible {
&:focus {
background-color: var(--color-background-dark);
}
}

// Folder overlay
.files-list__row-icon-overlay {
position: absolute;
max-height: 18px;
max-width: 18px;
color: var(--color-main-background);
// better alignment with the folder icon
margin-top: 2px;
}

/* Preview not loaded animation effect */
.files-list__row-icon-preview:not([style*='background']) {
background: var(--color-loading-dark);
Expand Down
9 changes: 9 additions & 0 deletions apps/files/src/components/FilesListVirtual.vue
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,15 @@ export default Vue.extend({
width: var(--icon-preview-size);
height: var(--icon-preview-size);
}
// Slightly increase the size of the folder icon
&.folder-icon {
margin: -3px;
svg {
width: calc(var(--icon-preview-size) + 6px);
height: calc(var(--icon-preview-size) + 6px);
}
}
}
&-preview {
Expand Down
3 changes: 3 additions & 0 deletions dist/5688-5688.js

Large diffs are not rendered by default.

File renamed without changes.
1 change: 1 addition & 0 deletions dist/5688-5688.js.map

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions dist/7761-7761.js

This file was deleted.

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

This file was deleted.

4 changes: 2 additions & 2 deletions dist/core-common.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-common.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-main.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files_sharing-files_sharing_tab.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files_sharing-files_sharing_tab.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/settings-users-8351.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/settings-users-8351.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/settings-vue-settings-apps-users-management.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/settings-vue-settings-apps-users-management.js.map

Large diffs are not rendered by default.

Loading