Skip to content

Commit fc59b7f

Browse files
committed
fix: types
Signed-off-by: Amit Amrutiya <[email protected]>
1 parent be19b85 commit fc59b7f

File tree

10 files changed

+48
-40
lines changed

10 files changed

+48
-40
lines changed

src/constants/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ export const DEFAULT_STROKE_WIDTH = '2';
99
export const CLOUD_URL = 'https://cloud.layer5.io';
1010
export const PLAYGROUND_MODES = {
1111
DESIGNER: 'design',
12-
VISUALIZER: 'visualize'
12+
OPERATOR: 'operator'
1313
} as const;

src/custom/CatalogDesignTable/CatalogDesignTable.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
22
import _ from 'lodash';
3+
import { MUIDataTableColumn } from 'mui-datatables';
34
import { useCallback, useMemo, useRef } from 'react';
45
import { PublishIcon } from '../../icons';
56
import { CHARCOAL, useTheme } from '../../theme';
@@ -14,7 +15,7 @@ import UnpublishTooltipIcon from './UnpublishTooltipIcon';
1415
interface CatalogDesignsTableProps {
1516
patterns: Pattern[];
1617
filter: any;
17-
columns: Array<any>;
18+
columns: MUIDataTableColumn[];
1819
totalCount: number;
1920
sortOrder: string;
2021
setSortOrder: (order: string) => void;
@@ -63,7 +64,7 @@ export const CatalogDesignsTable: React.FC<CatalogDesignsTableProps> = ({
6364
return new Date(date).toLocaleDateString('en-US', dateOptions);
6465
}, []);
6566

66-
const processedColumns = useMemo(() => {
67+
const processedColumns: MUIDataTableColumn[] = useMemo(() => {
6768
return columns.map((col) => {
6869
const newCol = { ...col };
6970
if (!newCol.options) newCol.options = {};
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/* eslint-disable @typescript-eslint/no-explicit-any */
2+
3+
export const getColumnValue = (tableMeta: any, targetColumn: string): any => {
4+
const rowData = tableMeta.tableData[tableMeta.rowIndex];
5+
return (rowData as any)[targetColumn] || '';
6+
};

src/custom/CatalogDesignTable/helper.tsx

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/custom/ResponsiveDataTable.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Theme, ThemeProvider, createTheme, styled } from '@mui/material';
2-
import MUIDataTable from 'mui-datatables';
2+
import MUIDataTable, { MUIDataTableColumn } from 'mui-datatables';
33
import React, { useCallback } from 'react';
44
import { Checkbox, Collapse, ListItemIcon, ListItemText, Menu, MenuItem } from '../base';
55
import { ShareIcon } from '../icons';
@@ -278,10 +278,10 @@ export interface Column {
278278

279279
export interface ResponsiveDataTableProps {
280280
data: string[][];
281-
columns: Column[];
281+
columns: MUIDataTableColumn[];
282282
options?: object;
283-
tableCols?: Column[];
284-
updateCols?: ((columns: Column[]) => void) | undefined;
283+
tableCols?: MUIDataTableColumn[];
284+
updateCols?: ((columns: MUIDataTableColumn[]) => void) | undefined;
285285
columnVisibility: Record<string, boolean> | undefined;
286286
theme?: object;
287287
colViews?: ColView[];

src/custom/TeamTable/TeamTable.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
22
import { Grid, TableCell } from '@mui/material';
3+
import { MUIDataTableColumn } from 'mui-datatables';
34
import { ErrorBoundary } from '../ErrorBoundary/ErrorBoundary.js';
45
import { ColView } from '../Helpers/ResponsiveColumns/responsive-coulmns.tsx/index.js';
56
import ResponsiveDataTable from '../ResponsiveDataTable.js';
@@ -11,7 +12,7 @@ interface TeamTableProps {
1112
columnVisibility: Record<string, boolean>;
1213
colViews: ColView[];
1314
tableCols: any[];
14-
columns: any[];
15+
columns: MUIDataTableColumn[];
1516
updateCols: (cols: any) => void;
1617
isRemoveFromTeamAllowed: boolean;
1718
org_id: string;

src/custom/TeamTable/TeamTableConfiguration.tsx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
2+
import { MUIDataTableColumn, MUIDataTableMeta } from 'mui-datatables';
23
import { useState } from 'react';
34
import { DeleteIcon, EditIcon } from '../../icons';
45
import LogoutIcon from '../../icons/Logout/LogOutIcon';
@@ -17,11 +18,12 @@ import {
1718
TableTopIcon,
1819
TableTopIconsWrapper
1920
} from '../Workspaces/styles';
21+
import { Team } from '../Workspaces/types';
2022

2123
// currently team does not support bulk team delete
2224
interface DeleteTeamsBtnProps {
2325
selected: any;
24-
teams: any[];
26+
teams: Team[];
2527
deleteTeamsModalHandler: (deleteTeams: { team_ids: string[]; team_names: string[] }) => void;
2628
}
2729

@@ -55,7 +57,7 @@ function DeleteTeamsBtn({ selected, teams, deleteTeamsModalHandler }: DeleteTeam
5557
}
5658

5759
interface TeamTableConfigurationProps {
58-
teams: any[];
60+
teams: Team[];
5961
count: number;
6062
page: number;
6163
pageSize: number;
@@ -65,9 +67,9 @@ interface TeamTableConfigurationProps {
6567
setSortOrder: (sortOrder: string) => void;
6668
bulkSelect: boolean;
6769
setBulkSelect: (bulkSelect: boolean) => void;
68-
handleTeamView: (ev: any, rowData: any) => void;
69-
handleDeleteTeam: (ev: any, rowData: any) => void;
70-
handleleaveTeam: (ev: any, rowData: any) => void;
70+
handleTeamView: (ev: React.MouseEvent, rowData: any) => void;
71+
handleDeleteTeam: (ev: React.MouseEvent, rowData: any) => void;
72+
handleleaveTeam: (ev: React.MouseEvent, rowData: any) => void;
7173
handleRemoveTeamFromWorkspace?: (rowData: any) => void;
7274
teamId: string;
7375
workspace?: boolean;
@@ -114,15 +116,15 @@ export default function TeamTableConfiguration({
114116
['actions', 'xs']
115117
];
116118

117-
const columns = [
119+
const columns: MUIDataTableColumn[] = [
118120
{
119121
name: 'id',
120122
label: 'ID',
121123
options: {
122124
filter: false,
123125
sort: false,
124126
searchable: false,
125-
customBodyRender: (value: any) => <FormatId id={value} />
127+
customBodyRender: (value: string) => <FormatId id={value} />
126128
}
127129
},
128130
{
@@ -141,7 +143,7 @@ export default function TeamTableConfiguration({
141143
filter: false,
142144
sort: true,
143145
searchable: false,
144-
customBodyRender: (value: any) => <ConditionalTooltip value={value} maxLength={30} />
146+
customBodyRender: (value: string) => <ConditionalTooltip value={value} maxLength={30} />
145147
}
146148
},
147149
{
@@ -171,10 +173,10 @@ export default function TeamTableConfiguration({
171173
sort: true,
172174
searchable: false,
173175
sortDescFirst: true,
174-
customBodyRender: (v: any) => JSON.stringify(v),
176+
customBodyRender: (v: string) => JSON.stringify(v),
175177
filterOptions: {
176178
names: ['Deleted', 'Not Deleted'],
177-
logic: (val: any, filters: any) => {
179+
logic: (val: string, filters: any) => {
178180
if (val != 'NA' && filters.indexOf('Deleted') >= 0) return true;
179181
else if (val == 'NA' && filters.indexOf('Not Deleted') >= 0) return true;
180182
return false;
@@ -190,7 +192,7 @@ export default function TeamTableConfiguration({
190192
filter: false,
191193
sort: false,
192194
searchable: false,
193-
customBodyRender: (_: any, tableMeta: any) => {
195+
customBodyRender: (_: string, tableMeta: MUIDataTableMeta) => {
194196
if (bulkSelect || tableMeta.rowData[4].Valid) {
195197
return (
196198
<TableIconsDisabledContainer>
@@ -251,7 +253,7 @@ export default function TeamTableConfiguration({
251253
<TooltipIcon
252254
id={`delete_team-${tableMeta.rowIndex}`}
253255
title={'Delete Team'}
254-
onClick={(ev: any) => {
256+
onClick={(ev: React.MouseEvent) => {
255257
isDeleteTeamAllowed && handleDeleteTeam(ev, tableMeta.rowData);
256258
}}
257259
iconType="delete"

src/custom/UsersTable/UsersTable.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
2+
import { MUIDataTableColumn, MUIDataTableMeta } from 'mui-datatables';
23
import { useRef, useState } from 'react';
34
import { Avatar, Box, Grid, Tooltip, Typography } from '../../base';
45
import { EditIcon, PersonIcon } from '../../icons';
@@ -18,7 +19,7 @@ import { parseDeletionTimestamp } from '../Workspaces/helper';
1819
import { TableIconsContainer, TableIconsDisabledContainer } from '../Workspaces/styles';
1920

2021
interface ActionButtonsProps {
21-
tableMeta: any;
22+
tableMeta: MUIDataTableMeta;
2223
isRemoveFromTeamAllowed: boolean;
2324
handleRemoveFromTeam: (data: any[]) => () => void;
2425
}
@@ -121,7 +122,7 @@ const UsersTable: React.FC<UsersTableProps> = ({
121122
}
122123
};
123124

124-
const getValidColumnValue = (rowData: any, columnName: string, columns: any) => {
125+
const getValidColumnValue = (rowData: any, columnName: string, columns: MUIDataTableColumn[]) => {
125126
const columnIndex = columns.findIndex((column: any) => column.name === columnName);
126127
return rowData[columnIndex];
127128
};
@@ -233,7 +234,7 @@ const UsersTable: React.FC<UsersTableProps> = ({
233234
// ["actions", "xs"]
234235
];
235236

236-
const columns: any[] = [
237+
const columns: MUIDataTableColumn[] = [
237238
{
238239
name: 'user_id',
239240
label: 'User ID',
@@ -250,7 +251,7 @@ const UsersTable: React.FC<UsersTableProps> = ({
250251
filter: false,
251252
sort: false,
252253
searchable: false,
253-
customBodyRender: (value: string, tableMeta: any) => (
254+
customBodyRender: (value: string, tableMeta: MUIDataTableMeta) => (
254255
<Box sx={{ '& > img': { mr: 2, flexShrink: 0 } }}>
255256
<Grid container alignItems="center">
256257
<Grid item>
@@ -295,7 +296,7 @@ const UsersTable: React.FC<UsersTableProps> = ({
295296
filter: false,
296297
sort: true,
297298
searchable: true,
298-
customBodyRender: (value: string, tableMeta: any) => (
299+
customBodyRender: (value: string, tableMeta: MUIDataTableMeta) => (
299300
<div style={{ display: 'flex' }}>
300301
{value}
301302

@@ -408,7 +409,7 @@ const UsersTable: React.FC<UsersTableProps> = ({
408409
},
409410
fullWidth: true
410411
},
411-
customBodyRender: (value: any, tableMeta: any) => {
412+
customBodyRender: (_: string, tableMeta: MUIDataTableMeta) => {
412413
const rowData = users[tableMeta.rowIndex];
413414
return parseDeletionTimestamp(rowData);
414415
}
@@ -421,7 +422,7 @@ const UsersTable: React.FC<UsersTableProps> = ({
421422
filter: false,
422423
sort: false,
423424
searchable: false,
424-
customBodyRender: (_: any, tableMeta: any) =>
425+
customBodyRender: (_: string, tableMeta: MUIDataTableMeta) =>
425426
getValidColumnValue(tableMeta.rowData, 'deleted_at', columns).Valid !== false ? (
426427
<TableIconsDisabledContainer>
427428
<EditIcon
@@ -445,7 +446,7 @@ const UsersTable: React.FC<UsersTableProps> = ({
445446
}
446447
];
447448

448-
const [tableCols, updateCols] = useState<any[]>(columns);
449+
const [tableCols, updateCols] = useState<MUIDataTableColumn[]>(columns);
449450

450451
const [columnVisibility] = useState<Record<string, boolean>>(() => {
451452
const showCols: Record<string, boolean> = updateVisibleColumns(colViews, width);

src/custom/Workspaces/EnvironmentTable.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
22
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
3-
import { MUIDataTableMeta } from 'mui-datatables';
3+
import { MUIDataTableColumn, MUIDataTableMeta } from 'mui-datatables';
44
import React, { useState } from 'react';
55
import { Accordion, AccordionDetails, AccordionSummary, Typography } from '../../base';
66
import { DeleteIcon, EnvironmentIcon } from '../../icons';
@@ -80,7 +80,7 @@ const EnvironmentTable: React.FC<EnvironmentTableProps> = ({
8080
});
8181
const { width } = useWindowDimensions();
8282
const [unassignEnvironmentFromWorkspace] = useUnassignEnvironmentFromWorkspaceMutation();
83-
const columns: any[] = [
83+
const columns: MUIDataTableColumn[] = [
8484
{
8585
name: 'id',
8686
label: 'ID',
@@ -150,7 +150,7 @@ const EnvironmentTable: React.FC<EnvironmentTableProps> = ({
150150
filter: false,
151151
sort: false,
152152
searchable: false,
153-
customBodyRender: (_: any, tableMeta: MUIDataTableMeta) => (
153+
customBodyRender: (_: string, tableMeta: MUIDataTableMeta) => (
154154
<IconWrapper disabled={!isRemoveAllowed}>
155155
<TooltipIcon
156156
id={`delete_team-${tableMeta.rowIndex}`}

src/custom/Workspaces/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,10 @@ export interface Environment {
3535
export interface Team {
3636
id: string;
3737
name: string;
38+
team_id: string;
39+
description?: string;
40+
team_name: string;
41+
deleted_at: {
42+
Valid: boolean;
43+
};
3844
}

0 commit comments

Comments
 (0)