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

[stable28] fix(files): Adjust sidebar - remove deprecated function calls and add aria label for favorite icon #43994

Merged
merged 2 commits into from
Mar 5, 2024
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
99 changes: 43 additions & 56 deletions apps/files/src/views/Sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@
@opened="handleOpened"
@closing="handleClosing"
@closed="handleClosed">
<template #subname>
<NcIconSvgWrapper v-if="fileInfo.isFavourited"
:path="mdiStar"
:name="t('files', 'Favorite')"
inline />
{{ size }}
<NcDateTime :timestamp="fileInfo.mtime" />
</template>

<!-- TODO: create a standard to allow multiple elements here? -->
<template v-if="fileInfo" #description>
<div class="sidebar__description">
Expand All @@ -50,11 +59,8 @@
<template v-if="fileInfo" #secondary-actions>
<NcActionButton :close-after-click="true"
@click="toggleStarred(!fileInfo.isFavourited)">
<template v-if="fileInfo.isFavourited" #icon>
<StarOutline :size="20" />
</template>
<template v-else #icon>
<Star :size="20" />
<template #icon>
<NcIconSvgWrapper :path="fileInfo.isFavourited ? mdiStarOutline : mdiStar" />
</template>
{{ fileInfo.isFavourited ? t('files', 'Remove from favorites') : t('files', 'Add to favorites') }}
</NcActionButton>
Expand Down Expand Up @@ -96,27 +102,29 @@
</NcAppSidebar>
</template>
<script>
import { getCurrentUser } from '@nextcloud/auth'
import { getCapabilities } from '@nextcloud/capabilities'
import { showError } from '@nextcloud/dialogs'
import { emit } from '@nextcloud/event-bus'
import { File, Folder, formatFileSize } from '@nextcloud/files'
import { encodePath } from '@nextcloud/paths'
import { File, Folder } from '@nextcloud/files'
import { getCapabilities } from '@nextcloud/capabilities'
import { getCurrentUser } from '@nextcloud/auth'
import { generateRemoteUrl, generateUrl } from '@nextcloud/router'
import { Type as ShareTypes } from '@nextcloud/sharing'
import $ from 'jquery'
import { mdiStar, mdiStarOutline } from '@mdi/js'
import axios from '@nextcloud/axios'
import moment from '@nextcloud/moment'

import Star from 'vue-material-design-icons/Star.vue'
import StarOutline from 'vue-material-design-icons/StarOutline.vue'
import $ from 'jquery'

import NcAppSidebar from '@nextcloud/vue/dist/Components/NcAppSidebar.js'
import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
import NcDateTime from '@nextcloud/vue/dist/Components/NcDateTime.js'
import NcEmptyContent from '@nextcloud/vue/dist/Components/NcEmptyContent.js'
import NcIconSvgWrapper from '@nextcloud/vue/dist/Components/NcIconSvgWrapper.js'

import FileInfo from '../services/FileInfo.js'
import LegacyView from '../components/LegacyView.vue'
import SidebarTab from '../components/SidebarTab.vue'
import SystemTags from '../../../systemtags/src/components/SystemTags.vue'
import logger from '../logger.js'

