@commercetools-frontend-extensions/export-resources-modal 3.2.1 → 3.3.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 CHANGED
@@ -24,13 +24,13 @@ Export Resources Modal is an internal component used to export resources into cs
24
24
  ```js
25
25
  import { ExportResourcesModal } from '@commercetools-frontend-extensions/export-resources-modal';
26
26
 
27
- // in case export all the resources
27
+ // Use case: Exporting all resources
28
28
  <ExportResourcesModal
29
29
  isOpen={true}
30
+ exportType="all"
30
31
  outputFormat="csv"
31
32
  resourceType="category"
32
33
  totalResourcesCount={143}
33
- exportType="all"
34
34
  fields={[
35
35
  {
36
36
  name: 'key',
@@ -65,6 +65,36 @@ import { ExportResourcesModal } from '@commercetools-frontend-extensions/export-
65
65
  isSelectedByDefault: false,
66
66
  },
67
67
  ]}
68
+ customFields={[
69
+ {
70
+ typeKey: 'general-category-attributes',
71
+ typeLabel: 'General category attributes',
72
+ fields: [
73
+ {
74
+ name: 'season',
75
+ label: 'Season',
76
+ },
77
+ {
78
+ name: 'target-audience',
79
+ label: 'Target audience',
80
+ },
81
+ ],
82
+ },
83
+ {
84
+ typeKey: 'book-category-attributes',
85
+ typeLabel: 'Book category attributes',
86
+ fields: [
87
+ {
88
+ name: 'genre',
89
+ label: 'Genre',
90
+ },
91
+ {
92
+ name: 'age-group',
93
+ label: 'Age group',
94
+ },
95
+ ],
96
+ }
97
+ ]}
68
98
  renderProperties={()=>(
69
99
  <>
70
100
  - The category parent is referenced by externalId or key.
@@ -75,13 +105,12 @@ import { ExportResourcesModal } from '@commercetools-frontend-extensions/export-
75
105
  }}
76
106
  />
77
107
 
78
- // in case export only selected resources
108
+ // Use case: Exporting only selected resources by their IDs
79
109
  <ExportResourcesModal
80
110
  isOpen={true}
111
+ exportType="selected"
81
112
  outputFormat="csv"
82
113
  resourceType="category"
83
- totalResourcesCount={143}
84
- exportType="selected"
85
114
  selectedResourceIds={['02ed9a7d-7c1f-40da-b2b7-4cca6752bf29', '04051276-1641-4e01-a03e-d4de16b7e4eb', 'ac7d9f7b-5c7d-4dd3-b82b-8555ab4a2a6e']}
86
115
  fields={[
87
116
  {
@@ -117,6 +146,36 @@ import { ExportResourcesModal } from '@commercetools-frontend-extensions/export-
117
146
  isSelectedByDefault: false,
118
147
  },
119
148
  ]}
149
+ customFields={[
150
+ {
151
+ typeKey: 'general-category-attributes',
152
+ typeLabel: 'General category attributes',
153
+ fields: [
154
+ {
155
+ name: 'season',
156
+ label: 'Season',
157
+ },
158
+ {
159
+ name: 'target-audience',
160
+ label: 'Target audience',
161
+ },
162
+ ],
163
+ },
164
+ {
165
+ typeKey: 'book-category-attributes',
166
+ typeLabel: 'Book category attributes',
167
+ fields: [
168
+ {
169
+ name: 'genre',
170
+ label: 'Genre',
171
+ },
172
+ {
173
+ name: 'age-group',
174
+ label: 'Age group',
175
+ },
176
+ ],
177
+ }
178
+ ]}
120
179
  renderProperties={()=>(
121
180
  <>
122
181
  - The category parent is referenced by externalId or key.
@@ -130,23 +189,29 @@ import { ExportResourcesModal } from '@commercetools-frontend-extensions/export-
130
189
 
131
190
  ## Properties
132
191
 
133
- | Props | Type | Required | Default | Description |
134
- | ------------------------------ | ------------------------------------------------------- | :----------------------------------------------: | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
135
- | `isOpen` | `boolean` | | `false` | Controls whether the export modal is open or closed |
136
- | `outputFormat` | `string`<br/>Possible values: `csv`, `json` | | `csv` | The file format to export |
137
- | `onExportSuccess` | `function` | | | Callback function that is called when the export operation is successful |
138
- | `onClose` | `function` | | | Callback function invoked when the modal is requested to close (on overlay click, close button click or `ESC` press). This function is also called after an export operation regardless of its success or failure |
139
- | `resourceType` | `string` | | | The type of the resource, example: `category`, `product`... |
140
- | `totalResourcesCount` | `Number` | | | The count of all resources of identified `resourceType` |
141
- | `exportType` | `string` <br/>Possible values:<br/>`all` and `selected` | | `all` | The type of export, so either export `all` resources or export only `selected` resources |
142
- | `selectedResourceIds` | `array` | (✅) Required only if `exportType` is `selected` | | Array of Ids of the selected resources |
143
- | `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) |
144
- | `fields[].name` | `string` | | | A string that represents the unique identifier for each field |
145
- | `fields[].label` | `string` | | | The label of the field to be shown in the export modal |
146
- | `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 |
147
- | `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. |
148
- | `fields[].isLocalized` | `boolean` | | `false` | The field is a localized field |
149
- | `renderProperties` | `function` | | | A prop to render properties that are resource-specific |
192
+ | Props | Type | Required | Default | Description |
193
+ | ------------------------------- | ------------------------------------------------------- | :--------------------------------------------------: | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
194
+ | `isOpen` | `boolean` | | `false` | Controls whether the export modal is open or closed |
195
+ | `outputFormat` | `string`<br/>Possible values: `csv`, `json` | | `csv` | The file format to export |
196
+ | `onExportSuccess` | `function` | | | Callback function that is called when the export operation is successful |
197
+ | `onClose` | `function` | | | Callback function invoked when the modal is requested to close (on overlay click, close button click or `ESC` press). This function is also called after an export operation regardless of its success or failure |
198
+ | `resourceType` | `string` | | | The type of the resource, example: `category`, `product`... |
199
+ | `totalResourcesCount` | `Number` | () Required only if the `exportType` is `all` | | The count of all resources of identified `resourceType` |
200
+ | `exportType` | `string` <br/>Possible values:<br/>`all` and `selected` | | `all` | The type of export, so either export `all` resources or export only `selected` resources |
201
+ | `selectedResourceIds` | `array` | (✅) Required only if the `exportType` is `selected` | | Array of Ids of the selected resources |
202
+ | `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) |
203
+ | `fields[].name` | `string` | | | A string that represents the unique identifier for each field |
204
+ | `fields[].label` | `string` || | The label of the field to be shown in the export modal |
205
+ | `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 |
206
+ | `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. |
207
+ | `fields[].isLocalized` | `boolean` | | `false` | The field is a localized field |
208
+ | `customFields` | `array` | | | Array of objects, each representing a group of custom fields defined under a specific custom type. |
209
+ | `customFields[].typeKey` | `string` | | | The unique identifier for the type. |
210
+ | `customFields[].typeLabel` | `string` | | | The label of the custom field type to be shown in the export modal. This label should match the name of the custom field type in the selected locale. |
211
+ | `customFields[].fields` | `array` | | | An array of objects with custom fields defined under the type represented by `typeKey`. |
212
+ | `customFields[].fields[].name` | `string` | | | The name of the custom field. |
213
+ | `customFields[].fields[].label` | `string` | | | The label of the custom field to be shown in the export modal. This should match the label of the custom field in the selected locale. |
214
+ | `renderProperties` | `function` | | | A prop to render properties that are resource-specific |
150
215
 
151
216
  ## Releasing
152
217