Skip to content

Commit

Permalink
Merge branch 'materialui-to-v5' into fix-startDate-tablefilter
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnei committed Mar 18, 2024
2 parents ef7f379 + e288955 commit b3bcc4a
Show file tree
Hide file tree
Showing 27 changed files with 537 additions and 223 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ const EditScheduledEventsEditPage = ({
const seriesOptions = useAppSelector(state => getSchedulingSeriesOptions(state));

// TODO: Get rid of the wrappers when modernizing redux is done
const checkForSchedulingConflictsWrapper = (events: any) => {
dispatch(checkForSchedulingConflicts(events));
const checkForSchedulingConflictsWrapper = async(events: any) => {
return dispatch(checkForSchedulingConflicts(events));
}

const user = useAppSelector(state => getUserInformation(state));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ const EventDetailsSchedulingTab = ({
<DatePicker
name="scheduleStartDate"
// @ts-expect-error TS(2322): Type 'string' is not assignable to type 'number'.
tabIndex={"1"}
tabIndex={1}
value={new Date(formik.values.scheduleStartDate)}
onChange={(value) =>
changeStartDate(
Expand Down Expand Up @@ -344,7 +344,7 @@ const EventDetailsSchedulingTab = ({
placeholder={t(
"EVENTS.EVENTS.DETAILS.SOURCE.PLACEHOLDER.HOUR"
)}
tabIndex={"2"}
tabIndex={2}
disabled={
!accessAllowed(formik.values.captureAgent)
}
Expand Down Expand Up @@ -373,7 +373,7 @@ const EventDetailsSchedulingTab = ({
placeholder={t(
"EVENTS.EVENTS.DETAILS.SOURCE.PLACEHOLDER.MINUTE"
)}
tabIndex={"3"}
tabIndex={3}
disabled={
!accessAllowed(formik.values.captureAgent)
}
Expand Down Expand Up @@ -418,7 +418,7 @@ const EventDetailsSchedulingTab = ({
)
}
placeholder={t("WIZARD.DURATION.HOURS")}
tabIndex={"4"}
tabIndex={4}
disabled={
!accessAllowed(formik.values.captureAgent)
}
Expand Down Expand Up @@ -447,7 +447,7 @@ const EventDetailsSchedulingTab = ({
)
}
placeholder={t("WIZARD.DURATION.MINUTES")}
tabIndex={"5"}
tabIndex={5}
disabled={
!accessAllowed(formik.values.captureAgent)
}
Expand Down Expand Up @@ -494,7 +494,7 @@ const EventDetailsSchedulingTab = ({
placeholder={t(
"EVENTS.EVENTS.DETAILS.SOURCE.PLACEHOLDER.HOUR"
)}
tabIndex={"6"}
tabIndex={6}
disabled={
!accessAllowed(formik.values.captureAgent)
}
Expand Down Expand Up @@ -523,7 +523,7 @@ const EventDetailsSchedulingTab = ({
placeholder={t(
"EVENTS.EVENTS.DETAILS.SOURCE.PLACEHOLDER.MINUTE"
)}
tabIndex={"7"}
tabIndex={7}
disabled={
!accessAllowed(formik.values.captureAgent)
}
Expand Down Expand Up @@ -595,7 +595,7 @@ const EventDetailsSchedulingTab = ({
placeholder={t(
"EVENTS.EVENTS.DETAILS.SOURCE.PLACEHOLDER.LOCATION"
)}
tabIndex={"8"}
tabIndex={8}
disabled={
!accessAllowed(formik.values.captureAgent)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const EventDetailsWorkflowErrors = ({
};

// @ts-expect-error TS(7006): Parameter 'tabType' implicitly has an 'any' type.
const openSubTab = (tabType, errorId: number | null = null) => {
const openSubTab = (tabType, errorId: number | undefined = undefined) => {
dispatch(removeNotificationWizardForm());
setHierarchy(tabType);
if (tabType === "workflow-error-details") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const EventDetailsWorkflowOperations = ({
}, []);

// @ts-expect-error TS(7006): Parameter 'tabType' implicitly has an 'any' type.
const openSubTab = (tabType, operationId: number | null = null) => {
const openSubTab = (tabType, operationId: number | undefined = undefined) => {
dispatch(removeNotificationWizardForm());
setHierarchy(tabType);
if (tabType === "workflow-operation-details") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ import {
changeStartMinute,
changeStartMinuteMultiple,
} from "../../../../utils/dateUtils";
import { parseISO } from "date-fns";
import { useAppDispatch, useAppSelector } from "../../../../store";
import { fetchRecordings } from "../../../../slices/recordingSlice";
import { removeNotificationWizardForm } from "../../../../slices/notificationSlice";
import { parseISO } from "date-fns";
import { checkConflicts } from "../../../../slices/eventSlice";

/**
Expand Down Expand Up @@ -398,8 +398,8 @@ const Schedule = ({ formik, inputDevices }) => {
);
}
}}
// @ts-expect-error TS(2322): Type 'string' is not assignable to type 'number'.
tabIndex="4"
// @ts-expect-error TS(2322):
tabIndex={4}
/>
</td>
</tr>
Expand All @@ -422,8 +422,8 @@ const Schedule = ({ formik, inputDevices }) => {
formik.setFieldValue
)
}
// @ts-expect-error TS(2322): Type 'string' is not assignable to type 'number'.
tabIndex="5"
// @ts-expect-error TS(2322):
tabIndex={5}
/>
</td>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import RenderMultiField from "../../../shared/wizard/RenderMultiField";
import { getUserInformation } from "../../../../selectors/userInfoSelectors";
import { useAppDispatch, useAppSelector } from "../../../../store";
import {
MetadataFieldSelected,
postEditMetadata,
updateBulkMetadata,
} from "../../../../slices/eventSlice";
Expand All @@ -30,7 +31,15 @@ const EditMetadataEventsModal = ({
const dispatch = useAppDispatch();

const [selectedEvents] = useState(selectedRows);
const [metadataFields, setMetadataFields] = useState({});
const [metadataFields, setMetadataFields] = useState<{
merged: string[],
mergedMetadata: MetadataFieldSelected[],
notFound?: string[],
runningWorkflow?: string[],
}>({
merged: [],
mergedMetadata: []
});
const [loading, setLoading] = useState(true);
const [fatalError, setFatalError] = useState({});
const [fetchedValues, setFetchedValues] = useState(null);
Expand Down Expand Up @@ -60,7 +69,12 @@ const EditMetadataEventsModal = ({
let initialValues = getInitialValues(result);
// @ts-expect-error TS(2345): Argument of type '{}' is not assignable to paramet... Remove this comment to see the full error message
setFetchedValues(initialValues);
setMetadataFields(result);
setMetadataFields({
merged: result.merged,
mergedMetadata: result.mergedMetadata,
notFound: result.notFound,
runningWorkflow: result.runningWorkflow,
});
}
});
setLoading(false);
Expand All @@ -80,7 +94,6 @@ const EditMetadataEventsModal = ({
const onChangeSelected = (e, fieldId) => {
let selected = e.target.checked;
let fields = metadataFields;
// @ts-expect-error TS(2339): Property 'mergedMetadata' does not exist on type '... Remove this comment to see the full error message
fields.mergedMetadata = metadataFields.mergedMetadata.map((field) => {
if (field.id === fieldId) {
return {
Expand All @@ -105,7 +118,6 @@ const EditMetadataEventsModal = ({
// @ts-expect-error TS(2531): Object is possibly 'null'.
if (fetchedValues[field.id] !== formikValues[field.id]) {
let fields = metadataFields;
// @ts-expect-error TS(2339): Property 'mergedMetadata' does not exist on type '... Remove this comment to see the full error message
fields.mergedMetadata = metadataFields.mergedMetadata.map((f) => {
if (f.id === field.id) {
return {
Expand Down Expand Up @@ -210,9 +222,7 @@ const EditMetadataEventsModal = ({
</tr>
</thead>
<tbody>
{/* @ts-expect-error TS(2339): Property 'mergedMetadata' does not exist on type '... Remove this comment to see the full error message */}
{metadataFields.mergedMetadata.map(
// @ts-expect-error TS(7006): Parameter 'metadata' implicitly has an 'any' type.
(metadata, key) =>
!metadata.readOnly && (
<tr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ const EditScheduledEventsModal = ({

const inputDevices = useAppSelector(state => getRecordings(state));
// TODO: Get rid of the wrappers when modernizing redux is done
const checkForSchedulingConflictsWrapper = (events: any) => {
dispatch(checkForSchedulingConflicts(events));
const checkForSchedulingConflictsWrapper = async(events: any) => {
return dispatch(checkForSchedulingConflicts(events));
}

const initialValues = initialFormValuesEditScheduledEvents;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const NewEventWizard: React.FC<{

const [page, setPage] = useState(0);
const [snapshot, setSnapshot] = useState(initialValues);
const [pageCompleted, setPageCompleted] = useState({});
const [pageCompleted, setPageCompleted] = useState<{ [key: number]: boolean }>({});

// Caption of steps used by Stepper
const steps = [
Expand Down Expand Up @@ -95,7 +95,6 @@ const NewEventWizard: React.FC<{

// set page as completely filled out
let updatedPageCompleted = pageCompleted;
// @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
updatedPageCompleted[page] = true;
setPageCompleted(updatedPageCompleted);

Expand Down
34 changes: 32 additions & 2 deletions app/src/components/shared/wizard/RenderField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const RenderField = ({
setEditMode={setEditMode}
form={form}
showCheck={showCheck}
handleKeyDown={handleKeyDown}
/>
)}
{metadataField.type === "text" &&
Expand Down Expand Up @@ -124,6 +125,7 @@ const RenderField = ({
editMode={editMode}
setEditMode={setEditMode}
showCheck={showCheck}
handleKeyDown={handleKeyDown}
/>
)}
{metadataField.type === "boolean" && (
Expand Down Expand Up @@ -178,6 +180,8 @@ const EditableDateValue = ({
setEditMode,
// @ts-expect-error TS(7031): Binding element 'showCheck' implicitly has an 'any... Remove this comment to see the full error message
showCheck,
// @ts-expect-error TS(7031):
handleKeyDown
}) => {
const { t } = useTranslation();

Expand All @@ -188,7 +192,19 @@ const EditableDateValue = ({
value={typeof field.value === "string" ? parseISO(field.value) : field.value}
onChange={(value) => setFieldValue(field.name, value)}
onClose={() => setEditMode(false)}
slotProps={{ textField: { fullWidth: true } }}
slotProps={{
textField: {
fullWidth: true,
onKeyDown: (event) => {
if (event.key === "Enter") {
handleKeyDown(event, "date")
}
},
onBlur: (event) => {
setEditMode(false)
}
}
}}
/>
</div>
) : (
Expand Down Expand Up @@ -372,6 +388,8 @@ const EditableSingleValueTime = ({
setEditMode,
// @ts-expect-error TS(7031): Binding element 'showCheck' implicitly has an 'any... Remove this comment to see the full error message
showCheck,
// @ts-expect-error TS(7031): Binding element 'handleKeyDown' implicitly has an ... Remove this comment to see the full error message
handleKeyDown,
}) => {
const { t } = useTranslation();

Expand All @@ -382,7 +400,19 @@ const EditableSingleValueTime = ({
value={parseISO(field.value)}
onChange={(value) => setFieldValue(field.name, value)}
onClose={() => setEditMode(false)}
slotProps={{ textField: { fullWidth: true } }}
slotProps={{
textField: {
fullWidth: true,
onKeyDown: (event) => {
if (event.key === "Enter") {
handleKeyDown(event, "date")
}
},
onBlur: (event) => {
setEditMode(false)
}
}
}}
/>
</div>
) : (
Expand Down
29 changes: 22 additions & 7 deletions app/src/slices/aclDetailsSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,22 @@ import { addNotification } from '../slices/notificationSlice';
/**
* This file contains redux reducer for actions affecting the state of details of an ACL
*/
type IncomingAcl = {
ace: { allow: boolean, role: string, action: string }[]
export type Ace = {
allow: boolean,
role: string,
action: string
}

type TransformedAcls = {
type IncomingAcls = {
ace: Ace[]
}

export type TransformedAcl = {
actions: string[], role: string, read: boolean, write: boolean
}[]
}


export type TransformedAcls = TransformedAcl[]

type AclDetailsState = {
status: 'uninitialized' | 'loading' | 'succeeded' | 'failed',
Expand All @@ -34,12 +43,12 @@ const initialState: AclDetailsState = {
};

// fetch details about a certain acl from server
export const fetchAclDetails = createAsyncThunk('aclDetails/fetchAclDetails', async (aclId: any, {dispatch}) => {
export const fetchAclDetails = createAsyncThunk('aclDetails/fetchAclDetails', async (aclId: number) => {
const res = await axios.get(`/admin-ng/acl/${aclId}`);

let aclDetails = res.data;

let acl: IncomingAcl = aclDetails.acl;
let acl: IncomingAcls = aclDetails.acl;
let transformedAcls: TransformedAcls = [];

// transform policies for further use
Expand Down Expand Up @@ -119,7 +128,13 @@ export const fetchAclDetails = createAsyncThunk('aclDetails/fetchAclDetails', as
});

// update details of a certain acl
export const updateAclDetails = createAsyncThunk('aclDetails/updateAclDetails', async (params: {values: any, aclId: any}, {dispatch}) => {
export const updateAclDetails = createAsyncThunk('aclDetails/updateAclDetails', async (params: {
values: {
name: string,
acls: TransformedAcls,
},
aclId: number,
}, {dispatch}) => {
const { values, aclId } = params
// transform ACLs back to structure used by backend
let acls = prepareAccessPolicyRulesForPost(values.acls);
Expand Down
Loading

0 comments on commit b3bcc4a

Please sign in to comment.