Skip to content

Commit 9fd03c5

Browse files
committed
UI: add info message about remaining days to publish changes
1 parent f87ce73 commit 9fd03c5

File tree

3 files changed

+69
-2
lines changed

3 files changed

+69
-2
lines changed

invenio_app_rdm/records_ui/utils.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,14 @@ def evaluate_file_modification(record):
167167
"valid_user": file_mod.valid_user,
168168
"allowed": fm_allowed,
169169
}
170+
170171
if fm_allowed:
171172
file_modification["fileModification"] = file_mod
172-
file_modification["context"] = {}
173+
modification_until = record._record.created + current_app.config.get(
174+
"RDM_FILE_MODIFICATION_PERIOD"
175+
)
176+
file_modification["context"] = {
177+
"modification_until": modification_until.isoformat()
178+
}
173179

174180
return file_modification
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// This file is part of InvenioRDM
2+
// Copyright (C) 2025 CERN.
3+
//
4+
// Invenio RDM Records is free software; you can redistribute it and/or modify it
5+
// under the terms of the MIT License; see LICENSE file for more details.
6+
7+
import React, { Component } from "react";
8+
import PropTypes from "prop-types";
9+
import { Trans } from "react-i18next";
10+
11+
export class FileModificationUntil extends Component {
12+
render() {
13+
const { filesLocked, fileModification, record } = this.props;
14+
15+
if (!fileModification.fileModification?.enabled) {
16+
return null;
17+
}
18+
19+
if (
20+
!filesLocked &&
21+
record.is_published &&
22+
fileModification.context?.modification_until
23+
) {
24+
const current = new Date();
25+
const until = new Date(fileModification.context?.modification_until);
26+
const oneDay = 1000 * 60 * 60 * 24;
27+
const daysUntil = Math.round((until - current) / oneDay);
28+
29+
return (
30+
<Trans daysUntil={daysUntil}>
31+
{" "}
32+
– Unlocked, {{ daysUntil }} days to publish changes
33+
</Trans>
34+
);
35+
}
36+
37+
return null;
38+
}
39+
}
40+
41+
FileModificationUntil.propTypes = {
42+
filesLocked: PropTypes.bool.isRequired,
43+
fileModification: PropTypes.object,
44+
record: PropTypes.object.isRequired,
45+
};
46+
47+
FileModificationUntil.defaultProps = {
48+
fileModification: {},
49+
};

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import { CopyrightsField } from "@js/invenio_rdm_records/src/deposit/fields/Copy
4848
import { ShareDraftButton } from "./ShareDraftButton";
4949
import { depositFormSectionsConfig, severityChecksConfig } from "./config";
5050
import { RecordDeletion } from "../components/RecordDeletion";
51+
import { FileModificationUntil } from "../components/FileModificationUntil";
5152

5253
export class RDMDepositForm extends Component {
5354
constructor(props) {
@@ -183,12 +184,23 @@ export class RDMDepositForm extends Component {
183184
record={record}
184185
config={this.config}
185186
noFiles={this.noFiles}
187+
fileModification={fileModification}
188+
filesLocked={filesLocked}
186189
>
187190
<AccordionField
188191
includesPaths={this.sectionsConfig["files-section"]}
189192
severityChecks={this.severityChecks}
190193
active
191-
label={i18next.t("Files")}
194+
label={
195+
<>
196+
{i18next.t("Files")}
197+
<FileModificationUntil
198+
fileModification={fileModification}
199+
filesLocked={filesLocked}
200+
record={record}
201+
/>
202+
</>
203+
}
192204
id="files-section"
193205
>
194206
{this.noFiles && record.is_published && (

0 commit comments

Comments
 (0)