Skip to content

Commit

Permalink
fix: Avoid layout jump with rich workspace
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliusknorr committed Sep 6, 2023
1 parent 372260b commit 0c2751e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
5 changes: 4 additions & 1 deletion src/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
import { linkTo } from '@nextcloud/router'
import { loadState } from '@nextcloud/initial-state'
import { registerFileListHeaders } from '@nextcloud/files'
import { registerFileListHeaders, registerDavProperty } from '@nextcloud/files'
import Vue from 'vue'

import { logger } from './helpers/logger.js'
Expand All @@ -35,6 +35,9 @@ __webpack_public_path__ = linkTo('text', 'js/') // eslint-disable-line
const workspaceAvailable = loadState('text', 'workspace_available')
const workspaceEnabled = loadState('text', 'workspace_enabled')

registerDavProperty('nc:rich-workspace', { nc: 'http://nextcloud.org/ns' })
registerDavProperty('nc:rich-workspace-file', { nc: 'http://nextcloud.org/ns' })

document.addEventListener('DOMContentLoaded', () => {
if (typeof OCA.Viewer === 'undefined') {
logger.error('Viewer app is not installed')
Expand Down
8 changes: 8 additions & 0 deletions src/helpers/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { getSharingToken } from './token.js'
import { openMimetypes } from './mime.js'
import RichWorkspace from '../views/RichWorkspace.vue'
import store from '../store/index.js'
import { has } from 'lodash'

Check failure on line 32 in src/helpers/files.js

View workflow job for this annotation

GitHub Actions / eslint

'has' is defined but never used

Check failure on line 32 in src/helpers/files.js

View workflow job for this annotation

GitHub Actions / eslint

"lodash" is extraneous

const FILE_ACTION_IDENTIFIER = 'Edit with text app'

Expand Down Expand Up @@ -187,6 +188,8 @@ export const FilesWorkspaceHeader = new Header({

render(el, folder, view) {
addMenuRichWorkspace()
console.log(el, folder, view)

Check failure on line 191 in src/helpers/files.js

View workflow job for this annotation

GitHub Actions / eslint

Unexpected console statement
const hasRichWorkspace = folder.attributes['rich-workspace-file']

import('vue').then((module) => {
el.id = 'files-workspace-wrapper'
Expand All @@ -201,14 +204,19 @@ export const FilesWorkspaceHeader = new Header({
vm = new View({
propsData: {
path: folder.path,
hasRichWorkspace,
},
store,
}).$mount(el)
console.log('mounted => ' , vm)

Check failure on line 211 in src/helpers/files.js

View workflow job for this annotation

GitHub Actions / eslint

Unexpected console statement

Check failure on line 211 in src/helpers/files.js

View workflow job for this annotation

GitHub Actions / eslint

There should be no space before ','
})
},

updated(folder, view) {
const hasRichWorkspace = folder.attributes['rich-workspace-file']
vm.path = folder.path
vm.hasRichWorkspace = hasRichWorkspace
console.log('updated => ' , vm)

Check failure on line 219 in src/helpers/files.js

View workflow job for this annotation

GitHub Actions / eslint

Unexpected console statement

Check failure on line 219 in src/helpers/files.js

View workflow job for this annotation

GitHub Actions / eslint

There should be no space before ','
},
})

Expand Down
22 changes: 12 additions & 10 deletions src/views/RichWorkspace.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@

<template>
<div v-if="enabled"
v-show="file"
v-show="hasRichWorkspace"
id="rich-workspace"
:class="{'focus': focus, 'dark': darkTheme, 'creatable': canCreate }">
:class="{'focus': focus, 'dark': darkTheme }">
<SkeletonLoading v-if="!loaded || !ready" />
<Editor v-if="file"
v-show="ready"
Expand Down Expand Up @@ -69,6 +69,10 @@ export default {
type: Boolean,
default: true,
},
hasRichWorkspace: {
type: Boolean,
default: false,
},
},
data() {
return {
Expand All @@ -87,9 +91,6 @@ export default {
shareToken() {
return document.getElementById('sharingToken')?.value
},
canCreate() {
return !!(this.folder && (this.folder.permissions & OC.PERMISSION_CREATE))
},
},
watch: {
path() {
Expand Down Expand Up @@ -134,9 +135,12 @@ export default {
})
},
getFileInfo(autofocus) {
this.loaded = false
this.autofocus = false
if (!this.hasRichWorkspace) {
return
}
this.ready = false
this.loaded = true
this.autofocus = false
const params = { path: this.path }
if (IS_PUBLIC) {
params.shareToken = this.shareToken
Expand Down Expand Up @@ -209,9 +213,7 @@ export default {
transition: max-height 0.5s cubic-bezier(0, 1, 0, 1);
z-index: 61;
position: relative;
&.creatable {
min-height: 100px;
}
min-height: 30vh;
}

/* For subfolders, where there are no Recommendations */
Expand Down

0 comments on commit 0c2751e

Please sign in to comment.