mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 01:46:07 +00:00
add frontend part for roles
This commit is contained in:
parent
802b7cc3dc
commit
ef16fd8e31
@ -14,7 +14,7 @@ describe('Sidebar', () => {
|
||||
$store: {
|
||||
state: {
|
||||
hasElopage: true,
|
||||
isAdmin: false,
|
||||
roles: [],
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -83,7 +83,7 @@ describe('Sidebar', () => {
|
||||
|
||||
describe('for admin users', () => {
|
||||
beforeAll(() => {
|
||||
mocks.$store.state.isAdmin = true
|
||||
mocks.$store.state.roles = ['admin']
|
||||
wrapper = Wrapper()
|
||||
})
|
||||
|
||||
|
||||
@ -49,12 +49,14 @@
|
||||
</b-nav-item>
|
||||
<b-nav-item
|
||||
class="mb-3 text-light"
|
||||
v-if="$store.state.isAdmin"
|
||||
v-if="$store.state.roles.length > 0"
|
||||
@click="$emit('admin')"
|
||||
active-class="activeRoute"
|
||||
>
|
||||
<b-icon icon="shield-check" aria-hidden="true"></b-icon>
|
||||
<span class="ml-2">{{ $t('navigation.admin_area') }}</span>
|
||||
<span class="ml-2">
|
||||
{{ $t('navigation.admin_area') }}
|
||||
</span>
|
||||
</b-nav-item>
|
||||
<b-nav-item
|
||||
class="font-weight-bold"
|
||||
|
||||
@ -156,7 +156,7 @@ export const login = gql`
|
||||
}
|
||||
hasElopage
|
||||
publisherId
|
||||
isAdmin
|
||||
roles
|
||||
hideAmountGDD
|
||||
hideAmountGDT
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@ export const verifyLogin = gql`
|
||||
}
|
||||
hasElopage
|
||||
publisherId
|
||||
isAdmin
|
||||
roles
|
||||
hideAmountGDD
|
||||
hideAmountGDT
|
||||
}
|
||||
|
||||
@ -40,8 +40,8 @@ export const mutations = {
|
||||
if (isNaN(pubId)) pubId = null
|
||||
state.publisherId = pubId
|
||||
},
|
||||
isAdmin: (state, isAdmin) => {
|
||||
state.isAdmin = !!isAdmin
|
||||
roles(state, roles) {
|
||||
state.roles = roles
|
||||
},
|
||||
hasElopage: (state, hasElopage) => {
|
||||
state.hasElopage = hasElopage
|
||||
@ -70,7 +70,7 @@ export const actions = {
|
||||
commit('newsletterState', data.klickTipp.newsletterState)
|
||||
commit('hasElopage', data.hasElopage)
|
||||
commit('publisherId', data.publisherId)
|
||||
commit('isAdmin', data.isAdmin)
|
||||
commit('roles', data.roles)
|
||||
commit('hideAmountGDD', data.hideAmountGDD)
|
||||
commit('hideAmountGDT', data.hideAmountGDT)
|
||||
commit('setDarkMode', data.darkMode)
|
||||
@ -84,7 +84,7 @@ export const actions = {
|
||||
commit('newsletterState', null)
|
||||
commit('hasElopage', false)
|
||||
commit('publisherId', null)
|
||||
commit('isAdmin', false)
|
||||
commit('roles', null)
|
||||
commit('hideAmountGDD', false)
|
||||
commit('hideAmountGDT', true)
|
||||
commit('email', '')
|
||||
@ -111,7 +111,7 @@ try {
|
||||
// username: '',
|
||||
token: null,
|
||||
tokenTime: null,
|
||||
isAdmin: false,
|
||||
roles: [],
|
||||
newsletterState: null,
|
||||
hasElopage: false,
|
||||
publisherId: null,
|
||||
|
||||
@ -29,7 +29,7 @@ const {
|
||||
username,
|
||||
newsletterState,
|
||||
publisherId,
|
||||
isAdmin,
|
||||
roles,
|
||||
hasElopage,
|
||||
hideAmountGDD,
|
||||
hideAmountGDT,
|
||||
@ -136,11 +136,11 @@ describe('Vuex store', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('isAdmin', () => {
|
||||
it('sets the state of isAdmin', () => {
|
||||
const state = { isAdmin: null }
|
||||
isAdmin(state, true)
|
||||
expect(state.isAdmin).toEqual(true)
|
||||
describe('roles', () => {
|
||||
it('sets the state of roles', () => {
|
||||
const state = { roles: [] }
|
||||
roles(state, ['admin'])
|
||||
expect(state.roles).toEqual(['admin'])
|
||||
})
|
||||
})
|
||||
|
||||
@ -192,7 +192,7 @@ describe('Vuex store', () => {
|
||||
},
|
||||
hasElopage: false,
|
||||
publisherId: 1234,
|
||||
isAdmin: true,
|
||||
roles: ['admin'],
|
||||
hideAmountGDD: false,
|
||||
hideAmountGDT: true,
|
||||
}
|
||||
@ -242,9 +242,9 @@ describe('Vuex store', () => {
|
||||
expect(commit).toHaveBeenNthCalledWith(8, 'publisherId', 1234)
|
||||
})
|
||||
|
||||
it('commits isAdmin', () => {
|
||||
it('commits roles', () => {
|
||||
login({ commit, state }, commitedData)
|
||||
expect(commit).toHaveBeenNthCalledWith(9, 'isAdmin', true)
|
||||
expect(commit).toHaveBeenNthCalledWith(9, 'roles', ['admin'])
|
||||
})
|
||||
|
||||
it('commits hideAmountGDD', () => {
|
||||
@ -307,9 +307,9 @@ describe('Vuex store', () => {
|
||||
expect(commit).toHaveBeenNthCalledWith(8, 'publisherId', null)
|
||||
})
|
||||
|
||||
it('commits isAdmin', () => {
|
||||
it('commits roles', () => {
|
||||
logout({ commit, state })
|
||||
expect(commit).toHaveBeenNthCalledWith(9, 'isAdmin', false)
|
||||
expect(commit).toHaveBeenNthCalledWith(9, 'roles', null)
|
||||
})
|
||||
|
||||
it('commits hideAmountGDD', () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user