Skip to content

Commit

Permalink
refactor(config): localized label fields of menu links is optional an…
Browse files Browse the repository at this point in the history
…d defaults to empty array (#2333)
  • Loading branch information
emmenko authored Aug 9, 2021
1 parent fd03430 commit d7b712e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 87 deletions.
5 changes: 5 additions & 0 deletions .changeset/blue-buses-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@commercetools-frontend/application-config': patch
---

Localized label field of menu links is optional and defaults to empty array.
73 changes: 15 additions & 58 deletions packages/application-config/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,7 @@
"type": "string",
"oneOf": [
{
"enum": [
"gcp-au",
"gcp-eu",
"gcp-us",
"aws-fra",
"aws-ohio"
]
"enum": ["gcp-au", "gcp-eu", "gcp-us", "aws-fra", "aws-ohio"]
},
{
"$ref": "#/definitions/envVariablePlaceholder"
Expand Down Expand Up @@ -71,10 +65,7 @@
}
},
"additionalProperties": false,
"required": [
"view",
"manage"
]
"required": ["view", "manage"]
},
"env": {
"description": "This is an object of keys that represents different environments (for example `production`). The environment used depends on the environment variable `MC_APP_ENV`. If `MC_APP_ENV` isn't set then `NODE_ENV` will be used. If neither is set, it defaults to `development`",
Expand Down Expand Up @@ -113,15 +104,11 @@
}
},
"additionalProperties": false,
"required": [
"url"
]
"required": ["url"]
}
},
"additionalProperties": false,
"required": [
"production"
]
"required": ["production"]
},
"additionalEnv": {
"description": "Additional environment values unique to your Custom Application that are injected in the application context.",
Expand Down Expand Up @@ -152,9 +139,7 @@
}
},
"additionalProperties": false,
"required": [
"connect-src"
]
"required": ["connect-src"]
},
"featurePolicies": {
"description": "Configuration for the HTTP Feature-Policy header (https://developer.mozilla.org/en-US/docs/Web/HTTP/Feature_Policy/Using_Feature_Policy)",
Expand All @@ -168,18 +153,13 @@
"description": "Additional configuration for the HTTP Strict-Transport-Security header (https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security)",
"type": "array",
"items": {
"enum": [
"includeSubDomains",
"preload"
]
"enum": ["includeSubDomains", "preload"]
},
"uniqueItems": true
}
},
"additionalProperties": false,
"required": [
"csp"
]
"required": ["csp"]
},
"menuLinks": {
"description": "Configuration for the menu links on the left-side navbar.",
Expand All @@ -196,30 +176,21 @@
"labelAllLocales": {
"description": "Localized label based on the application locales available from the user profile.",
"type": "array",
"default": [],
"items": {
"type": "object",
"properties": {
"locale": {
"type": "string",
"enum": [
"en",
"de",
"es",
"fr-FR",
"zh-CN",
"ja"
]
"enum": ["en", "de", "es", "fr-FR", "zh-CN", "ja"]
},
"value": {
"description": "A label for the specific locale or a reference to a translated message. For example `${intl:en:Menu.Avengers}` which looks for the message key `Menu.Avengers` in the `src/i18n/data/en.json`",
"type": "string"
}
},
"additionalProperties": false,
"required": [
"locale",
"value"
]
"required": ["locale", "value"]
}
},
"permissions": {
Expand Down Expand Up @@ -248,30 +219,21 @@
"labelAllLocales": {
"description": "Localized label based on the application locales available from the user profile.",
"type": "array",
"default": [],
"items": {
"type": "object",
"properties": {
"locale": {
"type": "string",
"enum": [
"en",
"de",
"es",
"fr-FR",
"zh-CN",
"ja"
]
"enum": ["en", "de", "es", "fr-FR", "zh-CN", "ja"]
},
"value": {
"description": "A label for the specific locale or a reference to a translated message. For example `${intl:en:Menu.Avengers}` which looks for the message key `Menu.Avengers` in the `src/i18n/data/en.json`",
"type": "string"
}
},
"additionalProperties": false,
"required": [
"locale",
"value"
]
"required": ["locale", "value"]
}
},
"permissions": {
Expand Down Expand Up @@ -304,10 +266,5 @@
}
},
"additionalProperties": true,
"required": [
"name",
"entryPointUriPath",
"cloudIdentifier",
"env"
]
}
"required": ["name", "entryPointUriPath", "cloudIdentifier", "env"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,13 @@
"value": "${intl:de:Menu.Avengers}"
}
],
"permissions": [
"ViewAvengers"
],
"permissions": ["ViewAvengers"],
"submenuLinks": [
{
"uriPath": "new",
"defaultLabel": "New Avenger",
"labelAllLocales": [
{
"locale": "en",
"value": "${intl:en:Menu.Avengers.New}"
},
{
"locale": "de",
"value": "${intl:de:Menu.Avengers.New}"
}
],
"permissions": [
"ManageAvengers"
]
"defaultLabel": "${intl:en:Menu.Avengers.New}",
"permissions": ["ManageAvengers"]
}
]
}
}
}
13 changes: 2 additions & 11 deletions packages/application-config/test/process-config.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -527,17 +527,8 @@ describe('processing a config with intl variable placeholders', () => {
submenuLinks: [
{
uriPath: 'new',
defaultLabel: 'New Avenger',
labelAllLocales: [
{
locale: 'en',
value: 'Add avenger',
},
{
locale: 'de',
value: 'Avenger hinzufügen',
},
],
defaultLabel: 'Add avenger',
labelAllLocales: [],
permissions: ['ManageAvengers'],
},
],
Expand Down

1 comment on commit d7b712e

@vercel
Copy link

@vercel vercel bot commented on d7b712e Aug 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.