Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 62 additions & 1 deletion CI/e2e/frontend.config.e2e.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,67 @@
"target": "_blank"
}
],
"publishedDataActionsEnabled": true,
"publishedDataActions": [
{
"id": "publish-published-data",
"description": "Publish published data",
"order": 1,
"label": "Publish",
"type": "xhr",
"mat_icon": "publish",
"method": "POST",
"url": "http://localhost:3000/api/v4/publisheddata/{{ @encodedDoi }}/publish",
"variables": {
"encodedDoi": "#encodedDoi",
"status": "#publisheddata[0].status"
},
"enabled": "@status === 'private'",
"payload": "{\"isPublished\":\"true\"}",
"headers": {
"Content-Type": "application/json",
"Authorization": "#tokenBearer"
}
},
{
"id": "register-published-data",
"description": "Register published data",
"order": 2,
"label": "Register",
"type": "xhr",
"mat_icon": "registration",
"method": "POST",
"url": "http://localhost:3000/api/v4/publisheddata/{{ @encodedDoi }}/register",
"variables": {
"encodedDoi": "#encodedDoi",
"status": "#publisheddata[0].status"
},
"enabled": "@status === 'public'",
"headers": {
"Content-Type": "application/json",
"Authorization": "#tokenBearer"
}
},
{
"id": "amend-published-data",
"description": "Amend published data",
"order": 3,
"label": "Amend",
"type": "xhr",
"mat_icon": "edit",
"method": "POST",
"url": "http://localhost:3000/api/v4/publisheddata/{{ @encodedDoi }}/amend",
"variables": {
"encodedDoi": "#encodedDoi",
"status": "#publisheddata[0].status"
},
"enabled": "@status === 'registered'",
"headers": {
"Content-Type": "application/json",
"Authorization": "#tokenBearer"
}
}
],
"datasetDetailsActionsEnabled": false,
"datasetDetailsActions": [],
"selectionActionsEnabled": true,
Expand Down Expand Up @@ -948,4 +1009,4 @@
"enabled": false,
"htmlContent": "Here you can place your custom info/about content for CI testing"
}
}
}
10 changes: 5 additions & 5 deletions cypress/e2e/published-data/published-data.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ describe("Datasets general", () => {

cy.get('[data-cy="status"]').contains("private");

cy.get('[data-cy="publishButton"]').click();
cy.get("configurable-action button").contains("Publish").click();

cy.get("simple-snack-bar").should("contain", "Publishing Failed.");
cy.get("simple-snack-bar").should("contain", "Action failed");
});

it("admins should be able to edit their private published data", () => {
Expand Down Expand Up @@ -365,7 +365,7 @@ describe("Datasets general", () => {

cy.get('[data-cy="status"]').contains("private");

cy.get('[data-cy="publishButton"]').click();
cy.get("configurable-action button").contains("Publish").click();

cy.get('[data-cy="status"]').contains("public");
});
Expand Down Expand Up @@ -436,7 +436,7 @@ describe("Datasets general", () => {

cy.get('[data-cy="status"]').contains("public");

cy.get('[data-cy="registerButton"]').click();
cy.get("configurable-action button").contains("Register").click();

cy.get('[data-cy="status"]').contains("registered");
});
Expand Down Expand Up @@ -525,7 +525,7 @@ describe("Datasets general", () => {

cy.get('[data-cy="status"]').contains("private");

cy.get('[data-cy="publishButton"]').click();
cy.get("configurable-action button").contains("Publish").click();

cy.get('[data-cy="status"]').contains("public");

Expand Down
147 changes: 147 additions & 0 deletions src/app/admin/schema/frontend.config.jsonforms.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,62 @@
}
}
},
"publishedDataActionsEnabled": { "type": "boolean" },
"publishedDataActions": {
"type": "array",
"items": {
"type": "object",
"properties": {
"label": { "type": "string" },
"id": { "type": "string" },
"description": { "type": "string" },
"order": { "type": "number" },
"mat_icon": { "type": "string" },
"url": { "type": "string" },
"target": { "type": "string" },
"enabled": { "type": "string" },
"authorization": { "type": "array", "items": { "type": "string" } },
"inputs": {
"type": "array",
"items": {
"type": "object",
"properties": {
"key": { "type": "string" },
"value": { "type": "string" }
}
}
},
"variables": {
"type": "array",
"items": {
"type": "object",
"properties": {
"key": { "type": "string" },
"value": { "type": "string" }
}
}
},
Comment on lines +200 to +219
"headers": {
"type": "object",
"properties": {
"content-type": { "type": "string" },
"Authorization": { "type": "string" }
}
},
"method": {
"type": "string",
"enum": ["GET", "POST", "PUT", "DELETE", "PATCH"]
},
"type": {
"type": "string",
"enum": ["form", "xhr", "link", "json-download"]
},
"icon": { "type": "string" },
"payload": { "type": "string" },
"filename": { "type": "string" }
}
}
},

"defaultDatasetsListSettings": {
"type": "object",
Expand Down Expand Up @@ -712,6 +768,97 @@
}
]
},
{
"type": "Group",
"label": "Published Data Actions",
"options": {
"expandable": true
},
"elements": [
{
"type": "Control",
"scope": "#/properties/publishedDataActionsEnabled"
},
{
"type": "ListWithDetail",
"scope": "#/properties/publishedDataActions",
"options": {
"detail": {
"type": "VerticalLayout",
"elements": [
{ "type": "Control", "scope": "#/properties/label" },
{ "type": "Control", "scope": "#/properties/id" },
{
"type": "Control",
"scope": "#/properties/description"
},
{ "type": "Control", "scope": "#/properties/order" },
{ "type": "Control", "scope": "#/properties/mat_icon" },
{ "type": "Control", "scope": "#/properties/url" },
{ "type": "Control", "scope": "#/properties/target" },
{ "type": "Control", "scope": "#/properties/enabled" },
{
"type": "Control",
"scope": "#/properties/method"
},
{ "type": "Control", "scope": "#/properties/type" },
{ "type": "Control", "scope": "#/properties/icon" },
{
"type": "Control",
"scope": "#/properties/payload",
"options": { "multi": true }
},
{ "type": "Control", "scope": "#/properties/filename" },
{
"type": "Control",
"scope": "#/properties/authorization"
},
{
"type": "Control",
"scope": "#/properties/variables",
"options": {
"detail": {
"type": "HorizontalLayout",
"elements": [
{ "type": "Control", "scope": "#/properties/key" },
{ "type": "Control", "scope": "#/properties/value" }
]
}
}
},
{
"type": "Control",
"scope": "#/properties/inputs",
"options": {
"detail": {
"type": "HorizontalLayout",
"elements": [
{ "type": "Control", "scope": "#/properties/key" },
{ "type": "Control", "scope": "#/properties/value" }
]
}
}
},
{
"type": "Group",
"label": "Headers",
"elements": [
{
"type": "Control",
"scope": "#/properties/headers/properties/content-type"
},
{
"type": "Control",
"scope": "#/properties/headers/properties/Authorization"
}
]
}
]
}
}
}
]
},
{
"type": "Group",
"label": "Localization",
Expand Down
3 changes: 2 additions & 1 deletion src/app/app-config.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
AppConfigService,
HelpMessages,
} from "app-config.service";
import { time } from "node:console";
import { Observable, of } from "rxjs";
import { MockHttp } from "shared/MockStubs";

