Skip to content

Commit

Permalink
Bug 1812139: List oc as first cli
Browse files Browse the repository at this point in the history
Reordered data so oc would be the first cli on the cli page.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1812139
  • Loading branch information
rebeccaalpert committed Mar 16, 2020
1 parent 55dadbc commit 7baa945
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 34 deletions.
79 changes: 79 additions & 0 deletions frontend/__tests__/components/command-line-tools.spec.tsx
@@ -0,0 +1,79 @@
import * as React from 'react';
import { shallow } from 'enzyme';

import { CommandLineTools } from '../../public/components/command-line-tools';

describe('CommandLineTools', () => {
let wrapper;
const obj = {
data: [
{
apiVersion: 'console.openshift.io/v1',

kind: 'ConsoleCLIDownload',

metadata: {
creationTimestamp: '2020-03-16T12:31:49Z',
generation: 1,

name: 'helm-download-links',

resourceVersion: '10488',

selfLink: '/apis/console.openshift.io/v1/consoleclidownloads/helm-download-links',

uid: '4984e824-96b7-465a-a67b-46b407aee972',
},
spec: {
description:
'Helm 3 is a package manager for Kubernetes applications which enables defining,↵installing, and upgrading applications packaged as Helm Charts.↵Helm 3 is a [Technology Preview](https://access.redhat.com/support/offerings/techpreview) feature on OpenShift 4.↵',

displayName: 'helm - Helm 3 CLI',
links: [],
},
},
{
apiVersion: 'console.openshift.io/v1',

kind: 'ConsoleCLIDownload',
metadata: {
creationTimestamp: '2020-03-16T12:38:38Z',

generation: 1,

name: 'oc-cli-downloads',

resourceVersion: '18788',

selfLink: '/apis/console.openshift.io/v1/consoleclidownloads/oc-cli-downloads',

uid: '42c1f210-3181-4745-bd45-a14ad350ecef',
},
spec: {
description:
'With the OpenShift command line interface, you can create applications and manage OpenShift projects from a terminal.↵↵The oc binary offers the same capabilities as the kubectl binary, but it is further extended to natively support OpenShift Container Platform features.↵',

displayName: 'oc - OpenShift Command Line Interface (CLI)',
links: [],
},
},
],
loadError: '',
loaded: true,
};

describe('When ordering is correct', () => {
beforeEach(() => {
wrapper = shallow(<CommandLineTools obj={obj} />);
});

it('shows oc first', () => {
expect(
wrapper
.find('.co-section-heading')
.first()
.text(),
).toEqual('oc - OpenShift Command Line Interface (CLI)');
});
});
});
67 changes: 33 additions & 34 deletions frontend/public/components/command-line-tools.tsx
Expand Up @@ -9,41 +9,40 @@ import { ConsoleCLIDownloadModel } from '../models';
import { referenceForModel } from '../module/k8s';
import { SyncMarkdownView } from './markdown-view';

const CommandLineTools: React.FC<CommandLineToolsProps> = ({ obj }) => {
export const CommandLineTools: React.FC<CommandLineToolsProps> = ({ obj }) => {
const title = 'Command Line Tools';
const additionalCommandLineTools = _.map(
_.sortBy(_.get(obj, 'data'), 'spec.displayName'),
(tool) => {
const displayName = tool.spec.displayName;
const defaultLinkText = `Download ${displayName}`;
return (
<React.Fragment key={tool.metadata.uid}>
<hr />
<h2 className="co-section-heading" data-test-id={displayName}>
{displayName}
</h2>
<SyncMarkdownView content={tool.spec.description} exactHeight />
{tool.spec.links.length === 1 && (
<p>
<ExternalLink
href={tool.spec.links[0].href}
text={tool.spec.links[0].text || defaultLinkText}
/>
</p>
)}
{tool.spec.links.length > 1 && (
<ul>
{_.map(tool.spec.links, (link, i) => (
<li key={i}>
<ExternalLink href={link.href} text={link.text || defaultLinkText} />
</li>
))}
</ul>
)}
</React.Fragment>
);
},
);
const data = _.sortBy(_.get(obj, 'data'), 'spec.displayName');
const cliData = _.remove(data, (item) => item.metadata.name === 'oc-cli-downloads');
const additionalCommandLineTools = _.map(cliData.concat(data), (tool) => {
const displayName = tool.spec.displayName;
const defaultLinkText = `Download ${displayName}`;
return (
<React.Fragment key={tool.metadata.uid}>
<hr />
<h2 className="co-section-heading" data-test-id={displayName}>
{displayName}
</h2>
<SyncMarkdownView content={tool.spec.description} exactHeight />
{tool.spec.links.length === 1 && (
<p>
<ExternalLink
href={tool.spec.links[0].href}
text={tool.spec.links[0].text || defaultLinkText}
/>
</p>
)}
{tool.spec.links.length > 1 && (
<ul>
{_.map(tool.spec.links, (link, i) => (
<li key={i}>
<ExternalLink href={link.href} text={link.text || defaultLinkText} />
</li>
))}
</ul>
)}
</React.Fragment>
);
});

return (
<>
Expand Down

0 comments on commit 7baa945

Please sign in to comment.