mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 02:24:11 +00:00
107671: Split Theme model & ThemeConfig classes in separate files to prevent circular dependencies
This commit is contained in:
@@ -13,7 +13,7 @@ import { AuthService } from '../core/auth/auth.service';
|
|||||||
import { CSSVariableService } from '../shared/sass-helper/css-variable.service';
|
import { CSSVariableService } from '../shared/sass-helper/css-variable.service';
|
||||||
import { MenuService } from '../shared/menu/menu.service';
|
import { MenuService } from '../shared/menu/menu.service';
|
||||||
import { HostWindowService } from '../shared/host-window.service';
|
import { HostWindowService } from '../shared/host-window.service';
|
||||||
import { ThemeConfig } from '../../config/theme.model';
|
import { ThemeConfig } from '../../config/theme.config';
|
||||||
import { Angulartics2DSpace } from '../statistics/angulartics/dspace-provider';
|
import { Angulartics2DSpace } from '../statistics/angulartics/dspace-provider';
|
||||||
import { environment } from '../../environments/environment';
|
import { environment } from '../../environments/environment';
|
||||||
import { slideSidebarPadding } from '../shared/animations/slide';
|
import { slideSidebarPadding } from '../shared/animations/slide';
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import { ThemeService } from '../theme-support/theme.service';
|
import { ThemeService } from '../theme-support/theme.service';
|
||||||
import { of as observableOf } from 'rxjs';
|
import { of as observableOf } from 'rxjs';
|
||||||
import { ThemeConfig } from '../../../config/theme.model';
|
import { ThemeConfig } from '../../../config/theme.config';
|
||||||
import { isNotEmpty } from '../empty.util';
|
import { isNotEmpty } from '../empty.util';
|
||||||
|
|
||||||
export function getMockThemeService(themeName = 'base', themes?: ThemeConfig[]): ThemeService {
|
export function getMockThemeService(themeName = 'base', themes?: ThemeConfig[]): ThemeService {
|
||||||
|
@@ -4,7 +4,7 @@ import { hasNoValue, hasValue, isNotEmpty } from '../../../empty.util';
|
|||||||
import { GenericConstructor } from '../../../../core/shared/generic-constructor';
|
import { GenericConstructor } from '../../../../core/shared/generic-constructor';
|
||||||
import { ListableObject } from '../listable-object.model';
|
import { ListableObject } from '../listable-object.model';
|
||||||
import { environment } from '../../../../../environments/environment';
|
import { environment } from '../../../../../environments/environment';
|
||||||
import { ThemeConfig } from '../../../../../config/theme.model';
|
import { ThemeConfig } from '../../../../../config/theme.config';
|
||||||
import { InjectionToken } from '@angular/core';
|
import { InjectionToken } from '@angular/core';
|
||||||
|
|
||||||
export const DEFAULT_VIEW_MODE = ViewMode.ListElement;
|
export const DEFAULT_VIEW_MODE = ViewMode.ListElement;
|
||||||
|
@@ -1,57 +1,13 @@
|
|||||||
/* eslint-disable max-classes-per-file */
|
/* eslint-disable max-classes-per-file */
|
||||||
import { Config } from './config.interface';
|
import { hasValue, hasNoValue, isNotEmpty } from '../empty.util';
|
||||||
import { hasValue, hasNoValue, isNotEmpty } from '../app/shared/empty.util';
|
import { DSpaceObject } from '../../core/shared/dspace-object.model';
|
||||||
import { DSpaceObject } from '../app/core/shared/dspace-object.model';
|
import { getDSORoute } from '../../app-routing-paths';
|
||||||
import { getDSORoute } from '../app/app-routing-paths';
|
import { HandleObject } from '../../core/shared/handle-object.model';
|
||||||
import { HandleObject } from '../app/core/shared/handle-object.model';
|
|
||||||
import { Injector } from '@angular/core';
|
import { Injector } from '@angular/core';
|
||||||
import { HandleService } from '../app/shared/handle.service';
|
import { HandleService } from '../handle.service';
|
||||||
import { combineLatest, Observable, of as observableOf } from 'rxjs';
|
import { combineLatest, Observable, of as observableOf } from 'rxjs';
|
||||||
import { map, take } from 'rxjs/operators';
|
import { map, take } from 'rxjs/operators';
|
||||||
|
import { HandleThemeConfig, NamedThemeConfig, RegExThemeConfig, UUIDThemeConfig, ThemeConfig } from '../../../config/theme.config';
|
||||||
export interface NamedThemeConfig extends Config {
|
|
||||||
name: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specify another theme to build upon: whenever a themed component is not found in the current theme,
|
|
||||||
* its ancestor theme(s) will be checked recursively before falling back to the default theme.
|
|
||||||
*/
|
|
||||||
extends?: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A list of HTML tags that should be added to the HEAD section of the document, whenever this theme is active.
|
|
||||||
*/
|
|
||||||
headTags?: HeadTagConfig[];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Interface that represents a single theme-specific HTML tag in the HEAD section of the page.
|
|
||||||
*/
|
|
||||||
export interface HeadTagConfig extends Config {
|
|
||||||
/**
|
|
||||||
* The name of the HTML tag
|
|
||||||
*/
|
|
||||||
tagName: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The attributes on the HTML tag
|
|
||||||
*/
|
|
||||||
attributes?: {
|
|
||||||
[key: string]: string;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface RegExThemeConfig extends NamedThemeConfig {
|
|
||||||
regex: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface HandleThemeConfig extends NamedThemeConfig {
|
|
||||||
handle: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface UUIDThemeConfig extends NamedThemeConfig {
|
|
||||||
uuid: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class Theme {
|
export class Theme {
|
||||||
constructor(public config: NamedThemeConfig) {
|
constructor(public config: NamedThemeConfig) {
|
||||||
@@ -71,7 +27,7 @@ export class RegExTheme extends Theme {
|
|||||||
}
|
}
|
||||||
|
|
||||||
matches(url: string, dso: DSpaceObject): Observable<boolean> {
|
matches(url: string, dso: DSpaceObject): Observable<boolean> {
|
||||||
let match;
|
let match: RegExpMatchArray;
|
||||||
const route = getDSORoute(dso);
|
const route = getDSORoute(dso);
|
||||||
|
|
||||||
if (isNotEmpty(route)) {
|
if (isNotEmpty(route)) {
|
||||||
@@ -133,9 +89,3 @@ export const themeFactory = (config: ThemeConfig, injector: Injector): Theme =>
|
|||||||
return new Theme(config as NamedThemeConfig);
|
return new Theme(config as NamedThemeConfig);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ThemeConfig
|
|
||||||
= NamedThemeConfig
|
|
||||||
| RegExThemeConfig
|
|
||||||
| HandleThemeConfig
|
|
||||||
| UUIDThemeConfig;
|
|
@@ -4,7 +4,7 @@ import { provideMockActions } from '@ngrx/effects/testing';
|
|||||||
import { LinkService } from '../../core/cache/builders/link.service';
|
import { LinkService } from '../../core/cache/builders/link.service';
|
||||||
import { hot } from 'jasmine-marbles';
|
import { hot } from 'jasmine-marbles';
|
||||||
import { SetThemeAction } from './theme.actions';
|
import { SetThemeAction } from './theme.actions';
|
||||||
import { Theme } from '../../../config/theme.model';
|
import { Theme } from './theme.model';
|
||||||
import { provideMockStore } from '@ngrx/store/testing';
|
import { provideMockStore } from '@ngrx/store/testing';
|
||||||
import { Community } from '../../core/shared/community.model';
|
import { Community } from '../../core/shared/community.model';
|
||||||
import { COMMUNITY } from '../../core/shared/community.resource-type';
|
import { COMMUNITY } from '../../core/shared/community.resource-type';
|
||||||
|
@@ -8,7 +8,8 @@ import { hasNoValue, hasValue, isNotEmpty } from '../empty.util';
|
|||||||
import { RemoteData } from '../../core/data/remote-data';
|
import { RemoteData } from '../../core/data/remote-data';
|
||||||
import { DSpaceObject } from '../../core/shared/dspace-object.model';
|
import { DSpaceObject } from '../../core/shared/dspace-object.model';
|
||||||
import { getFirstCompletedRemoteData, getFirstSucceededRemoteData, getRemoteDataPayload } from '../../core/shared/operators';
|
import { getFirstCompletedRemoteData, getFirstSucceededRemoteData, getRemoteDataPayload } from '../../core/shared/operators';
|
||||||
import { HeadTagConfig, Theme, ThemeConfig, themeFactory } from '../../../config/theme.model';
|
import { Theme, themeFactory } from './theme.model';
|
||||||
|
import { ThemeConfig, HeadTagConfig } from '../../../config/theme.config';
|
||||||
import { NO_OP_ACTION_TYPE, NoOpAction } from '../ngrx/no-op.action';
|
import { NO_OP_ACTION_TYPE, NoOpAction } from '../ngrx/no-op.action';
|
||||||
import { followLink } from '../utils/follow-link-config.model';
|
import { followLink } from '../utils/follow-link-config.model';
|
||||||
import { LinkService } from '../../core/cache/builders/link.service';
|
import { LinkService } from '../../core/cache/builders/link.service';
|
||||||
|
@@ -6,7 +6,7 @@ import { VarDirective } from '../utils/var.directive';
|
|||||||
import { ThemeService } from './theme.service';
|
import { ThemeService } from './theme.service';
|
||||||
import { getMockThemeService } from '../mocks/theme-service.mock';
|
import { getMockThemeService } from '../mocks/theme-service.mock';
|
||||||
import { TestComponent } from './test/test.component.spec';
|
import { TestComponent } from './test/test.component.spec';
|
||||||
import { ThemeConfig } from '../../../config/theme.model';
|
import { ThemeConfig } from '../../../config/theme.config';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-test-themed-component',
|
selector: 'ds-test-themed-component',
|
||||||
|
@@ -9,7 +9,7 @@ import { FormConfig } from './form-config.interfaces';
|
|||||||
import { LangConfig } from './lang-config.interface';
|
import { LangConfig } from './lang-config.interface';
|
||||||
import { ItemConfig } from './item-config.interface';
|
import { ItemConfig } from './item-config.interface';
|
||||||
import { CollectionPageConfig } from './collection-page-config.interface';
|
import { CollectionPageConfig } from './collection-page-config.interface';
|
||||||
import { ThemeConfig } from './theme.model';
|
import { ThemeConfig } from './theme.config';
|
||||||
import { AuthConfig } from './auth-config.interfaces';
|
import { AuthConfig } from './auth-config.interfaces';
|
||||||
import { UIServerConfig } from './ui-server-config.interface';
|
import { UIServerConfig } from './ui-server-config.interface';
|
||||||
import { MediaViewerConfig } from './media-viewer-config.interface';
|
import { MediaViewerConfig } from './media-viewer-config.interface';
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { environment } from '../environments/environment.production';
|
import { environment } from '../environments/environment.production';
|
||||||
import { extendEnvironmentWithAppConfig } from './config.util';
|
import { extendEnvironmentWithAppConfig } from './config.util';
|
||||||
import { DefaultAppConfig } from './default-app-config';
|
import { DefaultAppConfig } from './default-app-config';
|
||||||
import { HandleThemeConfig } from './theme.model';
|
import { HandleThemeConfig } from './theme.config';
|
||||||
|
|
||||||
describe('Config Util', () => {
|
describe('Config Util', () => {
|
||||||
describe('extendEnvironmentWithAppConfig', () => {
|
describe('extendEnvironmentWithAppConfig', () => {
|
||||||
|
@@ -5,7 +5,7 @@ import { environment } from '../environments/environment';
|
|||||||
import { hasNoValue } from '../app/shared/empty.util';
|
import { hasNoValue } from '../app/shared/empty.util';
|
||||||
|
|
||||||
import { AppConfig } from './app-config.interface';
|
import { AppConfig } from './app-config.interface';
|
||||||
import { ThemeConfig, NamedThemeConfig } from './theme.model';
|
import { ThemeConfig, NamedThemeConfig } from './theme.config';
|
||||||
import { BASE_THEME_NAME } from '../app/shared/theme-support/theme.constants';
|
import { BASE_THEME_NAME } from '../app/shared/theme-support/theme.constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -12,7 +12,7 @@ import { MediaViewerConfig } from './media-viewer-config.interface';
|
|||||||
import { INotificationBoardOptions } from './notifications-config.interfaces';
|
import { INotificationBoardOptions } from './notifications-config.interfaces';
|
||||||
import { ServerConfig } from './server-config.interface';
|
import { ServerConfig } from './server-config.interface';
|
||||||
import { SubmissionConfig } from './submission-config.interface';
|
import { SubmissionConfig } from './submission-config.interface';
|
||||||
import { ThemeConfig } from './theme.model';
|
import { ThemeConfig } from './theme.config';
|
||||||
import { UIServerConfig } from './ui-server-config.interface';
|
import { UIServerConfig } from './ui-server-config.interface';
|
||||||
import { BundleConfig } from './bundle-config.interface';
|
import { BundleConfig } from './bundle-config.interface';
|
||||||
import { ActuatorsConfig } from './actuators.config';
|
import { ActuatorsConfig } from './actuators.config';
|
||||||
|
51
src/config/theme.config.ts
Normal file
51
src/config/theme.config.ts
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
import { Config } from './config.interface';
|
||||||
|
|
||||||
|
export interface NamedThemeConfig extends Config {
|
||||||
|
name: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specify another theme to build upon: whenever a themed component is not found in the current theme,
|
||||||
|
* its ancestor theme(s) will be checked recursively before falling back to the default theme.
|
||||||
|
*/
|
||||||
|
extends?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A list of HTML tags that should be added to the HEAD section of the document, whenever this theme is active.
|
||||||
|
*/
|
||||||
|
headTags?: HeadTagConfig[];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface that represents a single theme-specific HTML tag in the HEAD section of the page.
|
||||||
|
*/
|
||||||
|
export interface HeadTagConfig extends Config {
|
||||||
|
/**
|
||||||
|
* The name of the HTML tag
|
||||||
|
*/
|
||||||
|
tagName: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes on the HTML tag
|
||||||
|
*/
|
||||||
|
attributes?: {
|
||||||
|
[key: string]: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RegExThemeConfig extends NamedThemeConfig {
|
||||||
|
regex: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface HandleThemeConfig extends NamedThemeConfig {
|
||||||
|
handle: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UUIDThemeConfig extends NamedThemeConfig {
|
||||||
|
uuid: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ThemeConfig
|
||||||
|
= NamedThemeConfig
|
||||||
|
| RegExThemeConfig
|
||||||
|
| HandleThemeConfig
|
||||||
|
| UUIDThemeConfig;
|
@@ -1,4 +1,4 @@
|
|||||||
import { HandleTheme, RegExTheme, Theme, UUIDTheme } from './theme.model';
|
import { HandleTheme, RegExTheme, Theme, UUIDTheme } from '../app/shared/theme-support/theme.model';
|
||||||
import { getCommunityModuleRoute } from '../app/community-page/community-page-routing-paths';
|
import { getCommunityModuleRoute } from '../app/community-page/community-page-routing-paths';
|
||||||
import { Community } from '../app/core/shared/community.model';
|
import { Community } from '../app/core/shared/community.model';
|
||||||
import { COMMUNITY } from '../app/core/shared/community.resource-type';
|
import { COMMUNITY } from '../app/core/shared/community.resource-type';
|
||||||
|
Reference in New Issue
Block a user