Skip to content

Commit 8ecb04a

Browse files
Removed redundant wrappers and updated empty state text
1 parent 2267d51 commit 8ecb04a

10 files changed

+23
-30
lines changed

packages/react/src/auto/shadcn/ShadcnAutoTable.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { type FindManyFunction, type GadgetRecord } from "@gadgetinc/api-client-core";
2+
import pluralize from "pluralize";
23
import * as React from "react";
3-
import { useCallback } from "react";
4+
import { useCallback, useMemo } from "react";
45
import { useTable } from "../../useTable.js";
56
import { type ColumnValueType, type OptionsType } from "../../utils.js";
67
import { type AutoTableProps } from "../AutoTable.js";
@@ -50,7 +51,7 @@ export const makeAutoTable = (elements: ShadcnElements) => {
5051
error, // TODO - add an error state
5152
selection, // TODO - add record selection and bulk action system
5253
sort, // TODO - add column sorting
53-
54+
metadata,
5455
data: rawRecords, // TODO - use this to get direct record access in callbacks
5556
} = methods;
5657

@@ -68,6 +69,15 @@ export const makeAutoTable = (elements: ShadcnElements) => {
6869
[onClick]
6970
);
7071

72+
const resourceName = useMemo(
73+
() =>
74+
props.resourceName ?? {
75+
singular: metadata?.name ?? "",
76+
plural: metadata ? pluralize(metadata.name) : "",
77+
},
78+
[props.resourceName, metadata]
79+
);
80+
7181
if (error) {
7282
return <Alert>Error</Alert>;
7383
}
@@ -105,7 +115,7 @@ export const makeAutoTable = (elements: ShadcnElements) => {
105115
) : (
106116
<TableRow>
107117
<TableCell colSpan={columns.length} className="h-24 text-center">
108-
No results.
118+
{`No ${resourceName.plural} yet`}
109119
</TableCell>
110120
</TableRow>
111121
)}

packages/react/src/auto/shadcn/table/ShadcnAutoTablePagination.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,5 @@ export const makeShadcnAutoTablePagination = (elements: ShadcnElements) => {
2323
);
2424
}
2525

26-
return (props: { page: PaginationResult }) => {
27-
return <ShadcnAutoTablePagination {...props} />;
28-
};
26+
return ShadcnAutoTablePagination;
2927
};

packages/react/src/auto/shadcn/table/ShadcnAutoTableSearch.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,5 @@ export const makeShadcnAutoTableSearch = (elements: ShadcnElements) => {
2222
);
2323
}
2424

25-
return (props: { search: SearchResult }) => {
26-
return <ShadcnAutoTableSearch {...props} />;
27-
};
25+
return ShadcnAutoTableSearch;
2826
};

packages/react/src/auto/shadcn/table/cells/ShadcnAutoTableBooleanCell.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ export const makeShadcnAutoTableBooleanCell = (elements: Pick<ShadcnElements, "L
1616
);
1717
}
1818

19-
return (props: { value: any }) => {
20-
return <ShadcnAutoTableBooleanCell {...props} />;
21-
};
19+
return ShadcnAutoTableBooleanCell;
2220
};
2321

2422
const Checkmark = "✓";

packages/react/src/auto/shadcn/table/cells/ShadcnAutoTableCellRenderer.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,5 @@ export const makeShadcnAutoTableCellRenderer = (elements: ShadcnElements) => {
6868
}
6969
}
7070

71-
return (props: { column: TableColumn; value: ColumnValueType }) => {
72-
return <ShadcnAutoTableCellRenderer {...props} />;
73-
};
71+
return ShadcnAutoTableCellRenderer;
7472
};

packages/react/src/auto/shadcn/table/cells/ShadcnAutoTableDateTimeCell.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,5 @@ export const makeShadcnAutoTableDateTimeCell = (elements: ShadcnAutoTableTextCel
1111
return value instanceof Date ? <ShadcnAutoTableTextCell value={formatLongDateTimeString(value, includeTime)} /> : null;
1212
}
1313

14-
return (props: { value: any; includeTime: boolean }) => {
15-
return <ShadcnAutoTableDateTimeCell {...props} />;
16-
};
14+
return ShadcnAutoTableDateTimeCell;
1715
};

packages/react/src/auto/shadcn/table/cells/ShadcnAutoTableEncryptedStringCell.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ export const makeShadcnAutoTableEncryptedStringCell = (elements: Pick<ShadcnElem
2828
);
2929
}
3030

31-
return (props: { value: any }) => {
32-
return <ShadcnAutoTableEncryptedStringCell {...props} />;
33-
};
31+
return ShadcnAutoTableEncryptedStringCell;
3432
};
3533

3634
const showButtonContent = <Eye />;

packages/react/src/auto/shadcn/table/cells/ShadcnAutoTableFileCell.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ export const makeShadcnAutoTableFileCell = (elements: Pick<ShadcnElements, "Labe
2121
</div>
2222
);
2323
}
24-
return (props: { value: FileValueType }) => {
25-
return <ShadcnAutoTableFileCell {...props} />;
26-
};
24+
25+
return ShadcnAutoTableFileCell;
2726
};
2827

2928
const nonImageFileIndicator = <FileIcon />;

packages/react/src/auto/shadcn/table/cells/ShadcnAutoTableTagCell.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,5 @@ export const makeShadcnAutoTableTagCell = (elements: ShadcnElements) => {
4646
);
4747
}
4848

49-
return (props: { value: any }) => {
50-
return <ShadcnAutoTableTagCell {...props} />;
51-
};
49+
return ShadcnAutoTableTagCell;
5250
};

packages/react/src/auto/shadcn/table/cells/ShadcnAutoTableTextCell.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,5 @@ export const makeShadcnAutoTableTextCell = (elements: ShadcnAutoTableTextCellEle
3333
);
3434
}
3535

36-
return (props: { value: any }) => {
37-
return <ShadcnAutoTableTextCell {...props} />;
38-
};
36+
return ShadcnAutoTableTextCell;
3937
};

0 commit comments

Comments
 (0)