Expand Down Expand Up @@ -95,6 +94,8 @@ const appConfig: AppConfigInterface = {
datafilesActions: [],
datasetSelectionActionsEnabled: false,
datasetSelectionActions: [],
publishedDataActionsEnabled: false,
publishedDataActions: [],
defaultDatasetsListSettings: {
columns: [
{
Expand Down
2 changes: 2 additions & 0 deletions src/app/app-config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ export interface AppConfigInterface {
datasetDetailsActions: ActionConfig[];
datasetSelectionActionsEnabled: boolean;
datasetSelectionActions: ActionConfig[];
publishedDataActions: ActionConfig[];
publishedDataActionsEnabled: boolean;
editDatasetEnabled: boolean;
editDatasetSampleEnabled: boolean;
editMetadataEnabled: boolean;
Expand Down
1 change: 1 addition & 0 deletions src/app/datasets/datafiles/datafiles.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ <h3>No files associated to this dataset</h3>
</div>

<configurable-actions
*ngIf="appConfig.datafilesActionsEnabled"
[actionsConfig]="appConfig.datafilesActions"
[actionItems]="actionItems"
></configurable-actions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
</a>
</div>
<configurable-actions
*ngIf="appConfig.datasetActionsEnabled"
[actionsConfig]="appConfig.datasetActions"
[actionItems]="actionItems"
></configurable-actions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,14 @@
</table>
</mat-card-content>

<mat-card-actions *ngIf="isLoggedIn$ | async">
<button
mat-raised-button
color="primary"
*ngIf="publishedData.status === 'registered'"
(click)="onAmendClick(publishedData.doi)"
>
Amend
</button>
<button
mat-raised-button
color="primary"
*ngIf="publishedData.status === 'public'"
(click)="onRegisterClick(publishedData.doi)"
data-cy="registerButton"
>
Register
</button>
<button
mat-raised-button
color="primary"
*ngIf="publishedData.status === 'private'"
(click)="onPublishClick(publishedData.doi)"
data-cy="publishButton"
>
Publish
</button>
<mat-card-actions>
<configurable-actions
*ngIf="appConfig.publishedDataActionsEnabled"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imo this should default to the old actions if none are provided otherwise it's a breaking change.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, that is the goal. I added action config to the config.json file as sensible defaults which restore the previous behaviour.

@fpotier fpotier Jun 19, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is the right solution for backward compatibility:

  • if the config comes from the frontend, it's usually overwritten with the facility config
  • if it comes from the backend I believe the frontend will first fetch it and ignore the frontend one (not 100% sure)

In both cases it requires some config changes

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well yes, but how else would you handle it? How did the other "hardcoded -> config. actions" transitions work? If the change is explained in the release notes that should be enough?

[actionsConfig]="appConfig.publishedDataActions"
[actionItems]="actionItems"
[buttonsStyle]="actionButtonsStyle"
(actionFinished)="onActionFinished($event)">
</configurable-actions>
Comment on lines +29 to +36

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Avoid rendering an empty mat-card-actions container when actions are disabled

mat-card-actions is always rendered, so when publishedDataActionsEnabled is false you end up with an empty actions row that can affect spacing. Please move the *ngIf to the <mat-card-actions> element so the container is not rendered when there are no actions.

Comment on lines +29 to +36
</mat-card-actions>
</mat-card>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,9 @@ mat-card {
margin: 0 1em;
}
}

configurable-actions {
display: flex;
flex-direction: row-reverse;
max-width: 80%;
}
Loading
Loading