Skip to content

Commit 925abf2

Browse files
committed
Merge branch 'main' into eslint-9
2 parents 3be837b + 9924392 commit 925abf2

12 files changed

Lines changed: 125 additions & 115 deletions

File tree

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import EventDetailsTabHierarchyNavigation from "./EventDetailsTabHierarchyNaviga
33
import Notifications from "../../../shared/Notifications";
44
import { style_button_spacing } from "../../../../utils/eventDetailsUtils";
55
import { Formik, FormikProps } from "formik";
6-
import { getAssetUploadOptions } from "../../../../selectors/eventSelectors";
76
import { translateOverrideFallback } from "../../../../utils/utils";
87
import { useAppDispatch, useAppSelector } from "../../../../store";
98
import { setModalAssetsTabHierarchy, updateAssets } from "../../../../slices/eventDetailsSlice";
109
import { AssetTabHierarchy } from "../modals/EventDetails";
1110
import { useTranslation } from "react-i18next";
11+
import { getUploadAssetOptions } from "../../../../selectors/eventDetailsSelectors";
1212
import ButtonLikeAnchor from "../../../shared/ButtonLikeAnchor";
1313
import ModalContentTable from "../../../shared/modals/ModalContentTable";
1414

@@ -23,15 +23,10 @@ const EventDetailsAssetsAddAsset = ({
2323
const { t } = useTranslation();
2424
const dispatch = useAppDispatch();
2525

26-
const uploadAssetOptions = useAppSelector(state => getAssetUploadOptions(state));
26+
const uploadAssetOptions = useAppSelector(state => getUploadAssetOptions(state));
2727

2828
const initialValues: { [key: string]: File } = {};
2929

30-
// Get upload assets that are not of type track
31-
const uploadAssets = uploadAssetOptions.filter(
32-
(asset) => asset.type !== "track"
33-
);
34-
3530
const openSubTab = (subTabName: AssetTabHierarchy) => {
3631
dispatch(setModalAssetsTabHierarchy(subTabName));
3732
};
@@ -81,14 +76,14 @@ const EventDetailsAssetsAddAsset = ({
8176
{/* file select for upload for different types of assets */}
8277
<table className="main-tbl">
8378
<tbody>
84-
{uploadAssets.length === 0 ? (
79+
{uploadAssetOptions && uploadAssetOptions.length === 0 ? (
8580
<tr>
8681
<td>
8782
{t("EVENTS.EVENTS.NEW.UPLOAD_ASSET.NO_OPTIONS")}
8883
</td>
8984
</tr>
9085
) : (
91-
uploadAssets.map((asset, key) => (
86+
uploadAssetOptions && uploadAssetOptions.map((asset, key) => (
9287
<tr key={key}>
9388
<td>
9489
{" "}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,7 @@ const EventDetailsAssetsTab = ({
162162
<th className="medium">
163163
{!isFetchingAssetUploadOptions &&
164164
!!uploadAssetOptions &&
165-
uploadAssetOptions.filter(
166-
(asset) => asset.type !== "track"
167-
).length > 0 &&
165+
uploadAssetOptions.length > 0 &&
168166
!transactionsReadOnly &&
169167
hasAccess(
170168
"ROLE_UI_EVENTS_DETAILS_ASSETS_EDIT",

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

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

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

33-
// Get upload assets that are not of type track
34-
const uploadAssets = uploadAssetOptions.filter(
35-
(asset) => asset.type !== "track"
36-
);
37-
3833
// if user not chose upload in step before, the skip this step
3934
if (formik.values.sourceMode !== "UPLOAD") {
4035
nextPage(formik.values);
@@ -61,14 +56,14 @@ const NewAssetUploadPage = <T extends RequiredFormProps>({
6156
<div className="obj-container">
6257
<table className="main-tbl">
6358
<tbody>
64-
{uploadAssets.length === 0 ? (
59+
{uploadAssetOptions.length === 0 ? (
6560
<tr>
6661
<td>
6762
{t("EVENTS.EVENTS.NEW.UPLOAD_ASSET.NO_OPTIONS")}
6863
</td>
6964
</tr>
7065
) : (
71-
uploadAssets.map((asset, key) => (
66+
uploadAssetOptions.map((asset, key) => (
7267
<tr key={key}>
7368
<td>
7469
{" "}

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

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,44 +53,39 @@ const NewEventSummary = <T extends RequiredFormProps>({
5353
}) => {
5454
const { t } = useTranslation();
5555

56-
const uploadAssetOptions = useAppSelector(state => getAssetUploadOptions(state));
57-
const metadataEvents = useAppSelector(state => getEventMetadata(state));
58-
const extendedMetadata = useAppSelector(state => getExtendedEventMetadata(state));
59-
const workflowDef = useAppSelector(state => getWorkflowDef(state));
60-
6156
// upload asset that user has provided
6257
const [uploadAssetsNonTrack, setUploadAssetsNonTrack] = useState<{
6358
name: string,
6459
translate?: string,
6560
value: any,
6661
}[]>([]);
6762

68-
// Get upload assets that are not of type track
69-
const uploadAssetsOptionsNonTrack = uploadAssetOptions.filter(
70-
(asset) => asset.type !== "track"
71-
);
63+
const uploadAssetOptions = useAppSelector(state => getAssetUploadOptions(state));
64+
const metadataEvents = useAppSelector(state => getEventMetadata(state));
65+
const extendedMetadata = useAppSelector(state => getExtendedEventMetadata(state));
66+
const workflowDef = useAppSelector(state => getWorkflowDef(state));
7267

68+
// upload asset that user has provided
7369
useEffect(() => {
74-
// upload asset that user has provided
7570
let uploadAssetsNonTrack: {
7671
name: string,
7772
translate?: string,
7873
value: any,
7974
}[] = [];
80-
for (let i = 0; uploadAssetsOptionsNonTrack.length > i; i++) {
81-
let fieldValue = formik.values[uploadAssetsOptionsNonTrack[i].id];
75+
for (let i = 0; uploadAssetOptions.length > i; i++) {
76+
let fieldValue = formik.values[uploadAssetOptions[i].id];
8277
if (!!fieldValue) {
83-
const displayOverride = uploadAssetsOptionsNonTrack[i].displayOverride as ParseKeys
78+
const displayOverride = uploadAssetOptions[i].displayOverride as ParseKeys
8479
setUploadAssetsNonTrack(uploadAssetsNonTrack.concat({
85-
name: uploadAssetsOptionsNonTrack[i].id,
80+
name: uploadAssetOptions[i].id,
8681
translate: !!displayOverride
8782
? t(displayOverride)
88-
: translateOverrideFallback(uploadAssetsOptionsNonTrack[i], t),
83+
: translateOverrideFallback(uploadAssetOptions[i], t),
8984
value: fieldValue,
9085
}));
9186
}
9287
}
93-
}, [formik.values, t, uploadAssetsNonTrack, uploadAssetsOptionsNonTrack]);
88+
}, [formik.values, t, uploadAssetsNonTrack, uploadAssetOptions]);
9489

9590

9691
// Get additional information about chosen workflow definition

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

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ import {
1414
getAssetUploadOptions,
1515
getEventMetadata,
1616
getExtendedEventMetadata,
17+
getSourceUploadOptions,
1718
} from "../../../../selectors/eventSelectors";
1819
import { useAppDispatch, useAppSelector } from "../../../../store";
1920
import { getOrgProperties, getUserInformation } from "../../../../selectors/userInfoSelectors";
20-
import { MetadataCatalog, UploadAssetOption, postNewEvent } from "../../../../slices/eventSlice";
21+
import { MetadataCatalog, UploadOption, postNewEvent } from "../../../../slices/eventSlice";
2122
import { UserInfoState } from "../../../../slices/userInfoSlice";
2223
import { removeNotificationWizardForm } from "../../../../slices/notificationSlice";
2324
import NewMetadataCommonPage from "../ModalTabsAndPages/NewMetadataCommonPage";
@@ -34,7 +35,8 @@ const NewEventWizard: React.FC<{
3435
}) => {
3536
const dispatch = useAppDispatch();
3637

37-
const uploadAssetOptions = useAppSelector(state => getAssetUploadOptions(state));
38+
const uploadSourceOptions = useAppSelector(state => getSourceUploadOptions(state));
39+
const assetUploadOptions = useAppSelector(state => getAssetUploadOptions(state));
3840
const metadataFields = useAppSelector(state => getEventMetadata(state));
3941
const extendedMetadata = useAppSelector(state => getExtendedEventMetadata(state));
4042
const user = useAppSelector(state => getUserInformation(state));
@@ -56,7 +58,7 @@ const NewEventWizard: React.FC<{
5658
const initialValues = getInitialValues(
5759
metadataFields,
5860
extendedMetadata,
59-
uploadAssetOptions,
61+
uploadSourceOptions,
6062
user,
6163
);
6264

@@ -88,9 +90,7 @@ const NewEventWizard: React.FC<{
8890
{
8991
translation: "EVENTS.EVENTS.NEW.UPLOAD_ASSET.CAPTION",
9092
name: "upload-asset",
91-
hidden:
92-
uploadAssetOptions.filter((asset) => asset.type !== "track").length ===
93-
0,
93+
hidden: assetUploadOptions.length === 0,
9494
},
9595
{
9696
translation: "EVENTS.EVENTS.NEW.PROCESSING.CAPTION",
@@ -250,7 +250,7 @@ const NewEventWizard: React.FC<{
250250
const getInitialValues = (
251251
metadataFields: MetadataCatalog,
252252
extendedMetadata: MetadataCatalog[],
253-
uploadAssetOptions: UploadAssetOption[],
253+
uploadSourceOptions: UploadOption[],
254254
user: UserInfoState
255255
) => {
256256
let initialValues = initialFormValuesNewEvents;
@@ -289,20 +289,16 @@ const getInitialValues = (
289289
}
290290

291291
// Add possible files that can be uploaded in source step
292-
if (!!uploadAssetOptions) {
292+
if (!!uploadSourceOptions) {
293293
initialValues.uploadAssetsTrack = [];
294294
// Sort by displayOrder
295-
uploadAssetOptions = uploadAssetOptions.slice().sort((a, b) => a.displayOrder - b.displayOrder)
295+
uploadSourceOptions = uploadSourceOptions.slice().sort((a, b) => a.displayOrder - b.displayOrder)
296296
// initial value of upload asset needs to be null, because object (file) is saved there
297-
for (const option of uploadAssetOptions) {
298-
if (option.type === "track") {
299-
initialValues.uploadAssetsTrack.push({
300-
...option,
301-
file: undefined,
302-
});
303-
} else {
304-
initialValues[option.id] = null;
305-
}
297+
for (const option of uploadSourceOptions) {
298+
initialValues.uploadAssetsTrack.push({
299+
...option,
300+
file: undefined,
301+
});
306302
};
307303
}
308304

src/i18n/org/opencastproject/adminui/languages/lang-en_US.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,8 @@
573573
"CAPTIONS_WEBVTT": "Captions WebVTT",
574574
"PREVIEW_IMAGE": "Preview image",
575575
"SMIL": "Smil catalog",
576-
"TRACK_PARTS": "Track parts"
576+
"TRACK_PARTS": "Track parts",
577+
"SUBTITLES": "Subtitles"
577578
}
578579
},
579580
"ACCESS": {

src/selectors/eventDetailsSelectors.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ export const isTransactionReadOnly = (state: RootState) =>
4040
state.eventDetails.transactionsReadOnly;
4141
export const getUploadAssetOptions = (state: RootState) =>
4242
state.eventDetails.uploadAssetOptions;
43+
export const getUploadSourceOptions = (state: RootState) =>
44+
state.eventDetails.uploadSourceOptions;
4345
export const getAssetAttachments = (state: RootState) =>
4446
state.eventDetails.assetAttachments;
4547
export const getAssetAttachmentDetails = (state: RootState) =>

src/selectors/eventSelectors.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const getSchedulingSeriesOptions = (state: RootState) =>
1717
state.events.schedulingInfo.seriesOptions;
1818
export const getTotalEvents = (state: RootState) => state.events.total;
1919
export const getAssetUploadOptions = (state: RootState) => state.events.uploadAssetOptions;
20+
export const getSourceUploadOptions = (state: RootState) => state.events.uploadSourceOptions;
2021
export const isFetchingAssetUploadOptions = (state: RootState) =>
2122
state.events.isFetchingAssetUploadOptions;
2223
export const getAssetUploadWorkflow = (state: RootState) =>

0 commit comments

Comments
 (0)