-
Notifications
You must be signed in to change notification settings - Fork 17
feat: add new role IsDatabaseAllowed and shrink breadcrumbs #2672
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -26,7 +26,7 @@ export const slice = createSlice({ | |||||
| } | ||||||
| }, | ||||||
| setUser: (state, action: PayloadAction<TUserToken>) => { | ||||||
| const {UserSID, AuthType, IsMonitoringAllowed} = action.payload; | ||||||
| const {UserSID, AuthType, IsMonitoringAllowed, IsViewerAllowed} = action.payload; | ||||||
|
|
||||||
| state.user = AuthType === 'Login' ? UserSID : undefined; | ||||||
|
|
||||||
|
|
@@ -35,17 +35,19 @@ export const slice = createSlice({ | |||||
| // Otherwise every user is allowed to make changes | ||||||
| // Anyway there will be guards on backend | ||||||
| state.isUserAllowedToMakeChanges = IsMonitoringAllowed !== false; | ||||||
| state.isViewerUser = IsViewerAllowed; | ||||||
|
||||||
| state.isViewerUser = IsViewerAllowed; | |
| state.isViewerUser = IsViewerAllowed || IsDatabaseAllowed; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IsViewerAllowed includes IsDatabaseAllowed and some more rights. So, if user has only IsDatabaseAllowed - it is not enough to be isViewerUser
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| export interface AuthenticationState { | ||
| isAuthenticated: boolean; | ||
| isUserAllowedToMakeChanges?: boolean; | ||
| isViewerUser?: boolean; | ||
| user: string | undefined; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,13 @@ | ||
| import {selectIsUserAllowedToMakeChanges} from '../../store/reducers/authentication/authentication'; | ||
| import { | ||
| selectIsUserAllowedToMakeChanges, | ||
| selectIsViewerUser, | ||
| } from '../../store/reducers/authentication/authentication'; | ||
|
|
||
| import {useTypedSelector} from './useTypedSelector'; | ||
|
|
||
| export function useIsUserAllowedToMakeChanges() { | ||
| return useTypedSelector(selectIsUserAllowedToMakeChanges); | ||
| } | ||
| export function useIsViewerUser() { | ||
| return useTypedSelector(selectIsViewerUser); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The destructuring should also include
IsDatabaseAllowedsince this new field was added to the API type and should be considered when determining viewer user status.