diff --git a/.deps/EXCLUDED/prod.md b/.deps/EXCLUDED/prod.md index 40ff38df9..419536d28 100644 --- a/.deps/EXCLUDED/prod.md +++ b/.deps/EXCLUDED/prod.md @@ -11,6 +11,7 @@ This file lists dependencies that do not need CQs or auto-detection does not wor | `blueimp-md5@2.19.0` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/blueimp-md5/2.19.0) | | `codemirror@5.65.16` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/codemirror/5.65.16) | | `cookie-signature@1.2.1` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/cookie-signature/1.2.1) | +| `ecc-jsbn@0.1.2` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/ecc-jsbn/0.1.2) | | `fast-uri@2.4.0` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/fast-uri/2.4.0) | | `fastify@4.28.1` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/fastify/4.28.1) | | `jsep@1.3.9` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/jsep/1.3.9) | diff --git a/packages/dashboard-frontend/jest.setup.tsx b/packages/dashboard-frontend/jest.setup.tsx index 1140edd10..87ff0773e 100644 --- a/packages/dashboard-frontend/jest.setup.tsx +++ b/packages/dashboard-frontend/jest.setup.tsx @@ -41,6 +41,6 @@ jest.mock('@/components/CheTooltip', () => { jest.mock('react-markdown', () => { return jest.fn(props => { - return React.createElement('div', null, props.children, props.content); + return React.createElement('a', null, props.children, props.content); }); }); diff --git a/packages/dashboard-frontend/src/components/EditorSelector/Gallery/Entry/index.module.css b/packages/dashboard-frontend/src/components/EditorSelector/Gallery/Entry/index.module.css index 8612cefd1..108ff27e8 100644 --- a/packages/dashboard-frontend/src/components/EditorSelector/Gallery/Entry/index.module.css +++ b/packages/dashboard-frontend/src/components/EditorSelector/Gallery/Entry/index.module.css @@ -18,3 +18,7 @@ .activeCard { color: #000; } + +.provider { + font-size: 75%; +} diff --git a/packages/dashboard-frontend/src/components/EditorSelector/Gallery/Entry/index.tsx b/packages/dashboard-frontend/src/components/EditorSelector/Gallery/Entry/index.tsx index 585ddd6ba..4df7af66f 100644 --- a/packages/dashboard-frontend/src/components/EditorSelector/Gallery/Entry/index.tsx +++ b/packages/dashboard-frontend/src/components/EditorSelector/Gallery/Entry/index.tsx @@ -14,6 +14,7 @@ import { Card, CardActions, CardBody, + CardFooter, CardHeader, Dropdown, DropdownItem, @@ -45,6 +46,8 @@ export type State = { const allowedTags = ['Tech Preview', 'Deprecated']; export class EditorSelectorEntry extends React.PureComponent { + private timerId: number | undefined; + constructor(props: Props) { super(props); @@ -59,7 +62,38 @@ export class EditorSelectorEntry extends React.PureComponent { }; } + // TODO temporary solution for making links open in a new browser tab (should be fixed with https://github.com/eclipse-che/che/issues/23219) + private setAttribute( + widgetId: string, + querySelector: string = 'a', + attributeName: string = 'target', + attributeValue: string = '_blank', + ): void { + clearTimeout(this.timerId); + this.timerId = window.setTimeout(() => { + const widget = document.getElementById(widgetId); + if (widget) { + widget.querySelectorAll(querySelector).forEach(targetElement => { + targetElement.setAttribute(attributeName, attributeValue); + }); + } + }, 500); + } + + private get id(): string { + return `editor-selector-card-${this.state.activeEditor.id}`; + } + + public componentDidMount(): void { + if (this.state.activeEditor.provider) { + this.setAttribute(this.id); + } + } + public componentDidUpdate(prevProps: Props): void { + if (this.state.activeEditor.provider) { + this.setAttribute(this.id); + } if (prevProps.selectedId !== this.props.selectedId) { const selectedEditor = this.props.editorsGroup.find( editor => editor.id === this.props.selectedId, @@ -176,7 +210,7 @@ export class EditorSelectorEntry extends React.PureComponent { return ( { {groupName} - {activeEditor.provider && ( -
- {activeEditor.provider} -
- )}
+ {activeEditor.provider && ( + + {activeEditor.provider} + + )}
); } diff --git a/packages/dashboard-frontend/src/components/EditorSelector/Gallery/__tests__/index.spec.tsx b/packages/dashboard-frontend/src/components/EditorSelector/Gallery/__tests__/index.spec.tsx index 5b811f839..fa0ed51b3 100644 --- a/packages/dashboard-frontend/src/components/EditorSelector/Gallery/__tests__/index.spec.tsx +++ b/packages/dashboard-frontend/src/components/EditorSelector/Gallery/__tests__/index.spec.tsx @@ -130,6 +130,34 @@ describe('EditorGallery', () => { expect(sortedEditors[1].version).toEqual('1.0.0'); }); + test('1.0.0(Deprecated) <=> latest', () => { + const editorA = editors[0]; + editorA.tags = ['Deprecated']; + editorA.version = '1.0.0'; + editorA.id = `${editorA.publisher}/${editorA.name}/${editorA.version}`; + + const editorB = editors[1]; // latest + + const sortedEditors = sortEditors([editorA, editorB]); + + expect(sortedEditors[0].version).toEqual('latest'); + expect(sortedEditors[1].version).toEqual('1.0.0'); // Deprecated + }); + + test('1.0.0 <=> latest(Deprecated)', () => { + const editorA = editors[0]; + editorA.version = '1.0.0'; + editorA.id = `${editorA.publisher}/${editorA.name}/${editorA.version}`; + + const editorB = editors[1]; // latest + editorB.tags = ['Deprecated']; + + const sortedEditors = sortEditors([editorA, editorB]); + + expect(sortedEditors[0].version).toEqual('1.0.0'); + expect(sortedEditors[1].version).toEqual('latest'); // Deprecated + }); + test('insiders <=> 1.0.0', () => { const editorA = editors[0]; // insiders const editorB = editors[1]; @@ -141,6 +169,34 @@ describe('EditorGallery', () => { expect(sortedEditors[0].version).toEqual('insiders'); expect(sortedEditors[1].version).toEqual('1.0.0'); }); + + test('insiders(Deprecated) <=> 1.0.0', () => { + const editorA = editors[0]; // insiders + editorA.id = `${editorA.publisher}/${editorA.name}/${editorA.version}`; + editorA.tags = ['Deprecated']; + + const editorB = editors[1]; + editorB.version = '1.0.0'; + + const sortedEditors = sortEditors([editorA, editorB]); + + expect(sortedEditors[0].version).toEqual('1.0.0'); + expect(sortedEditors[1].version).toEqual('insiders'); // Deprecated + }); + + test('insiders <=> 1.0.0(Deprecated)', () => { + const editorA = editors[0]; // insiders + editorA.id = `${editorA.publisher}/${editorA.name}/${editorA.version}`; + + const editorB = editors[1]; + editorB.version = '1.0.0'; + editorB.tags = ['Deprecated']; + + const sortedEditors = sortEditors([editorA, editorB]); + + expect(sortedEditors[0].version).toEqual('insiders'); + expect(sortedEditors[1].version).toEqual('1.0.0'); // Deprecated + }); }); describe('select editor', () => { diff --git a/packages/dashboard-frontend/src/components/EditorSelector/Gallery/index.tsx b/packages/dashboard-frontend/src/components/EditorSelector/Gallery/index.tsx index ae2c0bcb5..f7918dff3 100644 --- a/packages/dashboard-frontend/src/components/EditorSelector/Gallery/index.tsx +++ b/packages/dashboard-frontend/src/components/EditorSelector/Gallery/index.tsx @@ -135,23 +135,41 @@ export class EditorGallery extends React.PureComponent { } const VERSION_PRIORITY: ReadonlyArray = ['insiders', 'next', 'latest']; +const DEPRECATED_TAG = 'Deprecated'; export function sortEditors(editors: che.Plugin[]) { - const sorted = editors.sort((a, b) => { - if (a.name === b.name) { - const aPriority = VERSION_PRIORITY.indexOf(a.version); - const bPriority = VERSION_PRIORITY.indexOf(b.version); - - if (aPriority !== -1 && bPriority !== -1) { - return aPriority - bPriority; - } else if (aPriority !== -1) { - return -1; - } else if (bPriority !== -1) { - return 1; + const sorted = editors + .sort((a, b) => { + if (a.name === b.name) { + const aPriority = VERSION_PRIORITY.indexOf(a.version); + const bPriority = VERSION_PRIORITY.indexOf(b.version); + + if (aPriority !== -1 && bPriority !== -1) { + return aPriority - bPriority; + } else if (aPriority !== -1) { + return -1; + } else if (bPriority !== -1) { + return 1; + } + } + + return a.id.localeCompare(b.id); + }) + .sort((a, b) => { + if (a.name === b.name) { + const aPriority = a.tags?.includes(DEPRECATED_TAG) ? -1 : 1; + const bPriority = b.tags?.includes(DEPRECATED_TAG) ? -1 : 1; + + if (aPriority !== -1 && bPriority !== -1) { + return 0; + } else if (aPriority !== -1) { + return -1; + } else if (bPriority !== -1) { + return 1; + } } - } - return a.id.localeCompare(b.id); - }); + return a.id.localeCompare(b.id); + }); return sorted; } diff --git a/scripts/yarn/old_version/.deps/EXCLUDED/prod.md b/scripts/yarn/old_version/.deps/EXCLUDED/prod.md index 40ff38df9..419536d28 100644 --- a/scripts/yarn/old_version/.deps/EXCLUDED/prod.md +++ b/scripts/yarn/old_version/.deps/EXCLUDED/prod.md @@ -11,6 +11,7 @@ This file lists dependencies that do not need CQs or auto-detection does not wor | `blueimp-md5@2.19.0` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/blueimp-md5/2.19.0) | | `codemirror@5.65.16` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/codemirror/5.65.16) | | `cookie-signature@1.2.1` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/cookie-signature/1.2.1) | +| `ecc-jsbn@0.1.2` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/ecc-jsbn/0.1.2) | | `fast-uri@2.4.0` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/fast-uri/2.4.0) | | `fastify@4.28.1` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/fastify/4.28.1) | | `jsep@1.3.9` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/jsep/1.3.9) |