Skip to content

Commit

Permalink
feat: add an ability to show provider info into a sample
Browse files Browse the repository at this point in the history
Signed-off-by: Oleksii Orel <[email protected]>
  • Loading branch information
olexii4 committed Oct 23, 2024
1 parent 5252f8c commit 3efe8ae
Show file tree
Hide file tree
Showing 16 changed files with 1,656 additions and 20 deletions.
1 change: 1 addition & 0 deletions .deps/EXCLUDED/prod.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This file lists dependencies that do not need CQs or auto-detection does not wor
| `[email protected]` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/fast-uri/2.4.0) |
| `[email protected]` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/fastify/5.0.0) |
| `[email protected]` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/glob/11.0.0) |
| `[email protected]` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/hast-util-to-jsx-runtime/2.3.2) |
| `[email protected]` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/jsep/1.3.9) |
| `[email protected]` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/real-require/0.2.0) |
| `[email protected]` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/light-my-request/6.0.0) |
3 changes: 0 additions & 3 deletions .deps/dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@
| [`@types/[email protected]`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | clearlydefined |
| [`@types/[email protected]`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | #8935 |
| [`@types/[email protected]`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | #9382 |
| [`@types/[email protected]`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | #8266 |
| [`@types/[email protected]`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | #8266 |
| [`@types/[email protected]`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | clearlydefined |
| [`@types/[email protected]`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | clearlydefined |
Expand Down Expand Up @@ -129,7 +128,6 @@
| [`@typescript-eslint/[email protected]`](https://github.com/typescript-eslint/typescript-eslint.git) | BSD-2-Clause | #14423 |
| [`@typescript-eslint/[email protected]`](https://github.com/typescript-eslint/typescript-eslint.git) | MIT | clearlydefined |
| [`@typescript-eslint/[email protected]`](https://github.com/typescript-eslint/typescript-eslint.git) | MIT | clearlydefined |
| [`@ungap/[email protected]`](git+https://github.com/ungap/structured-clone.git) | ISC | clearlydefined |
| [`@webassemblyjs/[email protected]`](https://github.com/xtuc/webassemblyjs.git) | MIT | clearlydefined |
| [`@webassemblyjs/[email protected]`](https://github.com/xtuc/webassemblyjs.git) | MIT | #7959 |
| [`@webassemblyjs/[email protected]`](https://github.com/xtuc/webassemblyjs.git) | MIT | #7969 |
Expand Down Expand Up @@ -259,7 +257,6 @@
| [`[email protected]`](git+https://github.com/ljharb/define-data-property.git) | MIT | #10591 |
| `[email protected]` | MIT | clearlydefined |
| [`[email protected]`](git://github.com/ljharb/define-properties.git) | MIT | #7116 |
| `[email protected]` | MIT | clearlydefined |
| `[email protected]` | MIT | clearlydefined |
| `[email protected]` | MIT | clearlydefined |
| [`[email protected]`](https://github.com/jestjs/jest.git) | MIT | clearlydefined |
Expand Down
81 changes: 81 additions & 0 deletions .deps/prod.md

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions packages/dashboard-backend/src/constants/examples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ export const devWorkspaceResourcesExample = {
displayName: 'VS Code - Open Source',
name: 'che-code',
tags: ['Tech-Preview'],
attributes: {
title: 'VS Code - Open Source',
},
},
commands: [
{
Expand Down
6 changes: 6 additions & 0 deletions packages/dashboard-frontend/jest.setup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,9 @@ jest.mock('@/components/CheTooltip', () => {
}),
};
});

jest.mock('react-markdown', () => {
return jest.fn(props => {
return React.createElement('div', null, props.children, props.content);
});
});
1 change: 1 addition & 0 deletions packages/dashboard-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"react-copy-to-clipboard": "^5.1.0",
"react-dom": "^18.3.1",
"react-helmet": "^6.1.0",
"react-markdown": "^9.0.1",
"react-pluralize": "^1.6.3",
"react-redux": "^7.2.9",
"react-router-dom": "^6.26.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,17 @@ describe('Editor Selector Entry', () => {
});
});

describe('provider info', () => {
test('show text', () => {
renderComponent(
editorGroup[0].id,
[...editorGroup].map(editor => Object.assign({}, editor, { provider: 'Provided by...' })),
);

expect(screen.queryByText('Provided by...')).not.toBeNull();
});
});

describe('props change', () => {
test('sibling editor ID provided later', () => {
const { reRenderComponent } = renderComponent(editorGroup[0].id, editorGroup);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
} from '@patternfly/react-core';
import { CheckIcon } from '@patternfly/react-icons';
import React from 'react';
import ReactMarkdown from 'react-markdown';

import styles from '@/components/EditorSelector/Gallery/Entry/index.module.css';
import { TagLabel } from '@/components/TagLabel';
Expand Down Expand Up @@ -79,11 +80,13 @@ export class EditorSelectorEntry extends React.PureComponent<Props, State> {
}

private handleCardClick(event: React.MouseEvent) {
event.preventDefault();

const { selectedId, onSelect } = this.props;
const { activeEditor } = this.state;

if (!activeEditor.provider) {
event.preventDefault();
}

if (activeEditor.id === selectedId) {
return;
}
Expand Down Expand Up @@ -199,6 +202,11 @@ export class EditorSelectorEntry extends React.PureComponent<Props, State> {
</CardHeader>
<CardBody>
<span className={titleClassName}>{groupName}</span>
{activeEditor.provider && (
<div style={{ fontSize: '75%' }}>
<ReactMarkdown>{activeEditor.provider}</ReactMarkdown>
</div>
)}
</CardBody>
</Card>
);
Expand Down
1 change: 1 addition & 0 deletions packages/dashboard-frontend/src/services/models/che.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface Plugin {
type: string;
version: string;
description?: string;
provider?: string;
links: {
devfile: string;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ describe('convertToEditorPlugin', () => {
const plugin = convertToEditorPlugin(editor);

expect(plugin).toEqual({
description:
'Microsoft Visual Studio Code - Open Source IDE for Eclipse Che - Insiders build',
description: 'Open Source IDE for Eclipse Che....',
displayName: 'VS Code - Open Source',
icon: `<svg width="100" height="100" viewBox="0 0 100 100" fill="none" xmlns="http://www.w3.org/2000/svg"></svg>`,
iconMediatype: 'image/svg+xml',
Expand All @@ -88,6 +87,7 @@ describe('convertToEditorPlugin', () => {
devfile: '',
},
name: 'che-code',
provider: 'Provided by ....',
publisher: 'che-incubator',
tags: ['Tech-Preview'],
type: 'Che Editor',
Expand Down Expand Up @@ -123,11 +123,11 @@ function getEditor(): devfileApi.Devfile {
iconMediatype: 'image/svg+xml',
publisher: 'che-incubator',
repository: 'https://github.com/che-incubator/che-code',
title: 'Microsoft Visual Studio Code - Open Source IDE for Eclipse Che - Insiders build',
title: 'Open Source IDE for Eclipse Che ....',
version: 'insiders',
provider: 'Provided by ....',
},
description:
'Microsoft Visual Studio Code - Open Source IDE for Eclipse Che - Insiders build',
description: 'Open Source IDE for Eclipse Che....',
displayName: 'VS Code - Open Source',
name: 'che-code',
tags: ['Tech-Preview'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function convertToEditorPlugin(editor: devfileApi.Devfile): che.Plugin {
) {
throw new Error('Invalid editor metadata');
}
return {
const plugin: che.Plugin = {
id:
editor.metadata.attributes.publisher +
'/' +
Expand All @@ -42,4 +42,10 @@ export function convertToEditorPlugin(editor: devfileApi.Devfile): che.Plugin {
icon: editor.metadata.attributes.iconData,
iconMediatype: editor.metadata.attributes.iconMediatype,
};

if (editor.metadata.attributes?.provider) {
plugin.provider = editor.metadata.attributes.provider;
}

return plugin;
}
1 change: 1 addition & 0 deletions scripts/yarn/old_version/.deps/EXCLUDED/prod.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This file lists dependencies that do not need CQs or auto-detection does not wor
| `[email protected]` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/fast-uri/2.4.0) |
| `[email protected]` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/fastify/5.0.0) |
| `[email protected]` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/glob/11.0.0) |
| `[email protected]` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/hast-util-to-jsx-runtime/2.3.2) |
| `[email protected]` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/jsep/1.3.9) |
| `[email protected]` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/real-require/0.2.0) |
| `[email protected]` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/light-my-request/6.0.0) |
4 changes: 1 addition & 3 deletions scripts/yarn/old_version/.deps/dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
| [`@types/[email protected]`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | clearlydefined |
| [`@types/[email protected]`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | #8935 |
| [`@types/[email protected]`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | #9382 |
| [`@types/[email protected].5`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | #8266 |
| [`@types/[email protected].4`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | #8266 |
| [`@types/[email protected]`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | clearlydefined |
| [`@types/[email protected]`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | clearlydefined |
| [`@types/[email protected]`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | clearlydefined |
Expand Down Expand Up @@ -136,7 +136,6 @@
| [`@typescript-eslint/[email protected]`](https://github.com/typescript-eslint/typescript-eslint.git) | BSD-2-Clause | #14423 |
| [`@typescript-eslint/[email protected]`](https://github.com/typescript-eslint/typescript-eslint.git) | MIT | clearlydefined |
| [`@typescript-eslint/[email protected]`](https://github.com/typescript-eslint/typescript-eslint.git) | MIT | clearlydefined |
| [`@ungap/[email protected]`](git+https://github.com/ungap/structured-clone.git) | ISC | clearlydefined |
| [`@webassemblyjs/[email protected]`](https://github.com/xtuc/webassemblyjs.git) | MIT | clearlydefined |
| [`@webassemblyjs/[email protected]`](https://github.com/xtuc/webassemblyjs.git) | MIT | #7959 |
| [`@webassemblyjs/[email protected]`](https://github.com/xtuc/webassemblyjs.git) | MIT | #7969 |
Expand Down Expand Up @@ -255,7 +254,6 @@
| [`[email protected]`](git+https://github.com/ljharb/define-data-property.git) | MIT | #10591 |
| [`[email protected]`](https://github.com/sindresorhus/define-lazy-prop.git) | MIT | clearlydefined |
| [`[email protected]`](git://github.com/ljharb/define-properties.git) | MIT | #7116 |
| [`[email protected]`](https://github.com/lukeed/dequal.git) | MIT | clearlydefined |
| [`[email protected]`](https://github.com/sindresorhus/detect-indent.git) | MIT | clearlydefined |
| [`[email protected]`](https://github.com/sindresorhus/detect-newline.git) | MIT | clearlydefined |
| [`[email protected]`](https://github.com/jestjs/jest.git) | MIT | clearlydefined |
Expand Down
Loading

0 comments on commit 3efe8ae

Please sign in to comment.