refactor(editor): Apply Prettier (no-changelog) (#4920)

*  Adjust `format` script

* 🔥 Remove exemption for `editor-ui`

* 🎨 Prettify

* 👕 Fix lint
This commit is contained in:
Iván Ovejero
2022-12-14 10:04:10 +01:00
committed by GitHub
parent bcde07e032
commit 5ca2148c7e
284 changed files with 19247 additions and 15540 deletions

View File

@@ -8,7 +8,7 @@ Certain base text strings accept [singular and plural versions](https://kazupon.
```json
{
"tagsView.inUse": "{count} workflow | {count} workflows",
"tagsView.inUse": "{count} workflow | {count} workflows"
}
```
@@ -43,7 +43,7 @@ As a convenience, the base text file may contain the special key `_reusableBaseT
"duplicateWorkflowDialog.save": "@:_reusableBaseText.save",
"saveButton.save": "@:_reusableBaseText.save",
"saveButton.saving": "🇩🇪 Saving",
"saveButton.saved": "🇩🇪 Saved",
"saveButton.saved": "🇩🇪 Saved"
}
```
@@ -93,7 +93,7 @@ Currently only the keys `oauth.clientId` and `oauth.clientSecret` are supported
```json
{
"_reusableDynamicText.oauth2.clientId": "🇩🇪 Client ID",
"_reusableDynamicText.oauth2.clientSecret": "🇩🇪 Client Secret",
"_reusableDynamicText.oauth2.clientSecret": "🇩🇪 Client Secret"
}
```
@@ -105,7 +105,7 @@ Webhook node:
```json
{
"nodeView.eventTriggerDescription": "🇩🇪 Waiting for you to call the Test URL",
"nodeView.eventTriggerDescription": "🇩🇪 Waiting for you to call the Test URL"
}
```

View File

@@ -18,6 +18,7 @@ Currently, n8n does _not_ allow for internalization of:
- options that rely on `loadOptionsMethod`.
Pending functionality:
- Search in nodes panel by translated node name
- UI responsiveness to differently sized strings
- Locale-aware number formatting
@@ -101,6 +102,7 @@ credentials
├── githubApi.json
└── githubOAuth2Api.json
```
Every credential must have its own credential translation file.
The name of the credential translation file must be sourced from the credential's `description.name` property:
@@ -186,7 +188,7 @@ The object for each node credential parameter allows for the keys `displayName`,
"server.displayName": "🇩🇪 Github Server",
"server.description": "🇩🇪 The server to connect to. Only has to be set if Github Enterprise is used.",
"user.placeholder": "🇩🇪 Hans",
"accessToken.placeholder": "🇩🇪 123",
"accessToken.placeholder": "🇩🇪 123"
}
```
@@ -218,7 +220,7 @@ export class Github implements INodeType {
```json
{
"header.displayName": "🇩🇪 GitHub",
"header.description": "🇩🇪 Consume GitHub API",
"header.description": "🇩🇪 Consume GitHub API"
}
```
@@ -255,7 +257,7 @@ export class Github implements INodeType {
```json
{
"nodeView.resource.displayName": "🇩🇪 Resource",
"nodeView.resource.displayName": "🇩🇪 Resource"
}
```
@@ -280,7 +282,7 @@ Allowed keys: `displayName`, `description`, `placeholder`
{
"nodeView.owner.displayName": "🇩🇪 Repository Owner",
"nodeView.owner.placeholder": "🇩🇪 n8n-io",
"nodeView.owner.description": "🇩🇪 Owner of the repository",
"nodeView.owner.description": "🇩🇪 Owner of the repository"
}
```
@@ -319,7 +321,7 @@ Allowed subkeys: `options.{optionName}.displayName` and `options.{optionName}.de
"nodeView.resource.displayName": "🇩🇪 Resource",
"nodeView.resource.description": "🇩🇪 Resource to operate on",
"nodeView.resource.options.file.name": "🇩🇪 File",
"nodeView.resource.options.issue.name": "🇩🇪 Issue",
"nodeView.resource.options.issue.name": "🇩🇪 Issue"
}
```
@@ -333,7 +335,7 @@ For nodes whose credentials may be used in the HTTP Request node, an additional
{
"nodeView.resource.options.file.name": "🇩🇪 File",
"nodeView.resource.options.issue.name": "🇩🇪 Issue",
"nodeView.resource.options.__CUSTOM_API_CALL__.name": "🇩🇪 Custom API Call",
"nodeView.resource.options.__CUSTOM_API_CALL__.name": "🇩🇪 Custom API Call"
}
```
@@ -444,7 +446,7 @@ Example of `fixedCollection` parameter:
"nodeView.additionalParameters.options.author.values.name.placeholder": "🇩🇪 Jan",
"nodeView.additionalParameters.options.author.values.email.displayName": "🇩🇪 Email",
"nodeView.additionalParameters.options.author.values.email.description": "🇩🇪 Email of the author of the commit",
"nodeView.additionalParameters.options.author.values.email.placeholder": "🇩🇪 jan@n8n.io",
"nodeView.additionalParameters.options.author.values.email.placeholder": "🇩🇪 jan@n8n.io"
}
```

View File

@@ -7,15 +7,13 @@ import {
isNestedInCollectionLike,
normalize,
insertOptionsAndValues,
} from "./utils";
import {
locale,
} from 'n8n-design-system';
} from './utils';
import { locale } from 'n8n-design-system';
import englishBaseText from './locales/en.json';
import { useUIStore } from "@/stores/ui";
import { useNDVStore } from "@/stores/ndv";
import {INodeProperties, INodePropertyCollection, INodePropertyOptions} from "n8n-workflow";
import { useUIStore } from '@/stores/ui';
import { useNDVStore } from '@/stores/ndv';
import { INodeProperties, INodePropertyCollection, INodePropertyOptions } from 'n8n-workflow';
Vue.use(VueI18n);
locale.use('en');
@@ -26,16 +24,19 @@ export function I18nPlugin(vue: typeof Vue): void {
i18n = new I18nClass();
Object.defineProperty(vue, '$locale', {
get() { return i18n; },
get() {
return i18n;
},
});
Object.defineProperty(vue.prototype, '$locale', {
get() { return i18n; },
get() {
return i18n;
},
});
}
export class I18nClass {
private get i18n(): VueI18n {
return i18nInstance;
}
@@ -73,9 +74,7 @@ export class I18nClass {
/**
* Render a string of dynamic text, i.e. a string with a constructed path to the localized value.
*/
private dynamicRender(
{ key, fallback }: { key: string; fallback?: string; },
) {
private dynamicRender({ key, fallback }: { key: string; fallback?: string }) {
return this.i18n.te(key) ? this.i18n.t(key).toString() : fallback ?? '';
}
@@ -83,27 +82,24 @@ export class I18nClass {
* Render a string of header text (a node's name and description),
* used variously in the nodes panel, under the node icon, etc.
*/
headerText(arg: { key: string; fallback: string; }) {
headerText(arg: { key: string; fallback: string }) {
return this.dynamicRender(arg);
}
/**
* Namespace for methods to render text in the credentials details modal.
*/
credText () {
credText() {
const uiStore = useUIStore();
const credentialType = uiStore.activeCredentialType;
const credentialPrefix = `n8n-nodes-base.credentials.${credentialType}`;
const context = this;
return {
/**
* Display name for a top-level param.
*/
inputLabelDisplayName(
{ name: parameterName, displayName }: INodeProperties,
) {
inputLabelDisplayName({ name: parameterName, displayName }: INodeProperties) {
if (['clientId', 'clientSecret'].includes(parameterName)) {
return context.dynamicRender({
key: `_reusableDynamicText.oauth2.${parameterName}`,
@@ -120,9 +116,7 @@ export class I18nClass {
/**
* Hint for a top-level param.
*/
hint(
{ name: parameterName, hint }: INodeProperties,
) {
hint({ name: parameterName, hint }: INodeProperties) {
return context.dynamicRender({
key: `${credentialPrefix}.${parameterName}.hint`,
fallback: hint,
@@ -132,9 +126,7 @@ export class I18nClass {
/**
* Description (tooltip text) for an input label param.
*/
inputLabelDescription(
{ name: parameterName, description }: INodeProperties,
) {
inputLabelDescription({ name: parameterName, description }: INodeProperties) {
return context.dynamicRender({
key: `${credentialPrefix}.${parameterName}.description`,
fallback: description,
@@ -170,9 +162,7 @@ export class I18nClass {
/**
* Placeholder for a `string` param.
*/
placeholder(
{ name: parameterName, placeholder }: INodeProperties,
) {
placeholder({ name: parameterName, placeholder }: INodeProperties) {
return context.dynamicRender({
key: `${credentialPrefix}.${parameterName}.placeholder`,
fallback: placeholder,
@@ -185,7 +175,7 @@ export class I18nClass {
* Namespace for methods to render text in the node details view,
* except for `eventTriggerDescription`.
*/
nodeText () {
nodeText() {
const ndvStore = useNDVStore();
const activeNode = ndvStore.activeNode;
const nodeType = activeNode ? this.shortNodeType(activeNode.type as string) : ''; // unused in eventTriggerDescription
@@ -196,10 +186,7 @@ export class I18nClass {
/**
* Display name for an input label, whether top-level or nested.
*/
inputLabelDisplayName(
parameter: INodeProperties,
path: string,
) {
inputLabelDisplayName(parameter: INodeProperties, path: string) {
const middleKey = deriveMiddleKey(path, parameter);
return context.dynamicRender({
@@ -211,10 +198,7 @@ export class I18nClass {
/**
* Description (tooltip text) for an input label, whether top-level or nested.
*/
inputLabelDescription(
parameter: INodeProperties,
path: string,
) {
inputLabelDescription(parameter: INodeProperties, path: string) {
const middleKey = deriveMiddleKey(path, parameter);
return context.dynamicRender({
@@ -226,10 +210,7 @@ export class I18nClass {
/**
* Hint for an input, whether top-level or nested.
*/
hint(
parameter: INodeProperties,
path: string,
) {
hint(parameter: INodeProperties, path: string) {
const middleKey = deriveMiddleKey(path, parameter);
return context.dynamicRender({
@@ -244,10 +225,7 @@ export class I18nClass {
* - For an input label, the placeholder is unselectable greyed-out sample text.
* - For a `collection` or `fixedCollection`, the placeholder is the button text.
*/
placeholder(
parameter: INodeProperties,
path: string,
) {
placeholder(parameter: INodeProperties, path: string) {
let middleKey = parameter.name;
if (isNestedInCollectionLike(path)) {
@@ -332,19 +310,14 @@ export class I18nClass {
* Text for a button to add another option inside a `collection` or
* `fixedCollection` param having `multipleValues: true`.
*/
multipleValueButtonText(
{ name: parameterName, typeOptions}: INodeProperties,
) {
multipleValueButtonText({ name: parameterName, typeOptions }: INodeProperties) {
return context.dynamicRender({
key: `${initialKey}.${parameterName}.multipleValueButtonText`,
fallback: typeOptions?.multipleValueButtonText,
});
},
eventTriggerDescription(
nodeType: string,
eventTriggerDescription: string,
) {
eventTriggerDescription(nodeType: string, eventTriggerDescription: string) {
return context.dynamicRender({
key: `n8n-nodes-base.nodes.${nodeType}.nodeView.eventTriggerDescription`,
fallback: eventTriggerDescription,
@@ -361,7 +334,9 @@ export const i18nInstance = new VueI18n({
silentTranslationWarn: true,
});
locale.i18n((key: string, options?: {interpolate: object}) => i18nInstance.t(key, options && options.interpolate));
locale.i18n((key: string, options?: { interpolate: object }) =>
i18nInstance.t(key, options && options.interpolate),
);
const loadedLanguages = ['en'];
@@ -416,10 +391,7 @@ export function addNodeTranslation(
};
const newNodesBase = {
'n8n-nodes-base': Object.assign(
oldNodesBase,
{ nodes: updatedNodes },
),
'n8n-nodes-base': Object.assign(oldNodesBase, { nodes: updatedNodes }),
};
i18nInstance.setLocaleMessage(
@@ -444,10 +416,7 @@ export function addCredentialTranslation(
};
const newNodesBase = {
'n8n-nodes-base': Object.assign(
oldNodesBase,
{ credentials: updatedCredentials },
),
'n8n-nodes-base': Object.assign(oldNodesBase, { credentials: updatedCredentials }),
};
i18nInstance.setLocaleMessage(
@@ -459,10 +428,7 @@ export function addCredentialTranslation(
/**
* Add a node's header strings to the i18n instance's `messages` object.
*/
export function addHeaders(
headers: INodeTranslationHeaders,
language: string,
) {
export function addHeaders(headers: INodeTranslationHeaders, language: string) {
i18nInstance.setLocaleMessage(
language,
Object.assign(i18nInstance.messages[language], { headers }),
@@ -479,12 +445,10 @@ declare module 'vue/types/vue' {
}
}
type GetBaseTextKey<T> = T extends `_${string}` ? never : T;
type GetBaseTextKey<T> = T extends `_${string}` ? never : T;
export type BaseTextKey = GetBaseTextKey<keyof typeof englishBaseText>;
type GetCategoryName<T> = T extends `nodeCreator.categoryNames.${infer C}`
? C
: never;
type GetCategoryName<T> = T extends `nodeCreator.categoryNames.${infer C}` ? C : never;
export type CategoryName = GetCategoryName<keyof typeof englishBaseText>;

View File

@@ -6,24 +6,15 @@
*
* Location: `n8n-nodes-base.nodes.github.nodeView.<middleKey>.placeholder`
*/
export function deriveMiddleKey(
path: string,
parameter: { name: string; type: string; },
) {
export function deriveMiddleKey(path: string, parameter: { name: string; type: string }) {
let middleKey = parameter.name;
if (
isTopLevelCollection(path, parameter) ||
isNestedInCollectionLike(path)
) {
if (isTopLevelCollection(path, parameter) || isNestedInCollectionLike(path)) {
const pathSegments = normalize(path).split('.');
middleKey = insertOptionsAndValues(pathSegments).join('.');
}
if (
isNestedCollection(path, parameter) ||
isFixedCollection(path, parameter)
) {
if (isNestedCollection(path, parameter) || isFixedCollection(path, parameter)) {
const pathSegments = [...normalize(path).split('.'), parameter.name];
middleKey = insertOptionsAndValues(pathSegments).join('.');
}