@commercetools-frontend-extensions/export-resources-modal 1.5.3 → 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 CHANGED
@@ -27,95 +27,100 @@ import { ExportResourcesModal } from '@commercetools-frontend-extensions/export-
27
27
  // in case export all the resources
28
28
  <ExportResourcesModal
29
29
  outputFormat="csv"
30
- showExportSelection={true}
31
30
  resourceType="category"
32
- allResourcesCount={143}
33
- exportSelectionType="allResources"
31
+ totalResourcesCount={143}
32
+ exportType="all"
34
33
  fields={[
35
- { key: 'externalId' },
36
- { key: 'createdAt' },
37
- { key: 'lastModifiedAt' },
38
- { key: 'name', isLocalized: true },
39
- { key: 'parent', fields: [
40
- {
41
- key: 'name',
42
- isLocalized: true
43
- }
44
- ]},
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
+ },
45
66
  ]}
46
67
  renderProperties={()=>(
47
68
  <>
48
69
  - The category parent is referenced by externalId or key.
49
70
  </>
50
71
  )}
51
- closeModal={() => {
72
+ onClose={() => {
52
73
  ...
53
74
  }}
54
75
  />
55
76
 
56
- // in case export only resources matching filters & search
57
- <ExportResourcesModal
58
- outputFormat="csv"
59
- showExportSelection={true}
60
- resourceType="category"
61
- allResourcesCount={143}
62
- exportSelectionType="onlyMatching"
63
- fields={[
64
- { key: 'externalId' },
65
- { key: 'createdAt' },
66
- { key: 'lastModifiedAt' },
67
- { key: 'name', isLocalized: true },
68
- { key: 'parent', fields: [
69
- {
70
- key: 'name',
71
- isLocalized: true
72
- }
73
- ]},
74
- ]}
75
- appliedFilters={
76
- [
77
- {
78
- key: 'name',
79
- value: 'John'
80
- },
81
- ]
82
- }
83
- renderProperties={()=>(
84
- <>
85
- - The category parent is referenced by externalId or key.
86
- </>
87
- )}
88
- closeModal={() => {
89
- ...
90
- }}
91
- />
92
-
93
77
  // in case export only selected resources
94
78
  <ExportResourcesModal
95
79
  outputFormat="csv"
96
- showExportSelection={true}
97
80
  resourceType="category"
98
- allResourcesCount={143}
99
- exportSelectionType="onlySelected"
81
+ totalResourcesCount={143}
82
+ exportType="selected"
100
83
  selectedResourceIds={['02ed9a7d-7c1f-40da-b2b7-4cca6752bf29', '04051276-1641-4e01-a03e-d4de16b7e4eb', 'ac7d9f7b-5c7d-4dd3-b82b-8555ab4a2a6e']}
101
84
  fields={[
102
- { key: 'externalId' },
103
- { key: 'createdAt' },
104
- { key: 'lastModifiedAt' },
105
- { key: 'name', isLocalized: true },
106
- { key: 'parent', fields: [
107
- {
108
- key: 'name',
109
- isLocalized: true
110
- }
111
- ]},
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
+ },
112
117
  ]}
113
118
  renderProperties={()=>(
114
119
  <>
115
120
  - The category parent is referenced by externalId or key.
116
121
  </>
117
122
  )}
118
- closeModal={() => {
123
+ onClose={() => {
119
124
  ...
120
125
  }}
121
126
  />
@@ -123,23 +128,21 @@ import { ExportResourcesModal } from '@commercetools-frontend-extensions/export-
123
128
 
124
129
  ## Properties
125
130
 
126
- | Props | Type | Required | Default | Description |
127
- | ------------------------ | ----------------------------------------------------------------------------- | :---------------------------------------------------------: | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
128
- | `outputFormat` | `string`<br/>Possible values: `csv`, `json` | | `csv` | The file format to export |
129
- | `showExportSelection` | `boolean` | | `false` | Determines whether the export selection section is displayed. This section allows users to select specific fields for export. This feature is a WIP |
130
- | `closeModal` | `function` | Required | | 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 |
131
- | `resourceType` | `string` | Required | | The type of the resource, example: `category`, `product`... |
132
- | `allResourcesCount` | `Number` | ✅ Required | | The count of all resources of identified `resourceType` |
133
- | `exportSelectionType` | `string` <br/>Possible values:<br/>`allResources, onlyMatching, onlySelected` | | `allResources` | The type of export, so either export all resources or export only resources that match the filters & search or export only selected resources |
134
- | `matchingResourcesCount` | `Number` | Required only if `exportSelectionType` is `onlyMatching` | | The count of resources that matches the filters & search |
135
- | `selectedResourceIds` | `array` | Required only if `exportSelectionType` is `onlySelected` | | Array of Ids of the selected resources |
136
- | `fields` | `array` | ✅ Required | | Array of the fields to export |
137
- | `fields[].key` | `string` | Required | | The unique key of the field that is used to identify data type |
138
- | `fields[].label` | `string` | | | The label of the field to be shown in the export modal, if it's not set the key will be shown instead |
139
- | `fields[].isLocalized` | `boolean` | | `false` | The field is a localized field |
140
- | `appliedSearchTerms` | `array` | | `[]` | Array of the search terms that are used when `exportSelectionType` is `onlyMatching` |
141
- | `appliedFilters` | `array` | | `[]` | Array of the filters that are used when `exportSelectionType` is `onlyMatching` |
142
- | `renderProperties` | `function` | | | 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 |
143
146
 
144
147
  ## Releasing
145
148