@vendure/dashboard 3.3.8 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/README.md +62 -0
  2. package/dist/plugin/api/api-extensions.d.ts +1 -0
  3. package/dist/plugin/api/api-extensions.js +38 -0
  4. package/dist/plugin/api/metrics.resolver.d.ts +8 -0
  5. package/dist/plugin/api/metrics.resolver.js +40 -0
  6. package/dist/plugin/config/metrics-strategies.d.ts +39 -0
  7. package/dist/plugin/config/metrics-strategies.js +74 -0
  8. package/dist/plugin/constants.d.ts +4 -3
  9. package/dist/plugin/constants.js +10 -277
  10. package/dist/plugin/dashboard.plugin.d.ts +95 -0
  11. package/dist/plugin/dashboard.plugin.js +168 -0
  12. package/dist/plugin/index.d.ts +2 -1
  13. package/dist/plugin/index.js +18 -1
  14. package/dist/plugin/package.json +3 -0
  15. package/dist/plugin/service/metrics.service.d.ts +15 -0
  16. package/dist/plugin/service/metrics.service.js +145 -0
  17. package/dist/plugin/types.d.ts +20 -37
  18. package/dist/plugin/types.js +13 -1
  19. package/dist/vite/constants.d.ts +5 -0
  20. package/dist/vite/constants.js +277 -0
  21. package/dist/vite/index.d.ts +1 -0
  22. package/dist/vite/index.js +1 -0
  23. package/dist/vite/types.d.ts +40 -0
  24. package/dist/vite/utils/config-loader.js +1 -0
  25. package/dist/{plugin → vite}/utils/plugin-discovery.js +1 -1
  26. package/dist/vite/utils/ui-config.d.ts +3 -0
  27. package/dist/vite/utils/ui-config.js +30 -0
  28. package/dist/vite/vite-plugin-ui-config.d.ts +123 -0
  29. package/dist/{plugin → vite}/vite-plugin-ui-config.js +3 -11
  30. package/dist/{plugin → vite}/vite-plugin-vendure-dashboard.js +1 -1
  31. package/index.html +1 -1
  32. package/package.json +16 -7
  33. package/src/app/app-providers.tsx +1 -1
  34. package/src/app/routes/_authenticated/_collections/collections_.$id.tsx +1 -1
  35. package/src/app/routes/_authenticated/_facets/components/facet-values-table.tsx +20 -35
  36. package/src/app/routes/_authenticated/_facets/facets.graphql.ts +40 -0
  37. package/src/app/routes/_authenticated/_facets/facets_.$facetId.values_.$id.tsx +147 -0
  38. package/src/app/routes/_authenticated/_orders/components/order-history/order-history.tsx +380 -33
  39. package/src/app/routes/_authenticated/_products/components/option-value-input.tsx +1 -1
  40. package/src/app/routes/_authenticated/_system/healthchecks.tsx +1 -1
  41. package/src/app/routes/_authenticated/_system/job-queue.tsx +1 -0
  42. package/src/app/routes/_authenticated/index.tsx +2 -2
  43. package/src/app/routes/_authenticated.tsx +1 -1
  44. package/src/lib/components/data-input/rich-text-input.tsx +14 -8
  45. package/src/lib/components/data-table/data-table-bulk-actions.tsx +17 -4
  46. package/src/lib/components/layout/app-layout.tsx +2 -7
  47. package/src/lib/components/layout/channel-switcher.tsx +166 -57
  48. package/src/lib/components/layout/dev-mode-indicator.tsx +18 -0
  49. package/src/lib/components/layout/language-dialog.tsx +2 -1
  50. package/src/lib/components/layout/manage-languages-dialog.tsx +77 -40
  51. package/src/lib/components/layout/nav-item-wrapper.tsx +107 -0
  52. package/src/lib/components/layout/nav-main.tsx +196 -107
  53. package/src/lib/components/login/login-form.tsx +80 -45
  54. package/src/lib/components/shared/asset/asset-bulk-actions.tsx +19 -4
  55. package/src/lib/components/shared/asset/asset-gallery.tsx +2 -2
  56. package/src/lib/components/shared/detail-page-button.tsx +42 -0
  57. package/src/lib/components/shared/history-timeline/history-entry-date.tsx +37 -0
  58. package/src/lib/components/shared/history-timeline/history-entry.tsx +135 -65
  59. package/src/lib/components/shared/history-timeline/history-note-input.tsx +4 -4
  60. package/src/lib/components/shared/history-timeline/history-timeline.tsx +7 -54
  61. package/src/lib/components/shared/translatable-form-field.tsx +16 -2
  62. package/src/lib/framework/defaults.ts +4 -10
  63. package/src/lib/framework/extension-api/define-dashboard-extension.ts +4 -0
  64. package/src/lib/framework/extension-api/extension-api-types.ts +11 -2
  65. package/src/lib/framework/extension-api/logic/index.ts +1 -0
  66. package/src/lib/framework/extension-api/logic/login.ts +17 -0
  67. package/src/lib/framework/extension-api/logic/navigation.ts +1 -0
  68. package/src/lib/framework/extension-api/types/data-table.ts +12 -3
  69. package/src/lib/framework/extension-api/types/detail-forms.ts +13 -0
  70. package/src/lib/framework/extension-api/types/form-components.ts +11 -0
  71. package/src/lib/framework/extension-api/types/index.ts +1 -0
  72. package/src/lib/framework/extension-api/types/layout.ts +3 -6
  73. package/src/lib/framework/extension-api/types/login.ts +96 -0
  74. package/src/lib/framework/extension-api/types/navigation.ts +57 -0
  75. package/src/lib/framework/extension-api/types/widgets.ts +0 -4
  76. package/src/lib/framework/extension-api/use-login-extensions.ts +26 -0
  77. package/src/lib/framework/layout-engine/dev-mode-button.tsx +24 -0
  78. package/src/lib/framework/layout-engine/location-wrapper.tsx +5 -12
  79. package/src/lib/framework/registry/global-registry.ts +4 -0
  80. package/src/lib/framework/registry/registry-types.ts +2 -0
  81. package/src/lib/graphql/api.ts +25 -3
  82. package/src/lib/graphql/graphql-env.d.ts +28 -28
  83. package/src/lib/graphql/settings-store-operations.ts +17 -0
  84. package/src/lib/hooks/use-floating-bulk-actions.ts +82 -0
  85. package/src/lib/hooks/use-local-format.ts +20 -5
  86. package/src/lib/index.ts +2 -1
  87. package/src/lib/providers/channel-provider.tsx +13 -11
  88. package/src/lib/providers/user-settings.tsx +78 -3
  89. package/src/lib/virtual.d.ts +26 -2
  90. package/src/vite-env.d.ts +2 -0
  91. package/vite/utils/plugin-discovery.ts +1 -1
  92. package/vite/utils/ui-config.ts +30 -42
  93. package/vite/vite-plugin-ui-config.ts +119 -17
  94. package/vite/vite-plugin-vendure-dashboard.ts +1 -1
  95. package/dist/plugin/utils/ui-config.d.ts +0 -3
  96. package/dist/plugin/utils/ui-config.js +0 -34
  97. package/dist/plugin/vite-plugin-ui-config.d.ts +0 -15
  98. package/src/app/routes/_authenticated/_facets/components/add-facet-value-dialog.tsx +0 -146
  99. package/src/lib/components/shared/rich-text-editor.tsx +0 -0
  100. /package/dist/{plugin/utils/ast-utils.spec.d.ts → vite/types.js} +0 -0
  101. /package/dist/{plugin → vite}/utils/ast-utils.d.ts +0 -0
  102. /package/dist/{plugin → vite}/utils/ast-utils.js +0 -0
  103. /package/dist/{plugin/utils/config-loader.d.ts → vite/utils/ast-utils.spec.d.ts} +0 -0
  104. /package/dist/{plugin → vite}/utils/ast-utils.spec.js +0 -0
  105. /package/dist/{plugin → vite}/utils/compiler.d.ts +0 -0
  106. /package/dist/{plugin → vite}/utils/compiler.js +0 -0
  107. /package/dist/{plugin/utils/config-loader.js → vite/utils/config-loader.d.ts} +0 -0
  108. /package/dist/{plugin → vite}/utils/logger.d.ts +0 -0
  109. /package/dist/{plugin → vite}/utils/logger.js +0 -0
  110. /package/dist/{plugin → vite}/utils/plugin-discovery.d.ts +0 -0
  111. /package/dist/{plugin → vite}/utils/schema-generator.d.ts +0 -0
  112. /package/dist/{plugin → vite}/utils/schema-generator.js +0 -0
  113. /package/dist/{plugin → vite}/utils/tsconfig-utils.d.ts +0 -0
  114. /package/dist/{plugin → vite}/utils/tsconfig-utils.js +0 -0
  115. /package/dist/{plugin → vite}/vite-plugin-admin-api-schema.d.ts +0 -0
  116. /package/dist/{plugin → vite}/vite-plugin-admin-api-schema.js +0 -0
  117. /package/dist/{plugin → vite}/vite-plugin-config-loader.d.ts +0 -0
  118. /package/dist/{plugin → vite}/vite-plugin-config-loader.js +0 -0
  119. /package/dist/{plugin → vite}/vite-plugin-config.d.ts +0 -0
  120. /package/dist/{plugin → vite}/vite-plugin-config.js +0 -0
  121. /package/dist/{plugin → vite}/vite-plugin-dashboard-metadata.d.ts +0 -0
  122. /package/dist/{plugin → vite}/vite-plugin-dashboard-metadata.js +0 -0
  123. /package/dist/{plugin → vite}/vite-plugin-gql-tada.d.ts +0 -0
  124. /package/dist/{plugin → vite}/vite-plugin-gql-tada.js +0 -0
  125. /package/dist/{plugin → vite}/vite-plugin-tailwind-source.d.ts +0 -0
  126. /package/dist/{plugin → vite}/vite-plugin-tailwind-source.js +0 -0
  127. /package/dist/{plugin → vite}/vite-plugin-theme.d.ts +0 -0
  128. /package/dist/{plugin → vite}/vite-plugin-theme.js +0 -0
  129. /package/dist/{plugin → vite}/vite-plugin-transform-index.d.ts +0 -0
  130. /package/dist/{plugin → vite}/vite-plugin-transform-index.js +0 -0
  131. /package/dist/{plugin → vite}/vite-plugin-vendure-dashboard.d.ts +0 -0
