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 <oorel@redhat.com>
  • 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
| `fast-uri@2.4.0` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/fast-uri/2.4.0) |
| `fastify@5.0.0` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/fastify/5.0.0) |
| `glob@11.0.0` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/glob/11.0.0) |
| `hast-util-to-jsx-runtime@2.3.2` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/hast-util-to-jsx-runtime/2.3.2) |
| `jsep@1.3.9` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/jsep/1.3.9) |
| `real-require@0.2.0` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/real-require/0.2.0) |
| `light-my-request@6.0.0` | [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/babel__template@7.4.3`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | clearlydefined |
| [`@types/babel__traverse@7.20.3`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | #8935 |
| [`@types/eslint@8.44.6`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | #9382 |
| [`@types/estree@1.0.4`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | #8266 |
| [`@types/estree@1.0.5`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | #8266 |
| [`@types/fs-extra@11.0.3`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | clearlydefined |
| [`@types/graceful-fs@4.1.8`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | clearlydefined |
Expand Down Expand Up @@ -129,7 +128,6 @@
| [`@typescript-eslint/typescript-estree@6.10.0`](https://github.com/typescript-eslint/typescript-eslint.git) | BSD-2-Clause | #14423 |
| [`@typescript-eslint/utils@6.10.0`](https://github.com/typescript-eslint/typescript-eslint.git) | MIT | clearlydefined |
| [`@typescript-eslint/visitor-keys@6.10.0`](https://github.com/typescript-eslint/typescript-eslint.git) | MIT | clearlydefined |
| [`@ungap/structured-clone@1.2.0`](git+https://github.com/ungap/structured-clone.git) | ISC | clearlydefined |
| [`@webassemblyjs/ast@1.12.1`](https://github.com/xtuc/webassemblyjs.git) | MIT | clearlydefined |
| [`@webassemblyjs/floating-point-hex-parser@1.11.6`](https://github.com/xtuc/webassemblyjs.git) | MIT | #7959 |
| [`@webassemblyjs/helper-api-error@1.11.6`](https://github.com/xtuc/webassemblyjs.git) | MIT | #7969 |
Expand Down Expand Up @@ -259,7 +257,6 @@
| [`define-data-property@1.1.1`](git+https://github.com/ljharb/define-data-property.git) | MIT | #10591 |
| `define-lazy-prop@3.0.0` | MIT | clearlydefined |
| [`define-properties@1.2.1`](git://github.com/ljharb/define-properties.git) | MIT | #7116 |
| `dequal@2.0.3` | MIT | clearlydefined |
| `detect-indent@5.0.0` | MIT | clearlydefined |
| `detect-newline@3.1.0` | MIT | clearlydefined |
| [`diff-sequences@29.6.3`](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
| `fast-uri@2.4.0` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/fast-uri/2.4.0) |
| `fastify@5.0.0` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/fastify/5.0.0) |
| `glob@11.0.0` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/glob/11.0.0) |
| `hast-util-to-jsx-runtime@2.3.2` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/hast-util-to-jsx-runtime/2.3.2) |
| `jsep@1.3.9` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/jsep/1.3.9) |
| `real-require@0.2.0` | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/real-require/0.2.0) |
| `light-my-request@6.0.0` | [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/babel__template@7.4.3`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | clearlydefined |
| [`@types/babel__traverse@7.20.3`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | #8935 |
| [`@types/eslint@8.44.6`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | #9382 |
| [`@types/estree@1.0.5`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | #8266 |
| [`@types/estree@1.0.4`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | #8266 |
| [`@types/fs-extra@11.0.3`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | clearlydefined |
| [`@types/graceful-fs@4.1.8`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | clearlydefined |
| [`@types/history@4.7.11`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | clearlydefined |
Expand Down Expand Up @@ -136,7 +136,6 @@
| [`@typescript-eslint/typescript-estree@6.10.0`](https://github.com/typescript-eslint/typescript-eslint.git) | BSD-2-Clause | #14423 |
| [`@typescript-eslint/utils@6.10.0`](https://github.com/typescript-eslint/typescript-eslint.git) | MIT | clearlydefined |
| [`@typescript-eslint/visitor-keys@6.10.0`](https://github.com/typescript-eslint/typescript-eslint.git) | MIT | clearlydefined |
| [`@ungap/structured-clone@1.2.0`](git+https://github.com/ungap/structured-clone.git) | ISC | clearlydefined |
| [`@webassemblyjs/ast@1.12.1`](https://github.com/xtuc/webassemblyjs.git) | MIT | clearlydefined |
| [`@webassemblyjs/floating-point-hex-parser@1.11.6`](https://github.com/xtuc/webassemblyjs.git) | MIT | #7959 |
| [`@webassemblyjs/helper-api-error@1.11.6`](https://github.com/xtuc/webassemblyjs.git) | MIT | #7969 |
Expand Down Expand Up @@ -255,7 +254,6 @@
| [`define-data-property@1.1.1`](git+https://github.com/ljharb/define-data-property.git) | MIT | #10591 |
| [`define-lazy-prop@3.0.0`](https://github.com/sindresorhus/define-lazy-prop.git) | MIT | clearlydefined |
| [`define-properties@1.2.1`](git://github.com/ljharb/define-properties.git) | MIT | #7116 |
| [`dequal@2.0.3`](https://github.com/lukeed/dequal.git) | MIT | clearlydefined |
| [`detect-indent@5.0.0`](https://github.com/sindresorhus/detect-indent.git) | MIT | clearlydefined |
| [`detect-newline@3.1.0`](https://github.com/sindresorhus/detect-newline.git) | MIT | clearlydefined |
| [`diff-sequences@29.6.3`](https://github.com/jestjs/jest.git) | MIT | clearlydefined |
Expand Down
Loading

0 comments on commit 3efe8ae

Please sign in to comment.