Skip to content

Commit 6079587

Browse files
committed
refactor
1 parent 05f0a16 commit 6079587

File tree

9 files changed

+29
-91
lines changed

9 files changed

+29
-91
lines changed

src/components/ControlPlane/GitRepositories.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ export type GitRepoItem = GitReposResponse['items'][0] & {
2323
metadata: GitReposResponse['items'][0]['metadata'] & { namespace?: string };
2424
};
2525

26-
interface CellRow<T> {
27-
original: T;
28-
}
29-
3026
export function GitRepositories() {
3127
const { data, error, isLoading } = useApiResource(FluxRequest); //404 if component not enabled
3228
const { t } = useTranslation();
@@ -83,7 +79,7 @@ export function GitRepositories() {
8379
width: 125,
8480
hAlign: 'Center',
8581
Filter: ({ column }) => <StatusFilter column={column} />,
86-
Cell: ({ row }: { row: CellRow<FluxRow> }) =>
82+
Cell: ({ row }) =>
8783
row.original?.isReady != null ? (
8884
<ResourceStatusCell
8985
positiveText={t('common.ready')}
@@ -100,17 +96,15 @@ export function GitRepositories() {
10096
width: 75,
10197
accessor: 'yaml',
10298
disableFilters: true,
103-
Cell: ({ row }: { row: CellRow<FluxRow> }) => (
104-
<YamlViewButton variant="resource" resource={row.original.item as unknown as Resource} />
105-
),
99+
Cell: ({ row }) => <YamlViewButton variant="resource" resource={row.original.item as unknown as Resource} />,
106100
},
107101
{
108102
Header: t('ManagedResources.actionColumnHeader'),
109103
hAlign: 'Center',
110104
width: 60,
111105
disableFilters: true,
112106
accessor: 'actions',
113-
Cell: ({ row }: { row: CellRow<FluxRow> }) => {
107+
Cell: ({ row }) => {
114108
const item = row.original?.item;
115109
if (!item) return undefined;
116110
const actions: ActionItem<GitRepoItem>[] = [

src/components/ControlPlane/Kustomizations.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ export function Kustomizations() {
3030
const errorDialogRef = useRef<ErrorDialogHandle>(null);
3131
const handlePatch = useHandleResourcePatch(errorDialogRef);
3232

33-
interface CellRow<T> {
34-
original: T;
35-
}
36-
3733
type FluxRow = {
3834
name: string;
3935
created: string;
@@ -78,7 +74,7 @@ export function Kustomizations() {
7874
width: 125,
7975
hAlign: 'Center',
8076
Filter: ({ column }) => <StatusFilter column={column} />,
81-
Cell: ({ row }: { row: CellRow<FluxRow> }) =>
77+
Cell: ({ row }) =>
8278
row.original?.isReady != null ? (
8379
<ResourceStatusCell
8480
positiveText={t('common.ready')}
@@ -95,17 +91,15 @@ export function Kustomizations() {
9591
width: 75,
9692
accessor: 'yaml',
9793
disableFilters: true,
98-
Cell: ({ row }: { row: CellRow<FluxRow> }) => (
99-
<YamlViewButton variant="resource" resource={row.original.item as unknown as Resource} />
100-
),
94+
Cell: ({ row }) => <YamlViewButton variant="resource" resource={row.original.item as unknown as Resource} />,
10195
},
10296
{
10397
Header: t('ManagedResources.actionColumnHeader'),
10498
hAlign: 'Center',
10599
width: 60,
106100
disableFilters: true,
107101
accessor: 'actions',
108-
Cell: ({ row }: { row: CellRow<FluxRow> }) => {
102+
Cell: ({ row }) => {
109103
const item = row.original?.item;
110104
if (!item) return undefined;
111105
const actions: ActionItem<KustomizationItem>[] = [

src/components/ControlPlane/MCPHealthPopoverButton.tsx

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,6 @@ import { useLink } from '../../lib/shared/useLink.ts';
2525
import TooltipCell from '../Shared/TooltipCell.tsx';
2626
import type { Ui5CustomEvent } from '@ui5/webcomponents-react-base';
2727

28-
interface CellData<T> {
29-
cell: {
30-
value: T | undefined;
31-
row: {
32-
original: Record<string, unknown>;
33-
};
34-
};
35-
}
36-
3728
type MCPHealthPopoverButtonProps = {
3829
mcpStatus: ControlPlaneStatusType | undefined;
3930
projectName: string;
@@ -97,7 +88,7 @@ const MCPHealthPopoverButton = ({ mcpStatus, projectName, workspaceName, mcpName
9788
Header: t('MCPHealthPopoverButton.statusHeader'),
9889
accessor: 'status',
9990
width: 50,
100-
Cell: (instance: CellData<string>) => {
91+
Cell: (instance) => {
10192
const isReady = instance.cell.value === 'True';
10293
return (
10394
<Icon
@@ -111,31 +102,31 @@ const MCPHealthPopoverButton = ({ mcpStatus, projectName, workspaceName, mcpName
111102
Header: t('MCPHealthPopoverButton.typeHeader'),
112103
accessor: 'type',
113104
width: 150,
114-
Cell: (instance: CellData<string>) => {
105+
Cell: (instance) => {
115106
return <TooltipCell>{instance.cell.value}</TooltipCell>;
116107
},
117108
},
118109
{
119110
Header: t('MCPHealthPopoverButton.messageHeader'),
120111
accessor: 'message',
121112
width: 350,
122-
Cell: (instance: CellData<string>) => {
113+
Cell: (instance) => {
123114
return <TooltipCell>{instance.cell.value}</TooltipCell>;
124115
},
125116
},
126117
{
127118
Header: t('MCPHealthPopoverButton.reasonHeader'),
128119
accessor: 'reason',
129120
width: 100,
130-
Cell: (instance: CellData<string>) => {
121+
Cell: (instance) => {
131122
return <TooltipCell>{instance.cell.value}</TooltipCell>;
132123
},
133124
},
134125
{
135126
Header: t('MCPHealthPopoverButton.transitionHeader'),
136127
accessor: 'lastTransitionTime',
137128
width: 125,
138-
Cell: (instance: CellData<string>) => {
129+
Cell: (instance) => {
139130
const rawDate = instance.cell.value;
140131
const date = new Date(rawDate as string);
141132
return (

src/components/ControlPlane/ManagedResources.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ interface StatusFilterColumn {
4040
filterValue?: string;
4141
setFilter?: (value?: string) => void;
4242
}
43-
interface CellRow<T> {
44-
original: T;
45-
}
4643

4744
type ResourceRow = {
4845
kind: string;
@@ -130,7 +127,7 @@ export function ManagedResources() {
130127
hAlign: 'Center',
131128
width: 125,
132129
Filter: ({ column }: { column: StatusFilterColumn }) => <StatusFilter column={column} />,
133-
Cell: ({ row }: { row: CellRow<ResourceRow> }) => {
130+
Cell: ({ row }) => {
134131
const { original } = row;
135132
return original?.synced != null ? (
136133
<ResourceStatusCell
@@ -149,7 +146,7 @@ export function ManagedResources() {
149146
hAlign: 'Center',
150147
width: 125,
151148
Filter: ({ column }: { column: StatusFilterColumn }) => <StatusFilter column={column} />,
152-
Cell: ({ row }: { row: CellRow<ResourceRow> }) => {
149+
Cell: ({ row }) => {
153150
const { original } = row;
154151
return original?.ready != null ? (
155152
<ResourceStatusCell
@@ -168,7 +165,7 @@ export function ManagedResources() {
168165
width: 75,
169166
accessor: 'yaml',
170167
disableFilters: true,
171-
Cell: ({ row }: { row: CellRow<ResourceRow> }) => {
168+
Cell: ({ row }) => {
172169
const { original } = row;
173170
return original?.item ? (
174171
<YamlViewButton variant="resource" resource={original.item as unknown as Resource} />
@@ -180,7 +177,7 @@ export function ManagedResources() {
180177
hAlign: 'Center',
181178
width: 60,
182179
disableFilters: true,
183-
Cell: ({ row }: { row: CellRow<ResourceRow> }) => {
180+
Cell: ({ row }) => {
184181
const { original } = row;
185182
const item = original?.item;
186183
if (!item) return undefined;

src/components/ControlPlane/Providers.tsx

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,6 @@ import StatusFilter from '../Shared/StatusFilter/StatusFilter.tsx';
2424
import { ResourceStatusCell } from '../Shared/ResourceStatusCell.tsx';
2525
import { Resource } from '../../utils/removeManagedFieldsAndFilterData.ts';
2626

27-
type CellInstance = {
28-
cell: {
29-
row: {
30-
original: Record<string, unknown>;
31-
};
32-
};
33-
};
34-
3527
type ProvidersRow = {
3628
name: string;
3729
version: string;
@@ -77,7 +69,7 @@ export function Providers() {
7769
width: 125,
7870
Filter: ({ column }) => <StatusFilter column={column} />,
7971
filter: 'equals',
80-
Cell: (cellData: CellInstance) =>
72+
Cell: (cellData) =>
8173
cellData.cell.row.original?.installed != null ? (
8274
<ResourceStatusCell
8375
isOk={cellData.cell.row.original?.installed === 'true'}
@@ -95,7 +87,7 @@ export function Providers() {
9587
width: 125,
9688
Filter: ({ column }) => <StatusFilter column={column} />,
9789
filter: 'equals',
98-
Cell: (cellData: CellInstance) =>
90+
Cell: (cellData) =>
9991
cellData.cell.row.original?.installed != null ? (
10092
<ResourceStatusCell
10193
isOk={cellData.cell.row.original?.healthy === 'true'}
@@ -112,7 +104,7 @@ export function Providers() {
112104
width: 75,
113105
accessor: 'yaml',
114106
disableFilters: true,
115-
Cell: (cellData: CellInstance) => (
107+
Cell: (cellData) => (
116108
<YamlViewButton variant="resource" resource={cellData.cell.row.original?.item as Resource} />
117109
),
118110
},

src/components/ControlPlane/ProvidersConfig.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ type Rows = {
3232
resource: ProviderConfigItem;
3333
};
3434

35-
interface CellRow<T> {
36-
original: T;
37-
}
38-
3935
export function ProvidersConfig() {
4036
const { t } = useTranslation();
4137
const { openInAside } = useSplitter();
@@ -104,7 +100,7 @@ export function ProvidersConfig() {
104100
width: 75,
105101
accessor: 'yaml',
106102
disableFilters: true,
107-
Cell: ({ row }: { row: CellRow<Rows> }) => {
103+
Cell: ({ row }) => {
108104
const item = row.original?.resource;
109105
return item ? <YamlViewButton variant="resource" resource={item as unknown as Resource} /> : undefined;
110106
},
@@ -115,7 +111,7 @@ export function ProvidersConfig() {
115111
width: 60,
116112
disableFilters: true,
117113
accessor: 'actions',
118-
Cell: ({ row }: { row: CellRow<Rows> }) => {
114+
Cell: ({ row }) => {
119115
const item = row.original?.resource;
120116
if (!item) return undefined;
121117
const actions: ActionItem<ProviderConfigItem>[] = [

src/components/Members/ImportMembersDialog.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,6 @@ import { useTranslation } from 'react-i18next';
2525
import IllustratedError from '../Shared/IllustratedError.tsx';
2626
import { TFunction } from 'i18next';
2727

28-
interface CellData<T> {
29-
cell: {
30-
value: T | undefined;
31-
row: {
32-
original: Record<string, unknown>;
33-
};
34-
};
35-
}
36-
3728
type FilteredFor = 'All' | 'Users' | 'ServiceAccounts';
3829
type SourceType = 'Workspace' | 'Project';
3930
type TableRow = {
@@ -100,7 +91,7 @@ export const ImportMembersDialog: FC<ImportMembersDialogProps> = ({
10091
Header: t('MemberTable.columnTypeHeader'),
10192
accessor: 'kind',
10293
width: 145,
103-
Cell: (instance: CellData<string>) => {
94+
Cell: (instance) => {
10495
const original = instance.cell.row.original as TableRow;
10596
const kind = ACCOUNT_TYPES.find(({ value }) => value === original.kind);
10697
return (

src/components/Members/MemberTable.tsx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,6 @@ type MemberTableProps = {
2222
requireAtLeastOneMember: boolean;
2323
};
2424

25-
type CellInstance = {
26-
cell: {
27-
row: {
28-
original: Record<string, unknown>;
29-
};
30-
};
31-
};
32-
3325
export const MemberTable: FC<MemberTableProps> = ({
3426
members,
3527
onDeleteMember,
@@ -49,7 +41,7 @@ export const MemberTable: FC<MemberTableProps> = ({
4941
Header: t('MemberTable.columnTypeHeader'),
5042
accessor: 'kind',
5143
width: 145,
52-
Cell: (instance: CellInstance) => {
44+
Cell: (instance) => {
5345
const kind = ACCOUNT_TYPES.find(({ value }) => value === instance.cell.row.original.kind);
5446
return (
5547
<FlexBox gap={'0.5rem'} wrap={'NoWrap'}>
@@ -75,7 +67,7 @@ export const MemberTable: FC<MemberTableProps> = ({
7567
Header: '',
7668
id: 'edit',
7769
width: 100,
78-
Cell: (instance: CellInstance) => (
70+
Cell: (instance) => (
7971
<FlexBox gap={'0.5rem'} justifyContent={'SpaceBetween'}>
8072
<Button
8173
icon="edit"

src/components/Projects/ProjectsList.tsx

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AnalyticalTable, Link } from '@ui5/webcomponents-react';
1+
import { AnalyticalTable, AnalyticalTableColumnDefinition, Link } from '@ui5/webcomponents-react';
22

33
import { CopyButton } from '../Shared/CopyButton.tsx';
44
import useLuigiNavigate from '../Shared/useLuigiNavigate.tsx';
@@ -18,15 +18,6 @@ type ProjectListRow = {
1818
nameSpace: string;
1919
};
2020

21-
type ProjectListCellInstance<T> = {
22-
cell: {
23-
value: T | undefined;
24-
row: {
25-
original: Record<string, unknown>;
26-
};
27-
};
28-
};
29-
3021
export default function ProjectsList() {
3122
const navigate = useLuigiNavigate();
3223
const { data, error } = useApiResource(ListProjectNames, {
@@ -42,12 +33,12 @@ export default function ProjectsList() {
4233
}) ?? [],
4334
[data],
4435
);
45-
const stabilizedColumns = useMemo(
36+
const stabilizedColumns: AnalyticalTableColumnDefinition[] = useMemo(
4637
() => [
4738
{
4839
Header: t('ProjectsListView.title'),
4940
accessor: 'projectName',
50-
Cell: (instance: ProjectListCellInstance<string>) => (
41+
Cell: (instance) => (
5142
<Link
5243
design={'Emphasized'}
5344
style={{
@@ -68,7 +59,7 @@ export default function ProjectsList() {
6859
Header: 'Namespace',
6960
accessor: 'nameSpace',
7061
width: 340,
71-
Cell: (instance: ProjectListCellInstance<string>) => (
62+
Cell: (instance) => (
7263
<div
7364
style={{
7465
display: 'flex',
@@ -89,7 +80,7 @@ export default function ProjectsList() {
8980
width: 75,
9081
disableFilters: true,
9182
hAlign: 'Center' as const,
92-
Cell: (instance: ProjectListCellInstance<string>) => (
83+
Cell: (instance) => (
9384
<div
9485
style={{
9586
width: '100%',
@@ -112,7 +103,7 @@ export default function ProjectsList() {
112103
width: 60,
113104
disableFilters: true,
114105
hAlign: 'Center' as const,
115-
Cell: (instance: ProjectListCellInstance<string>) => (
106+
Cell: (instance) => (
116107
<div
117108
style={{
118109
width: '100%',

0 commit comments

Comments
 (0)