diff --git a/ui/src/app/core/reducer/configuration.reducer.spec.ts b/ui/src/app/core/reducer/configuration.reducer.spec.ts new file mode 100644 index 000000000..e8e8a802e --- /dev/null +++ b/ui/src/app/core/reducer/configuration.reducer.spec.ts @@ -0,0 +1,35 @@ +import { reducer } from './configuration.reducer'; +import * as fromConfiguration from './configuration.reducer'; +import * as actions from '../action/configuration.action'; + +describe('Configuration Reducer', () => { + const initialState: fromConfiguration.ConfigState = { + roles: [] + }; + + describe('undefined action', () => { + it('should return the default state', () => { + const result = reducer(undefined, {} as any); + expect(result).toEqual(initialState); + }); + }); + + describe('Role Load Request', () => { + it('should set fetching to true', () => { + const action = new actions.LoadRoleSuccess(['ADMIN']); + const result = reducer(initialState, action); + expect(result).toEqual( + { + ...initialState, + roles: ['ADMIN'] + } + ); + }); + }); + + describe('selector functions', () => { + it('should return the roles from state', () => { + expect(fromConfiguration.getRoles(initialState)).toEqual([]); + }); + }); +}); diff --git a/ui/src/app/core/reducer/index.spec.ts b/ui/src/app/core/reducer/index.spec.ts index f14a08006..5a1fbef3e 100644 --- a/ui/src/app/core/reducer/index.spec.ts +++ b/ui/src/app/core/reducer/index.spec.ts @@ -10,7 +10,6 @@ describe('Core index reducers', () => { version: fromVersion.initialState as fromVersion.VersionState, config: fromConfig.initialState as fromConfig.ConfigState }; - describe('getUserStateFn function', () => { it('should return the user state', () => { expect(fromIndex.getUserStateFn(state)).toEqual(state.user); @@ -21,4 +20,21 @@ describe('Core index reducers', () => { expect(fromIndex.getVersionStateFn(state)).toEqual(state.version); }); }); + describe('getConfigStateFn function', () => { + it('should return the config state', () => { + expect(fromIndex.getConfigStateFn(state)).toEqual(state.config); + }); + }); + describe('filterRolesFn', () => { + it('should return the roles that are not `non roles`', () => { + expect(fromIndex.filterRolesFn(['ROLE_ADMIN', 'ROLE_NONE'])).toEqual(['ROLE_ADMIN']); + }); + }); + describe('isUserAdminFn', () => { + it('should check if the provided user has the ROLE_ADMIN role', () => { + expect(fromIndex.isUserAdminFn({role: 'ROLE_ADMIN'})).toBe(true); + expect(fromIndex.isUserAdminFn({role: 'ROLE_USER'})).toBe(false); + expect(fromIndex.isUserAdminFn(null)).toBe(false); + }); + }); }); diff --git a/ui/src/app/core/reducer/index.ts b/ui/src/app/core/reducer/index.ts index f2d64e934..f5e5b94c2 100644 --- a/ui/src/app/core/reducer/index.ts +++ b/ui/src/app/core/reducer/index.ts @@ -40,7 +40,7 @@ export const getVersionLoading = createSelector(getVersionState, fromVersion.get export const getVersionError = createSelector(getVersionState, fromVersion.getVersionError); export const filterRolesFn = (roles: string[]) => roles.filter(r => r !== 'ROLE_NONE'); -export const isUserAdminFn = (user) => user ? user.role === 'ROLE_ADMIN' : null; +export const isUserAdminFn = (user) => user ? user.role === 'ROLE_ADMIN' : false; export const getConfigState = createSelector(getCoreFeature, getConfigStateFn); export const getRoles = createSelector(getConfigState, fromConfig.getRoles); diff --git a/ui/src/app/metadata/configuration/component/array-property.component.html b/ui/src/app/metadata/configuration/component/array-property.component.html index c2f976657..d51a8e0fb 100644 --- a/ui/src/app/metadata/configuration/component/array-property.component.html +++ b/ui/src/app/metadata/configuration/component/array-property.component.html @@ -13,7 +13,7 @@ container="body" [ngStyle]="{'width': width}" class="text-truncate" - popoverClass="popover-lg"> + popoverClass="popover-lg popover-info"> {{ version[i][prop] }}
@@ -59,7 +59,7 @@ class="list-unstyled py-2 m-0" [ngbPopover]="popContent" triggers="mouseenter:mouseleave" - popoverClass="popover-lg" + popoverClass="popover-lg popover-info" *ngIf="v && v.length > 0">
  • diff --git a/ui/src/app/metadata/configuration/component/filter-configuration-list-item.component.html b/ui/src/app/metadata/configuration/component/filter-configuration-list-item.component.html index a08d9de7a..42ed9652e 100644 --- a/ui/src/app/metadata/configuration/component/filter-configuration-list-item.component.html +++ b/ui/src/app/metadata/configuration/component/filter-configuration-list-item.component.html @@ -38,7 +38,8 @@ [editable]="false" [configuration]="configuration" [entity]="filter" - [definition]="definition"> + [definition]="definition" + (preview)="onPreview($event)">
  • - Current (v{{ i + 1 }}) - v{{ i + 1 }} - {{ version.date | date }} + Current (v{{ history.length - i }}) + v{{ history.length - (i) }} + {{ version.date | date:'medium' }} {{ version.creator }}