You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
561 B

  1. import _ from 'lodash'
  2. export default _.debounce(async function({ app, store, route, redirect }) {
  3. try {
  4. await store.dispatch('projects/setCurrentProject', route.params.id)
  5. } catch(e) {
  6. redirect('/projects')
  7. }
  8. const role = store.getters['projects/getCurrentUserRole']
  9. const projectRoot = app.localePath('/projects/' + route.params.id)
  10. const path = route.fullPath.replace(/\/$/g, '')
  11. if (role.is_project_admin || path === projectRoot || path.startsWith(projectRoot + '/dataset')) {
  12. return
  13. }
  14. return redirect(projectRoot)
  15. }, 1000)