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
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ import {
Step,
} from "semantic-ui-react";
import { i18next } from "@translations/invenio_app_rdm/i18next";
import { EPApprovalSubmitModal } from "./EPApprovalSubmitModal";
import { CommitteeApprovalSubmitModal } from "./CommitteeApprovalSubmitModal";
import { CreatePublicRecordModal } from "./CreatePublicRecordModal";
import PropTypes from "prop-types";

export class EPApprovalManageSection extends Component {
export class CommitteeApprovalManageSection extends Component {
constructor(props) {
super(props);
const recordManagementDiv = document.getElementById("recordManagement");
const epApprovalData = recordManagementDiv
? JSON.parse(recordManagementDiv.dataset.epApproval || "null")
const committeeApprovalData = recordManagementDiv
? JSON.parse(recordManagementDiv.dataset.committeeApproval || "null")
: null;

this.state = {
epApproval: epApprovalData,
committeeApproval: committeeApprovalData,
submitModalOpen: false,
createPublicModalOpen: false,
newVersionModalOpen: false,
Expand All @@ -46,10 +46,11 @@ export class EPApprovalManageSection extends Component {
}

componentDidUpdate(_prevProps, prevState) {
const { epApproval } = this.state;
const prevEpApproval = prevState.epApproval;
const { committeeApproval } = this.state;
const prevEpApproval = prevState.committeeApproval;
if (
epApproval?.open_request?.status !== prevEpApproval?.open_request?.status
committeeApproval?.open_request?.status !==
prevEpApproval?.open_request?.status
) {
this._detachNewVersionInterceptor();
this._attachNewVersionInterceptor();
Expand All @@ -61,8 +62,8 @@ export class EPApprovalManageSection extends Component {
}

_attachNewVersionInterceptor() {
const { epApproval } = this.state;
if (epApproval?.open_request?.status !== "submitted") return;
const { committeeApproval } = this.state;
if (committeeApproval?.open_request?.status !== "submitted") return;

// Find the "New version" button rendered by InvenioRDM's RecordManagement.
const btn = Array.from(document.querySelectorAll("button")).find(
Expand Down Expand Up @@ -92,18 +93,19 @@ export class EPApprovalManageSection extends Component {
}

get shouldRender() {
const { epApproval } = this.state;
const { committeeApproval } = this.state;
return (
epApproval &&
(epApproval.community_enrolled || epApproval.is_public_approved_record)
committeeApproval &&
(committeeApproval.community_enrolled ||
committeeApproval.is_public_approved_record)
);
}

handleSubmitSuccess = (request) => {
this.setState((prev) => ({
submitModalOpen: false,
epApproval: {
...prev.epApproval,
committeeApproval: {
...prev.committeeApproval,
open_request: {
id: request.id,
status: "submitted",
Expand All @@ -122,7 +124,7 @@ export class EPApprovalManageSection extends Component {

render() {
const {
epApproval,
committeeApproval,
submitModalOpen,
createPublicModalOpen,
newVersionModalOpen,
Expand All @@ -136,12 +138,12 @@ export class EPApprovalManageSection extends Component {
}

// Public EP-approved record — show a compact provenance note.
if (epApproval.is_public_approved_record) {
if (committeeApproval.is_public_approved_record) {
const {
approved_report_number: pubRn,
draft_record_id: draftRecordId,
can_view_reviewed_version: canViewReviewedVersion,
} = epApproval;
} = committeeApproval;

return (
<Grid.Column className="pb-20 pt-0">
Expand Down Expand Up @@ -180,15 +182,15 @@ export class EPApprovalManageSection extends Component {
open_request: openRequest,
approved_report_number: approvedReportNumber,
receiver_group: receiverGroup,
ep_approval: epApprovalField,
} = epApproval;
committee_approval: committeeApprovalField,
} = committeeApproval;

// Public record URL: prefer the URL captured at creation time; fall back to
// the recid stored on the parent (approved_public_version) for page-load case.
const resolvedPublicRecordUrl =
publicRecordUrl ||
(epApprovalField?.approved_public_version
? `/records/${epApprovalField.approved_public_version}`
(committeeApprovalField?.approved_public_version
? `/records/${committeeApprovalField.approved_public_version}`
: null);

const isPending = openRequest?.status === "submitted";
Expand Down Expand Up @@ -232,12 +234,12 @@ export class EPApprovalManageSection extends Component {
vertical
fluid
size="mini"
className="ep-step-group"
className="committee-step-group"
>
{/* Step 1 — Request for approval */}
<Step completed={step1Completed} active={step1Active}>
<Step.Content>
<div className="ep-action-step">
<div className="committee-action-step">
<div>
<Step.Title>{i18next.t("Request for approval")}</Step.Title>
<Step.Description>
Expand Down Expand Up @@ -283,7 +285,7 @@ export class EPApprovalManageSection extends Component {
</Step.Content>

{canResubmit && (
<EPApprovalSubmitModal
<CommitteeApprovalSubmitModal
open={submitModalOpen}
record={record}
receiverGroup={receiverGroup}
Expand All @@ -300,7 +302,7 @@ export class EPApprovalManageSection extends Component {
disabled={step2Disabled}
>
<Step.Content>
<div className="ep-action-step">
<div className="committee-action-step">
<div>
<Step.Title>{i18next.t("EP Board review")}</Step.Title>
<Step.Description>
Expand Down Expand Up @@ -347,7 +349,7 @@ export class EPApprovalManageSection extends Component {
disabled={step3Disabled}
>
<Step.Content>
<div className="ep-action-step">
<div className="committee-action-step">
<div>
<Step.Title>
{step3Completed
Expand Down Expand Up @@ -433,6 +435,6 @@ export class EPApprovalManageSection extends Component {
}
}

EPApprovalManageSection.propTypes = {
CommitteeApprovalManageSection.propTypes = {
record: PropTypes.object.isRequired,
};
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const buildInitialForm = (record) => ({
additional_communication: "",
});

export class EPApprovalSubmitModal extends Component {
export class CommitteeApprovalSubmitModal extends Component {
constructor(props) {
super(props);
this.state = {
Expand Down Expand Up @@ -58,7 +58,7 @@ export class EPApprovalSubmitModal extends Component {
payload: { ...form },
};
const response = await http.post(
`/api/records/${record.id}/ep-approval`,
`/api/records/${record.id}/committee-approval`,
payload,
{ headers: { "Content-Type": "application/json" } }
);
Expand Down Expand Up @@ -187,14 +187,14 @@ export class EPApprovalSubmitModal extends Component {
}
}

EPApprovalSubmitModal.propTypes = {
CommitteeApprovalSubmitModal.propTypes = {
open: PropTypes.bool.isRequired,
record: PropTypes.object.isRequired,
receiverGroup: PropTypes.string,
onClose: PropTypes.func.isRequired,
onSuccess: PropTypes.func.isRequired,
};

EPApprovalSubmitModal.defaultProps = {
CommitteeApprovalSubmitModal.defaultProps = {
receiverGroup: null,
};
10 changes: 5 additions & 5 deletions assets/js/components/record_details/CreatePublicRecordModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class CreatePublicRecordModal extends Component {
this.setState({ submitting: true, error: null, alreadyExists: false });
try {
const response = await http.post(
`/api/records/${record.id}/ep-approval/publish-public`,
`/api/records/${record.id}/committee-approval/publish-public`,
{},
{ headers: { "Content-Type": "application/json" } }
);
Expand Down Expand Up @@ -83,11 +83,11 @@ export class CreatePublicRecordModal extends Component {
const versionIndex = record?.versions?.index;
const canPublish = agreedToTerms && agreedToCommunity;

const epApprovalEl = document.getElementById("recordManagement");
const epApproval = epApprovalEl
? JSON.parse(epApprovalEl.dataset.epApproval || "null")
const committeeApprovalEl = document.getElementById("recordManagement");
const committeeApproval = committeeApprovalEl
? JSON.parse(committeeApprovalEl.dataset.committeeApproval || "null")
: null;
const communityId = epApproval?.cern_scientific_community_id;
const communityId = committeeApproval?.cern_scientific_community_id;

return (
<Modal open={open} onClose={this.handleClose} size="small" closeIcon>
Expand Down
10 changes: 5 additions & 5 deletions assets/js/components/record_details/RecordVersionItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@ import { i18next } from "@translations/invenio_app_rdm/i18next";
import PropTypes from "prop-types";
import { CopyButton } from "@js/invenio_app_rdm/components/CopyButton";

function readEpApprovalData() {
function readCommitteeApprovalData() {
const el = document.getElementById("recordManagement");
if (!el) return null;
try {
return JSON.parse(el.dataset.epApproval || "null");
return JSON.parse(el.dataset.committeeApproval || "null");
} catch (_) {
return null;
}
}

export const RecordVersionItemContent = ({ item, activeVersion, doi }) => {
const epApproval = useMemo(readEpApprovalData, []);
const committeeApproval = useMemo(readCommitteeApprovalData, []);

// --- Internal draft side ---
// ep_approval is the parent record's approval dict, shared by all versions.
// committee_approval is the parent record's approval dict, shared by all versions.
// Keys: reportnumber, approved_internal_version, approved_public_version,
// source_public_version (internal parent); source_internal_version (public parent).
const ea = epApproval?.ep_approval || {};
const ea = committeeApproval?.committee_approval || {};
const approvedReportNumber = ea.reportnumber;
// approved_internal_version: recid of the version that was submitted and approved.
const isApprovedVersion =
Expand Down
4 changes: 2 additions & 2 deletions assets/js/invenio_app_rdm/overridableRegistry/mapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { CDSRecordsResultsListItem } from "../../components/frontpage/overrides/
import { CDSRecordsResultsListItemDescription } from "../../components/search/overrides/CDSRecordsResultsListItemDescription";
import { CDSAffiliationsSuggestions } from "../../components/deposit/overrides/CDSAffiliationsSuggestions";
import { CLCSync } from "../../components/record_details/clc_sync";
import { EPApprovalManageSection } from "../../components/record_details/EPApproval";
import { CommitteeApprovalManageSection } from "../../components/record_details/CommitteeApproval";
import {
PublishModalComponent,
SubmitReviewModalComponent,
Expand All @@ -24,7 +24,7 @@ import { RecordVersionItemContent } from "../../components/record_details/Record
const RecordManagementContainer = (props) => (
<>
<CLCSync {...props} />
<EPApprovalManageSection {...props} />
<CommitteeApprovalManageSection {...props} />
</>
);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.ep-step-group .step {
.committee-step-group .step {
.content {
flex: 1;
}
Expand All @@ -12,7 +12,7 @@
}
}

.ep-action-step {
.committee-action-step {
display: flex;
justify-content: space-between;
align-items: center;
Expand All @@ -24,15 +24,15 @@
}
}

dl.ep-submission-details {
dl.committee-submission-details {
dt {
font-size: 0.9em;
color: @mutedTextColor;
margin-bottom: 2px;
}

dd {
.ep-details-note {
.committee-details-note {
// A little bit darker than @mutedTextColor to distinguish from the labels
color: #555;
}
Expand Down
2 changes: 1 addition & 1 deletion assets/less/cds-rdm/globals/site.overrides
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@import "../mixins.less";
@import "./hero.less";
@import "../administration/harvester-reports.less";
@import "../ep_approval/ep-workflow.less";
@import "../committee_approval/committee-workflow.less";

.rdm-logo {
padding: 1em 1em 1em 0;
Expand Down
16 changes: 8 additions & 8 deletions invenio.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ from invenio_app_rdm.config import \
STATS_AGGREGATIONS as _APP_RDM_STATS_AGGREGATIONS
from invenio_app_rdm.config import STATS_EVENTS as _APP_RDM_STATS_EVENTS
from invenio_app_rdm.config import NOTIFICATIONS_BUILDERS
from cds_rdm.notifications.ep_approval import (
EPApprovalAcceptNotificationBuilder,
EPApprovalDeclineNotificationBuilder,
EPApprovalSubmitNotificationBuilder,
from cds_rdm.notifications.committee_approval import (
CommitteeApprovalAcceptNotificationBuilder,
CommitteeApprovalDeclineNotificationBuilder,
CommitteeApprovalSubmitNotificationBuilder,
)
from invenio_cern_sync.sso import cern_keycloak, cern_remote_app_name
from invenio_cern_sync.users.profile import CERNUserProfileSchema
Expand Down Expand Up @@ -452,7 +452,7 @@ CDS_CERN_SCIENTIFIC_COMMUNITY_ID = ""
# EP / Publication Approval Workflow
# ==================================

CDS_EP_APPROVAL_COMMUNITIES = {
CDS_COMMITTEE_APPROVAL_COMMUNITIES = {
# Map community UUID → workflow config.
# UUIDs are used (not slugs) because slugs can be renamed.
#
Expand Down Expand Up @@ -793,9 +793,9 @@ NOTIFICATIONS_BUILDERS = {
RepositoryReleaseFailureNotificationBuilder.type: RepositoryReleaseFailureNotificationBuilder,
RepositoryReleaseCommunityRequiredNotificationBuilder.type: RepositoryReleaseCommunityRequiredNotificationBuilder,
RepositoryReleaseCommunitySubmittedNotificationBuilder.type: RepositoryReleaseCommunitySubmittedNotificationBuilder,
EPApprovalSubmitNotificationBuilder.type: EPApprovalSubmitNotificationBuilder,
EPApprovalAcceptNotificationBuilder.type: EPApprovalAcceptNotificationBuilder,
EPApprovalDeclineNotificationBuilder.type: EPApprovalDeclineNotificationBuilder,
CommitteeApprovalSubmitNotificationBuilder.type: CommitteeApprovalSubmitNotificationBuilder,
CommitteeApprovalAcceptNotificationBuilder.type: CommitteeApprovalAcceptNotificationBuilder,
CommitteeApprovalDeclineNotificationBuilder.type: CommitteeApprovalDeclineNotificationBuilder,
}
NOTIFICATIONS_GROUP_EMAIL_DOMAIN = "cern.ch"

Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,11 @@
"npm": ">=8"
},
"name": "invenio-assets",
"peerDependencies": {},
"private": true,
"scripts": {
"build": "NODE_PRESERVE_SYMLINKS=1 NODE_ENV=production webpack --config ./build/webpack.config.js",
"postinstall": "patch-package",
"start": "NODE_PRESERVE_SYMLINKS=1 NODE_ENV=development webpack --watch --progress --config ./build/webpack.config.js"
},
"version": "2.0.0"
}
}
Loading
Loading