export default {
name: 'Sidebar',
Expand All @@ -125,11 +133,23 @@ export default {
LegacyView,
NcActionButton,
NcAppSidebar,
NcDateTime,
NcEmptyContent,
NcIconSvgWrapper,
SidebarTab,
SystemTags,
Star,
StarOutline,
},

setup() {
const currentUser = getCurrentUser()

// Non reactive properties
return {
currentUser,

mdiStar,
mdiStarOutline,
}
},

data() {
Expand All @@ -140,7 +160,6 @@ export default {
error: null,
loading: true,
fileInfo: null,
starLoading: false,
isFullScreen: false,
hasLowHeight: false,
}
Expand Down Expand Up @@ -182,55 +201,26 @@ export default {
* @return {string}
*/
davPath() {
const user = OC.getCurrentUser().uid
return OC.linkToRemote(`dav/files/${user}${encodePath(this.file)}`)
const user = this.currentUser.uid
return generateRemoteUrl(`dav/files/${user}${encodePath(this.file)}`)
},

/**
* Current active tab handler
*
* @param {string} id the tab id to set as active
* @return {string} the current active tab
*/
activeTab() {
return this.Sidebar.activeTab
},

/**
* Sidebar subtitle
*
* @return {string}
*/
subtitle() {
const starredIndicator = this.fileInfo.isFavourited ? '★ ' : ''
return `${starredIndicator} ${this.size}, ${this.time}`
},

/**
* File last modified formatted string
*
* @return {string}
*/
time() {
return OC.Util.relativeModifiedDate(this.fileInfo.mtime)
},

/**
* File last modified full string
*
* @return {string}
*/
fullTime() {
return moment(this.fileInfo.mtime).format('LLL')
},

/**
* File size formatted string
*
* @return {string}
*/
size() {
return OC.Util.humanFileSize(this.fileInfo.size)
return formatFileSize(this.fileInfo.size)
},

/**
Expand All @@ -251,7 +241,6 @@ export default {
if (this.fileInfo) {
return {
'data-mimetype': this.fileInfo.mimetype,
'star-loading': this.starLoading,
active: this.activeTab,
background: this.background,
class: {
Expand All @@ -260,8 +249,6 @@ export default {
},
compact: this.hasLowHeight || !this.fileInfo.hasPreview || this.isFullScreen,
loading: this.loading,
subname: this.subtitle,
subtitle: this.fullTime,
name: this.fileInfo.name,
title: this.fileInfo.name,
}
Expand Down Expand Up @@ -346,7 +333,7 @@ export default {

getPreviewIfAny(fileInfo) {
if (fileInfo.hasPreview && !this.isFullScreen) {
return OC.generateUrl(`/core/preview?fileId=${fileInfo.id}&x=${screen.width}&y=${screen.height}&a=true`)
return generateUrl(`/core/preview?fileId=${fileInfo.id}&x=${screen.width}&y=${screen.height}&a=true`)
}
return this.getIconUrl(fileInfo)
},
Expand Down Expand Up @@ -405,7 +392,6 @@ export default {
*/
async toggleStarred(state) {
try {
this.starLoading = true
await axios({
method: 'PROPPATCH',
url: this.davPath,
Expand All @@ -431,11 +417,12 @@ export default {
root: `/files/${getCurrentUser().uid}`,
mime: isDir ? undefined : this.fileInfo.mimetype,
}))

this.fileInfo.isFavourited = state
} catch (error) {
OC.Notification.showTemporary(t('files', 'Unable to change the favourite state of the file'))
console.error('Unable to change favourite state', error)
showError(t('files', 'Unable to change the favourite state of the file'))
logger.error('Unable to change favourite state', { error })
}
this.starLoading = false
},

onDefaultAction() {
Expand Down
4 changes: 2 additions & 2 deletions dist/5951-5951.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/comments-comments-app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/comments-comments-app.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/comments-comments-tab.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/comments-comments-tab.js.map

Large diffs are not rendered by default.

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/core-legacy-unified-search.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-legacy-unified-search.js.map

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/dav-settings-personal-availability.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/dav-settings-personal-availability.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/federatedfilesharing-vue-settings-admin.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/federatedfilesharing-vue-settings-admin.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/federatedfilesharing-vue-settings-personal.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/federatedfilesharing-vue-settings-personal.js.map

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-init.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-personal-settings.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files_external-init.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files_external-init.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files_reminders-init.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files_reminders-init.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/files_sharing-personal-settings.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/settings-vue-settings-admin-basic-settings.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/settings-vue-settings-admin-basic-settings.js.map

Large diffs are not rendered by default.

Loading
Loading