Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Capability Levels to OperatorHub items #3896

Merged
merged 1 commit into from Jan 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -1,18 +1,61 @@
import * as React from 'react';
import * as _ from 'lodash';
import * as classNames from 'classnames';
import { Modal } from 'patternfly-react';
import { Button } from '@patternfly/react-core';
import {
CatalogItemHeader,
PropertiesSidePanel,
PropertyItem,
} from '@patternfly/react-catalog-view-extension';
import { CheckCircleIcon } from '@patternfly/react-icons';
import { Link } from 'react-router-dom';
import { history, ExternalLink, HintBlock } from '@console/internal/components/utils';
import { RH_OPERATOR_SUPPORT_POLICY_LINK } from '@console/internal/const';
import { MarkdownView } from '../clusterserviceversion';
import { SubscriptionModel } from '../../models';
import { OperatorHubItem } from './index';

const CapabilityLevel: React.FC<CapabilityLevelProps> = ({ capabilityLevel }) => {
const levels = [
'Basic Install',
'Seamless Upgrades',
'Full Lifecycle',
'Deep Insights',
'Auto Pilot',
];
const capabilityLevelIndex = _.indexOf(levels, capabilityLevel);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: no need for lodash here

Suggested change
const capabilityLevelIndex = _.indexOf(levels, capabilityLevel);
const capabilityLevelIndex = levels.indexOf(capabilityLevel);


return (
<ul className="properties-side-panel-pf-property-value__capability-levels">
{levels.map((level, i) => {
const active = capabilityLevelIndex >= i;
return (
<li
className={classNames('properties-side-panel-pf-property-value__capability-level', {
'properties-side-panel-pf-property-value__capability-level--active': active,
})}
key={level}
>
{active && (
<CheckCircleIcon
color="var(--pf-global--primary-color--100)"
className="properties-side-panel-pf-property-value__capability-level-icon"
title="Checked"
/>
)}
{level}
</li>
);
})}
</ul>
);
};

type CapabilityLevelProps = {
capabilityLevel: string;
};

export const OperatorHubItemDetails: React.SFC<OperatorHubItemDetailsProps> = ({
item,
closeOverlay,
Expand All @@ -37,6 +80,7 @@ export const OperatorHubItemDetails: React.SFC<OperatorHubItemDetailsProps> = ({
support,
catalogSource,
catalogSourceNamespace,
capabilityLevel,
} = item;
const notAvailable = <span className="properties-side-panel-pf-property-label">N/A</span>;

Expand Down Expand Up @@ -121,6 +165,16 @@ export const OperatorHubItemDetails: React.SFC<OperatorHubItemDetailsProps> = ({
</Button>
)}
<PropertyItem label="Operator Version" value={version || notAvailable} />
<PropertyItem
label="Capability Level"
value={
capabilityLevel ? (
<CapabilityLevel capabilityLevel={capabilityLevel} />
) : (
notAvailable
)
}
/>
<PropertyItem label="Provider Type" value={providerType || notAvailable} />
<PropertyItem label="Provider" value={provider || notAvailable} />
<PropertyItem label="Repository" value={repository || notAvailable} />
Expand Down
48 changes: 48 additions & 0 deletions frontend/public/components/catalog/_catalog.scss
@@ -1,3 +1,6 @@
$catalog-capability-level-icon-left: -20px;
$catalog-capability-level-icon-top: 4px;
$catalog-capability-level-inactive-color: var(--pf-global--Color--400);
$catalog-item-icon-size-lg: 40px;
$catalog-item-icon-size-sm: 24px;
$co-modal-ignore-warning-icon-width: 30px;
Expand Down Expand Up @@ -235,6 +238,51 @@ $co-modal-ignore-warning-icon-width: 30px;
font-size: ($font-size-base - 1);
}

.properties-side-panel-pf-property-value__capability-level {
color: $catalog-capability-level-inactive-color;
margin-bottom: 5px;
position: relative;

&--active {
color: inherit;

&::before {
display: none; // hide empty circle since icon is present
}
}

&::before { // empty circle
border: 1px solid $catalog-capability-level-inactive-color;
border-radius: 10px;
content: "";
height: 14px;
left: $catalog-capability-level-icon-left;
position: absolute;
top: $catalog-capability-level-icon-top;
width: 14px;
}

&:not(:last-child)::after { // pipe after circle
background: $catalog-capability-level-inactive-color;
content: "";
height: 6px;
left: -13px;
position: absolute;
top: 22px;
width: 1px;
}
}

.properties-side-panel-pf-property-value__capability-level-icon {
left: $catalog-capability-level-icon-left;
position: absolute;
top: $catalog-capability-level-icon-top;
}

.properties-side-panel-pf-property-value__capability-levels {
list-style: none;
}

// set font size to 14px
.vertical-tabs-pf-tab > a {
font-size: $font-size-base;
Expand Down