Skip to content

Commit 036298f

Browse files
committed
Merge branch 'dropdown-options-typing' of Arnei/opencast-admin-interface into main
Pull request #1075 Add typing to dropdown options
2 parents 3c4b409 + 9fa732e commit 036298f

18 files changed

Lines changed: 145 additions & 217 deletions

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,7 @@ const EditScheduledEventsEditPage = <T extends RequiredFormProps>({
218218
text={
219219
formik.values.editedEvents.length > 0 ? findSeriesName(seriesOptions, formik.values.editedEvents) : ""
220220
}
221-
options={seriesOptions}
222-
type={"isPartOf"}
221+
options={seriesOptions.map((option) => ({ label: option.name, value: option.value }) )}
223222
required={false}
224223
handleChange={(element) => {
225224
if (element) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,7 @@ const EventDetailsCommentsTab = ({
246246
<DropDown
247247
value={commentReason}
248248
text={t(commentReason)}
249-
options={Object.entries(commentReasons)}
250-
type={"comment"}
249+
options={Object.entries(commentReasons).map(([key, value]) => ({ label: value, value: key }))}
251250
required={true}
252251
handleChange={(element) => {
253252
if (element) {
@@ -257,6 +256,7 @@ const EventDetailsCommentsTab = ({
257256
placeholder={t(
258257
"EVENTS.EVENTS.DETAILS.COMMENTS.SELECTPLACEHOLDER"
259258
)}
259+
customCSS={{width: 200, optionPaddingTop: 5, optionLineHeight: "105%"}}
260260
/>
261261
</div>
262262

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { renderValidDate } from "../../../../utils/dateUtils";
2929
import { Tooltip } from "../../../shared/Tooltip";
3030
import { WorkflowTabHierarchy } from "../modals/EventDetails";
3131
import { useTranslation } from "react-i18next";
32+
import { formatWorkflowsForDropdown } from "../../../../utils/dropDownUtils";
3233

3334
/**
3435
* This component manages the workflows tab of the event details modal
@@ -334,10 +335,9 @@ const EventDetailsWorkflowTab = ({
334335
options={
335336
!!workflowDefinitions &&
336337
workflowDefinitions.length > 0
337-
? workflowDefinitions /*w.id as w.title for w in workflowDefinitions | orderBy: 'displayOrder':true*/
338+
? formatWorkflowsForDropdown(workflowDefinitions)
338339
: []
339340
}
340-
type={"workflow"}
341341
required={true}
342342
handleChange={(element) => {
343343
if (element) {
@@ -358,6 +358,7 @@ const EventDetailsWorkflowTab = ({
358358
!hasCurrentAgentAccess() ||
359359
!isRoleWorkflowEdit
360360
}
361+
customCSS={{width: "100%"}}
361362
/>
362363
{/*pre-select-from="workflowDefinitionIds"*/}
363364
</div>

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { fetchSeriesDetailsAcls } from "../../../../slices/seriesDetailsSlice";
2121
import { getSeriesDetailsAcl } from "../../../../selectors/seriesDetailsSelectors";
2222
import WizardNavigationButtons from "../../../shared/wizard/WizardNavigationButtons";
2323
import { TransformedAcl } from "../../../../slices/aclDetailsSlice";
24+
import { formatAclRolesForDropdown, formatAclTemplatesForDropdown } from "../../../../utils/dropDownUtils";
2425

2526
/**
2627
* This component renders the access page for new events and series in the wizards.
@@ -148,8 +149,7 @@ const NewAccessPage = <T extends RequiredFormProps>({
148149
aclTemplates,
149150
formik.values.aclTemplate
150151
)}
151-
options={aclTemplates}
152-
type={"aclTemplate"}
152+
options={formatAclTemplatesForDropdown(aclTemplates)}
153153
required={true}
154154
handleChange={(element) => {
155155
if (element) {
@@ -160,6 +160,7 @@ const NewAccessPage = <T extends RequiredFormProps>({
160160
"EVENTS.SERIES.NEW.ACCESS.ACCESS_POLICY.LABEL"
161161
)}
162162
autoFocus={true}
163+
customCSS={{ width: 200, optionPaddingTop: 5 }}
163164
/>
164165
</div>
165166
</td>
@@ -235,11 +236,12 @@ const NewAccessPage = <T extends RequiredFormProps>({
235236
<DropDown
236237
value={policy.role}
237238
text={policy.role}
238-
options={filterRoles(
239-
roles,
240-
formik.values.acls
239+
options={formatAclRolesForDropdown(
240+
filterRoles(
241+
roles,
242+
formik.values.acls
243+
)
241244
)}
242-
type={"aclRole"}
243245
required={true}
244246
handleChange={(element) => {
245247
if (element) {
@@ -258,6 +260,7 @@ const NewAccessPage = <T extends RequiredFormProps>({
258260
user
259261
)
260262
}
263+
customCSS={{ width: 360, optionPaddingTop: 5 }}
261264
/>
262265
</td>
263266
{/* Checkboxes for policy.read and policy.write*/}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import DropDown from "../../../shared/DropDown";
77
import { useAppDispatch, useAppSelector } from "../../../../store";
88
import { fetchWorkflowDef } from "../../../../slices/workflowSlice";
99
import { FormikProps } from "formik";
10+
import { formatWorkflowsForDropdown } from "../../../../utils/dropDownUtils";
1011
import WizardNavigationButtons from "../../../shared/wizard/WizardNavigationButtons";
1112

1213
/**
@@ -86,8 +87,7 @@ const NewProcessingPage = <T extends RequiredFormProps>({
8687
formik.values.processingWorkflow === workflow.id
8788
)?.title ?? ""
8889
}
89-
options={workflowDef}
90-
type={"workflow"}
90+
options={formatWorkflowsForDropdown(workflowDef)}
9191
required={true}
9292
handleChange={(element) => {
9393
if (element) {
@@ -97,6 +97,7 @@ const NewProcessingPage = <T extends RequiredFormProps>({
9797
placeholder={t(
9898
"EVENTS.EVENTS.NEW.PROCESSING.SELECT_WORKFLOW"
9999
)}
100+
customCSS={{width: "100%"}}
100101
/>
101102
</div>
102103
) : (

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ const NewThemePage = <T extends RequiredFormProps>({
6060
text={
6161
getName(formik.values.theme) ?? ""
6262
}
63-
options={seriesThemes}
64-
type={"newTheme"}
63+
options={seriesThemes.map(theme => ({ label: theme.name, value: theme.id}))}
6564
required={false}
6665
handleChange={(element) => {
6766
if (element) {
6867
formik.setFieldValue("theme", element.value)
6968
}
7069
}}
7170
placeholder={t("EVENTS.SERIES.NEW.THEME.LABEL")}
71+
customCSS={{ width: "100%" }}
7272
/>
7373
</div>
7474
</p>

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ const SeriesDetailsThemeTab = ({
1919
seriesId,
2020
}: {
2121
theme: string,
22-
themeNames: unknown[]
22+
themeNames: {
23+
id: string;
24+
value: string;
25+
}[],
2326
seriesId: string
2427
}) => {
2528
const { t } = useTranslation();
@@ -64,8 +67,7 @@ const SeriesDetailsThemeTab = ({
6467
<DropDown
6568
value={formik.values.theme}
6669
text={formik.values.theme}
67-
options={themeNames}
68-
type={"theme"}
70+
options={themeNames.map(names => ({ label: names.value, value: names.id }))}
6971
required={false}
7072
handleChange={(element) => {
7173
if (element) {
@@ -79,6 +81,7 @@ const SeriesDetailsThemeTab = ({
7981
user
8082
)
8183
}
84+
customCSS={{ width: "100%" }}
8285
/>
8386
</div>
8487
)}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import DropDown from "../../../shared/DropDown";
77
import { useAppDispatch, useAppSelector } from "../../../../store";
88
import { fetchWorkflowDef } from "../../../../slices/workflowSlice";
99
import { FormikProps } from "formik";
10+
import { formatWorkflowsForDropdown } from "../../../../utils/dropDownUtils";
1011
import WizardNavigationButtons from "../../../shared/wizard/WizardNavigationButtons";
1112

1213
/**
@@ -76,8 +77,7 @@ const StartTaskWorkflowPage = <T extends RequiredFormProps>({
7677
workflowDef.id === formik.values.workflow
7778
)?.title ?? ""
7879
}
79-
options={workflowDef}
80-
type={"workflow"}
80+
options={formatWorkflowsForDropdown(workflowDef)}
8181
required={true}
8282
handleChange={(element) => {
8383
if (element) {
@@ -88,6 +88,7 @@ const StartTaskWorkflowPage = <T extends RequiredFormProps>({
8888
"EVENTS.EVENTS.DETAILS.PUBLICATIONS.SELECT_WORKFLOW"
8989
)}
9090
tabIndex={99}
91+
customCSS={{width: "100%"}}
9192
/>
9293
</div>
9394
)}

src/components/events/partials/wizards/scheduling/SchedulingLocation.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from "react";
22
import { useTranslation } from "react-i18next";
33
import DropDown from "../../../../shared/DropDown";
44
import { Recording } from "../../../../../slices/recordingSlice";
5+
import { formatCaptureAgentForDropdown } from "../../../../../utils/dropDownUtils";
56

67
const SchedulingLocation = ({
78
location,
@@ -34,8 +35,7 @@ const SchedulingLocation = ({
3435
<DropDown
3536
value={location}
3637
text={location}
37-
options={inputDevices}
38-
type={"captureAgent"}
38+
options={formatCaptureAgentForDropdown(inputDevices)}
3939
required={true}
4040
handleChange={(element) => {
4141
if (element) {

src/components/events/partials/wizards/scheduling/SchedulingTime.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from "react";
22
import { useTranslation } from "react-i18next";
33
import DropDown from "../../../../shared/DropDown";
44
import { hours, minutes } from "../../../../../configs/modalConfig";
5+
import { formatTimeForDropdown } from "../../../../../utils/dropDownUtils";
56

67
const SchedulingTime = ({
78
hour,
@@ -35,8 +36,7 @@ const SchedulingTime = ({
3536
<DropDown
3637
value={hour}
3738
text={hour}
38-
options={hours}
39-
type={"time"}
39+
options={formatTimeForDropdown(hours)}
4040
required={true}
4141
handleChange={(element) => {
4242
if (element) {
@@ -46,14 +46,14 @@ const SchedulingTime = ({
4646
}}
4747
placeholder={t(hourPlaceholder)}
4848
disabled={disabled}
49+
customCSS={{width: 70}}
4950
/>
5051

5152
{/* drop-down for minute */}
5253
<DropDown
5354
value={minute}
5455
text={minute}
55-
options={minutes}
56-
type={"time"}
56+
options={formatTimeForDropdown(minutes)}
5757
required={true}
5858
handleChange={(element) => {
5959
if (element) {
@@ -62,6 +62,7 @@ const SchedulingTime = ({
6262
}}
6363
placeholder={t(minutePlaceholder)}
6464
disabled={disabled}
65+
customCSS={{width: 70}}
6566
/>
6667
</td>
6768
</tr>

0 commit comments

Comments
 (0)