Skip to content

Commit

Permalink
Live Preview: Add possibility to disable the feature in the config fr…
Browse files Browse the repository at this point in the history
…om the backend
  • Loading branch information
GeoffreyKarnbach authored and ValentinFutterer committed Dec 3, 2024
1 parent c0d8a21 commit 6465994
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions apps/damap-frontend/src/app/services/config.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ describe('ConfigService', () => {
authUser: '',
personSearchServiceConfigs: [],
fitsServiceAvailable: false,
livePreviewAvailable: true,
};

mockOAuthService.loadDiscoveryDocumentAndTryLogin.and.returnValue(
Expand Down Expand Up @@ -115,6 +116,7 @@ describe('ConfigService', () => {
authUser: '',
personSearchServiceConfigs: [],
fitsServiceAvailable: false,
livePreviewAvailable: true,
};

service['config'] = mockConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
{{ "button.version" | translate }}
</button>
<div
*ngIf="preview"
matTooltip="{{ 'button.preview.tooltipDisabled' | translate }}"
[matTooltipDisabled]="previewEnabled()">
<button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { selectDmpSaving } from '../../../store/selectors/dmp.selectors';
export class DmpActionsComponent implements OnInit, OnDestroy {
@Input() stepChanged$: Subject<any>;
@Input() admin = false;
@Input() preview = false;

dmpForm: FormGroup;

Expand Down
3 changes: 2 additions & 1 deletion libs/damap/src/lib/components/dmp/dmp.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -223,4 +223,5 @@
<app-actions
class="dmp-actions"
[stepChanged$]="stepChanged$"
[admin]="admin"></app-actions>
[admin]="admin"
[preview]="livePreviewEnabled"></app-actions>
6 changes: 5 additions & 1 deletion libs/damap/src/lib/components/dmp/dmp.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export class DmpComponent implements OnInit, OnDestroy {
@ViewChild('legalEthicalAspects')
legalEthicalAspectsComponent: LegalEthicalAspectsComponent;
@ViewChild('repo') repoComponent: RepoComponent;
livePreviewEnabled: boolean = true;

selectedViewStorage: 'primaryView' | 'secondaryView' = 'primaryView';

Expand Down Expand Up @@ -117,7 +118,10 @@ export class DmpComponent implements OnInit, OnDestroy {
setTimeout(() => {
this.getInstruction(0);
this.config$ = this.backendService.loadServiceConfig();
this.config$.subscribe(() => this.cdr.detectChanges());
this.config$.subscribe(config => {
this.livePreviewEnabled = config.livePreviewAvailable;
this.cdr.detectChanges();
});
this.dmpForm.valueChanges.subscribe(() => this.cdr.detectChanges());
this.dmpForm.valueChanges.subscribe(value => {
this.logger.debug(value);
Expand Down
1 change: 1 addition & 0 deletions libs/damap/src/lib/domain/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ export interface Config {
readonly env: string;
readonly personSearchServiceConfigs: ServiceConfig[];
readonly fitsServiceAvailable: boolean;
readonly livePreviewAvailable: boolean;
}
1 change: 1 addition & 0 deletions libs/damap/src/lib/mocks/config-service-mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ export const configMockData: Config = {
env: '',
personSearchServiceConfigs: serviceConfigMockData,
fitsServiceAvailable: true,
livePreviewAvailable: true,
};

0 comments on commit 6465994

Please sign in to comment.