Skip to content

Commit 28e822b

Browse files
Merge branch 'main' into unused-stuff
2 parents b647131 + 458a674 commit 28e822b

16 files changed

+366
-306
lines changed

package-lock.json

Lines changed: 49 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"react-redux": "^9.2.0",
3636
"react-router": "^7.4.1",
3737
"react-select": "^5.10.1",
38+
"react-textarea-autosize": "^8.5.7",
3839
"redux": "^5.0.1",
3940
"redux-persist": "^6.0.0",
4041
"redux-thunk": "^3.1.0",
@@ -69,7 +70,6 @@
6970
"@vitejs/plugin-react-swc": "^3.8.1",
7071
"eslint": "^9.23.0",
7172
"prop-types": "^15.8.1",
72-
"rollup-preserve-directives": "^1.1.3",
7373
"sass": "^1.86.1",
7474
"typescript": "^5.8.2",
7575
"typescript-eslint": "^8.29.0",

src/components/events/partials/ModalTabsAndPages/DetailsMetadataTab.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ import WizardNavigationButtons from "../../../shared/wizard/WizardNavigationButt
1919
import { ParseKeys } from "i18next";
2020
import ModalContentTable from "../../../shared/modals/ModalContentTable";
2121

22+
type InitialValues = {
23+
[key: string]: string | string[];
24+
}
25+
2226
/**
2327
* This component renders metadata details of a certain event or series
2428
*/
@@ -27,6 +31,7 @@ const DetailsMetadataTab = ({
2731
metadata,
2832
updateResource,
2933
editAccessRole,
34+
formikRef,
3035
header,
3136
}: {
3237
resourceId: string,
@@ -37,6 +42,7 @@ const DetailsMetadataTab = ({
3742
catalog: MetadataCatalog;
3843
}, any> //(id: string, values: { [key: string]: any }, catalog: MetadataCatalog) => void,
3944
editAccessRole: string,
45+
formikRef?: React.RefObject<FormikProps<InitialValues> | null>
4046
header?: ParseKeys
4147
}) => {
4248
const { t } = useTranslation();
@@ -81,11 +87,12 @@ const DetailsMetadataTab = ({
8187
metadata.length > 0 &&
8288
metadata.map((catalog, key) => (
8389
// initialize form
84-
<Formik
90+
<Formik<InitialValues>
8591
key={key}
8692
enableReinitialize
8793
initialValues={getInitialValues(catalog)}
8894
onSubmit={(values) => handleSubmit(values, catalog)}
95+
innerRef={formikRef}
8996
>
9097
{(formik) => (
9198
/* Render table for each metadata catalog */
@@ -127,13 +134,15 @@ const DetailsMetadataTab = ({
127134
name={field.id}
128135
fieldInfo={field}
129136
showCheck
137+
isFirstField={index === 0}
130138
component={RenderMultiField}
131139
/>
132140
) : (
133141
<Field
134142
name={field.id}
135143
metadataField={field}
136144
showCheck
145+
isFirstField={index === 0}
137146
component={RenderField}
138147
/>
139148
)}

src/components/events/partials/ModalTabsAndPages/EventDetailsSchedulingTab.tsx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,28 @@ import SchedulingConflicts from "../wizards/scheduling/SchedulingConflicts";
5454
import { ParseKeys } from "i18next";
5555
import ModalContentTable from "../../../shared/modals/ModalContentTable";
5656

57-
/**../wizards/scheduling/SchedulingTime
57+
export type InitialValues = {
58+
scheduleStartDate: string;
59+
scheduleStartHour: string;
60+
scheduleStartMinute: string;
61+
scheduleDurationHours: string;
62+
scheduleDurationMinutes: string;
63+
scheduleEndDate: string;
64+
scheduleEndHour: string;
65+
scheduleEndMinute: string;
66+
captureAgent: string;
67+
inputs: string[];
68+
}
69+
70+
/**
5871
* This component manages the main assets tab of event details modal
5972
*/
6073
const EventDetailsSchedulingTab = ({
6174
eventId,
75+
formikRef
6276
}: {
6377
eventId: string,
78+
formikRef?: React.RefObject<FormikProps<InitialValues> | null>
6479
}) => {
6580
const { t } = useTranslation();
6681
const dispatch = useAppDispatch();
@@ -234,10 +249,11 @@ const EventDetailsSchedulingTab = ({
234249
/* Scheduling configuration */
235250
hasSchedulingProperties && (
236251
/* Initialize form */
237-
<Formik
252+
<Formik<InitialValues>
238253
enableReinitialize
239254
initialValues={getInitialValues()}
240255
onSubmit={(values) => submitForm(values).then((r) => {})}
256+
innerRef={formikRef}
241257
>
242258
{(formik) => (
243259
<div className="obj tbl-details">

src/components/events/partials/ModalTabsAndPages/EventDetailsWorkflowTab.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useEffect } from "react";
2-
import { Formik } from "formik";
2+
import { Formik, FormikProps } from "formik";
33
import {
44
deletingWorkflow as getDeletingWorkflow,
55
getBaseWorkflow,
@@ -32,13 +32,22 @@ import ButtonLikeAnchor from "../../../shared/ButtonLikeAnchor";
3232
import { formatWorkflowsForDropdown } from "../../../../utils/dropDownUtils";
3333
import { ParseKeys } from "i18next";
3434

35+
type InitialValues = {
36+
workflowDefinition: string;
37+
configuration: {
38+
[key: string]: any;
39+
} | undefined;
40+
}
41+
3542
/**
3643
* This component manages the workflows tab of the event details modal
3744
*/
3845
const EventDetailsWorkflowTab = ({
3946
eventId,
47+
formikRef,
4048
}: {
4149
eventId: string,
50+
formikRef?: React.RefObject<FormikProps<InitialValues> | null>
4251
}) => {
4352
const { t } = useTranslation();
4453
const dispatch = useAppDispatch();
@@ -280,10 +289,11 @@ const EventDetailsWorkflowTab = ({
280289

281290
{workflows.scheduling &&
282291
(isLoading || (
283-
<Formik
292+
<Formik<InitialValues>
284293
initialValues={setInitialValues()}
285294
enableReinitialize
286295
onSubmit={(values) => handleSubmit(values)}
296+
innerRef={formikRef}
287297
>
288298
{(formik) => (
289299
<div className="obj list-obj">

src/components/events/partials/ModalTabsAndPages/NewAssetUploadPage.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,6 @@ const NewAssetUploadPage = <T extends RequiredFormProps>({
3030

3131
const uploadAssetOptions = useAppSelector(state => getAssetUploadOptions(state));
3232

33-
// if user not chose upload in step before, the skip this step
34-
if (formik.values.sourceMode !== "UPLOAD") {
35-
nextPage(formik.values);
36-
return null;
37-
}
38-
3933
const handleChange = (e: React.ChangeEvent<HTMLInputElement>, assetId: string) => {
4034
if (e.target.files) {
4135
if (e.target.files.length === 0) {

src/components/events/partials/modals/EventDetails.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import {
4545
} from "../../../../slices/eventDetailsSlice";
4646
import { addNotification, removeNotificationByKey, removeNotificationWizardForm, removeNotificationWizardTobira } from "../../../../slices/notificationSlice";
4747
import DetailsTobiraTab from "../ModalTabsAndPages/DetailsTobiraTab";
48+
import { FormikProps } from "formik";
4849
import ButtonLikeAnchor from "../../../shared/ButtonLikeAnchor";
4950
import { NOTIFICATION_CONTEXT } from "../../../../configs/modalConfig";
5051
import { unwrapResult } from "@reduxjs/toolkit";
@@ -73,10 +74,12 @@ const EventDetails = ({
7374
eventId,
7475
policyChanged,
7576
setPolicyChanged,
77+
formikRef,
7678
}: {
7779
eventId: string,
7880
policyChanged: boolean,
7981
setPolicyChanged: (value: boolean) => void,
82+
formikRef: React.RefObject<FormikProps<any> | null>
8083
}) => {
8184
const { t } = useTranslation();
8285
const dispatch = useAppDispatch();
@@ -241,6 +244,7 @@ const EventDetails = ({
241244
metadata={[metadata]}
242245
updateResource={updateMetadata}
243246
editAccessRole="ROLE_UI_EVENTS_DETAILS_METADATA_EDIT"
247+
formikRef={formikRef}
244248
header={tabs[page].bodyHeaderTranslation}
245249
/>
246250
)}
@@ -250,6 +254,7 @@ const EventDetails = ({
250254
metadata={extendedMetadata}
251255
updateResource={updateExtendedMetadata}
252256
editAccessRole="ROLE_UI_EVENTS_DETAILS_METADATA_EDIT"
257+
formikRef={formikRef}
253258
/>
254259
)}
255260
{page === EventDetailsPage.Publication && <EventDetailsPublicationTab eventId={eventId} />}
@@ -259,12 +264,16 @@ const EventDetails = ({
259264
/>
260265
)}
261266
{page === EventDetailsPage.Scheduling && !isLoadingScheduling && (
262-
<EventDetailsSchedulingTab eventId={eventId} />
267+
<EventDetailsSchedulingTab
268+
eventId={eventId}
269+
formikRef={formikRef}
270+
/>
263271
)}
264272
{page === EventDetailsPage.Workflow &&
265273
((workflowTabHierarchy === "entry" && (
266274
<EventDetailsWorkflowTab
267275
eventId={eventId}
276+
formikRef={formikRef}
268277
/>
269278
)) ||
270279
(workflowTabHierarchy === "workflow-details" && (

src/components/events/partials/modals/EventDetailsModal.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { removeNotificationWizardForm } from "../../../../slices/notificationSli
66
import { getModalEvent } from "../../../../selectors/eventDetailsSelectors";
77
import { setModalEvent, setShowModal } from "../../../../slices/eventDetailsSlice";
88
import { Modal } from "../../../shared/modals/Modal";
9+
import { FormikProps } from "formik";
910

1011
/**
1112
* This component renders the modal for displaying event details
@@ -16,6 +17,7 @@ const EventDetailsModal = () => {
1617

1718
// tracks, whether the policies are different to the initial value
1819
const [policyChanged, setPolicyChanged] = useState(false);
20+
const formikRef = useRef<FormikProps<any>>(null);
1921

2022
const event = useAppSelector(state => getModalEvent(state))!;
2123

@@ -29,7 +31,13 @@ const EventDetailsModal = () => {
2931
};
3032

3133
const close = () => {
32-
if (!policyChanged || confirmUnsaved()) {
34+
let isUnsavedChanges = false
35+
isUnsavedChanges = policyChanged
36+
if (formikRef.current && formikRef.current.dirty !== undefined && formikRef.current.dirty) {
37+
isUnsavedChanges = true
38+
}
39+
40+
if (!isUnsavedChanges || confirmUnsaved()) {
3341
setPolicyChanged(false);
3442
dispatch(removeNotificationWizardForm());
3543
hideModal();
@@ -49,6 +57,7 @@ const EventDetailsModal = () => {
4957
eventId={event.id}
5058
policyChanged={policyChanged}
5159
setPolicyChanged={(value) => setPolicyChanged(value)}
60+
formikRef={formikRef}
5261
/>
5362
</Modal>
5463
);

src/components/events/partials/wizards/NewEventWizard.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ const NewEventWizard: React.FC<{
128128
let newPage = page;
129129
do {
130130
newPage = newPage + 1;
131+
// Skip asset upload step when scheduling
132+
if (steps[newPage].name === "upload-asset" && values.sourceMode !== "UPLOAD") {
133+
newPage = newPage + 1;
134+
}
131135
} while(steps[newPage] && steps[newPage].hidden);
132136
if (steps[newPage]) {
133137
setPage(newPage)
@@ -140,6 +144,10 @@ const NewEventWizard: React.FC<{
140144
let newPage = page;
141145
do {
142146
newPage = newPage - 1;
147+
// Skip asset upload step when scheduling
148+
if (steps[newPage].name === "upload-asset" && values.sourceMode !== "UPLOAD") {
149+
newPage = newPage - 1;
150+
}
143151
} while(steps[newPage] && steps[newPage].hidden);
144152
if (steps[newPage]) {
145153
setPage(newPage)

0 commit comments

Comments
 (0)