Skip to content

Commit 5280a98

Browse files
committed
form: added severity checks config
1 parent 40f123c commit 5280a98

File tree

3 files changed

+34
-11
lines changed

3 files changed

+34
-11
lines changed

invenio_app_rdm/config.py

+12
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,18 @@ def github_link_render(record):
941941
"visibility-section": ["access.embargo.until"],
942942
}
943943

944+
945+
APP_RDM_SEVERITY_CHECKS = {
946+
"info": {
947+
"label": _("Recommended"),
948+
"description": _("This check is recommended but not mandatory."),
949+
},
950+
"error": {
951+
"label": _("Error"),
952+
"description": _("This check indicates a critical issue that must be addressed."),
953+
},
954+
}
955+
944956
APP_RDM_DEPOSIT_FORM_DEFAULTS = {
945957
"publication_date": lambda: datetime.now().strftime("%Y-%m-%d"),
946958
"rights": [

invenio_app_rdm/records_ui/views/deposits.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,6 @@ def get_form_config(**kwargs):
359359
cf for cf in custom_fields["ui"] if not cf.get("hide_from_upload_form", False)
360360
]
361361
quota = deepcopy(conf.get("APP_RDM_DEPOSIT_FORM_QUOTA", {}))
362-
sections_config = deepcopy(conf.get("APP_RDM_DEPOSIT_FORM_SECTIONS_CONFIG", {}))
363362
record_quota = kwargs.pop("quota", None)
364363
if record_quota:
365364
quota["maxStorage"] = record_quota["quota_size"]
@@ -383,7 +382,8 @@ def get_form_config(**kwargs):
383382
),
384383
user_communities_memberships=get_user_communities_memberships(),
385384
custom_fields=custom_fields,
386-
sections_config=sections_config,
385+
sections_config=current_app.config.get("APP_RDM_DEPOSIT_FORM_SECTIONS_CONFIG", {}),
386+
severity_checks=current_app.config.get("APP_RDM_SEVERITY_CHECKS", {}),
387387
publish_modal_extra=current_app.config.get(
388388
"APP_RDM_DEPOSIT_FORM_PUBLISH_MODAL_EXTRA"
389389
),

invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/deposit/RDMDepositForm.js

+20-9
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ export class RDMDepositForm extends Component {
9090
this.noFiles = true;
9191
}
9292

93+
this.sectionsConfig = this.config.sections_config;
94+
this.severityChecks = this.config.severity_checks;
95+
9396
// hide community header for branded communities
9497
this.hide_community_selection = this.config.hide_community_selection || false;
9598
}
@@ -115,7 +118,6 @@ export class RDMDepositForm extends Component {
115118
...section,
116119
id: section.section.toLowerCase().replace(/\s+/g, "-") + "-section",
117120
}));
118-
const sectionsConfig = this.config.sections_config;
119121

120122
return (
121123
<Overridable
@@ -147,7 +149,7 @@ export class RDMDepositForm extends Component {
147149
<FormFeedback
148150
fieldPath="message"
149151
labels={this.config.custom_fields.error_labels}
150-
sectionsConfig={sectionsConfig}
152+
sectionsConfig={this.sectionsConfig}
151153
/>
152154
</Overridable>
153155

@@ -172,7 +174,8 @@ export class RDMDepositForm extends Component {
172174
noFiles={this.noFiles}
173175
>
174176
<AccordionField
175-
includesPaths={sectionsConfig["files-section"]}
177+
includesPaths={this.sectionsConfig["files-section"]}
178+
severityChecks={this.severityChecks}
176179
active
177180
label={i18next.t("Files")}
178181
id="files-section"
@@ -208,7 +211,8 @@ export class RDMDepositForm extends Component {
208211
vocabularies={this.vocabularies}
209212
>
210213
<AccordionField
211-
includesPaths={sectionsConfig["basic-information-section"]}
214+
includesPaths={this.sectionsConfig["basic-information-section"]}
215+
severityChecks={this.severityChecks}
212216
active
213217
label={i18next.t("Basic information")}
214218
id="basic-information-section"
@@ -366,7 +370,10 @@ export class RDMDepositForm extends Component {
366370
record={record}
367371
>
368372
<AccordionField
369-
includesPaths={sectionsConfig["recommended-information-section"]}
373+
includesPaths={
374+
this.sectionsConfig["recommended-information-section"]
375+
}
376+
severityChecks={this.severityChecks}
370377
label={i18next.t("Recommended information")}
371378
id="recommended-information-section"
372379
>
@@ -457,7 +464,8 @@ export class RDMDepositForm extends Component {
457464
ui={this.accordionStyle}
458465
>
459466
<AccordionField
460-
includesPaths={sectionsConfig["funding-section"]}
467+
includesPaths={this.sectionsConfig["funding-section"]}
468+
severityChecks={this.severityChecks}
461469
active
462470
label="Funding"
463471
ui={this.accordionStyle}
@@ -551,7 +559,8 @@ export class RDMDepositForm extends Component {
551559
vocabularies={this.vocabularies}
552560
>
553561
<AccordionField
554-
includesPaths={sectionsConfig["alternate-identifiers-section"]}
562+
includesPaths={this.sectionsConfig["alternate-identifiers-section"]}
563+
severityChecks={this.severityChecks}
555564
active
556565
label={i18next.t("Alternate identifiers")}
557566
id="alternate-identifiers-section"
@@ -577,7 +586,8 @@ export class RDMDepositForm extends Component {
577586
vocabularies={this.vocabularies}
578587
>
579588
<AccordionField
580-
includesPaths={sectionsConfig["related-works-section"]}
589+
includesPaths={this.sectionsConfig["related-works-section"]}
590+
severityChecks={this.severityChecks}
581591
active
582592
label={i18next.t("Related works")}
583593
id="related-works-section"
@@ -600,7 +610,8 @@ export class RDMDepositForm extends Component {
600610
vocabularies={this.vocabularies}
601611
>
602612
<AccordionField
603-
includesPaths={sectionsConfig["references-section"]}
613+
includesPaths={this.sectionsConfig["references-section"]}
614+
severityChecks={this.severityChecks}
604615
active
605616
label={i18next.t("References")}
606617
id="references-section"

0 commit comments

Comments
 (0)