diff --git a/src/app/app-config.service.spec.ts b/src/app/app-config.service.spec.ts index 93397aaf2..f681b54f9 100644 --- a/src/app/app-config.service.spec.ts +++ b/src/app/app-config.service.spec.ts @@ -1,6 +1,6 @@ import { HttpClient } from "@angular/common/http"; import { TestBed } from "@angular/core/testing"; -import { AppConfig, AppConfigService } from "app-config.service"; +import { AppConfig, AppConfigService, HelpMessages } from "app-config.service"; import { of } from "rxjs"; import { MockHttp } from "shared/MockStubs"; @@ -119,7 +119,8 @@ const appConfig: AppConfig = { shoppingCartOnHeader: true, tableSciDataEnabled: true, fileserverBaseURL: "", - fileserverButtonLabel: "" + fileserverButtonLabel: "", + helpMessages: new HelpMessages(), }; describe("AppConfigService", () => { @@ -159,4 +160,5 @@ describe("AppConfigService", () => { expect(config).toEqual(appConfig); }); }); + }); diff --git a/src/app/app-config.service.ts b/src/app/app-config.service.ts index 4bcfc1cd7..b64383d9a 100644 --- a/src/app/app-config.service.ts +++ b/src/app/app-config.service.ts @@ -14,6 +14,20 @@ export class RetrieveDestinations { option = ""; } +export class HelpMessages { + ingestManual: string; + gettingStarted: string; + + constructor( + gettingStarted = "gives a brief description on how to get started using the data catalog.", + ingestManual = `provides detailed information on how to make your data available to the + catalog as well as archiving and retrieval of datasets.` + ) { + this.gettingStarted = gettingStarted; + this.ingestManual = ingestManual; + } +} + export interface AppConfig { accessTokenPrefix: string; addDatasetEnabled: boolean; @@ -57,6 +71,7 @@ export interface AppConfig { tableSciDataEnabled: boolean; fileserverBaseURL: string; fileserverButtonLabel: string | undefined; + helpMessages?: HelpMessages; } @Injectable() diff --git a/src/app/help/help/help.component.html b/src/app/help/help/help.component.html index 1cf10cb6e..ad6fa1f7d 100644 --- a/src/app/help/help/help.component.html +++ b/src/app/help/help/help.component.html @@ -17,7 +17,7 @@ The Getting Started Guide - gives a brief description on how to get started using the data catalog. + {{ helpMessages.gettingStarted }}

@@ -65,8 +65,7 @@ The Ingest Manual - provides detailed information on how to make your data available to the - catalog as well as archiving and retrieval of datasets. + {{ helpMessages.ingestManual }}

diff --git a/src/app/help/help/help.component.spec.ts b/src/app/help/help/help.component.spec.ts index b36a23b96..f03b03ba8 100644 --- a/src/app/help/help/help.component.spec.ts +++ b/src/app/help/help/help.component.spec.ts @@ -1,12 +1,16 @@ import { ComponentFixture, TestBed, waitForAsync } from "@angular/core/testing"; import { HelpComponent } from "./help.component"; import { MatCardModule } from "@angular/material/card"; -import { AppConfigService } from "app-config.service"; +import { AppConfigService, HelpMessages } from "app-config.service"; const getConfig = () => ({ facility: "ESS", + gettingStarted: true, + ingestManual: true }); +const helpMessages = new HelpMessages(); + describe("HelpComponent", () => { let component: HelpComponent; let fixture: ComponentFixture; @@ -42,4 +46,45 @@ describe("HelpComponent", () => { it("should create", () => { expect(component).toBeTruthy(); }); + + it("should have default messages", () => { + const compiled = fixture.debugElement.nativeElement; + expect(compiled.innerHTML).toContain(helpMessages.gettingStarted); + expect(compiled.innerHTML).toContain(helpMessages.ingestManual); + }); + + describe("should have custom messages", () => { + let customHelpMessages: HelpMessages; + beforeEach(() => { + fixture = TestBed.createComponent(HelpComponent); + component = fixture.componentInstance; + customHelpMessages = { gettingStarted: "someGettingStart", ingestManual: "someOtherIngest" }; + component.appConfig.helpMessages = customHelpMessages; + fixture.detectChanges(); + }); + + it("should have custom messages", () => { + const compiled = fixture.debugElement.nativeElement; + expect(compiled.innerHTML).toContain(customHelpMessages.gettingStarted); + expect(compiled.innerHTML).toContain(customHelpMessages.ingestManual); + }); + }); + + describe("should set only one custom message", () => { + let customHelpMessages: HelpMessages; + beforeEach(() => { + fixture = TestBed.createComponent(HelpComponent); + component = fixture.componentInstance; + customHelpMessages = new HelpMessages("someGettingStart"); + component.appConfig.helpMessages = customHelpMessages; + fixture.detectChanges(); + }); + + it("should set only one custom message", () => { + const compiled = fixture.debugElement.nativeElement; + expect(compiled.innerHTML).toContain(customHelpMessages.gettingStarted); + expect(compiled.innerHTML).toContain(helpMessages.ingestManual); + }); + }); + }); diff --git a/src/app/help/help/help.component.ts b/src/app/help/help/help.component.ts index 3b42a48e1..336bda220 100644 --- a/src/app/help/help/help.component.ts +++ b/src/app/help/help/help.component.ts @@ -1,5 +1,5 @@ import { Component, OnInit } from "@angular/core"; -import { AppConfigService } from "app-config.service"; +import { AppConfigService, HelpMessages } from "app-config.service"; @Component({ selector: "help", @@ -12,11 +12,16 @@ export class HelpComponent implements OnInit { ingestManual: string | null = null; gettingStarted: string | null = null; shoppingCartEnabled = false; + helpMessages: HelpMessages; constructor(public appConfigService: AppConfigService) {} ngOnInit() { this.facility = this.appConfig.facility; this.ingestManual = this.appConfig.ingestManual; + this.helpMessages = new HelpMessages( + this.appConfig.helpMessages?.gettingStarted, + this.appConfig.helpMessages?.ingestManual + ); this.gettingStarted = this.appConfig.gettingStarted; this.shoppingCartEnabled = this.appConfig.shoppingCartEnabled; }