Skip to content

Commit 41047b3

Browse files
authored
feat(dashboard): configurable product views (#13408)
* feat: add a reusable configurable data table * fix: cleanup * fix: cleanup * fix: cache invalidation * fix: test * fix: add configurable products * feat: add configurable product table * fix: build errors+table style * fix: sticky header column * add translations * fix: cleanup counterenderer * fix: formatting * fix: client still skips nulls * fix: test * fix: cleanup * fix: revert client bracket format * fix: better typing * fix: add placeholder data to product list
1 parent 9563ee4 commit 41047b3

File tree

22 files changed

+865
-433
lines changed

22 files changed

+865
-433
lines changed

integration-tests/http/__tests__/views/admin/columns.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ medusaIntegrationTestRunner({
224224
id: "title",
225225
name: "Title",
226226
field: "title",
227-
default_visible: true,
227+
default_visible: false,
228228
})
229229

230230
const handleColumn = response.data.columns.find(
@@ -235,7 +235,7 @@ medusaIntegrationTestRunner({
235235
id: "handle",
236236
name: "Handle",
237237
field: "handle",
238-
default_visible: true,
238+
default_visible: false,
239239
})
240240
})
241241
})

packages/admin/dashboard/src/components/data-table/data-table.tsx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,14 @@ interface DataTableProps<TData> {
6666
filters?: DataTableFilter[]
6767
commands?: DataTableCommand[]
6868
action?: DataTableActionProps
69+
actions?: DataTableActionProps[]
6970
actionMenu?: DataTableActionMenuProps
7071
rowCount?: number
7172
getRowId: (row: TData) => string
7273
enablePagination?: boolean
7374
enableSearch?: boolean
7475
autoFocusSearch?: boolean
76+
enableFilterMenu?: boolean
7577
rowHref?: (row: TData) => string
7678
emptyState?: DataTableEmptyStateProps
7779
heading?: string
@@ -105,12 +107,14 @@ export const DataTable = <TData,>({
105107
filters,
106108
commands,
107109
action,
110+
actions,
108111
actionMenu,
109112
getRowId,
110113
rowCount = 0,
111114
enablePagination = true,
112115
enableSearch = true,
113116
autoFocusSearch = false,
117+
enableFilterMenu,
114118
rowHref,
115119
heading,
116120
subHeading,
@@ -138,6 +142,7 @@ export const DataTable = <TData,>({
138142
const effectiveEnableViewSelector = isViewConfigEnabled && enableViewSelector
139143

140144
const enableFiltering = filters && filters.length > 0
145+
const showFilterMenu = enableFilterMenu !== undefined ? enableFilterMenu : enableFiltering
141146
const enableCommands = commands && commands.length > 0
142147
const enableSorting = columns.some((column) => column.enableSorting)
143148

@@ -381,7 +386,7 @@ export const DataTable = <TData,>({
381386
)}
382387
</div>
383388
<div className="flex items-center gap-x-2">
384-
{enableFiltering && <UiDataTable.FilterMenu />}
389+
{showFilterMenu && <UiDataTable.FilterMenu />}
385390
{enableSorting && <UiDataTable.SortingMenu />}
386391
{enableSearch && (
387392
<div className="w-full md:w-auto">
@@ -392,7 +397,8 @@ export const DataTable = <TData,>({
392397
</div>
393398
)}
394399
{actionMenu && <ActionMenu variant="primary" {...actionMenu} />}
395-
{action && <DataTableAction {...action} />}
400+
{actions && actions.length > 0 && <DataTableActions actions={actions} />}
401+
{!actions && action && <DataTableAction {...action} />}
396402
</div>
397403
</div>
398404
</UiDataTable.Toolbar>
@@ -505,3 +511,13 @@ const DataTableAction = ({
505511
)
506512
}
507513

514+
const DataTableActions = ({ actions }: { actions: DataTableActionProps[] }) => {
515+
return (
516+
<div className="flex items-center gap-x-2">
517+
{actions.map((action, index) => (
518+
<DataTableAction key={index} {...action} />
519+
))}
520+
</div>
521+
)
522+
}
523+

0 commit comments

Comments
 (0)