Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(editor): Format action names properly when action is not defined #11030

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/editor-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"@vueuse/core": "^10.11.0",
"axios": "catalog:",
"bowser": "2.11.0",
"change-case": "^5.4.4",
"chart.js": "^4.4.0",
"codemirror-lang-html-n8n": "^1.0.0",
"dateformat": "^3.0.3",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { SectionCreateElement } from '@/Interface';
import { groupItemsInSections, sortNodeCreateElements } from '../utils';
import { formatTriggerActionName, groupItemsInSections, sortNodeCreateElements } from '../utils';
import { mockActionCreateElement, mockNodeCreateElement, mockSectionCreateElement } from './utils';

describe('NodeCreator - utils', () => {
Expand Down Expand Up @@ -62,4 +62,15 @@ describe('NodeCreator - utils', () => {
expect(sortNodeCreateElements([node1, node2, node3])).toEqual([node1, node2, node3]);
});
});

describe('formatTriggerActionName', () => {
test.each([
['project.created', 'project created'],
['Project Created', 'project created'],
['field.value.created', 'field value created'],
['attendee.checked_in', 'attendee checked in'],
])('Action name %i should become as %i', (actionName, expected) => {
expect(formatTriggerActionName(actionName)).toEqual(expected);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type {
import { i18n } from '@/plugins/i18n';

import { getCredentialOnlyNodeType } from '@/utils/credentialOnlyNodes';
import { formatTriggerActionName } from '../utils';

const PLACEHOLDER_RECOMMENDED_ACTION_KEY = 'placeholder_recommended';

Expand Down Expand Up @@ -138,7 +139,7 @@ function triggersCategory(nodeTypeDescription: INodeTypeDescription): ActionType
displayName:
categoryItem.action ??
cachedBaseText('nodeCreator.actionsCategory.onEvent', {
interpolate: { event: startCase(categoryItem.name) },
interpolate: { event: formatTriggerActionName(categoryItem.name) },
}),
description: categoryItem.description ?? '',
displayOptions: matchedProperty.displayOptions,
Expand Down
9 changes: 9 additions & 0 deletions packages/editor-ui/src/components/Node/NodeCreator/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { sublimeSearch } from '@/utils/sortUtils';
import type { NodeViewItemSection } from './viewsData';
import { i18n } from '@/plugins/i18n';
import { sortBy } from 'lodash-es';
import * as changeCase from 'change-case';

import { usePostHog } from '@/stores/posthog.store';

Expand Down Expand Up @@ -177,3 +178,11 @@ export function groupItemsInSections(

return result;
}

export const formatTriggerActionName = (actionPropertyName: string) => {
let name = actionPropertyName;
if (actionPropertyName.includes('.')) {
name = actionPropertyName.split('.').join(' ');
}
return changeCase.noCase(name);
};
127 changes: 15 additions & 112 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading