Skip to content

Commit

Permalink
fix: prop types updated to resolve build error
Browse files Browse the repository at this point in the history
  • Loading branch information
hwinsby committed Jan 3, 2024
1 parent 0db1969 commit b06153c
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 66 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const SET_ERROR_NOTIFICATION = "SET_ERROR_NOTIFICATION";
export const CLEAR_ERROR_NOTIFICATION = "CLEAR_ERROR_NOTIFICATION";

export function setErrorNotification(message) {
export function setErrorNotification(message: string) {
return {
type: SET_ERROR_NOTIFICATION,
value: message,
Expand Down
2 changes: 1 addition & 1 deletion src/actions/keystoreActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export type SetKeystoreAction = {
version: string;
};

type SetKeystoreNoteAction = {
export type SetKeystoreNoteAction = {
type: typeof SET_KEYSTORE_NOTE;
value: string;
};
Expand Down
8 changes: 4 additions & 4 deletions src/actions/testRunActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type ResetTestRunAction = {
testRunIndex: number;
};

type SetTestRunNoteAction = {
export type SetTestRunNoteAction = {
type: typeof SET_TEST_RUN_NOTE;
testRunIndex: number;
note: string;
Expand Down Expand Up @@ -60,12 +60,12 @@ export function resetTestRun(testRunIndex: number): ResetTestRunAction {
}

export function setTestRunNote(
testRunIndex: number,
text: string
text: string,
testRunIndex?: number
): SetTestRunNoteAction {
return {
type: SET_TEST_RUN_NOTE,
testRunIndex,
testRunIndex: testRunIndex || 0,
note: text,
};
}
88 changes: 28 additions & 60 deletions src/components/TestSuiteRun/Note.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,20 @@
import React from "react";
import { connect } from "react-redux";
import { useSelector, useDispatch } from "react-redux";

import { TextField } from "@mui/material";
import { setKeystoreNote } from "../../actions/keystoreActions";
import { setTestRunNote } from "../../actions/testRunActions";
import { setKeystoreNote as setKeystoreNoteAction } from "../../actions/keystoreActions";
import { setTestRunNote as setTestRunNoteAction } from "../../actions/testRunActions";

const KEYSTORE_MODE = "keystore";
const TEST_RUN_MODE = "testRun";
import { getKeystore } from "../../selectors/keystore";
import { getTestSuiteRun } from "../../selectors/testSuiteRun";

interface NoteBaseProps {
note: string;
mode: string;
setNote: (note: string) => void;
testRunIndex?: number;
testSuiteRun?: {
currentTestRunIndex: number;
started: boolean;
testRuns: any[];
};
}

const NoteBase = ({ note, mode, setNote, testRunIndex = 0 }: NoteBaseProps) => {
export const KeystoreNote = () => {
const note = useSelector(getKeystore).note;
const dispatch = useDispatch();
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const newNote = event.target.value;
if (mode === TEST_RUN_MODE) {
setNote(String(testRunIndex));
} else {
setNote(newNote);
}

dispatch(setKeystoreNoteAction(newNote));
};

return (
Expand All @@ -44,43 +31,24 @@ const NoteBase = ({ note, mode, setNote, testRunIndex = 0 }: NoteBaseProps) => {
);
};

const mapStateToKeystoreNoteProps = (state: { keystore: NoteBaseProps }) => {
return {
note: state.keystore.note,
mode: KEYSTORE_MODE,
};
};

const mapDispatchToKeystoreNoteProps = {
setNote: setKeystoreNote,
};

const mapStateToTestRunNoteProps = (state: {
testSuiteRun: {
testRuns: any[];
currentTestRunIndex: number;
};
keystore: NoteBaseProps;
}) => {
return {
mode: TEST_RUN_MODE,
testRunIndex: state.testSuiteRun.currentTestRunIndex,
note: state.testSuiteRun.testRuns[state.testSuiteRun.currentTestRunIndex]
.note,
export const TestRunNote = () => {
const testRunIndex = useSelector(getTestSuiteRun).currentTestRunIndex | 0;
const note = useSelector(getTestSuiteRun).testRuns[testRunIndex].note;
const dispatch = useDispatch();
const handleChange = () => {
dispatch(setTestRunNoteAction(String(testRunIndex)));
};
};

const mapDispatchToTestRunNoteProps = {
setNote: setTestRunNote,
return (
<TextField
name="notes"
label="Notes"
value={note}
variant="standard"
onChange={handleChange}
multiline
fullWidth
rows={3}
/>
);
};

const KeystoreNote = connect(
mapStateToKeystoreNoteProps,
mapDispatchToKeystoreNoteProps
)(NoteBase);
const TestRunNote = connect(
mapStateToTestRunNoteProps,
mapDispatchToTestRunNoteProps
)(NoteBase);

export { KeystoreNote, TestRunNote };

0 comments on commit b06153c

Please sign in to comment.