@@ -1,13 +1,13 @@
1
+ import { DetailPageButton } from '@/vdb/components/shared/detail-page-button.js';
1
2
  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';
4
3
  import { addCustomFields } from '@/vdb/framework/document-introspection/add-custom-fields.js';
5
4
  import { graphql } from '@/vdb/graphql/graphql.js';
6
5
  import { Trans } from '@/vdb/lib/trans.js';
6
+ import { Link } from '@tanstack/react-router';
7
+ import { Button } from '@/vdb/components/ui/button.js';
7
8
  import { ColumnFiltersState, SortingState } from '@tanstack/react-table';
9
+ import { PlusIcon } from 'lucide-react';
8
10
  import { useRef, useState } from 'react';
9
- import { AddFacetValueDialog } from './add-facet-value-dialog.js';
10
- import { EditFacetValue } from './edit-facet-value.js';
11
11
  import { deleteFacetValuesDocument } from '../facets.graphql.js';
12
12
 
13
13
  export const facetValueListDocument = graphql(`
@@ -82,41 +82,26 @@ export function FacetValuesTable({ facetId, registerRefresher }: Readonly<FacetV
82
82
  },
83
83
  };
84
84
  }}
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
+ ),
110
95
  },
111
96
  }}
112
97
  />
113
98
  <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>
120
105
  </div>
121
106
  </>
122
107
  );
@@ -141,3 +141,43 @@ export const deleteFacetValuesDocument = graphql(`
141
141
  }
