Skip to content

Commit

Permalink
frontend: Add links to IBM Marketplace workflows in OperatorHub
Browse files Browse the repository at this point in the history
Read annotations and use action text, remote workflow link, and support link from annotations if present. Default to original values if not found.

Fixes https://issues.redhat.com/projects/CONSOLE/issues/CONSOLE-1953
  • Loading branch information
rebeccaalpert committed Jan 3, 2020
1 parent 6860f48 commit dda3a6b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from 'react';
import * as _ from 'lodash';
import { Modal } from 'patternfly-react';
import { Button } from '@patternfly/react-core';
import {
Expand Down Expand Up @@ -28,6 +29,7 @@ export const OperatorHubItemDetails: React.SFC<OperatorHubItemDetailsProps> = ({
imgUrl,
provider,
providerType,
obj,
longDescription,
description,
version,
Expand All @@ -39,6 +41,8 @@ export const OperatorHubItemDetails: React.SFC<OperatorHubItemDetailsProps> = ({
catalogSourceNamespace,
} = item;
const notAvailable = <span className="properties-side-panel-pf-property-label">N/A</span>;
const actionText =
_.get(obj, ['metadata', 'annotations', 'marketplace.openshift.io/action-text']) || 'Install';

const getHintBlock = () => {
if (installed) {
Expand Down Expand Up @@ -87,6 +91,12 @@ export const OperatorHubItemDetails: React.SFC<OperatorHubItemDetailsProps> = ({
item.subscription.metadata.name
}?showDelete=true`;

const createLinkWorkflow =
_.get(obj, ['metadata', 'annotations', 'marketplace.openshift.io/remote-workflow']) ||
createLink;
const supportWorkflow =
_.get(obj, ['metadata', 'annotations', 'marketplace.openshift.io/support-workflow']) || support;

return (
<>
<Modal.Header>
Expand All @@ -106,9 +116,9 @@ export const OperatorHubItemDetails: React.SFC<OperatorHubItemDetailsProps> = ({
{!installed ? (
<Link
className="pf-c-button pf-m-primary co-catalog-page__overlay-create"
to={createLink}
to={createLinkWorkflow}
>
Install
{actionText}
</Link>
) : (
<Button
Expand All @@ -126,7 +136,7 @@ export const OperatorHubItemDetails: React.SFC<OperatorHubItemDetailsProps> = ({
<PropertyItem label="Repository" value={repository || notAvailable} />
<PropertyItem label="Container Image" value={containerImage || notAvailable} />
<PropertyItem label="Created At" value={createdAt || notAvailable} />
<PropertyItem label="Support" value={support || notAvailable} />
<PropertyItem label="Support" value={supportWorkflow || notAvailable} />
</PropertiesSidePanel>
<div className="co-catalog-page__overlay-description">
{getHintBlock()}
Expand Down
2 changes: 1 addition & 1 deletion frontend/public/components/utils/webhooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const WebhookTriggers: React.FC<WebhookTriggersProps> = (props) => {
setWebhookSecrets(_.compact(secrets));
setLoaded(true);
});
}, [isLoaded, canGetSecret]);
}, [isLoaded, canGetSecret, secretNames, namespace]);

if (_.isEmpty(webhooks)) {
return null;
Expand Down

0 comments on commit dda3a6b

Please sign in to comment.