@ 商业工具- 前端- 延伸/ 输出- 资源- 模式
从Merchant Center应用程序输出资源的软件包.
此库考虑到了您正在构建一个 Merchant Center 应用程序, 您可以找到文件 这里。 。 。 . 这些组成部分遵循《公约》的同样原则 用户界面Kit 组件.
开始
$ npm install --save @commercetools-frontend-extensions/export-resources-modal
// or
$ yarn add @commercetools-frontend-extensions/export-resources-modal
说明
导出资源 Modal是一个用于将资源导出到csv或json文件的内部组件,它正在使用 出口商服务 创建 Aync 导出任务.
使用量
import ExportResourcesModal from '@commercetools-frontend-extensions/export-resources-modal';
// Use case: Exporting all resources
<ExportResourcesModal
isOpen={true}
outputFormat="csv"
resourceType="category"
totalResourcesCount={143}
fieldGroups={[
{
groupLabel: 'All general fields',
groupName: 'general-fields',
previewGroupLabel: 'general fields',
fields: [
{
name: 'key',
label: 'Category key',
isRequired: true,
},
{
name: 'externalId',
label: 'External id',
},
{
name: 'createdAt',
label: 'Created at',
isSelectedByDefault: true,
},
{
name: 'lastModifiedAt',
label: 'Last modified at',
isSelectedByDefault: true,
},
{ name: 'name', label: 'Name', isSelectedByDefault: true },
{
name: 'parent',
label: 'parent',
isSelectedByDefault: true,
fields: [
{
name: 'parent.name',
label: 'Parent name',
},
{
name: 'parent.key',
label: 'Parent key',
},
],
},
{
name: 'id',
label: 'Id',
isSelectedByDefault: true,
},
],
},
{
groupLabel: 'All custom fields',
groupName: 'custom-fields',
previewGroupLabel: 'custom fields',
fields: [
{
name: 'custom-type-key-and-type-id',
label: 'Custom type key and type id',
},
{
name: 'general-category-attributes',
label: 'General category attributes',
fields: [
{
name: 'custom.fields.season',
label: 'Season',
},
{
name: 'custom.fields.target-audience',
label: 'Target audience',
},
],
},
{
name: 'book-category-attributes',
label: 'Book category attributes',
fields: [
{
name: 'custom.fields.genre',
label: 'Genre',
},
{
name: 'custom.fields.age-group',
label: 'Age group',
},
],
},
],
},
]}
fieldOrder={['*', 'custom']}
onClose={() => {
...
}}
/>
// Use case: Exporting filtered resources
<ExportResourcesModal
isOpen={true}
outputFormat="csv"
resourceType="category"
filters={{
{
filters: [ 'key = "category-key"'],
fullText: {
text: 'category-text',
locale: 'en'
}
},
total: 20
}}
totalResourcesCount={143}
fieldGroups={[
{
groupLabel: 'All general fields',
groupName: 'general-fields',
previewGroupLabel: 'general fields',
fields: [
{
name: 'key',
label: 'Category key',
isRequired: true,
},
{
name: 'externalId',
label: 'External id',
},
{
name: 'createdAt',
label: 'Created at',
isSelectedByDefault: true,
},
{
name: 'lastModifiedAt',
label: 'Last modified at',
isSelectedByDefault: true,
},
{ name: 'name', label: 'Name', isSelectedByDefault: true },
{
name: 'parent',
label: 'parent',
isSelectedByDefault: true,
fields: [
{
name: 'parent.name',
label: 'Parent name',
},
{
name: 'parent.key',
label: 'Parent key',
},
],
},
{
name: 'id',
label: 'Id',
isSelectedByDefault: true,
},
],
},
{
groupLabel: 'All custom fields',
groupName: 'custom-fields',
previewGroupLabel: 'custom fields',
fields: [
{
name: 'custom-type-key-and-type-id',
label: 'Custom type key and type id',
},
{
name: 'general-category-attributes',
label: 'General category attributes',
fields: [
{
name: 'custom.fields.season',
label: 'Season',
},
{
name: 'custom.fields.target-audience',
label: 'Target audience',
},
],
},
{
name: 'book-category-attributes',
label: 'Book category attributes',
fields: [
{
name: 'custom.fields.genre',
label: 'Genre',
},
{
name: 'custom.fields.age-group',
label: 'Age group',
},
],
},
],
},
]}
fieldOrder={['*', 'custom']}
onClose={() => {
...
}}
/>
// Use case: Exporting only selected resources by their IDs
<ExportResourcesModal
isOpen={true}
outputFormat="csv"
resourceType="category"
selectedResourceIds={['02ed9a7d-7c1f-40da-b2b7-4cca6752bf29', '04051276-1641-4e01-a03e-d4de16b7e4eb', 'ac7d9f7b-5c7d-4dd3-b82b-8555ab4a2a6e']}
fields={[
{
groupLabel: 'All General fields',
groupName: 'general-fields',
previewGroupLabel: 'general fields',
fields:[
{
name: 'key',
label: 'Category key',
isRequired: true,
isSelectedByDefault: true,
},
{
name: 'externalId',
label: 'External id',
},
{ name: 'createdAt', label: 'Created at', isSelectedByDefault: true, },
{ name: 'lastModifiedAt', label: 'Last modified at', isSelectedByDefault: true, },
{ name: 'name', label: 'Name', isSelectedByDefault: true, },
{
name: 'parent',
isSelectedByDefault: true,
fields: [
{
name: 'parent.name',
label: 'Parent name',
},
{
name: 'parent.key',
label: 'Parent key',
},
],
},
{
name: 'id',
label: 'Id',
},
]
},
{
groupLabel: 'All custom fields',
groupName: 'custom-fields',
previewGroupLabel: 'custom fields',
fields: [
{
name: 'custom-type-key-and-typeid',
label: 'Custom type key and type id',
isSelectedByDefault: false,
},
{
name: 'general-category-attributes',
label: 'General category attributes',
isSelectedByDefault: false,
fields: [
{
name: 'season',
label: 'Season',
},
{
name: 'target-audience',
label: 'Target audience',
},
],
},
{
name: 'book-category-attributes',
label: 'Book category attributes',
isSelectedByDefault: false,
fields: [
{
name: 'genre',
label: 'Genre',
},
{
name: 'age-group',
label: 'Age group',
},
],
},
]
}
]}
onClose={() => {
...
}}
/>
属性
| 道具 | 类型 | 需求 | 默认 | 说明 |
|---|---|---|---|---|
isOpen | boolean | false | 控制出口模式是否开放或关闭 | |
outputFormat | string可能的值 : csv, (中文(简体) ), json | csv | 要导出的文件格式 | |
onExportSuccess | function | 当导出操作成功时调用回调函数 | ||
onClose | function | 在请求关闭模式时引用的调用函数( 在上方点击、 关闭按钮点击或) ESC 页:1 此函数在导出操作后也被称为 | ||
resourceType | string | ✅ | 资源类型, 例如 : category, (中文(简体) ), product. | |
filters | Filters | 过滤器可以设置为过滤对象 query 属性或字符串数组。 也可以设置为简单的字符串 where 属性。 最后,另一个选项是将过滤器设置为 fulltext 对象为 text 财务报告和审定财务报表 locale 字符串属性 . | ||
baseFilters | Pick<Filters, 'where'> | 这些过滤器总是被传送到API(与 filters 如果存在道具),并且不能被用户所绕过. | ||
totalResourcesCount | number | ✅ | 查明的所有资源数 resourceType | |
selectedResourceIds | array | 选定资源的 Ids 矩阵 | ||
fieldGroups | array | ✅ | 组数 fields 以导出. | |
fieldGroups[].groupLabel | string | ✅ | 在字段选择 UI 中显示的字段组标签 | |
fieldGroups[].previewGroupLabel | string | ✅ | 在预览屏幕中显示组名的标签 | |
fieldGroups[].groupName | string | ✅ | 用于确定扩展组状态的字段组名称 | |
fieldGroups[].isExpanded | string | false | 此属性用于控制UI中每个可扩展组段的默认状态. 若为 isExpanded 设置为 true,然后当组件加载时,相应的组会被扩展. 默认值为 false 意思是除非明确规定 true,该组在初始负载时会倒塌 | |
fieldGroups[].fields | array | ✅ | 要导出字段的矩阵 。 字段必须与 aPI 计划。田园可以筑巢 fields 阵列. | |
fieldGroups[].fields[].name | string | ✅ | 代表每个字段唯一标识符的字符串。 叶子字段必须与商务工具HTTP API字段相配合,而母字段则可以针对开发者进行特制并用于分组目的. | |
fieldGroups[].fields[].label | string | ✅ | 在导出模式中显示的字段标签 | |
fieldGroups[].fields[].isRequired | boolean | false | isRequired 字段表示导出过程是否需要字段。 若为 true 字段默认会被选中,用户无法取消选择。 这对于对出口过程至关重要的领域是有用的。 按需要标记的字段将有一个 * 在UI中标签的后附 | |
fieldGroups[].fields[].extendedFieldNames | array | 在导出数据时, 一系列额外的字段名称应该与主字段名称一起包含 . | ||
fieldGroups[].fields[].dependentGroupNames | array | 所提供的组名数组决定了复选框的状态. 如果报告中提到的任何群体: dependentGroupNames 已选择至少一个复选框,然后自动选择字段。 可以选择, dependentFieldNames 可用于指定组内的特定字段. 说明: 字段如果有依赖性,则只读取 . | ||
fieldGroups[].fields[].dependentFieldNames | array | 组合内用于确定复选框状态的特定字段的字段名称数组。 如果 dependentFieldNames 中,将自动选择字段. | ||
fieldGroups[].fields[].isSelectedByDefault | boolean | false | 这个领域是 fields 数组用于控制UI中相应复选框的默认状态. 若为 isSelectedByDefault 设置为真,当组件加载时,默认将检查该特定字段的复选框. | |
fieldGroups[].fields[].isExpandable | boolean | false | isExpandable 属性表示是否可以在UI上扩展/缩放字段。 如果 isExpandable ,然后在 UI 上显示扩展/缩放按钮以控制 | |
fieldGroups[].fields[].isExpanded | boolean | false | 此属性与 fieldGroups[].fields[].isExpandable 以控制UI中每个可扩展字段的默认状态。 若为 fieldGroups[].fields[].isExpanded 设置为 true,然后当组件加载时,相应的字段会被扩展. 默认值为 false 意思是除非明确规定 true,在初始负载时会崩溃 | |
fieldOrder | string[] | 字段名称根据通过的顺序排序. 数值 * 可以传递以表示任何字段,例如字段命令=['*','custom']会将所有从自定义开始的字段推到列表中最后一个字段,而其他字段会位于列表开头 | ||
stores | Array<{ key: string; name: string }> | 提供时 resourceType 定义 exportScopeSpecificStore ),使附加的"特定商店"范围选项带有商店选择下放. 选择存储集 where=store(key="<key>") 关于出口请求. | ||
selectedScopeQueryPredicateBuilder | (selectedResourceIds: string[]) => string | 覆盖 where 为Selected范围生产出上游. 有用时 selectedResourceIds 引用相关的资源——例如,在标识为产品标识的地方,调整出口,所以上游必须是: product(id in (...)) 而不是默认 id in (...)。 。 。 . |
释放
此软件包使用 changesets 向国家预防机制释放人员.
如果您想要发布新版本, 并需要最新修改 :
- 添加一个更改列表
pnpm changeset选择@commercetools-frontend-extensions/export-resources-modal作为已修改的软件包. - 为了完成发行工作,将出现一些选项:
patch: 使用此释放来修正或小修改minor: 使用此释放用于调试升级或中度更改major: 使用此发布来打破更改
- 在选择选项后, 您需要为发布注释添加注释 。 我们建议对犯法者采用同样的方式.
- 例如:
feat(utils): add utils for dates
- 例如:
- 推开
changeset到您的分支和 GitHub 动作将检测 PR 包含影响已出版库的更改 . - 在公关合并后,将创建另一个公关
Version Packages这也是GitHub Actions将发现的 向国家预防机制释放的人. - 确保一切正确,然后合并
Version Packages公关. - 等待国家防范机制提供新版本,然后在CircleCI中部署自定义.
加那利释放
加那利版本在成功构建后通过CI自动发布到发行渠道并合并到 主要 树枝.
i18n (英语)
Repo被配置为与Transifex的集成. i18n的流程与商贸中心使用的流程相同.
pnpm i18n:build 用于将新密钥添加到 transifex.
一旦公关合并到 main transifex将收到一份带有需要翻译的新密钥的通知(这就是为什么必须 description 财务报告和审定财务报表 defaultMessage 说明性足够.
每当翻译者完成翻译并按原样进行标记时,repo会收到一个PR(每个语言)来添加被翻译的信息.
一旦我们审查翻译的密钥正确无误并添加一个 changeset 我们可以合并公关 (别忘了部署自定义应用程序)