142
142
  }
143
143
  `);
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,0 +1,147 @@
1
+ import { ErrorPage } from '@/vdb/components/shared/error-page.js';
2
+ import { FormFieldWrapper } from '@/vdb/components/shared/form-field-wrapper.js';
3
+ import { PermissionGuard } from '@/vdb/components/shared/permission-guard.js';
4
+ import { TranslatableFormFieldWrapper } from '@/vdb/components/shared/translatable-form-field.js';
5
+ import { Button } from '@/vdb/components/ui/button.js';
6
+ import { Input } from '@/vdb/components/ui/input.js';
7
+ import { NEW_ENTITY_PATH } from '@/vdb/constants.js';
8
+ import {
9
+ CustomFieldsPageBlock,
10
+ DetailFormGrid,
11
+ Page,
12
+ PageActionBar,
13
+ PageActionBarRight,
14
+ PageBlock,
15
+ PageLayout,
16
+ PageTitle,
17
+ } from '@/vdb/framework/layout-engine/page-layout.js';
18
+ import { detailPageRouteLoader } from '@/vdb/framework/page/detail-page-route-loader.js';
19
+ import { useDetailPage } from '@/vdb/framework/page/use-detail-page.js';
20
+ import { Trans, useLingui } from '@/vdb/lib/trans.js';
21
+ import { createFileRoute, useNavigate } from '@tanstack/react-router';
22
+ import { toast } from 'sonner';
23
+ import {
24
+ createFacetValueDocument,
25
+ facetValueDetailDocument,
26
+ updateFacetValueDocument,
27
+ } from './facets.graphql.js';
28
+ import { PageBreadcrumb } from '@/vdb/components/layout/generated-breadcrumbs.js';
29
+
30
+ const pageId = 'facet-value-detail';
31
+
32
+ export const Route = createFileRoute('/_authenticated/_facets/facets_/$facetId/values_/$id')({
33
+ component: FacetValueDetailPage,
34
+ loader: detailPageRouteLoader({
35
+ pageId,
36
+ queryDocument: facetValueDetailDocument,
37
+ breadcrumb(isNew, entity) {
38
+ const facetName = entity?.facet.name ?? 'Facet Value';
39
+ const breadcrumb: PageBreadcrumb[] = [{ path: '/facets', label: 'Facets' }];
40
+ if (isNew) {
41
+ breadcrumb.push(<Trans>New facet value</Trans>);
42
+ } else if (entity) {
43
+ breadcrumb.push({ path: `/facets/${entity?.facet.id}`, label: facetName }, entity.name);
44
+ }
45
+ return breadcrumb;
46
+ },
47
+ }),
48
+ errorComponent: ({ error }) => <ErrorPage message={error.message} />,
49
+ });
50
+
51
+ function FacetValueDetailPage() {
52
+ const params = Route.useParams();
53
+ const navigate = useNavigate();
54
+ const creatingNewEntity = params.id === NEW_ENTITY_PATH;
55
+ const { i18n } = useLingui();
56
+
57
+ const { form, submitHandler, entity, isPending, resetForm } = useDetailPage({
58
+ pageId,
59
+ queryDocument: facetValueDetailDocument,
60
+ createDocument: createFacetValueDocument,
61
+ updateDocument: updateFacetValueDocument,
62
+ setValuesForUpdate: entity => {
63
+ return {
64
+ id: entity.id,
65
+ code: entity.code,
66
+ name: entity.name,
67
+ translations: entity.translations.map(translation => ({
68
+ id: translation.id,
69
+ languageCode: translation.languageCode,
70
+ name: translation.name,
71
+ customFields: (translation as any).customFields,
72
+ })),
73
+ customFields: entity.customFields as any,
74
+ };
75
+ },
76
+ transformCreateInput: (value): any => {
77
+ return {
78
+ ...value,
79
+ facetId: params.facetId,
80
+ };
81
+ },
82
+ params: { id: params.id },
83
+ onSuccess: async data => {
84
+ toast(i18n.t('Successfully updated facet value'));
85
+ resetForm();
86
+ const created = Array.isArray(data) ? data[0] : data;
87
+ if (creatingNewEntity && created) {
88
+ await navigate({ to: `../$id`, params: { id: (created as any).id } });
89
+ }
90
+ },
91
+ onError: err => {
92
+ toast(i18n.t('Failed to update facet value'), {
93
+ description: err instanceof Error ? err.message : 'Unknown error',
94
+ });
95
+ },
96
+ });
97
+
98
+ return (
99
+ <Page pageId={pageId} form={form} submitHandler={submitHandler} entity={entity}>
100
+ <PageTitle>
101
+ {creatingNewEntity ? <Trans>New facet value</Trans> : ((entity as any)?.name ?? '')}
102
+ </PageTitle>
103
+ <PageActionBar>
104
+ <PageActionBarRight>
105
+ <PermissionGuard requires={['UpdateProduct', 'UpdateCatalog']}>
106
+ <Button
107
+ type="submit"
108
+ disabled={!form.formState.isDirty || !form.formState.isValid || isPending}
109
+ >
110
+ <Trans>Update</Trans>
111
+ </Button>
112
+ </PermissionGuard>
113
+ </PageActionBarRight>
114
+ </PageActionBar>
115
+ <PageLayout>
116
+ <PageBlock column="side" blockId="facet-info">
117
+ {entity?.facet && (
118
+ <div className="space-y-2">
119
+ <div className="text-sm font-medium">
120
+ <Trans>Facet</Trans>
121
+ </div>
122
+ <div className="text-sm text-muted-foreground">{entity?.facet.name}</div>
123
+ <div className="text-xs text-muted-foreground">{entity?.facet.code}</div>
124
+ </div>
125
+ )}
126
+ </PageBlock>
127
+ <PageBlock column="main" blockId="main-form">
128
+ <DetailFormGrid>
129
+ <TranslatableFormFieldWrapper
130
+ control={form.control}
131
+ name="name"
132
+ label={<Trans>Name</Trans>}
133
+ render={({ field }) => <Input {...field} />}
134
+ />
135
+ <FormFieldWrapper
136
+ control={form.control}
137
+ name="code"
138
+ label={<Trans>Code</Trans>}
139
+ render={({ field }) => <Input {...field} />}
140
+ />
141
+ </DetailFormGrid>
142
+ </PageBlock>
143
+ <CustomFieldsPageBlock column="main" entityType="FacetValue" control={form.control} />
144
+ </PageLayout>
145
+ </Page>
146
+ );
147
+ }