Skip to content

Commit

Permalink
types
Browse files Browse the repository at this point in the history
  • Loading branch information
MiRo1310 committed Oct 10, 2024
1 parent cbef2a9 commit 7e64e9d
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 56 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ module.exports = {
"arrow-parens": ["error", "always"],
curly: ["error", "all"],
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-namespace": "off",
},
overrides: [
{
Expand Down
42 changes: 0 additions & 42 deletions admin/app.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,6 @@ import { HelperText } from "@/config/helper";

export type Nullable<T> = T | null | undefined;

export interface AdditionalPropInfo extends GenericAppProps {
themeName: string;
}
interface AppProps {
encryptedFields: string[];
Connection: AdminConnection;
translations: any;
}


export type ExtendedAppProps = AppProps & AdditionalPropInfo;
export interface AdditionalStateInfo extends GenericAppState {
showDropBox: boolean;
native: Native;
connectionReady: boolean;
activeMenu: string;
usedTrigger: string[];
dropDifferenzX: number;
dropDifferenzY: number;
instances: string[];
doubleTrigger: string[];
unUsedTrigger: string[];
triggerObject: TriggerObject;
tab: string;
popupMenuOpen: boolean;
subTab: string;
draggingRowIndex: number | null;
showTriggerInfo: boolean;
data: {};
showPopupMenuList: boolean;
dropBoxTop: number;
dropBoxRight: number;
copyDataObject: { targetCheckboxes: { [key: number]: boolean }, targetActionName: string };

}

export interface PropsSettings {
data: DataMainContent;
callback: CallbackFunctionsApp;
Expand Down Expand Up @@ -107,12 +71,6 @@ export interface TabValueEntries {
password?: boolean;
type?: string;
}
export type UpdateNative = {
updateNative: UpdateNativeFunction;
};
export interface SetState {
setState: SetStateFunction;
}

export interface PropsTableDndNav {
card: string;
Expand Down
2 changes: 1 addition & 1 deletion admin/build/index.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions admin/build/index.js.map

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions admin/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ import AppTriggerOverview from "@/pages/AppTriggerOverview";
import ErrorBoundary from "@components/ErrorBoundary";
import { AdminConnection, GenericApp } from "@iobroker/adapter-react-v5";
import { Grid } from "@mui/material";
import { AdditionalPropInfo, AdditionalStateInfo, ExtendedAppProps, Native, Nullable, TriggerObject } from "admin/app";
import { Dropbox, Native, Nullable, TriggerObject } from "admin/app";
import React from "react";
import { getDefaultDropBoxCoordinates } from "./lib/dragNDrop";
import { getDoubleEntries, getFirstItem as getFirstObjectKey } from "./lib/object";
import { TelegramMenuApp } from "./types/props-types";

class App extends GenericApp<AdditionalPropInfo, AdditionalStateInfo> {
dropBoxRef: React.RefObject<HTMLDivElement> | undefined;
class App extends GenericApp<TelegramMenuApp.AdditionalProps, TelegramMenuApp.AdditionalState> {
dropBoxRef: Dropbox.Ref;
constructor(props: any) {

Check warning on line 22 in admin/src/app.tsx

View workflow job for this annotation

GitHub Actions / check-and-lint

Argument 'props' should be typed with a non-any type
const extendedProps: ExtendedAppProps = {
const extendedProps: TelegramMenuApp.ExtendedProps = {
...props,
encryptedFields: [],
Connection: AdminConnection,
Expand All @@ -42,7 +43,7 @@ class App extends GenericApp<AdditionalPropInfo, AdditionalStateInfo> {
this.state = {
...this.state,
native: {} as Native,
data: {},
// data: {},
tab: "nav",
subTab: "set",
draggingRowIndex: null,
Expand Down Expand Up @@ -84,7 +85,7 @@ class App extends GenericApp<AdditionalPropInfo, AdditionalStateInfo> {

newX: Nullable<number> = null;
newY: Nullable<number> = null;
componentDidUpdate(prevProps: Readonly<AdditionalPropInfo>, prevState: Readonly<AdditionalStateInfo>): void {
componentDidUpdate(prevProps: Readonly<TelegramMenuApp.AdditionalProps>, prevState: Readonly<TelegramMenuApp.AdditionalState>): void {
if (prevState.native.instance !== this.state.native.instance && this.state.connectionReady) {
this.getUsersFromTelegram();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class AppContentTabActionContentRowEditorTableHead extends Component<PropsAction
componentDidMount(): void {
this.props.setRef(this);
}
clickCheckBox = (event: EventCheckbox): void => {
this.setState({ isChecked: event.isChecked });
this.props.callback.checkAll(event.isChecked);
clickCheckBox = ({ isChecked }: EventCheckbox): void => {
this.setState({ isChecked });
this.props.callback.checkAll(isChecked);
};
resetCheckboxHeader(): void {
this.setState({ isChecked: false });
Expand Down
52 changes: 51 additions & 1 deletion admin/src/types/props-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,66 @@ import {
Data,
DataMainContent,
DataTabActionContent,
Native,
RowsSetState,
StateTabNavigation,
TabActionContentTableProps,
TabValueEntries,
TabValues,
TriggerObject,
} from "../../app";
import { SetStateFunction } from "admin/app";
import { EventButton } from "./event";
import { ShowButtons, RowForButton } from "../../app";
import AppContentTabActionContentRowEditorTableHead from "@/pages/AppContentTabActionContentRowEditorTableHead";
import { GenericAppProps, AdminConnection, GenericAppState } from "@iobroker/adapter-react-v5";

export namespace TelegramMenuApp {
export interface AdditionalProps extends GenericAppProps {
themeName: string;
}
interface AppProps {
encryptedFields: string[];
Connection: AdminConnection;
translations: Translation;
}
export type ExtendedProps = AppProps & AdditionalProps;
export interface AdditionalState extends GenericAppState {
showDropBox: boolean;
native: Native;
connectionReady: boolean;
activeMenu: string;
usedTrigger: string[];
dropDifferenzX: number;
dropDifferenzY: number;
instances: string[];
doubleTrigger: string[];
unUsedTrigger: string[];
triggerObject: TriggerObject;
tab: string;
popupMenuOpen: boolean;
subTab: string;
draggingRowIndex: number | null;
showTriggerInfo: boolean;
showPopupMenuList: boolean;
dropBoxTop: number;
dropBoxRight: number;
copyDataObject: { targetCheckboxes: { [key: number]: boolean }; targetActionName: string };
}
interface Translation {
en: Record<string, string>;
de: Record<string, string>;
ru: Record<string, string>;
pt: Record<string, string>;
nl: Record<string, string>;
fr: Record<string, string>;
it: Record<string, string>;
es: Record<string, string>;
pl: Record<string, string>;
uk: Record<string, string>;
"zh-cn": Record<string, string>;
}
}

export interface AppContentTabActionContentRowEditorButtonsProps {
data: DataMainContent & TabActionContentTableProps & DataTabActionContent & { rows: RowsSetState[]; indexRow: number };
Expand Down Expand Up @@ -51,7 +101,7 @@ export interface PropsButtonCard {

export interface PropsActionEditHeader {
tab: TabValues;
callback: { checkAll: (check) => void };
callback: { checkAll: (check: boolean) => void };
setRef: (ref: AppContentTabActionContentRowEditorTableHead) => void;
}

Expand Down

0 comments on commit 7e64e9d

Please sign in to comment.