;
@@ -79,7 +78,6 @@ describe('App component', () => {
{ provide: MenuService, useValue: menuService },
{ provide: CSSVariableService, useClass: CSSVariableServiceStub },
{ provide: HostWindowService, useValue: new HostWindowServiceStub(800) },
- { provide: ThemeService, useValue: {getCurrentTheme: () => {/* No implementation */}} },
AppComponent,
RouteService
],
diff --git a/src/app/app.component.ts b/src/app/app.component.ts
index 7abc1aab97..c1de58819e 100644
--- a/src/app/app.component.ts
+++ b/src/app/app.component.ts
@@ -32,7 +32,6 @@ import { Observable } from 'rxjs/internal/Observable';
import { slideSidebarPadding } from './shared/animations/slide';
import { combineLatest as combineLatestObservable, of } from 'rxjs';
import { HostWindowService } from './shared/host-window.service';
-import { ThemeService } from './core/theme/theme.service';
import { Theme } from '../config/theme.inferface';
@Component({
@@ -64,7 +63,6 @@ export class AppComponent implements OnInit, AfterViewInit {
private cssService: CSSVariableService,
private menuService: MenuService,
private windowService: HostWindowService,
- private themeService: ThemeService
) {
// Load all the languages that are defined as active from the config file
@@ -91,7 +89,6 @@ export class AppComponent implements OnInit, AfterViewInit {
}
ngOnInit() {
- this.theme = this.themeService.getCurrentTheme();
const env: string = this.config.production ? 'Production' : 'Development';
const color: string = this.config.production ? 'red' : 'green';
diff --git a/src/app/core/core.module.ts b/src/app/core/core.module.ts
index 6f8614b0ae..6550435aa3 100644
--- a/src/app/core/core.module.ts
+++ b/src/app/core/core.module.ts
@@ -87,7 +87,6 @@ import { MyDSpaceResponseParsingService } from './data/mydspace-response-parsing
import { ClaimedTaskDataService } from './tasks/claimed-task-data.service';
import { PoolTaskDataService } from './tasks/pool-task-data.service';
import { TaskResponseParsingService } from './tasks/task-response-parsing.service';
-import { ThemeService } from './theme/theme.service';
const IMPORTS = [
CommonModule,
@@ -176,7 +175,6 @@ const PROVIDERS = [
TaskResponseParsingService,
ClaimedTaskDataService,
PoolTaskDataService,
- ThemeService,
// register AuthInterceptor as HttpInterceptor
{
provide: HTTP_INTERCEPTORS,
diff --git a/src/app/core/core.reducers.ts b/src/app/core/core.reducers.ts
index 3ab3564844..c93b4bf44b 100644
--- a/src/app/core/core.reducers.ts
+++ b/src/app/core/core.reducers.ts
@@ -13,7 +13,6 @@ import {
objectUpdatesReducer,
ObjectUpdatesState
} from './data/object-updates/object-updates.reducer';
-import { themeReducer, ThemeState } from './theme/theme.reducer';
export interface CoreState {
'cache/object': ObjectCacheState,
@@ -22,8 +21,7 @@ export interface CoreState {
'data/request': RequestState,
'index': MetaIndexState,
'auth': AuthState,
- 'json/patch': JsonPatchOperationsState,
- 'theme': ThemeState
+ 'json/patch': JsonPatchOperationsState
}
export const coreReducers: ActionReducerMap = {
@@ -33,6 +31,5 @@ export const coreReducers: ActionReducerMap = {
'data/request': requestReducer,
'index': indexReducer,
'auth': authReducer,
- 'json/patch': jsonPatchOperationsReducer,
- 'theme': themeReducer
+ 'json/patch': jsonPatchOperationsReducer
};
diff --git a/src/app/core/theme/theme.actions.ts b/src/app/core/theme/theme.actions.ts
deleted file mode 100644
index 550a53c91d..0000000000
--- a/src/app/core/theme/theme.actions.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * The list of ObjectUpdatesAction type definitions
- */
-import { type } from '../../shared/ngrx/type';
-import { Action } from '@ngrx/store';
-import { Theme } from '../../../config/theme.inferface';
-
-export const ThemeActionTypes = {
- SET: type('dspace/core/theme/SET'),
-};
-
-/* tslint:disable:max-classes-per-file */
-
-/**
- * An ngrx action to set a the repository's current theme
- */
-export class SetThemeAction implements Action {
- type = ThemeActionTypes.SET;
- payload: {
- theme: Theme
- };
-
- /**
- * Create a new SetThemeAction
- *
- * @param theme
- * the theme configuration to change the current theme to
- */
- constructor(
- theme: Theme
- ) {
- this.payload = { theme };
- }
-}
-
-export type ThemeAction
- = SetThemeAction;
diff --git a/src/app/core/theme/theme.reducer.spec.ts b/src/app/core/theme/theme.reducer.spec.ts
deleted file mode 100644
index 662f9bb852..0000000000
--- a/src/app/core/theme/theme.reducer.spec.ts
+++ /dev/null
@@ -1,46 +0,0 @@
-import * as deepFreeze from 'deep-freeze';
-import { SetThemeAction } from './theme.actions';
-import { themeReducer } from './theme.reducer';
-import { Theme } from '../../../config/theme.inferface';
-
-class NullAction extends SetThemeAction {
- type = null;
- payload = null;
-
- constructor() {
- super(null);
- }
-}
-
-const newTheme: Theme = { name: 'New theme', cssClass: 'new-class' };
-describe('themeReducer', () => {
- const testState = { theme: { name: 'test theme', cssClass: 'test-class' } };
- deepFreeze(testState);
-
- it('should return the current state when no valid actions have been made', () => {
- const action = new NullAction();
- const newState = themeReducer(testState, action);
-
- expect(newState).toEqual(testState);
- });
-
- it('should start with an empty object', () => {
- const action = new NullAction();
- const initialState = themeReducer(undefined, action);
-
- expect(initialState).toEqual({} as any);
- });
-
- it('should perform the SET action without affecting the previous state', () => {
- const action = new SetThemeAction(newTheme);
- // testState has already been frozen above
- themeReducer(testState, action);
- });
-
- it('should return a new state with the new theme when calling the SET action with this new theme', () => {
- const action = new SetThemeAction(newTheme);
-
- const newState = themeReducer(testState, action);
- expect(newState.theme).toEqual(newTheme);
- });
-});
diff --git a/src/app/core/theme/theme.reducer.ts b/src/app/core/theme/theme.reducer.ts
deleted file mode 100644
index 26f717872d..0000000000
--- a/src/app/core/theme/theme.reducer.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import { Theme } from '../../../config/theme.inferface';
-import { ThemeAction, ThemeActionTypes } from './theme.actions';
-
-/**
- * Represents the state of the current theme in the store
- */
-export interface ThemeState {
- theme: Theme
-}
-
-// Object.create(null) ensures the object has no default js properties (e.g. `__proto__`)
-const initialState = Object.create(null);
-
-/**
- * Reducer the current theme state to the new state depending on a given action
- * @param state The previous state, equal to the initial state when it was not defined before
- * @param action The action to perform on the current theme state
- */
-export function themeReducer(state = initialState, action: ThemeAction): ThemeState {
- switch (action.type) {
- case ThemeActionTypes.SET: {
- return Object.assign({}, state, { theme: action.payload.theme });
- }
- }
- return state;
-}
diff --git a/src/app/core/theme/theme.service.spec.ts b/src/app/core/theme/theme.service.spec.ts
deleted file mode 100644
index 3edbc764a3..0000000000
--- a/src/app/core/theme/theme.service.spec.ts
+++ /dev/null
@@ -1,60 +0,0 @@
-import { Store } from '@ngrx/store';
-import { CoreState } from '../core.reducers';
-import { ThemeService } from './theme.service';
-import { SetThemeAction } from './theme.actions';
-import * as ngrx from '@ngrx/store';
-import { Theme } from '../../../config/theme.inferface';
-import { of as observableOf } from 'rxjs';
-import { first } from 'rxjs/operators';
-
-describe('ThemeService', () => {
- let service: ThemeService;
- let store: Store;
- const initialTheme: Theme = {
- name: 'test theme',
- cssClass: 'test-class'
- };
- const config = {
- themes: [initialTheme]
- } as any;
- beforeEach(() => {
- store = new Store(undefined, undefined, undefined);
- spyOn(store, 'dispatch');
- service = new ThemeService(store, config);
- });
-
- describe('when the service is created', () => {
- beforeEach(() => {
- spyOn(ThemeService.prototype, 'setCurrentTheme');
- service = new ThemeService(store, config);
- });
-
- it('should call setCurrentTheme action on itself with the theme from the configuration', () => {
- expect(service.setCurrentTheme).toHaveBeenCalledWith(initialTheme);
- });
- });
-
- describe('when setCurrentTheme op the service is called', () => {
- it('should dispatch a SET action on the store', () => {
- service.setCurrentTheme(initialTheme);
- expect(store.dispatch).toHaveBeenCalledWith(new SetThemeAction(initialTheme));
- });
- });
-
- describe('when getCurrentTheme op the service is called', () => {
- beforeEach(() => {
- spyOnProperty(ngrx, 'select').and.callFake(() => {
- return () => {
- return () => observableOf({ theme: initialTheme });
- };
- });
- });
-
- it('should select the current theme from the store', () => {
- const theme = service.getCurrentTheme();
- theme.pipe(first()).subscribe((newTheme) => {
- expect(newTheme).toEqual(initialTheme);
- });
- });
- });
-});
diff --git a/src/app/core/theme/theme.service.ts b/src/app/core/theme/theme.service.ts
deleted file mode 100644
index 2da6a28f38..0000000000
--- a/src/app/core/theme/theme.service.ts
+++ /dev/null
@@ -1,50 +0,0 @@
-import { createSelector, MemoizedSelector, select, Store } from '@ngrx/store';
-import { coreSelector, CoreState } from '../core.reducers';
-import { Inject, Injectable } from '@angular/core';
-import { Theme } from '../../../config/theme.inferface';
-import { Observable } from 'rxjs';
-import { map } from 'rxjs/operators';
-import { ThemeState } from './theme.reducer';
-import { SetThemeAction } from './theme.actions';
-import { isNotEmpty } from '../../shared/empty.util';
-import { GLOBAL_CONFIG, GlobalConfig } from '../../../config';
-
-function themeStateSelector(): MemoizedSelector {
- return createSelector(coreSelector, (state: CoreState) => state.theme);
-}
-
-/**
- * Service that dispatches to and reads from the Theme state in the store
- */
-@Injectable()
-export class ThemeService {
- /**
- * Sets the initial theme read from configuration
- * @param store The current store for the core state
- * @param config The global configuration
- */
- constructor(private store: Store, @Inject(GLOBAL_CONFIG) public config: GlobalConfig) {
- const availableThemes: Theme[] = this.config.themes;
- if (isNotEmpty(availableThemes)) {
- this.setCurrentTheme(availableThemes[0]);
- }
- }
-
- /**
- * Returns the current theme from the store
- */
- public getCurrentTheme(): Observable {
- return this.store.pipe(
- select(themeStateSelector()),
- map((state: ThemeState) => state.theme)
- );
- }
-
- /**
- * Sets the current theme in the store
- * @param theme The new theme
- */
- public setCurrentTheme(theme: Theme): void {
- return this.store.dispatch(new SetThemeAction(theme));
- }
-}