updates addNotification type hints in components

This commit is contained in:
Mose Müller 2023-11-27 15:41:30 +01:00
parent 914997cc6b
commit 613b1dd6a4
12 changed files with 24 additions and 12 deletions

View File

@ -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<string, string>;
docString?: string;
hideOutput?: boolean;
addNotification: (message: string) => void;
addNotification: (message: string, levelname?: LevelName) => void;
}
export const AsyncMethodComponent = React.memo((props: AsyncMethodProps) => {

View File

@ -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) => {

View File

@ -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<string, string>;
addNotification: (message: string) => void;
addNotification: (message: string, levelname?: LevelName) => void;
}
export const ColouredEnumComponent = React.memo((props: ColouredEnumComponentProps) => {

View File

@ -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<string, Attribute>;

View File

@ -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<string, string>;
addNotification: (message: string) => void;
addNotification: (message: string, levelname?: LevelName) => void;
}
export const EnumComponent = React.memo((props: EnumComponentProps) => {

View File

@ -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(

View File

@ -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) => {

View File

@ -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) => {

View File

@ -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<string, string>;
docString?: string;
hideOutput?: boolean;
addNotification: (message: string) => void;
addNotification: (message: string, levelname?: LevelName) => void;
}
export const MethodComponent = React.memo((props: MethodProps) => {

View File

@ -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

View File

@ -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) => {

View File

@ -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) => {