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
580 B

2 years ago
2 years ago
  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 member = await app.$repositories.member.fetchMyRole(route.params.id)
  9. const projectRoot = app.localePath('/projects/' + route.params.id)
  10. const path = route.fullPath.replace(/\/$/g, '')
  11. if (member.isProjectAdmin || path === projectRoot || path.startsWith(projectRoot + '/dataset')) {
  12. return
  13. }
  14. return redirect(projectRoot)
  15. }, 1000)