Skip to content

Commit 16c2e5e

Browse files
fix(dashboard): Improved facet value editing
1 parent b635d23 commit 16c2e5e

File tree

7 files changed

+251
-210
lines changed

7 files changed

+251
-210
lines changed

packages/dashboard/src/app/routes/_authenticated/_facets/components/add-facet-value-dialog.tsx

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

packages/dashboard/src/app/routes/_authenticated/_facets/components/facet-values-table.tsx

Lines changed: 20 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1+
import { DetailPageButton } from '@/vdb/components/shared/detail-page-button.js';
12
import { PaginatedListDataTable } from '@/vdb/components/shared/paginated-list-data-table.js';
2-
import { Button } from '@/vdb/components/ui/button.js';
3-
import { Popover, PopoverContent, PopoverTrigger } from '@/vdb/components/ui/popover.js';
43
import { addCustomFields } from '@/vdb/framework/document-introspection/add-custom-fields.js';
54
import { graphql } from '@/vdb/graphql/graphql.js';
65
import { Trans } from '@/vdb/lib/trans.js';
6+
import { Link } from '@tanstack/react-router';
7+
import { Button } from '@/vdb/components/ui/button.js';
78
import { ColumnFiltersState, SortingState } from '@tanstack/react-table';
9+
import { PlusIcon } from 'lucide-react';
810
import { useRef, useState } from 'react';
9-
import { AddFacetValueDialog } from './add-facet-value-dialog.js';
10-
import { EditFacetValue } from './edit-facet-value.js';
1111
import { deleteFacetValuesDocument } from '../facets.graphql.js';
1212

1313
export const facetValueListDocument = graphql(`
@@ -82,41 +82,26 @@ export function FacetValuesTable({ facetId, registerRefresher }: Readonly<FacetV
8282
},
8383
};
8484
}}
85-
additionalColumns={{
86-
actions: {
87-
header: 'Actions',
88-
cell: ({ row }) => {
89-
const [open, setOpen] = useState(false);
90-
const facetValue = row.original;
91-
return (
92-
<Popover open={open} onOpenChange={setOpen}>
93-
<PopoverTrigger asChild>
94-
<Button type="button" variant="outline" size="sm">
95-
<Trans>Edit</Trans>
96-
</Button>
97-
</PopoverTrigger>
98-
<PopoverContent className="w-80">
99-
<EditFacetValue
100-
facetValueId={facetValue.id}
101-
onSuccess={() => {
102-
setOpen(false);
103-
refreshRef.current?.();
104-
}}
105-
/>
106-
</PopoverContent>
107-
</Popover>
108-
);
109-
},
85+
customizeColumns={{
86+
name: {
87+
header: 'Name',
88+
cell: ({ row }) => (
89+
<DetailPageButton
90+
id={row.original.id}
91+
label={row.original.name}
92+
href={`/facets/${facetId}/values/${row.original.id}`}
93+
/>
94+
),
11095
},
11196
}}
11297
/>
11398
<div className="mt-4">
114-
<AddFacetValueDialog
115-
facetId={facetId}
116-
onSuccess={() => {
117-
refreshRef.current?.();
118-
}}
119-
/>
99+
<Button asChild variant="outline">
100+
<Link to="./values/new">
101+
<PlusIcon />
102+
<Trans>Add facet value</Trans>
103+
</Link>
104+
</Button>
120105
</div>
121106
</>
122107
);

packages/dashboard/src/app/routes/_authenticated/_facets/facets.graphql.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,3 +141,43 @@ export const deleteFacetValuesDocument = graphql(`
141141
}
142142
}
143143
`);
144+
145+
export const facetValueDetailDocument = graphql(`
146+
query FacetValueDetail($id: ID!) {
147+
facetValue(id: $id) {
148+
id
149+
createdAt
150+
updatedAt
151+
name
152+
code
153+
languageCode
154+
translations {
155+
id
156+
languageCode
157+
name
158+
}
159+
facet {
160+
id
161+
name
162+
code
163+
}
164+
customFields
165+
}
166+
}
167+
`);
168+
169+
export const createFacetValueDocument = graphql(`
170+
mutation CreateFacetValue($input: CreateFacetValueInput!) {
171+
createFacetValue(input: $input) {
172+
id
173+
}
174+
}
175+
`);
176+
177+
export const updateFacetValueDocument = graphql(`
178+
mutation UpdateFacetValue($input: UpdateFacetValueInput!) {
179+
updateFacetValue(input: $input) {
180+
id
181+
}
182+
}
183+
`);

0 commit comments

Comments
 (0)