Skip to content

Commit

Permalink
feat: swap 4462 proposal metadata and label localization (#1717)
Browse files Browse the repository at this point in the history
## Description
This PR streamline showing the metadata for proposals and add
localization to the proposals

## Motivation
Showing metadata on proposals involves multiple configurations settings
and a simplification was needed.
Following up the dataset labels localization, it was easy to extend to
proposals

## Changes:
* Proposal module
* Proposal details html page

## Tests included
- [ ] Included for each change/fix?
- [ ] Passing? (Merge will not be approved unless this is checked) 

## Documentation
- [X] swagger documentation updated \[required\]
- [X] official documentation updated \[nice-to-have\]

### official documentation info
If you have updated the official documentation, please provide PR # and
URL of the pages where the updates are included

## Backend version
- [x] Does it require a specific version of the backend
- which version of the backend is required: BE PR still needs to be
created

## Summary by Sourcery

Add localization to proposal metadata and simplify metadata display
configuration.

New Features:
- Added localization support for proposal metadata.

Tests:
- No tests were included in this pull request.
  • Loading branch information
nitrosx authored Feb 7, 2025
2 parents 2ded711 + 5467614 commit 9977cfd
Show file tree
Hide file tree
Showing 22 changed files with 230 additions and 100 deletions.
8 changes: 4 additions & 4 deletions CI/e2e/frontend.config.e2e.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"files": "all",
"mat_icon": "download",
"type": "form",
"url": "https://www.scicat.info/download/all",
"url": "http://localhost:4200/download/all",
"target": "_blank",
"enabled": "#SizeLimit",
"authorization": ["#datasetAccess", "#datasetPublic"]
Expand All @@ -77,7 +77,7 @@
"files": "selected",
"mat_icon": "download",
"type": "form",
"url": "https://www.scicat.info/download/selected",
"url": "http://localhost:4200/download/selected",
"target": "_blank",
"enabled": "#Selected && #SizeLimit",
"authorization": ["#datasetAccess", "#datasetPublic"]
Expand All @@ -89,7 +89,7 @@
"files": "all",
"icon": "/assets/icons/jupyter_logo.png",
"type": "form",
"url": "https://www.scicat.info/notebook/all",
"url": "http://localhost:4200/notebook/all",
"target": "_blank",
"authorization": ["#datasetAccess", "#datasetPublic"]
},
Expand All @@ -100,7 +100,7 @@
"files": "selected",
"icon": "/assets/icons/jupyter_logo.png",
"type": "form",
"url": "https://www.scicat.info/notebook/selected",
"url": "http://localhost:4200/notebook/selected",
"target": "_blank",
"enabled": "#Selected",
"authorization": ["#datasetAccess", "#datasetPublic"]
Expand Down
14 changes: 10 additions & 4 deletions cypress/e2e/datasets/datasets-datafiles.cy.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
describe("Dataset datafiles", () => {
beforeEach(() => {
cy.readFile("CI/e2e/frontend.config.e2e.json").then((baseConfig) => {
cy.intercept("GET", "**/admin/config", baseConfig).as(
"getFrontendConfig",
);
});
cy.login(Cypress.env("username"), Cypress.env("password"));
cy.intercept("PATCH", "/api/v3/datasets/**/*").as("change");
cy.intercept("GET", "*").as("fetch");
cy.visit("/");
});

after(() => {
Expand All @@ -11,10 +17,10 @@ describe("Dataset datafiles", () => {

describe("Datafiles action test", () => {
const actionUrl = {
downloadSelected: "https://www.scicat.info/download/selected",
downloadAll: "https://www.scicat.info/download/all",
notebookSelected: "https://www.scicat.info/notebook/selected",
notebookAll: "https://www.scicat.info/notebook/all",
downloadSelected: "http://localhost:4200/download/selected",
downloadAll: "http://localhost:4200/download/all",
notebookSelected: "http://localhost:4200/notebook/selected",
notebookAll: "http://localhost:4200/notebook/all",
};
it("Should be able to download/notebook with selected/all", () => {
cy.createDataset("raw", undefined, "small");
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/datasets/datasets-detail-dynamic.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { mergeConfig } from "../../support/utils";
describe("Datasets Detail View Dynamic", () => {
const dynamicComponentConfig = testConfig.dynamicDetialViewComponent;
const customizedLabelSets =
dynamicComponentConfig.datasetDetailViewLabelOption.labelSets.test;
dynamicComponentConfig.labelsLocalization.datasetCustom;
const customizedComponents =
dynamicComponentConfig.datasetDetailComponent.customization;

Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/datasets/datasets-general.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe("Datasets general", () => {
});
});

describe.only("Dataset page filter and scientific condition UI test", () => {
describe("Dataset page filter and scientific condition UI test", () => {
it("should not be able to add duplicated conditions ", () => {
cy.visit("/datasets");

Expand Down
56 changes: 56 additions & 0 deletions cypress/e2e/proposals/proposals-general.cy.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
import { testData } from "../../fixtures/testData";
import { testConfig } from "../../fixtures/testData";
import { mergeConfig } from "../../support/utils";

describe("Proposals general", () => {
let proposal;
const proposalLabelsConfig = testConfig.proposalViewCustomLabels;
beforeEach(() => {
cy.readFile("CI/e2e/frontend.config.e2e.json").then((baseConfig) => {
const mergedConfig = mergeConfig(baseConfig, proposalLabelsConfig);
cy.intercept("GET", "**/admin/config", mergedConfig).as(
"getFrontendConfig",
);
});
cy.login(Cypress.env("username"), Cypress.env("password"));
});

Expand Down Expand Up @@ -210,4 +219,51 @@ describe("Proposals general", () => {
.click();
});
});

describe("Proposal view details labelization", () => {
it("should load proposal with fallback labels when no custom labels are available", () => {
const fallbackLabelsToCheck = ["Main proposer", "Proposal Type"];
const customizedLabelsToCheck = [
"Test Proposal Title",
"Test Abstract",
"Test Proposal Id",
];

proposal = {
...testData.proposal,
title: "Cypress test parent proposal",
proposalId: Math.floor(100000 + Math.random() * 900000).toString(),
};
cy.createProposal(proposal);

cy.visit("/proposals");

cy.get("mat-table mat-header-row").should("exist");

cy.finishedLoading();

cy.get("mat-table mat-row").should("contain", proposal.proposalId);

cy.get("mat-row")
.contains(proposal.proposalId)
.parent()
.contains(proposal.title)
.click();

cy.url().should("include", `/proposals/${proposal.proposalId}`);

cy.contains(proposal.title);

cy.wrap([...fallbackLabelsToCheck, ...customizedLabelsToCheck]).each(
(value) => {
cy.get("mat-card").should(($matCards) => {
const matchFound = [...$matCards].some((card) =>
card.innerText.includes(value),
);
expect(matchFound).to.be.true;
});
},
);
});
});
});
58 changes: 31 additions & 27 deletions cypress/fixtures/testData.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,21 +152,18 @@ export const testData = {

export const testConfig = {
dynamicDetialViewComponent: {
datasetDetailViewLabelOption: {
currentLabelSet: "test",
labelSets: {
test: {
datasetName: "Test String",
description: "Test Copy",
ownerEmail: "Test Linky",
keywords: "Test Tag",
"Section Label Regular": "Test Section Regular",
"Section Label Attachments": "Test Section Attachments",
"Section Label Metadata JSON": "Test Section Metadata JSON",
"Section Label Metadata TABLE": "Test Section Metadata TABLE",
"Section Label Metadata TREE": "Test Section Metadata TREE",
"Section Label Dataset JsonView": "Test Section Dataset JsonView",
},
labelsLocalization: {
datasetCustom: {
datasetName: "Test String",
description: "Test Copy",
ownerEmail: "Test Linky",
keywords: "Test Tag",
"Section Label Regular": "Test Section Regular",
"Section Label Attachments": "Test Section Attachments",
"Section Label Metadata JSON": "Test Section Metadata JSON",
"Section Label Metadata TABLE": "Test Section Metadata TABLE",
"Section Label Metadata TREE": "Test Section Metadata TREE",
"Section Label Dataset JsonView": "Test Section Dataset JsonView",
},
},
datasetDetailComponent: {
Expand Down Expand Up @@ -235,23 +232,30 @@ export const testConfig = {
},
},
defaultDetailViewComponent: {
datasetDetailViewLabelOption: {
currentLabelSet: "test",
labelSets: {
test: {
"Dataset Name": "Test Dataset name",
Description: "Test Description",
"Creation time": "Test Creation time",
Pid: "Test Pid",
Type: "Test Type",
"General Information": "Test General Information",
"Creator Information": "Creator Information",
},
labelsLocalization: {
datasetDefault: {
"Dataset Name": "Test Dataset name",
Description: "Test Description",
"Creation time": "Test Creation time",
Pid: "Test Pid",
Type: "Test Type",
"General Information": "Test General Information",
"Creator Information": "Creator Information",
},
},
datasetDetailComponent: {
enableCustomizedComponent: false,
customization: [],
},
},
proposalViewCustomLabels: {
labelsLocalization: {
proposalDefault: {
"General Information": "Test Proposal Information",
Title: "Test Proposal Title",
Abstract: "Test Abstract",
"Proposal Id": "Test Proposal Id",
},
},
},
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "scicat-frontend",
"version": "4.5.0",
"version": "local.dev",
"license": "BSD-3-Clause",
"scripts": {
"ng": "ng",
Expand Down
4 changes: 2 additions & 2 deletions src/app/app-config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { Injectable } from "@angular/core";
import { timeout } from "rxjs/operators";
import {
DatasetDetailComponentConfig,
DatasetDetailViewLabelOption,
DatasetsListSettings,
LabelMaps,
LabelsLocalization,
TableColumn,
} from "state-management/models";

Expand Down Expand Up @@ -103,8 +103,8 @@ export interface AppConfig {
labelMaps: LabelMaps;
thumbnailFetchLimitPerPage: number;
maxFileUploadSizeInMb?: string;
datasetDetailViewLabelOption?: DatasetDetailViewLabelOption;
datasetDetailComponent?: DatasetDetailComponentConfig;
labelsLocalization?: LabelsLocalization;
}

@Injectable()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ describe("DatasetDetailDynamicComponent", () => {
navigateByUrl: jasmine.createSpy("navigateByUrl"),
};

const getConfig = () => ({
datasetDetailViewLabelOption: {
currentLabel: "test",
},
});
const getConfig = () => ({});

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ export class DatasetDetailDynamicComponent implements OnInit {
private store: Store,
private fb: FormBuilder,
) {
this.translateService.use(
this.appConfig.datasetDetailViewLabelOption?.currentLabelSet,
);
this.translateService.use("datasetCustom");
}

ngOnInit() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,7 @@ describe("DatasetDetailComponent", () => {
navigateByUrl: jasmine.createSpy("navigateByUrl"),
};

const getConfig = () => ({
datasetDetailViewLabelOption: {
currentLabel: "test",
},
});
const getConfig = () => ({});

let store: MockStore;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ export class DatasetDetailComponent implements OnInit, OnDestroy {
private router: Router,
private fb: FormBuilder,
) {
this.translateService.use(
this.appConfig.datasetDetailViewLabelOption?.currentLabelSet,
);
this.translateService.use("datasetDefault");
}

ngOnInit() {
Expand Down
Loading

0 comments on commit 9977cfd

Please sign in to comment.