Skip to content

Commit

Permalink
Federated and lightweight accounts
Browse files Browse the repository at this point in the history
Reduced functionality depending on user account type.
  • Loading branch information
elizavetaRa authored and diocas committed Jun 1, 2023
1 parent 9c37d8c commit 9c4ec26
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 10 deletions.
15 changes: 12 additions & 3 deletions packages/web-app-files/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import fileSideBars from './fileSideBars'
import { buildRoutes } from './router'
import get from 'lodash-es/get'


// dirty: importing view from other extension within project
import SearchResults from '../../web-app-search/src/views/List.vue'

Expand Down Expand Up @@ -50,11 +51,15 @@ const navItems = [
path: `/${appInfo.id}/favorites`
},
enabled(capabilities) {
return capabilities.files && capabilities.files.favorites
return (
!(window as any).__$store.getters.user.isLightweight && capabilities.files && capabilities.files.favorites
)
}
},
{
name: $gettext('Shares'),
name(capabilities) {
return (window as any).__$store.getters.user.isLightweight ? $gettext('Shared with me') : $gettext('Shares')
},
icon: 'share-forward',
route: {
path: `/${appInfo.id}/shares`
Expand Down Expand Up @@ -82,7 +87,11 @@ const navItems = [
path: `/${appInfo.id}/trash/eos`
},
enabled(capabilities) {
return capabilities.dav && capabilities.dav.trashbin === '1.0'
return (
!(window as any).__$store.getters.user.isLightweight &&
capabilities.dav &&
capabilities.dav.trashbin === '1.0'
)
}
},
{
Expand Down
3 changes: 2 additions & 1 deletion packages/web-app-files/src/views/shares/SharedWithMe.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="oc-flex">
<files-view-wrapper class="oc-flex-column">
<app-bar
:has-shares-navigation="true"
:has-shares-navigation="!user.isLightweight"
:has-bulk-actions="true"
:side-bar-open="sideBarOpen"
/>
Expand Down Expand Up @@ -222,6 +222,7 @@ export default defineComponent({
computed: {
...mapGetters(['configuration']),
...mapGetters(['user']),
groupingSettings() {
const that = this
Expand Down
17 changes: 13 additions & 4 deletions packages/web-app-files/src/views/spaces/GenericSpace.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<template>
<div class="oc-flex oc-width-1-1" :class="{ 'space-frontpage': isSpaceFrontpage }">
<home v-if="isLightweightHome" />
<div v-else class="oc-flex oc-width-1-1" :class="{ 'space-frontpage': isSpaceFrontpage }">
<keyboard-actions :paginated-resources="paginatedResources" :space="space" />
<files-view-wrapper>
<app-bar
Expand Down Expand Up @@ -186,6 +187,7 @@ import { FolderLoaderOptions } from '../../services/folder'
import { CreateTargetRouteOptions } from 'web-app-files/src/helpers/folderLink/types'
import SingleSharedFile from './SingleSharedFile.vue'
import Home from './Home.vue'
const visibilityObserver = new VisibilityObserver()
Expand All @@ -208,7 +210,8 @@ export default defineComponent({
ResourceTiles,
SideBar,
SpaceHeader,
SingleSharedFile
SingleSharedFile,
Home
},
mixins: [MixinAccessibleBreadcrumb, MixinFileActions],
Expand Down Expand Up @@ -392,7 +395,13 @@ export default defineComponent({
...mapState('Files', ['files']),
...mapGetters('Files', ['currentFolder', 'totalFilesCount', 'totalFilesSize']),
...mapGetters(['user', 'configuration']),
...mapGetters(['homeFolder']),
isLightweightHome() {
return (
this.user.isLightweight && this.homeFolder === `/${this.$route.params.driveAliasAndItem}`
)
},
isSingleFile() {
if (
this.paginatedResources.length === 1 &&
Expand Down Expand Up @@ -422,12 +431,12 @@ export default defineComponent({
watch: {
item: {
handler: function () {
this.performLoaderTask(true)
!this.isLightweightHome && this.performLoaderTask(true)
}
},
space: {
handler: function () {
this.performLoaderTask(true)
!this.isLightweightHome && this.performLoaderTask(true)
}
},
paginatedResources: function () {
Expand Down
22 changes: 22 additions & 0 deletions packages/web-app-files/src/views/spaces/Home.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<template>
<div class="oc-text-center centered">
<h1 v-translate class="oc-text-lead">Welcome to CERNBox</h1>
<p v-translate>With this account you can access shared content and collaborate on projects</p>
</div>
</template>

<script>
export default {
methods: {}
}
</script>

<style scoped>
.full-height {
height: 100%;
}
.centered {
width: 50%;
margin: 0 auto;
}
</style>
2 changes: 1 addition & 1 deletion packages/web-app-files/src/views/spaces/Projects.vue
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export default defineComponent({
return this.$gettext('Show members')
},
hasCreatePermission() {
return true
return !this.user.isLightweight
}
},
watch: {
Expand Down
3 changes: 2 additions & 1 deletion packages/web-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"web-runtime": "workspace:*",
"webdav": "^4.10.0",
"webfontloader": "^1.6.28",
"xml-js": "^1.6.11"
"xml-js": "^1.6.11",
"jwt-decode": "^3.1.2"
},
"devDependencies": {
"@jest/globals": "29.3.1",
Expand Down
1 change: 1 addition & 0 deletions packages/web-runtime/src/services/auth/userManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ export class UserManager extends OidcUserManager {
displayname: user.displayname || login['display-name'],
email: login?.email || user?.email || '',
groups: graphUser?.data?.memberOf || userGroups || [],
isLightweight: ['federated', 'lightweight'].includes(user['user-type']),
role,
language: login?.language
})
Expand Down
2 changes: 2 additions & 0 deletions packages/web-runtime/src/store/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const getInitialState = () => ({
uuid: '',
displayname: '',
email: '',
isLightweight: false,
capabilities: [],
version: {},
groups: [],
Expand Down Expand Up @@ -46,6 +47,7 @@ const mutations = {
state.groups = user.groups
state.language = user.language
state.role = user.role
state.isLightweight = user.isLightweight
sentrySetUser({ username: user.id })
},
SET_CAPABILITIES(state, data) {
Expand Down
2 changes: 2 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9c4ec26

Please sign in to comment.