@commercetools-frontend-extensions/export-resources-modal 2.0.0 → 3.0.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.
- package/README.md +89 -59
- package/dist/commercetools-frontend-extensions-export-resources-modal.cjs.dev.js +779 -984
- package/dist/commercetools-frontend-extensions-export-resources-modal.cjs.prod.js +748 -948
- package/dist/commercetools-frontend-extensions-export-resources-modal.esm.js +1015 -0
- package/package.json +49 -32
package/README.md
CHANGED
|
@@ -26,70 +26,101 @@ import { ExportResourcesModal } from '@commercetools-frontend-extensions/export-
|
|
|
26
26
|
|
|
27
27
|
// in case export all the resources
|
|
28
28
|
<ExportResourcesModal
|
|
29
|
-
isOpen={true}
|
|
30
29
|
outputFormat="csv"
|
|
31
30
|
resourceType="category"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
{
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
totalResourcesCount={143}
|
|
32
|
+
exportType="all"
|
|
33
|
+
fields={[
|
|
34
|
+
{
|
|
35
|
+
name: 'key',
|
|
36
|
+
label: 'Category key',
|
|
37
|
+
isRequired: true
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: 'externalId',
|
|
41
|
+
label: 'External id',
|
|
42
|
+
isSelectedByDefault: false,
|
|
43
|
+
},
|
|
44
|
+
{ name: 'createdAt', label: 'Created at' },
|
|
45
|
+
{ name: 'lastModifiedAt', label: 'Last modified at' },
|
|
46
|
+
{ name: 'name', isLocalized: true, label: 'Name' },
|
|
47
|
+
{
|
|
48
|
+
name: 'parent',
|
|
49
|
+
fields: [
|
|
50
|
+
{
|
|
51
|
+
name: 'name',
|
|
52
|
+
isLocalized: true,
|
|
53
|
+
label: 'Parent name',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: 'key',
|
|
57
|
+
label: 'Parent key',
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: 'id',
|
|
63
|
+
label: 'Id',
|
|
64
|
+
isSelectedByDefault: false,
|
|
65
|
+
},
|
|
39
66
|
]}
|
|
40
67
|
renderProperties={()=>(
|
|
41
68
|
<>
|
|
42
69
|
- The category parent is referenced by externalId or key.
|
|
43
70
|
</>
|
|
44
71
|
)}
|
|
45
|
-
|
|
72
|
+
onClose={() => {
|
|
46
73
|
...
|
|
47
74
|
}}
|
|
48
75
|
/>
|
|
49
76
|
|
|
50
|
-
// in case export only resources matching filters & search
|
|
51
|
-
<ExportResourcesModal
|
|
52
|
-
isOpen={true}
|
|
53
|
-
outputFormat="csv"
|
|
54
|
-
resourceType="category"
|
|
55
|
-
allResourcesCount={143}
|
|
56
|
-
exportSelectionType="onlyMatching"
|
|
57
|
-
columns={[
|
|
58
|
-
{ key: 'externalId' },
|
|
59
|
-
{ key: 'createdAt' },
|
|
60
|
-
{ key: 'lastModifiedAt' },
|
|
61
|
-
{ key: 'name', isLocalised: true },
|
|
62
|
-
]}
|
|
63
|
-
renderProperties={()=>(
|
|
64
|
-
<>
|
|
65
|
-
- The category parent is referenced by externalId or key.
|
|
66
|
-
</>
|
|
67
|
-
)}
|
|
68
|
-
closeModal={() => {
|
|
69
|
-
...
|
|
70
|
-
}}
|
|
71
|
-
/>
|
|
72
|
-
|
|
73
77
|
// in case export only selected resources
|
|
74
78
|
<ExportResourcesModal
|
|
75
|
-
isOpen={true}
|
|
76
79
|
outputFormat="csv"
|
|
77
80
|
resourceType="category"
|
|
78
|
-
|
|
79
|
-
|
|
81
|
+
totalResourcesCount={143}
|
|
82
|
+
exportType="selected"
|
|
80
83
|
selectedResourceIds={['02ed9a7d-7c1f-40da-b2b7-4cca6752bf29', '04051276-1641-4e01-a03e-d4de16b7e4eb', 'ac7d9f7b-5c7d-4dd3-b82b-8555ab4a2a6e']}
|
|
81
|
-
|
|
82
|
-
{
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
fields={[
|
|
85
|
+
{
|
|
86
|
+
name: 'key',
|
|
87
|
+
label: 'Category key',
|
|
88
|
+
isRequired: true,
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: 'externalId',
|
|
92
|
+
label: 'External id',
|
|
93
|
+
isSelectedByDefault: false,
|
|
94
|
+
},
|
|
95
|
+
{ name: 'createdAt', label: 'Created at' },
|
|
96
|
+
{ name: 'lastModifiedAt', label: 'Last modified at' },
|
|
97
|
+
{ name: 'name', isLocalized: true, label: 'Name' },
|
|
98
|
+
{
|
|
99
|
+
name: 'parent',
|
|
100
|
+
fields: [
|
|
101
|
+
{
|
|
102
|
+
name: 'name',
|
|
103
|
+
isLocalized: true,
|
|
104
|
+
label: 'Parent name',
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: 'key',
|
|
108
|
+
label: 'Parent key',
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
name: 'id',
|
|
114
|
+
label: 'Id',
|
|
115
|
+
isSelectedByDefault: false,
|
|
116
|
+
},
|
|
86
117
|
]}
|
|
87
118
|
renderProperties={()=>(
|
|
88
119
|
<>
|
|
89
120
|
- The category parent is referenced by externalId or key.
|
|
90
121
|
</>
|
|
91
122
|
)}
|
|
92
|
-
|
|
123
|
+
onClose={() => {
|
|
93
124
|
...
|
|
94
125
|
}}
|
|
95
126
|
/>
|
|
@@ -97,22 +128,21 @@ import { ExportResourcesModal } from '@commercetools-frontend-extensions/export-
|
|
|
97
128
|
|
|
98
129
|
## Properties
|
|
99
130
|
|
|
100
|
-
| Props
|
|
101
|
-
|
|
|
102
|
-
| `
|
|
103
|
-
| `
|
|
104
|
-
| `
|
|
105
|
-
| `
|
|
106
|
-
| `
|
|
107
|
-
| `
|
|
108
|
-
| `
|
|
109
|
-
| `
|
|
110
|
-
| `
|
|
111
|
-
| `
|
|
112
|
-
| `
|
|
113
|
-
| `
|
|
114
|
-
| `
|
|
115
|
-
| `renderProperties` | `function` | ✅ Required | | A prop to render properties that are resource-specific |
|
|
131
|
+
| Props | Type | Required | Default | Description |
|
|
132
|
+
| ------------------------------ | ------------------------------------------------------- | :----------------------------------------------: | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
133
|
+
| `outputFormat` | `string`<br/>Possible values: `csv`, `json` | | `csv` | The file format to export |
|
|
134
|
+
| `onClose` | `function` | ✅ | | Called when the page closes click on overlay, click on close button, press ESC. If the function is not provided, the page cannot be closed by any of the listed options |
|
|
135
|
+
| `resourceType` | `string` | ✅ | | The type of the resource, example: `category`, `product`... |
|
|
136
|
+
| `totalResourcesCount` | `Number` | ✅ | | The count of all resources of identified `resourceType` |
|
|
137
|
+
| `exportType` | `string` <br/>Possible values:<br/>`all` and `selected` | | `all` | The type of export, so either export `all` resources or export only `selected` resources |
|
|
138
|
+
| `selectedResourceIds` | `array` | (✅) Required only if `exportType` is `selected` | | Array of Ids of the selected resources |
|
|
139
|
+
| `fields` | `array` | ✅ | | Array of the fields to export. The fields must align with the [commercetools GraphQL schema](https://docs.commercetools.com/getting-started/using-graphql#how-to-structure-graphql-requests) |
|
|
140
|
+
| `fields[].name` | `string` | ✅ | | A string that represents the unique identifier for each field |
|
|
141
|
+
| `fields[].label` | `string` | | | The label of the field to be shown in the export modal |
|
|
142
|
+
| `fields[].isRequired` | `boolean` | | `false` | `isRequired` field indicates whether a field is required for the export process. If `true` the field will be selected by default and cannot be deselected by the user. This is useful for fields that are essential for the export process. Fields marked as required will have a `*` appended to their label in the UI |
|
|
143
|
+
| `fields[].isSelectedByDefault` | `boolean` | | `true` | This field is a part of the `fields` array is used to control the default state of the corresponding checkbox in the UI. If `isSelectedByDefault` is set to true, the checkbox for that particular field will be checked by default when the component loads. The default value of this attribute is `true` which means unless explicitly set to `false`, the checkbox for the field will be checked on initial load. |
|
|
144
|
+
| `fields[].isLocalized` | `boolean` | | `false` | The field is a localized field |
|
|
145
|
+
| `renderProperties` | `function` | | | A prop to render properties that are resource-specific |
|
|
116
146
|
|
|
117
147
|
## Releasing
|
|
118
148
|
|
|
@@ -120,7 +150,7 @@ This package uses [`changesets`](https://github.com/atlassian/changesets) in ord
|
|
|
120
150
|
|
|
121
151
|
In case you want to publish a new version with the latest changes you need to:
|
|
122
152
|
|
|
123
|
-
1. Add a changeset with `
|
|
153
|
+
1. Add a changeset with `pnpm changeset` and select `@commercetools-frontend-extensions/export-resources-modal` as the modified package.
|
|
124
154
|
2. Some options would be appear in order to do the release:
|
|
125
155
|
- `patch`: use this release for fixes or small changes
|
|
126
156
|
- `minor`: use this release for depenency upgrades or medium changes
|
|
@@ -136,7 +166,7 @@ In case you want to publish a new version with the latest changes you need to:
|
|
|
136
166
|
|
|
137
167
|
The repo is configured with an integration with Transifex. The process for i18n is the same as the Merchant Center uses.
|
|
138
168
|
|
|
139
|
-
`
|
|
169
|
+
`pnpm i18n:build` for adding the new keys to transifex.
|
|
140
170
|
|
|
141
171
|
Once the PR gets merged to `main` transifex will receive a notification with new keys that need to be translated (that's why is important that `description` and `defaultMessage` are descriptive enough).
|
|
142
172
|
|