Skip to content

Commit

Permalink
Merge branch 'main' into type-create-policy
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianKniephoff committed Sep 5, 2024
2 parents 6ef722c + b137dd1 commit e9a3826
Show file tree
Hide file tree
Showing 96 changed files with 1,033 additions and 1,063 deletions.
393 changes: 149 additions & 244 deletions package-lock.json

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
"@types/dompurify": "^3.0.5",
"@types/react-router-dom": "^5.3.3",
"array-move": "^4.0.0",
"axios": "^1.7.2",
"axios": "^1.7.7",
"bourbon": "^7.3.0",
"classnames": "^2.5.1",
"date-fns": "^3.6.0",
"dompurify": "^3.1.6",
"font-awesome": "^4.7.0",
"formik": "^2.4.6",
"http-proxy-middleware": "^2.0.6",
"i18next": "^23.11.5",
"http-proxy-middleware": "^3.0.1",
"i18next": "^23.14.0",
"i18next-browser-languagedetector": "^8.0.0",
"i18next-http-backend": "^2.5.2",
"i18next-http-backend": "^2.6.1",
"lodash": "^4.17.21",
"moment": "^2.30.1",
"moment-timezone": "^0.5.45",
Expand All @@ -31,16 +31,16 @@
"react-datepicker": "^7.3.0",
"react-dom": "^18.3.1",
"react-hotkeys-hook": "^4.4.4",
"react-i18next": "^15.0.0",
"react-i18next": "^15.0.1",
"react-icons": "^5.2.1",
"react-redux": "^7.2.9",
"react-router-dom": "^6.24.0",
"react-router-dom": "^6.26.1",
"react-select": "^5.8.0",
"redux": "^5.0.1",
"redux-persist": "^6.0.0",
"redux-thunk": "^3.1.0",
"reselect": "^5.1.1",
"styled-components": "^6.1.12",
"styled-components": "^6.1.13",
"yup": "^1.4.0"
},
"scripts": {
Expand All @@ -64,10 +64,10 @@
"devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.8.0",
"@eslint/js": "^9.9.1",
"@redux-devtools/extension": "^3.3.0",
"@types/lodash": "^4.17.7",
"@types/node": "^22.0.2",
"@types/node": "^22.5.1",
"@types/react-dom": "^18.3.0",
"@types/uuid": "^10.0.0",
"@typescript-eslint/eslint-plugin": "^7.14.1",
Expand All @@ -77,11 +77,11 @@
"prop-types": "^15.8.1",
"rollup-preserve-directives": "^1.1.1",
"sass": "^1.77.8",
"typescript": "^5.5.2",
"typescript": "^5.5.4",
"uuid": "^10.0.0",
"vite": "^5.3.5",
"vite": "^5.4.2",
"vite-plugin-svgr": "^4.2.0",
"vite-tsconfig-paths": "^4.3.2",
"vite-tsconfig-paths": "^5.0.1",
"vitest": "^2.0.5"
}
}
6 changes: 3 additions & 3 deletions src/components/configuration/partials/ThemesActionsCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ import {
import { getUserInformation } from "../../../selectors/userInfoSelectors";
import { hasAccess } from "../../../utils/utils";
import { useAppDispatch, useAppSelector } from "../../../store";
import { deleteTheme } from "../../../slices/themeSlice";
import { deleteTheme, ThemeDetailsType } from "../../../slices/themeSlice";
import { Tooltip } from "../../shared/Tooltip";

/**
* This component renders the action cells of themes in the table view
*/
const ThemesActionsCell = ({
// @ts-expect-error TS(7031): Binding element 'row' implicitly has an 'any' type... Remove this comment to see the full error message
row,
}: {
row: ThemeDetailsType
}) => {
const { t } = useTranslation();
const dispatch = useAppDispatch();
Expand Down Expand Up @@ -61,7 +62,6 @@ const ThemesActionsCell = ({
{displayThemeDetails && (
<ThemeDetailsModal
handleClose={hideThemeDetails}
themeId={row.id}
themeName={row.name}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { initialFormValuesNewThemes } from "../../../../configs/modalConfig";
import { usePageFunctions } from "../../../../hooks/wizardHooks";
import { NewThemeSchema } from "../../../../utils/validate";
import { useAppDispatch } from "../../../../store";
import { postNewTheme } from "../../../../slices/themeSlice";
import { postNewTheme, ThemeDetailsInitialValues } from "../../../../slices/themeSlice";

/**
* This component manages the pages of the new theme wizard and the submission of values
Expand Down Expand Up @@ -64,7 +64,7 @@ const NewThemeWizard: React.FC<{
// Validation schema of current page
const currentValidationSchema = NewThemeSchema[page];

const handleSubmit = (values: any) => {
const handleSubmit = (values: ThemeDetailsInitialValues) => {
dispatch(postNewTheme(values));
close();
};
Expand Down
4 changes: 2 additions & 2 deletions src/components/configuration/partials/wizard/ThemeDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import ModalNavigation from "../../../shared/modals/ModalNavigation";
import { NewThemeSchema } from "../../../../utils/validate";
import { useAppDispatch, useAppSelector } from "../../../../store";
import { updateThemeDetails } from "../../../../slices/themeDetailsSlice";
import { ThemeDetailsType } from "../../../../slices/themeSlice";
import { ThemeDetailsInitialValues } from "../../../../slices/themeSlice";

/**
* This component manages the pages of the theme details
Expand Down Expand Up @@ -86,7 +86,7 @@ const ThemeDetails : React.FC<{
const currentValidationSchema = NewThemeSchema[page];

// update theme
const handleSubmit = (values: ThemeDetailsType) => {
const handleSubmit = (values: ThemeDetailsInitialValues) => {
dispatch(updateThemeDetails({id: themeDetails.id, values: values}));
close();
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import ThemeDetails from "./ThemeDetails";
* This component renders the modal for displaying theme details
*/
const ThemeDetailsModal = ({
handleClose,
themeId,
themeName
}: any) => {
handleClose,
themeName
}: {
handleClose: () => void,
themeName: string
}) => {
const { t } = useTranslation();

const close = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ const WatermarkPage = <T extends RequiredFormProps>({
}) => {
const { t } = useTranslation();

// @ts-expect-error TS(7006): Parameter 'position' implicitly has an 'any' type.
const handleButtonClick = (position) => {
const handleButtonClick = (position: "topLeft" | "topRight" | "bottomLeft" | "bottomRight") => {
formik.setFieldValue("watermarkPosition", position);
};

Expand Down
3 changes: 1 addition & 2 deletions src/components/events/partials/EventActionCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ const EventActionCell = ({
setDeleteConfirmation(false);
};

// @ts-expect-error TS(7006): Parameter 'id' implicitly has an 'any' type.
const deletingEvent = (id) => {
const deletingEvent = (id: string) => {
dispatch(deleteEvent(id));
};

Expand Down
4 changes: 2 additions & 2 deletions src/components/events/partials/EventsNotesCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ const EventsNotesCell = ({
});
}

const updateComment = (event: React.ChangeEvent<HTMLTextAreaElement>, commentId: any) => {
const updateComment = (event: React.ChangeEvent<HTMLTextAreaElement>, commentId: number) => {
if (!event.target.value || !row.id || !commentId) {
return;
}
dispatch(updateNewComment({eventId: row.id, commentId, commentText: event.target.value, commentReason: notesCommentReason}))
}

const deleteComment = (event: React.FocusEvent<HTMLTextAreaElement>, commentId: any) => {
const deleteComment = (event: React.FocusEvent<HTMLTextAreaElement>, commentId: number) => {
if (!row.id || !commentId) {
return;
}
Expand Down
13 changes: 8 additions & 5 deletions src/components/events/partials/EventsSeriesCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,31 @@ const EventsSeriesCell = ({
const filterMap = useAppSelector(state => getFilters(state));

// Filter with value of current cell
// @ts-expect-error TS(7006): Parameter 'series' implicitly has an 'any' type.
const addFilter = async (series) => {
const addFilter = async (seriesId: string) => {
let filter = filterMap.find(({ name }) => name === "series");
if (!!filter) {
await dispatch(editFilterValue({filterName: filter.name, value: series.id}));
await dispatch(editFilterValue({filterName: filter.name, value: seriesId}));
await dispatch(fetchEvents());
dispatch(loadEventsIntoTable());
}
};

return (
!!row.series && (
!!row.series ? (
// Link template for series of event
<Tooltip title={t("EVENTS.EVENTS.TABLE.TOOLTIP.SERIES")}>
<button
className="button-like-anchor crosslink"
onClick={() => addFilter(row.series)}
onClick={() => row.series
? addFilter(row.series.id)
: console.error("Tried to sort by a series, but the series did not exist.")
}
>
{row.series.title}
</button>
</Tooltip>
)
: <></>
);
};

Expand Down
3 changes: 1 addition & 2 deletions src/components/events/partials/EventsTechnicalDateCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ const EventsTechnicalDateCell = ({
<Tooltip title={t("EVENTS.EVENTS.TABLE.TOOLTIP.START")}>
<button
className="button-like-anchor crosslink"
// @ts-expect-error TS(2554): Expected 1 arguments, but got 0.
onClick={() => addFilter()}
onClick={() => addFilter(row.date)}
>
{t("dateFormats.date.short", { date: renderValidDate(row.technical_start) })}
</button>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { useTranslation } from "react-i18next";
import { Formik } from "formik";
import { Formik, FormikProps } from "formik";
import { Field } from "../../../shared/Field";
import cn from "classnames";
import _ from "lodash";
Expand All @@ -13,8 +13,10 @@ import {
parseValueForBooleanStrings,
} from "../../../../utils/utils";
import { getMetadataCollectionFieldName } from "../../../../utils/resourceUtils";
import { useAppSelector } from "../../../../store";
import { useAppDispatch, useAppSelector } from "../../../../store";
import { MetadataCatalog } from "../../../../slices/eventSlice";
import { AsyncThunk } from "@reduxjs/toolkit";
import { AsyncThunkConfig } from "@reduxjs/toolkit/dist/createAsyncThunk";

/**
* This component renders metadata details of a certain event or series
Expand All @@ -28,34 +30,37 @@ const DetailsExtendedMetadataTab = ({
resourceId: string,
editAccessRole: string,
metadata: MetadataCatalog[],
updateResource: (id: string, values: { [key: string]: any }, catalog: MetadataCatalog) => void,
updateResource: AsyncThunk<void, {
id: string;
values: { [key: string]: any; };
catalog: MetadataCatalog;
}, AsyncThunkConfig> //(id: string, values: { [key: string]: any }, catalog: MetadataCatalog) => void,
}) => {
const { t } = useTranslation();
const dispatch = useAppDispatch();

const user = useAppSelector(state => getUserInformation(state));

const handleSubmit = (values: { [key: string]: any }, catalog: MetadataCatalog) => {
updateResource(resourceId, values, catalog);
dispatch(updateResource({id: resourceId, values, catalog}));
};

// set current values of metadata fields as initial values
const getInitialValues = (metadataCatalog: MetadataCatalog) => {
let initialValues = {};
let initialValues: { [key: string]: any } = {};

// Transform metadata fields and their values provided by backend (saved in redux)
if (!!metadataCatalog.fields && metadataCatalog.fields.length > 0) {
metadataCatalog.fields.forEach((field) => {
let value = parseValueForBooleanStrings(field.value);
// @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
initialValues[field.id] = value;
});
}

return initialValues;
};

// @ts-expect-error TS(7006): Parameter 'formik' implicitly has an 'any' type.
const checkValidity = (formik) => {
const checkValidity = (formik: FormikProps<{}>) => {
if (formik.dirty && formik.isValid && hasAccess(editAccessRole, user)) {
// check if user provided values differ from initial ones
return !_.isEqual(formik.values, formik.initialValues);
Expand Down Expand Up @@ -154,7 +159,7 @@ const DetailsExtendedMetadataTab = ({
</button>
<button
className="cancel"
onClick={() => formik.resetForm({ values: "" })}
onClick={() => formik.resetForm()}
>
{t("CANCEL")}
</button>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { useTranslation } from "react-i18next";
import { Formik } from "formik";
import { Formik, FormikProps } from "formik";
import { Field } from "../../../shared/Field";
import cn from "classnames";
import _ from "lodash";
Expand All @@ -11,8 +11,10 @@ import RenderField from "../../../shared/wizard/RenderField";
import { getUserInformation } from "../../../../selectors/userInfoSelectors";
import { hasAccess } from "../../../../utils/utils";
import { getMetadataCollectionFieldName } from "../../../../utils/resourceUtils";
import { useAppSelector } from "../../../../store";
import { useAppDispatch, useAppSelector } from "../../../../store";
import { MetadataCatalog } from "../../../../slices/eventSlice";
import { AsyncThunk } from "@reduxjs/toolkit";
import { AsyncThunkConfig } from "@reduxjs/toolkit/dist/createAsyncThunk";

/**
* This component renders metadata details of a certain event or series
Expand All @@ -25,22 +27,23 @@ const DetailsMetadataTab = ({
editAccessRole,
}: {
metadataFields: MetadataCatalog,
updateResource: (id: string, values: { [key: string]: any }) => void,
updateResource: AsyncThunk<void, { id: string; values: { [key: string]: any; }; }, AsyncThunkConfig>
resourceId: string,
header: string,
editAccessRole: string,
}) => {
const { t } = useTranslation();
const dispatch = useAppDispatch();

const user = useAppSelector(state => getUserInformation(state));

const handleSubmit = (values: { [key: string]: any }) => {
updateResource(resourceId, values);
dispatch(updateResource({id: resourceId, values}));
};

// set current values of metadata fields as initial values
const getInitialValues = () => {
let initialValues = {};
let initialValues: { [key: string]: string | string[] } = {};

// Transform metadata fields and their values provided by backend (saved in redux)
if (
Expand All @@ -49,16 +52,14 @@ const DetailsMetadataTab = ({
metadataFields.fields.length > 0
) {
metadataFields.fields.forEach((field) => {
// @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
initialValues[field.id] = field.value;
});
}

return initialValues;
};

// @ts-expect-error TS(7006): Parameter 'formik' implicitly has an 'any' type.
const checkValidity = (formik) => {
const checkValidity = (formik: FormikProps<{ [key: string]: string | string[] }>) => {
if (formik.dirty && formik.isValid && hasAccess(editAccessRole, user)) {
// check if user provided values differ from initial ones
return !_.isEqual(formik.values, formik.initialValues);
Expand Down Expand Up @@ -152,7 +153,7 @@ const DetailsMetadataTab = ({
</button>
<button
className="cancel"
onClick={() => formik.resetForm({ values: "" })}
onClick={() => formik.resetForm()}
>
{t("CANCEL")}
</button>
Expand Down
Loading

0 comments on commit e9a3826

Please sign in to comment.