From 613b1dd6a41eb2d96bc2ba872b2e7a82e8ad9ad8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mose=20M=C3=BCller?= Date: Mon, 27 Nov 2023 15:41:30 +0100 Subject: [PATCH] updates addNotification type hints in components --- frontend/src/components/AsyncMethodComponent.tsx | 3 ++- frontend/src/components/ButtonComponent.tsx | 3 ++- frontend/src/components/ColouredEnumComponent.tsx | 3 ++- frontend/src/components/DataServiceComponent.tsx | 3 ++- frontend/src/components/EnumComponent.tsx | 3 ++- frontend/src/components/GenericComponent.tsx | 3 ++- frontend/src/components/ImageComponent.tsx | 3 ++- frontend/src/components/ListComponent.tsx | 3 ++- frontend/src/components/MethodComponent.tsx | 3 ++- frontend/src/components/NumberComponent.tsx | 3 ++- frontend/src/components/SliderComponent.tsx | 3 ++- frontend/src/components/StringComponent.tsx | 3 ++- 12 files changed, 24 insertions(+), 12 deletions(-) diff --git a/frontend/src/components/AsyncMethodComponent.tsx b/frontend/src/components/AsyncMethodComponent.tsx index c848600..d55538d 100644 --- a/frontend/src/components/AsyncMethodComponent.tsx +++ b/frontend/src/components/AsyncMethodComponent.tsx @@ -3,6 +3,7 @@ import { runMethod } from '../socket'; import { InputGroup, Form, Button } from 'react-bootstrap'; import { DocStringComponent } from './DocStringComponent'; import { getIdFromFullAccessPath } from '../utils/stringUtils'; +import { LevelName } from './NotificationsComponent'; interface AsyncMethodProps { name: string; @@ -11,7 +12,7 @@ interface AsyncMethodProps { value: Record; docString?: string; hideOutput?: boolean; - addNotification: (message: string) => void; + addNotification: (message: string, levelname?: LevelName) => void; } export const AsyncMethodComponent = React.memo((props: AsyncMethodProps) => { diff --git a/frontend/src/components/ButtonComponent.tsx b/frontend/src/components/ButtonComponent.tsx index 70b87d3..f3915b2 100644 --- a/frontend/src/components/ButtonComponent.tsx +++ b/frontend/src/components/ButtonComponent.tsx @@ -3,6 +3,7 @@ import { ToggleButton } from 'react-bootstrap'; import { setAttribute } from '../socket'; import { DocStringComponent } from './DocStringComponent'; import { getIdFromFullAccessPath } from '../utils/stringUtils'; +import { LevelName } from './NotificationsComponent'; interface ButtonComponentProps { name: string; @@ -11,7 +12,7 @@ interface ButtonComponentProps { readOnly: boolean; docString: string; mapping?: [string, string]; // Enforce a tuple of two strings - addNotification: (message: string) => void; + addNotification: (message: string, levelname?: LevelName) => void; } export const ButtonComponent = React.memo((props: ButtonComponentProps) => { diff --git a/frontend/src/components/ColouredEnumComponent.tsx b/frontend/src/components/ColouredEnumComponent.tsx index c6f5cfc..d2b8393 100644 --- a/frontend/src/components/ColouredEnumComponent.tsx +++ b/frontend/src/components/ColouredEnumComponent.tsx @@ -3,6 +3,7 @@ import { InputGroup, Form, Row, Col } from 'react-bootstrap'; import { setAttribute } from '../socket'; import { DocStringComponent } from './DocStringComponent'; import { getIdFromFullAccessPath } from '../utils/stringUtils'; +import { LevelName } from './NotificationsComponent'; interface ColouredEnumComponentProps { name: string; @@ -11,7 +12,7 @@ interface ColouredEnumComponentProps { docString?: string; readOnly: boolean; enumDict: Record; - addNotification: (message: string) => void; + addNotification: (message: string, levelname?: LevelName) => void; } export const ColouredEnumComponent = React.memo((props: ColouredEnumComponentProps) => { diff --git a/frontend/src/components/DataServiceComponent.tsx b/frontend/src/components/DataServiceComponent.tsx index 2146c16..00f2ca3 100644 --- a/frontend/src/components/DataServiceComponent.tsx +++ b/frontend/src/components/DataServiceComponent.tsx @@ -4,13 +4,14 @@ import { Card, Collapse } from 'react-bootstrap'; import { ChevronDown, ChevronRight } from 'react-bootstrap-icons'; import { Attribute, GenericComponent } from './GenericComponent'; import { getIdFromFullAccessPath } from '../utils/stringUtils'; +import { LevelName } from './NotificationsComponent'; type DataServiceProps = { name: string; props: DataServiceJSON; parentPath?: string; isInstantUpdate: boolean; - addNotification: (message: string) => void; + addNotification: (message: string, levelname?: LevelName) => void; }; export type DataServiceJSON = Record; diff --git a/frontend/src/components/EnumComponent.tsx b/frontend/src/components/EnumComponent.tsx index f6c7376..e53cd83 100644 --- a/frontend/src/components/EnumComponent.tsx +++ b/frontend/src/components/EnumComponent.tsx @@ -2,6 +2,7 @@ import React, { useEffect, useRef } from 'react'; import { InputGroup, Form, Row, Col } from 'react-bootstrap'; import { setAttribute } from '../socket'; import { DocStringComponent } from './DocStringComponent'; +import { LevelName } from './NotificationsComponent'; interface EnumComponentProps { name: string; @@ -9,7 +10,7 @@ interface EnumComponentProps { value: string; docString?: string; enumDict: Record; - addNotification: (message: string) => void; + addNotification: (message: string, levelname?: LevelName) => void; } export const EnumComponent = React.memo((props: EnumComponentProps) => { diff --git a/frontend/src/components/GenericComponent.tsx b/frontend/src/components/GenericComponent.tsx index b138ba1..368f6f6 100644 --- a/frontend/src/components/GenericComponent.tsx +++ b/frontend/src/components/GenericComponent.tsx @@ -10,6 +10,7 @@ import { ListComponent } from './ListComponent'; import { DataServiceComponent, DataServiceJSON } from './DataServiceComponent'; import { ImageComponent } from './ImageComponent'; import { ColouredEnumComponent } from './ColouredEnumComponent'; +import { LevelName } from './NotificationsComponent'; type AttributeType = | 'str' @@ -40,7 +41,7 @@ type GenericComponentProps = { name: string; parentPath: string; isInstantUpdate: boolean; - addNotification: (message: string) => void; + addNotification: (message: string, levelname?: LevelName) => void; }; export const GenericComponent = React.memo( diff --git a/frontend/src/components/ImageComponent.tsx b/frontend/src/components/ImageComponent.tsx index 30834d8..c1b41fa 100644 --- a/frontend/src/components/ImageComponent.tsx +++ b/frontend/src/components/ImageComponent.tsx @@ -3,6 +3,7 @@ import { Card, Collapse, Image } from 'react-bootstrap'; import { DocStringComponent } from './DocStringComponent'; import { ChevronDown, ChevronRight } from 'react-bootstrap-icons'; import { getIdFromFullAccessPath } from '../utils/stringUtils'; +import { LevelName } from './NotificationsComponent'; interface ImageComponentProps { name: string; @@ -11,7 +12,7 @@ interface ImageComponentProps { readOnly: boolean; docString: string; format: string; - addNotification: (message: string) => void; + addNotification: (message: string, levelname?: LevelName) => void; } export const ImageComponent = React.memo((props: ImageComponentProps) => { diff --git a/frontend/src/components/ListComponent.tsx b/frontend/src/components/ListComponent.tsx index ee65ecb..5286321 100644 --- a/frontend/src/components/ListComponent.tsx +++ b/frontend/src/components/ListComponent.tsx @@ -2,6 +2,7 @@ import React, { useEffect, useRef } from 'react'; import { DocStringComponent } from './DocStringComponent'; import { Attribute, GenericComponent } from './GenericComponent'; import { getIdFromFullAccessPath } from '../utils/stringUtils'; +import { LevelName } from './NotificationsComponent'; interface ListComponentProps { name: string; @@ -9,7 +10,7 @@ interface ListComponentProps { value: Attribute[]; docString: string; isInstantUpdate: boolean; - addNotification: (message: string) => void; + addNotification: (message: string, levelname?: LevelName) => void; } export const ListComponent = React.memo((props: ListComponentProps) => { diff --git a/frontend/src/components/MethodComponent.tsx b/frontend/src/components/MethodComponent.tsx index c0daa65..a877b15 100644 --- a/frontend/src/components/MethodComponent.tsx +++ b/frontend/src/components/MethodComponent.tsx @@ -3,6 +3,7 @@ import { runMethod } from '../socket'; import { Button, InputGroup, Form, Collapse } from 'react-bootstrap'; import { DocStringComponent } from './DocStringComponent'; import { getIdFromFullAccessPath } from '../utils/stringUtils'; +import { LevelName } from './NotificationsComponent'; interface MethodProps { name: string; @@ -10,7 +11,7 @@ interface MethodProps { parameters: Record; docString?: string; hideOutput?: boolean; - addNotification: (message: string) => void; + addNotification: (message: string, levelname?: LevelName) => void; } export const MethodComponent = React.memo((props: MethodProps) => { diff --git a/frontend/src/components/NumberComponent.tsx b/frontend/src/components/NumberComponent.tsx index 44f3062..0ff815e 100644 --- a/frontend/src/components/NumberComponent.tsx +++ b/frontend/src/components/NumberComponent.tsx @@ -4,6 +4,7 @@ import { setAttribute } from '../socket'; import { DocStringComponent } from './DocStringComponent'; import '../App.css'; import { getIdFromFullAccessPath } from '../utils/stringUtils'; +import { LevelName } from './NotificationsComponent'; // TODO: add button functionality @@ -23,7 +24,7 @@ interface NumberComponentProps { value: number, callback?: (ack: unknown) => void ) => void; - addNotification: (message: string) => void; + addNotification: (message: string, levelname?: LevelName) => void; } // TODO: highlight the digit that is being changed by setting both selectionStart and diff --git a/frontend/src/components/SliderComponent.tsx b/frontend/src/components/SliderComponent.tsx index c911400..fc4bb3a 100644 --- a/frontend/src/components/SliderComponent.tsx +++ b/frontend/src/components/SliderComponent.tsx @@ -5,6 +5,7 @@ import { DocStringComponent } from './DocStringComponent'; import { Slider } from '@mui/material'; import { NumberComponent } from './NumberComponent'; import { getIdFromFullAccessPath } from '../utils/stringUtils'; +import { LevelName } from './NotificationsComponent'; interface SliderComponentProps { name: string; @@ -16,7 +17,7 @@ interface SliderComponentProps { docString: string; stepSize: number; isInstantUpdate: boolean; - addNotification: (message: string) => void; + addNotification: (message: string, levelname?: LevelName) => void; } export const SliderComponent = React.memo((props: SliderComponentProps) => { diff --git a/frontend/src/components/StringComponent.tsx b/frontend/src/components/StringComponent.tsx index cd76487..4a084e8 100644 --- a/frontend/src/components/StringComponent.tsx +++ b/frontend/src/components/StringComponent.tsx @@ -4,6 +4,7 @@ import { setAttribute } from '../socket'; import { DocStringComponent } from './DocStringComponent'; import '../App.css'; import { getIdFromFullAccessPath } from '../utils/stringUtils'; +import { LevelName } from './NotificationsComponent'; // TODO: add button functionality @@ -14,7 +15,7 @@ interface StringComponentProps { readOnly: boolean; docString: string; isInstantUpdate: boolean; - addNotification: (message: string) => void; + addNotification: (message: string, levelname?: LevelName) => void; } export const StringComponent = React.memo((props: StringComponentProps) => {