Skip to content

Commit

Permalink
Redirect to private link after log in
Browse files Browse the repository at this point in the history
Added Url to name and default value to null
  • Loading branch information
Lukas Hirt committed Sep 6, 2019
1 parent 55919fe commit e422aa6
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 16 deletions.
15 changes: 7 additions & 8 deletions apps/files/src/components/FileList.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div class="uk-height-1-1">
<div class="uk-flex uk-flex-column uk-height-1-1">
<div class="uk-overflow-auto uk-flex-auto">
<div id="files-list-container" class="uk-overflow-auto uk-flex-auto">
<oc-table middle divider class="oc-filelist uk-margin-remove-bottom" id="files-list" v-show="!loadingFolder">
<thead>
<oc-table-row>
Expand Down Expand Up @@ -146,19 +146,18 @@ export default {
absolutePath = !this.item ? this.configuration.rootFolder : this.item
}
const self = this
this.loadFolder({
client: this.$client,
absolutePath: absolutePath,
$gettext: this.$gettext,
routeName: this.$route.name
}).then(() => {
const scrollTo = self.$route.query.scrollTo
if (scrollTo) {
self.$nextTick(() => {
self.setHighlightedFile(scrollTo)
const file = self.highlightedFile
self.$scrollTo(`#file-row-${file.id}`, 500, {
const scrollTo = this.$route.query.scrollTo
if (scrollTo && this.activeFiles.length > 0) {
this.$nextTick(() => {
const file = this.activeFiles.find(item => item.name === scrollTo)
this.setHighlightedFile(file)
this.$scrollTo(`#file-row-${file.id}`, 500, {
container: '#files-list-container'
})
})
Expand Down
15 changes: 12 additions & 3 deletions apps/files/src/components/FilesApp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div id="files">
<files-app-bar />
<oc-grid class="uk-height-1-1" oc-scroll-offset=".oc-app-bar">
<div class="uk-width-expand uk-overflow-auto uk-height-1-1" @dragover="$_ocApp_dragOver" :class="{ 'uk-visible@m' : _sidebarOpen }" id="files-list-container">
<div class="uk-width-expand uk-overflow-auto uk-height-1-1" @dragover="$_ocApp_dragOver" :class="{ 'uk-visible@m' : _sidebarOpen }">
<oc-loader id="files-list-progress" v-if="loadingFolder"></oc-loader>
<trash-bin v-if="$route.name === 'files-trashbin'" :fileData="activeFiles" />
<SharedFilesList v-else-if="sharedList" @toggle="toggleFileSelect" :fileData="activeFiles" />
Expand Down Expand Up @@ -53,7 +53,7 @@ export default {
},
methods: {
...mapActions('Files', ['resetFileSelection', 'addFileSelection', 'removeFileSelection', 'dragOver', 'setHighlightedFile', 'toggleFileSelect']),
...mapActions(['openFile', 'showMessage']),
...mapActions(['openFile', 'showMessage', 'setPrivateLinkUrlPath']),
trace () {
console.info('trace', arguments)
Expand Down Expand Up @@ -122,7 +122,7 @@ export default {
computed: {
...mapGetters('Files', ['selectedFiles', 'activeFiles', 'dropzone', 'loadingFolder', 'highlightedFile']),
...mapGetters(['extensions']),
...mapGetters(['extensions', 'privateLinkUrlPath']),
_sidebarOpen () {
return this.highlightedFile !== null
Expand All @@ -136,6 +136,15 @@ export default {
$route () {
this.setHighlightedFile(null)
}
},
beforeMount () {
// Redirect to private link after authorization
if (this.privateLinkUrlPath) {
this.$router.push(this.privateLinkUrlPath)
// Resets private link path in store
// Needed due to persistance of that state
this.setPrivateLinkUrlPath(null)
}
}
}
</script>
2 changes: 1 addition & 1 deletion apps/files/src/components/FilesAppBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="uk-width-expand">
<oc-breadcrumb id="files-breadcrumb" :items="breadcrumbs" v-if="showBreadcrumb" home></oc-breadcrumb>
<span class="uk-flex uk-flex-middle" v-if="!showBreadcrumb">
<oc-icon :name="pageIcon" class="uk-margin-small-right"></oc-icon>
<oc-icon v-if="pageIcon" :name="pageIcon" class="uk-margin-small-right" />
<span class="uk-text-lead">{{pageTitle}}</span>
</span>
</div>
Expand Down
5 changes: 4 additions & 1 deletion src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const router = new Router({
path: '/f/:fileId',
name: 'privateLink',
redirect: '/files/private-link/:fileId',
meta: { auth: false, hideHeadbar: true }
meta: { hideHeadbar: true }
},
{
path: '/s/:token',
Expand All @@ -66,6 +66,9 @@ const router = new Router({
})

router.beforeEach(function (to, from, next) {
if (to.name === 'private-link') {
store.dispatch('setPrivateLinkUrlPath', to.path)
}
let authRequired = true
if (to.meta.auth === false) {
authRequired = false
Expand Down
8 changes: 5 additions & 3 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ import app from './app'
import apps from './apps'
import config from './config'
import user from './user'
import links from './links'

Vue.use(Vuex)

const vuexPersist = new VuexPersistence({
key: 'phoenixState',
storage: window.localStorage,
filter: (mutation) => (['SET_USER', 'SET_TOKEN'].indexOf(mutation.type) > -1),
modules: ['user']
filter: (mutation) => (['SET_USER', 'SET_TOKEN', 'SET_PRIVATE_LINK_URL_PATH'].indexOf(mutation.type) > -1),
modules: ['user', 'links']
})

const strict = process.env.NODE_ENV === 'development'
Expand All @@ -29,7 +30,8 @@ export const Store = new Vuex.Store({
app,
apps,
user,
config
config,
links
},
strict
})
Expand Down
30 changes: 30 additions & 0 deletions src/store/links.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const state = {
/**
* Private link path in case user needs to log in first
* @return {string} path to the file/folder
*/
privateLinkUrlPath: null
}

const actions = {
setPrivateLinkUrlPath ({ commit }, path) {
commit('SET_PRIVATE_LINK_URL_PATH', path)
}
}

const mutations = {
SET_PRIVATE_LINK_URL_PATH (state, path) {
state.privateLinkUrlPath = path
}
}

const getters = {
privateLinkUrlPath: state => state.privateLinkUrlPath
}

export default {
state,
actions,
mutations,
getters
}

0 comments on commit e422aa6

Please sign in to comment.