fix(editor): UX Improvements to RBAC feature set (#9683)

This commit is contained in:
Csaba Tuncsik
2024-07-18 14:17:27 +02:00
committed by GitHub
parent 5b440a7679
commit 028a8a2c75
32 changed files with 337 additions and 112 deletions

View File

@@ -97,7 +97,7 @@ import N8nIcon from '../N8nIcon';
import ConditionalRouterLink from '../ConditionalRouterLink';
import type { IMenuItem } from '../../types';
import { doesMenuItemMatchCurrentRoute } from './routerUtil';
import { getInitials } from './labelUtil';
import { getInitials } from '../../utils/labelUtil';
interface MenuItemProps {
item: IMenuItem;

View File

@@ -1,29 +0,0 @@
import { getInitials } from '../labelUtil';
describe('labelUtil.getInitials', () => {
it.each([
['', ''],
// simple words
['Hello', 'He'],
['Hello World', 'HW'],
['H', 'H'],
// multiple spaces
['Double Space', 'DS'],
[' ', ''],
// simple emoji
['👋 Hello', '👋H'],
['👋Hello', '👋H'],
['Hello 👋', 'H👋'],
['Hello👋', 'He'],
// combined emojis
['1⃣ 1⃣', '1⃣1⃣'],
['1⃣', '1⃣'],
['👩D 👩D', '👩‍⚕️👩‍⚕️'],
])('turns "%s" into "%s"', (input, output) => {
expect(getInitials(input)).toBe(output);
});
});

View File

@@ -1,25 +0,0 @@
export const getInitials = (label: string): string => {
const words = label
.split(' ')
.filter((word) => word !== '')
.map((word) => [...new Intl.Segmenter().segment(word)]);
if (words.length === 0) {
return '';
} else if (words.length === 1) {
// first two segments of the first word
return (
words
.at(0)
?.slice(0, 2)
.map((grapheme) => grapheme.segment)
.join('') ?? ''
);
} else {
// first segment ok the first two words
return words
.slice(0, 2)
.map((word) => word.at(0)?.segment ?? '')
.join('');
}
};