@commercetools-frontend-extensions/export-resources-modal 2.0.0 → 3.1.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
@@ -29,67 +29,100 @@ import { ExportResourcesModal } from '@commercetools-frontend-extensions/export-
29
29
  isOpen={true}
30
30
  outputFormat="csv"
31
31
  resourceType="category"
32
- allResourcesCount={143}
33
- exportSelectionType="allResources"
34
- columns={[
35
- { key: 'externalId' },
36
- { key: 'createdAt' },
37
- { key: 'lastModifiedAt' },
38
- { key: 'name', isLocalised: true },
32
+ totalResourcesCount={143}
33
+ exportType="all"
34
+ fields={[
35
+ {
36
+ name: 'key',
37
+ label: 'Category key',
38
+ isRequired: true
39
+ },
40
+ {
41
+ name: 'externalId',
42
+ label: 'External id',
43
+ isSelectedByDefault: false,
44
+ },
45
+ { name: 'createdAt', label: 'Created at' },
46
+ { name: 'lastModifiedAt', label: 'Last modified at' },
47
+ { name: 'name', isLocalized: true, label: 'Name' },
48
+ {
49
+ name: 'parent',
50
+ fields: [
51
+ {
52
+ name: 'name',
53
+ isLocalized: true,
54
+ label: 'Parent name',
55
+ },
56
+ {
57
+ name: 'key',
58
+ label: 'Parent key',
59
+ },
60
+ ],
61
+ },
62
+ {
63
+ name: 'id',
64
+ label: 'Id',
65
+ isSelectedByDefault: false,
66
+ },
39
67
  ]}
40
68
  renderProperties={()=>(
41
69
  <>
42
70
  - The category parent is referenced by externalId or key.
43
71
  </>
44
72
  )}
45
- closeModal={() => {
73
+ onClose={() => {
46
74
  ...
47
75
  }}
48
76
  />
49
77
 
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
78
  // in case export only selected resources
74
79
  <ExportResourcesModal
75
80
  isOpen={true}
76
81
  outputFormat="csv"
77
82
  resourceType="category"
78
- allResourcesCount={143}
79
- exportSelectionType="onlySelected"
83
+ totalResourcesCount={143}
84
+ exportType="selected"
80
85
  selectedResourceIds={['02ed9a7d-7c1f-40da-b2b7-4cca6752bf29', '04051276-1641-4e01-a03e-d4de16b7e4eb', 'ac7d9f7b-5c7d-4dd3-b82b-8555ab4a2a6e']}
81
- columns={[
82
- { key: 'externalId' },
83
- { key: 'createdAt' },
84
- { key: 'lastModifiedAt' },
85
- { key: 'name', isLocalised: true },
86
+ fields={[
87
+ {
88
+ name: 'key',
89
+ label: 'Category key',
90
+ isRequired: true,
91
+ },
92
+ {
93
+ name: 'externalId',
94
+ label: 'External id',
95
+ isSelectedByDefault: false,
96
+ },
97
+ { name: 'createdAt', label: 'Created at' },
98
+ { name: 'lastModifiedAt', label: 'Last modified at' },
99
+ { name: 'name', isLocalized: true, label: 'Name' },
100
+ {
101
+ name: 'parent',
102
+ fields: [
103
+ {
104
+ name: 'name',
105
+ isLocalized: true,
106
+ label: 'Parent name',
107
+ },
108
+ {
109
+ name: 'key',
110
+ label: 'Parent key',
111
+ },
112
+ ],
113
+ },
114
+ {
115
+ name: 'id',
116
+ label: 'Id',
117
+ isSelectedByDefault: false,
118
+ },
86
119
  ]}
87
120
  renderProperties={()=>(
88
121
  <>
89
122
  - The category parent is referenced by externalId or key.
90
123
  </>
91
124
  )}
92
- closeModal={() => {
125
+ onClose={() => {
93
126
  ...
94
127
  }}
95
128
  />
@@ -97,22 +130,23 @@ import { ExportResourcesModal } from '@commercetools-frontend-extensions/export-
97
130
 
98
131
  ## Properties
99
132
 
100
- | Props | Type | Required | Default | Description |
101
- | ------------------------ | ----------------------------------------------------------------------------- | :---------------------------------------------------------: | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
102
- | `isOpen` | `boolean` | Required | | Indicates whether the Modal is open or closed. The parent component needs to manage this state |
103
- | `outputFormat` | `string`<br/>Possible values: `json`, `csv` | | `json` | The file format to export |
104
- | `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 |
105
- | `resourceType` | `string` | ✅ Required | | The type of the resource, example: `category`, `product`... |
106
- | `allResourcesCount` | `Number` | Required | | The count of all resources of identified `resourceType` |
107
- | `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 |
108
- | `matchingResourcesCount` | `Number` | Required only if `exportSelectionType` is `onlyMatching` | | The count of resources that matches the filters & search |
109
- | `selectedResourceIds` | `array` | ✅ Required only if `exportSelectionType` is `onlySelected` | | Array of Ids of the selected resources |
110
- | `columns` | `array` | Required | | Array of the columns to export |
111
- | `columns[].key` | `string` | Required | | The unique key of the column that is used to identify data type |
112
- | `columns[].isLocalised` | `boolean` | ✅ Required | | The column is a localised field |
113
- | `appliedSearchTerms` | `array` | | [] | Array of the search terms that are used when `exportSelectionType` is `onlyMatching` |
114
- | `appliedFilters` | `array` | | [] | Array of the filters that are used when `exportSelectionType` is `onlyMatching` |
115
- | `renderProperties` | `function` | ✅ Required | | A prop to render properties that are resource-specific |
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 |
116
150
 
117
151
  ## Releasing
118
152
 
@@ -120,7 +154,7 @@ This package uses [`changesets`](https://github.com/atlassian/changesets) in ord
120
154
 
121
155
  In case you want to publish a new version with the latest changes you need to:
122
156
 
123
- 1. Add a changeset with `yarn changeset` and select `@commercetools-frontend-extensions/export-resources-modal` as the modified package.
157
+ 1. Add a changeset with `pnpm changeset` and select `@commercetools-frontend-extensions/export-resources-modal` as the modified package.
124
158
  2. Some options would be appear in order to do the release:
125
159
  - `patch`: use this release for fixes or small changes
126
160
  - `minor`: use this release for depenency upgrades or medium changes
@@ -136,7 +170,7 @@ In case you want to publish a new version with the latest changes you need to:
136
170
 
137
171
  The repo is configured with an integration with Transifex. The process for i18n is the same as the Merchant Center uses.
138
172
 
139
- `yarn i18n:build` for adding the new keys to transifex.
173
+ `pnpm i18n:build` for adding the new keys to transifex.
140
174
 
141
175
  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
176