Skip to content

Commit acb1010

Browse files
authored
feat: make configurable action buttons shared component (#1977)
## Description This PR refactors the datafiles action as a configurable components that can be used in other pages of the app. The configuration has been updated to make the configurable actions more flexible. ## Motivation Up to this point, SciCat had only configurable actions for the data files associated to each dataset. In the last year, it have become clear that we need to expand this concept also to dataset as a whole, the datasets list, all the way to the selection. ## Changes: Please provide a list of the changes implemented by this PR * created configurable actions component * migrate datafiles action to use configurable actions component ## Tests included - [x] Included for each change/fix? - [x] Passing? (Merge will not be approved unless this is checked) ## Documentation - [ ] swagger documentation updated \[required\] Not needed - [x] official documentation updated \[nice-to-have\] ## Backend version - [ ] Does it require a specific version of the backend - which version of the backend is required: ## Summary by Sourcery Extract datafiles action buttons into a shared, configurable component and remove the legacy dataset-specific implementations New Features: - Introduce a shared ConfigurableActionsModule providing reusable ConfigurableActionsComponent and ConfigurableActionComponent for rendering action buttons Enhancements: - Replace dataset-specific DatafilesActions and DatafilesAction components and templates with the generic configurable actions component - Refactor component logic to use optional chaining for file inputs and update input type annotations Tests: - Update specs to reference ConfigurableActionComponent and ConfigurableActionsComponent instead of the old datafiles action components - Remove obsolete mocks and commented-out test code Chores: - Add ConfigurableActionsModule to SharedScicatFrontendModule and remove legacy DatafilesAction declarations from DatasetsModule - Delete deprecated datafiles-actions component files and SCSS ## Summary by Sourcery Introduce a reusable configurable action buttons component and migrate the existing datafiles actions to use it, generalize action settings in the app config, and clean up the legacy implementations. Also add a suite of shared dataset filter components and update tests accordingly. New Features: - Add ConfigurableActionsModule with ConfigurableActionsComponent and ConfigurableActionComponent for rendering action buttons based on configuration. - Add new shared dataset filter components (keyword, location, group, type, date range, PID, text, and condition filters) under shared/modules/filters. Enhancements: - Migrate datafiles action buttons (and scaffold batch-view and dataset-detail) to use the generic configurable actions component and extend AppConfigInterface with datasetActions, datasetDetailsActions, and datasetSelectionActions. - Simplify DatafilesComponent lifecycle and data handling by delegating form and request logic to the shared ConfigurableActionComponent. Tests: - Update existing specs to reference ConfigurableActionsComponent and add comprehensive mock data and tests for configurable actions. - Remove obsolete mocks, commented-out code, and legacy datafiles-actions component tests. Chores: - Remove deprecated DatafilesActionsComponent/DatafilesActionComponent files and update module declarations to import ConfigurableActionsModule. - Clean up shared module imports by removing unused Material modules and adding ConfigurableActionsModule and TranslateModule.
2 parents 0f91e21 + bc08c24 commit acb1010

File tree

59 files changed

+3632
-1629
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+3632
-1629
lines changed

.vscode/launch.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
"version": "0.2.0",
33
"configurations": [
44
{
5-
"name": "ng serve",
5+
"name": "Debug SciCat frontend in Chrome",
66
"type": "chrome",
77
"request": "launch",
8-
"url": "http://localhost:4200/#",
9-
"webRoot": "${workspaceFolder}"
8+
"url": "http://localhost:4200",
9+
"webRoot": "${workspaceFolder}",
10+
"sourceMaps": true,
11+
"trace": true
1012
},
1113
{
1214
"name": "ng test",

CI/e2e/.env.backend.e2e

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,7 @@ ES_MAX_RESULT=210000
4545
ES_FIELDS_LIMIT=400000
4646
ES_INDEX="dataset"
4747
ES_REFRESH="wait_for"
48+
49+
FRONTEND_CONFIG_FILE="./dist/config/frontend.config.json"
50+
FRONTEND_THEME_FILE="./dist/config/frontend.theme.json"
51+

CI/e2e/docker-compose.e2e.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ services:
3131
- "./CI/e2e/functionalAccounts.e2e.json:/home/node/app/functionalAccounts.json"
3232
- "./CI/e2e/proposalTypes.e2e.json:/home/node/app/proposalTypes.json"
3333
- "./CI/e2e/frontend.config.e2e.json:/home/node/app/dist/config/frontend.config.json"
34+
- "./CI/e2e/frontend.theme.e2e.json:/home/node/app/dist/config/frontend.theme.json"
3435
- "./CI/e2e/publishedDataConfig.e2e.json:/home/node/app/publishedDataConfig.json"
3536
environment:
3637
- DOI_USERNAME=${DOI_USERNAME}

CI/e2e/frontend.config.e2e.json

Lines changed: 193 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"accessTokenPrefix": "Bearer ",
33
"addDatasetEnabled": false,
4+
"allowConfigOverrides": true,
45
"archiveWorkflowEnabled": false,
56
"datasetReduceEnabled": true,
67
"datasetJsonScientificMetadata": true,
@@ -10,8 +11,10 @@
1011
"editPublishedData": true,
1112
"addSampleEnabled": false,
1213
"externalAuthEndpoint": "/api/v3/auth/msad",
13-
"facility": "SciCat Vanilla",
14+
"facility": "SciCat Vanilla CI Test",
1415
"siteIcon": "site-header-logo.png",
16+
"sitetitle": "",
17+
"siteSciCatLogo": "",
1518
"loginFacilityLabel": "SciCat Vanilla",
1619
"loginLdapLabel": "Ldap",
1720
"loginLocalLabel": "Local",
@@ -24,12 +27,20 @@
2427
"ingestManual": null,
2528
"jobsEnabled": true,
2629
"jsonMetadataEnabled": true,
27-
"jupyterHubUrl": "",
2830
"landingPage": "doi.ess.eu/detail/",
2931
"lbBaseURL": "http://localhost:3000",
32+
"ingestorComponent": {
33+
"ingestorEnabled": false,
34+
"ingestorAutodiscoveryOptions": [
35+
{
36+
"mailDomain": "university.ch",
37+
"description": "University/facility of Choice",
38+
"facilityBackend": "http://localhost:8888"
39+
}
40+
]
41+
},
3042
"logbookEnabled": true,
3143
"loginFormEnabled": true,
32-
"maxDirectDownloadSize": 1047521824,
3344
"thumbnailFetchLimitPerPage": 100,
3445
"metadataPreviewEnabled": true,
3546
"metadataStructure": "",
@@ -38,7 +49,7 @@
3849
"oAuth2Endpoints": [
3950
{
4051
"authURL": "api/v3/auth/oidc",
41-
"displayText": "ESS One Identity"
52+
"displayText": "CI Test Identity"
4253
}
4354
],
4455
"policiesEnabled": true,
@@ -50,6 +61,9 @@
5061
"searchSamples": true,
5162
"sftpHost": "",
5263
"shareEnabled": true,
64+
"sourceFolder": "/data/scicat/vanilla",
65+
"maxDirectDownloadSize": 5000000000,
66+
"maxFileSizeWarning": "Some files are above <maxDirectDownloadSize> and cannot be downloaded directly. These file can be downloaded via sftp host: <sftpHost> in directory: <sourceFolder>",
5367
"shoppingCartEnabled": true,
5468
"shoppingCartOnHeader": true,
5569
"tableSciDataEnabled": true,
@@ -60,52 +74,216 @@
6074
"datafilesActions": [
6175
{
6276
"id": "eed8efec-4354-11ef-a3b5-d75573a5d37f",
63-
"order": 4,
77+
"description": "This action let users download all files using the zip service",
78+
"order": 1,
6479
"label": "Download All",
6580
"files": "all",
6681
"mat_icon": "download",
6782
"type": "form",
6883
"url": "http://localhost:4200/download/all",
6984
"target": "_blank",
70-
"enabled": "#SizeLimit",
85+
"variables" : {
86+
"pid": "#Dataset0Pid",
87+
"files": "#Dataset0FilesPath",
88+
"totalSize": "#Dataset0FilesTotalSize",
89+
"folder": "#Dataset0SourceFolder"
90+
},
91+
"enabled": "#MaxDownloadableSize(@totalSize)",
92+
"inputs" : {
93+
"item[]" : "@pid",
94+
"directory[]" : "@folder",
95+
"files[]": "@files"
96+
},
7197
"authorization": ["#datasetAccess", "#datasetPublic"]
7298
},
7399
{
74100
"id": "3072fafc-4363-11ef-b9f9-ebf568222d26",
75-
"order": 3,
101+
"description": "This action let users download selected files using the zip service",
102+
"order": 2,
76103
"label": "Download Selected",
77104
"files": "selected",
78105
"mat_icon": "download",
79106
"type": "form",
80107
"url": "http://localhost:4200/download/selected",
81108
"target": "_blank",
82-
"enabled": "#Selected && #SizeLimit",
109+
"variables" : {
110+
"pid": "#Dataset0Pid",
111+
"files": "#Dataset0SelectedFilesPath",
112+
"selected": "#Dataset0SelectedFilesCount",
113+
"totalSize": "#Dataset0SelectedFilesTotalSize",
114+
"folder": "#Dataset0SourceFolder"
115+
},
116+
"inputs" : {
117+
"auth_token" : "#tokenBearer",
118+
"jwt" : "#jwt",
119+
"item[]" : "@pid",
120+
"directory[]" : "@folder",
121+
"files[]": "@files"
122+
},
123+
"enabled": "#Length(@files) && #MaxDownloadableSize(@totalSize)",
83124
"authorization": ["#datasetAccess", "#datasetPublic"]
84125
},
85126
{
86127
"id": "4f974f0e-4364-11ef-9c63-03d19f813f4e",
87-
"order": 2,
88-
"label": "Notebook All",
128+
"description": "This action let users download jupyter notebook properly populated with dataset pid and all files using an instance of sciwyrm",
129+
"order": 3,
130+
"label": "Notebook All (Form)",
89131
"files": "all",
90132
"icon": "/assets/icons/jupyter_logo.png",
91133
"type": "form",
92-
"url": "http://localhost:4200/notebook/all",
134+
"url": "http://localhost:4200/notebook/all/form",
93135
"target": "_blank",
136+
"variables" : {
137+
"pid": "#Dataset0Pid",
138+
"files": "#Dataset0FilesPath",
139+
"totalSize": "#Dataset0FilesTotalSize",
140+
"folder": "#Dataset0SourceFolder"
141+
},
142+
"enabled": "",
143+
"inputs" : {
144+
"auth_token" : "#token",
145+
"jwt" : "#jwt",
146+
"item[]" : "@pid",
147+
"directory[]" : "@folder",
148+
"files[]": "@files"
149+
},
94150
"authorization": ["#datasetAccess", "#datasetPublic"]
95151
},
96152
{
97153
"id": "fa3ce6ee-482d-11ef-95e9-ff2c80dd50bd",
98-
"order": 1,
99-
"label": "Notebook Selected",
154+
"order": 4,
155+
"label": "Notebook Selected (Form)",
100156
"files": "selected",
101157
"icon": "/assets/icons/jupyter_logo.png",
102158
"type": "form",
103-
"url": "http://localhost:4200/notebook/selected",
159+
"url": "http://localhost:4200/notebook/selected/form",
104160
"target": "_blank",
105-
"enabled": "#Selected",
161+
"variables" : {
162+
"pid": "#Dataset0Pid",
163+
"files": "#Dataset0SelectedFilesPath",
164+
"selected": "#Dataset0SelectedFilesCount",
165+
"totalSize": "#Dataset0SelectedFilesTotalSize",
166+
"folder": "#Dataset0SourceFolder"
167+
},
168+
"inputs" : {
169+
"auth_token" : "#token",
170+
"jwt" : "#jwt",
171+
"item[]" : "@pid",
172+
"directory[]" : "@folder",
173+
"files[]": "@files"
174+
},
175+
"enabled": "#Length(@files) > 0",
106176
"authorization": ["#datasetAccess", "#datasetPublic"]
177+
},
178+
{
179+
"id": "0cd5b592-0b1a-11f0-a42c-23e177127ee7",
180+
"description": "This action let users download jupyter notebook properly populated with dataset pid and all files using an instance of sciwyrm",
181+
"order": 5,
182+
"label": "Notebook All (Download JSON)",
183+
"files": "all",
184+
"type": "json-download",
185+
"icon": "/assets/icons/jupyter_logo.png",
186+
"url": "http://localhost:5000/notebook/all/json",
187+
"target": "_blank",
188+
"authorization": ["#datasetAccess", "#datasetPublic"],
189+
"variables" : {
190+
"pid": "#Dataset0Pid",
191+
"files": "#Dataset0FilesPath",
192+
"folder": "#Dataset0SourceFolder"
193+
},
194+
"payload": "{\"template_id\":\"c975455e-ede3-11ef-94fb-138c9cd51fc0\",\"parameters\":{\"dataset\":\"{{ @pid }}\",\"directory\":\"{{ @folder }}\",\"files\": {{ @files[] }},\"jwt\":\"{{ #jwt }}\",\"scicat_url\":\"https://staging.scicat.ess.url\",\"file_server_url\":\"sftserver2.esss.dk\",\"file_server_port\":\"22\"}}",
195+
"filename": "{{ #uuid }}.ipynb"
196+
},
197+
{
198+
"id": "a414773a-a526-11f0-a7f2-ff1026e5dba9",
199+
"description": "This action let users download jupyter notebook properly populated with dataset pid and selected files using an instance of sciwyrm",
200+
"order": 6,
201+
"label": "Notebook Selected (Download JSON)",
202+
"type": "json-download",
203+
"icon": "/assets/icons/jupyter_logo.png",
204+
"url": "http://localhost:5000/notebook/selected/json",
205+
"target": "_blank",
206+
"enabled": "#Length(@files) > 0",
207+
"authorization": ["#datasetAccess", "#datasetPublic"],
208+
"variables" : {
209+
"pid": "#Dataset0Pid",
210+
"files": "#Dataset0SelectedFilesPath",
211+
"selected": "#Dataset0SelectedFilesCount",
212+
"folder": "#Dataset0SourceFolder"
213+
},
214+
"payload": "{\"template_id\":\"c975455e-ede3-11ef-94fb-138c9cd51fc0\",\"parameters\":{\"dataset\":\"{{ @pid }}\",\"directory\":\"{{ @folder }}\",\"files\": {{ @files[] }},\"jwt\":\"{{ #jwt }}\",\"scicat_url\":\"https://staging.scicat.ess.url\",\"file_server_url\":\"sftserver2.esss.dk\",\"file_server_port\":\"22\"}}",
215+
"filename": "{{ #uuid }}.ipynb"
216+
},
217+
{
218+
"id": "9c6a11b6-a526-11f0-8795-6f025b320cc3",
219+
"description": "This action let users make a call an arbitrary URL and store the reply in the store",
220+
"order": 7,
221+
"label": "Publish",
222+
"type": "xhr",
223+
"mat_icon": "lock_open",
224+
"method" : "PATCH",
225+
"url": "http://localhost:3000/dataset/{{ @pid }}/",
226+
"target": "_blank",
227+
"enabled": "(#datasetOwner || #userIsAdmin) && !@isPublished",
228+
"authorization": "#datasetOwner && !@isPublished",
229+
"variables" : {
230+
"pid": "@Dataset0Pid",
231+
"isPublished" : "#Dataset[0]Field[isPublished]"
232+
},
233+
"payload": "{\"isPublished\":\"true\"}",
234+
"headers": {
235+
"Content-Type": "application/json",
236+
"Authorization": "#tokenBearer"
237+
}
238+
},
239+
{
240+
"id": "94a1d694-a526-11f0-947b-038d53cd837a",
241+
"description": "This action let users make a call an arbitrary URL and store the reply in the store",
242+
"order": 8,
243+
"label": "Unpublish",
244+
"type": "xhr",
245+
"mat_icon": "lock",
246+
"method" : "PATCH",
247+
"url": "http://localhost:3000/dataset/{{ @pid }}/",
248+
"target": "_blank",
249+
"enabled": "(#datasetOwner || #userIsAdmin) && @isPublished",
250+
"authorization": "#datasetOwner && @isPublished",
251+
"variables" : {
252+
"pid": "#Dataset0Pid",
253+
"isPublished" : "#Dataset[0]Field[isPublished]"
254+
},
255+
"payload": "{\"isPublished\":\"false\"}",
256+
"headers": {
257+
"Content-Type": "application/json",
258+
"Authorization": "#tokenBearer"
259+
}
260+
},
261+
{
262+
"id": "c3bcbd40-a526-11f0-915a-93eeff0860ab",
263+
"description": "This action let users jump to another URL entirely",
264+
"order": 9,
265+
"label": "ESS",
266+
"type": "link",
267+
"icon": "/assets/icons/button_ess.png",
268+
"url": "http://localhost:5000/external",
269+
"target": "_blank"
107270
}
108271
],
272+
"datasetDetailsActionsEnabled": false,
273+
"datasetDetailsActions": [],
274+
"selectionActionsEnabled": true,
275+
"selectionActions": [],
276+
"labelMaps": {
277+
"filters": {
278+
"LocationFilter": "Location",
279+
"PidFilter": "Pid",
280+
"GroupFilter": "Group",
281+
"TypeFilter": "Type",
282+
"KeywordFilter": "Keyword",
283+
"DateRangeFilter": "Start Date - End Date",
284+
"TextFilter": "Text"
285+
}
286+
},
109287
"defaultDatasetsListSettings": {
110288
"columns": [
111289
{

CI/e2e/frontend.theme.e2e.json

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"name": "light",
3+
"properties": {
4+
"--theme-primary-default": "#27aae1",
5+
"--theme-primary-default-contrast": "#ffffff",
6+
"--theme-primary-lighter": "#99d5e9",
7+
"--theme-primary-lighter-contrast": "#000000",
8+
"--theme-primary-darker": "#325b84",
9+
"--theme-primary-darker-contrast": "#ffffff",
10+
"--theme-accent-default": "#99be00",
11+
"--theme-accent-default-contrast": "#ffffff",
12+
"--theme-accent-lighter": "#d6e599",
13+
"--theme-accent-lighter-contrast": "#000000",
14+
"--theme-accent-darker": "#adcb32",
15+
"--theme-accent-darker-contrast": "#ffffff",
16+
"--theme-warn-default": "#c81919",
17+
"--theme-warn-default-contrast": "#ffffff",
18+
"--theme-warn-lighter": "#ff6e6e",
19+
"--theme-warn-lighter-contrast": "#000000",
20+
"--theme-warn-darker": "#820019",
21+
"--theme-warn-darker-contrast": "#ffffff",
22+
"--theme-warn-2-default": "#ffbe00",
23+
"--theme-warn-2-default-contrast": "#ffffff",
24+
"--theme-warn-2-lighter": "#e1dc7d",
25+
"--theme-warn-2-lighter-contrast": "#000000",
26+
"--theme-warn-2-darker": "#d28c14",
27+
"--theme-warn-2-darker-contrast": "#ffffff",
28+
"--theme-header-1-default": "#003366",
29+
"--theme-header-1-default-contrast": "#ffffff",
30+
"--theme-header-1-lighter": "#99adc1",
31+
"--theme-header-1-lighter-contrast": "#000000",
32+
"--theme-header-1-darker": "#325b84",
33+
"--theme-header-1-darker-contrast": "#ffffff",
34+
"--theme-header-2-default": "#006646",
35+
"--theme-header-2-default-contrast": "#ffffff",
36+
"--theme-header-2-lighter": "#99c1b5",
37+
"--theme-header-2-lighter-contrast": "#000000",
38+
"--theme-header-2-darker": "#32846a",
39+
"--theme-header-2-darker-contrast": "#ffffff",
40+
"--theme-header-3-default": "#ff7d00",
41+
"--theme-header-3-default-contrast": "#ffffff",
42+
"--theme-header-3-lighter": "#ffcb99",
43+
"--theme-header-3-lighter-contrast": "#000000",
44+
"--theme-header-3-darker": "#ff9732",
45+
"--theme-header-3-darker-contrast": "#ffffff",
46+
"--theme-header-4-default": "#821482",
47+
"--theme-header-4-default-contrast": "#ffffff",
48+
"--theme-header-4-lighter": "#cda1cd",
49+
"--theme-header-4-lighter-contrast": "#000000",
50+
"--theme-header-4-darker": "#9b429b",
51+
"--theme-header-4-darker-contrast": "#ffffff",
52+
"--theme-hover-default": "#7f7f7f",
53+
"--theme-hover-default-contrast": "#000000",
54+
"--theme-hover-lighter": "#e5e5e5",
55+
"--theme-hover-lighter-contrast": "#000000",
56+
"--theme-hover-darker": "#b2b2b2",
57+
"--theme-hover-darker-contrast": "#000000"
58+
}
59+
}

angular.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
{
5757
"type": "initial",
5858
"maximumWarning": "500kb",
59-
"maximumError": "4mb"
59+
"maximumError": "4.5mb"
6060
},
6161
{
6262
"type": "anyComponentStyle",

0 commit comments

Comments
 (0)