Skip to content

Commit

Permalink
Fix client load requirement for sidebar
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ (skjnldsv) <[email protected]>
Signed-off-by: npmbuildbot[bot] <npmbuildbot[bot]@users.noreply.github.com>
  • Loading branch information
skjnldsv committed Dec 5, 2019
1 parent 92705ad commit ea4f253
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 15 deletions.
12 changes: 6 additions & 6 deletions js/photos.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos.js.map

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions lib/Controller/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ public function index(): TemplateResponse {
$this->initialStateService->provideInitialState($this->appName, 'mimes', Application::MIMES);
$this->initialStateService->provideInitialState($this->appName, 'maps', $this->config->getAppValue('maps', 'enabled', 'no') === 'yes');


// used by the sidebar to parse files requests
// TODO: move to a standalone dav fileinfo parser
Util::addScript('files', 'files/client');
Util::addScript($this->appName, 'photos');
Util::addStyle($this->appName, 'icons');

Expand Down
15 changes: 11 additions & 4 deletions src/components/Navigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<h2 class="photos-navigation__title">
{{ name }}
</h2>
<Actions class="photos-navigation__share">
<Actions v-if="!isRoot && showActions" class="photos-navigation__share">
<ActionButton
icon="icon-shared"
@click="showSidebar">
Expand Down Expand Up @@ -63,6 +63,10 @@ export default {
type: String,
required: true,
},
showActions: {
type: Boolean,
default: false,
},
rootTitle: {
type: String,
default: t('photos', 'Photos'),
Expand Down Expand Up @@ -92,7 +96,7 @@ export default {
},
backToText() {
if (this.parentPath === '/') {
return t('photos', 'Back to home')
return t('photos', 'Back to {folder}', { folder: this.rootTitle })
}
return t('photos', 'Back to {folder}', { folder: this.parentName })
},
Expand Down Expand Up @@ -132,8 +136,8 @@ export default {
},
showSidebar() {
OCA.Files.Sidebar.open(this.filename)
}
},
},
}
</script>
Expand All @@ -151,6 +155,9 @@ export default {
&__title {
margin: 0;
}
&__share {
margin-left: 10px;
}
}
// generate variants based on grid sizes
Expand Down
9 changes: 9 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ sync(store, router)
Vue.prototype.t = translate
Vue.prototype.n = translatePlural

// TODO: remove when we have a proper fileinfo standalone library
window.addEventListener('DOMContentLoaded', () => {
// register unused client for the sidebar to have access to its parser methods
if (!window.OCA.Files) {
window.OCA.Files = {}
}
Object.assign(window.OCA.Files, { App: { fileList: { filesClient: OC.Files.getClient() } } }, window.OCA.Files)
})

export default new Vue({
el: '#content',
// eslint-disable-next-line vue/match-component-file-name
Expand Down
1 change: 1 addition & 0 deletions src/mixins/FileFolder.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
display: flex;
align-items: center;
justify-content: center;
user-select: none;

.cover {
z-index: 2;
Expand Down
3 changes: 3 additions & 0 deletions src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export default new Router({
path: `/${route.params.path ? route.params.path : ''}`,
// if path is empty
isRoot: !route.params.path,
rootTitle: t('photos', 'Your albums'),
}),
},
{
Expand All @@ -68,6 +69,7 @@ export default new Router({
path: `/${route.params.path ? route.params.path : ''}`,
// if path is empty
isRoot: !route.params.path,
rootTitle: t('photos', 'Shared albums'),
showShared: true,
}),
},
Expand All @@ -87,6 +89,7 @@ export default new Router({
path: `${route.params.path ? route.params.path : ''}`,
// if path is empty
isRoot: !route.params.path,
rootTitle: t('photos', 'Tagged photos'),
}),
},
{
Expand Down
15 changes: 12 additions & 3 deletions src/views/Albums.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@

<!-- Folder content -->
<Grid v-else>
<Navigation v-if="folder" key="navigation" v-bind="folder" />
<Navigation v-if="folder"
key="navigation"
v-bind="folder"
:root-title="rootTitle"
:show-actions="true" />

<Folder v-for="dir in folderList"
:key="dir.fileid"
Expand Down Expand Up @@ -67,6 +71,10 @@ export default {
Navigation,
},
props: {
rootTitle: {
type: String,
required: true,
},
path: {
type: String,
default: '/',
Expand Down Expand Up @@ -163,8 +171,9 @@ export default {
// cancel any pending requests
this.cancelRequest('Changed folder')
// close any potential opened viewer
OCA.Viewer.close()
// close any potential opened viewer & sidebar
OCA.Viewer && OCA.Viewer.close()
OCA.Files && OCA.Files.Sidebar.close()
// if we don't already have some cached data let's show a loader
if (!this.files[this.folderId]) {
Expand Down
6 changes: 5 additions & 1 deletion src/views/Tags.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
key="navigation"
:basename="path"
:filename="'/' + path"
:root-title="t('photos', 'Tags')" />
:root-title="rootTitle" />
<template v-if="isRoot">
<Tag v-for="id in tagsNames"
:key="id"
Expand Down Expand Up @@ -76,6 +76,10 @@ export default {
Navigation,
},
props: {
rootTitle: {
type: String,
required: true,
},
path: {
type: String,
default: '',
Expand Down

0 comments on commit ea4f253

Please sign in to comment.