From 6742faec19f9dc010593c6f51c934ae760c228c2 Mon Sep 17 00:00:00 2001 From: Samuel Padgett Date: Tue, 2 Apr 2019 08:57:01 -0400 Subject: [PATCH] Bug 1694542 - Hide View CSV action when no installed CSV Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1694542 --- .../operator-lifecycle-manager/subscription.tsx | 14 +++++++++----- frontend/public/components/utils/dropdown.jsx | 2 +- frontend/public/components/utils/kebab.tsx | 3 ++- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/frontend/public/components/operator-lifecycle-manager/subscription.tsx b/frontend/public/components/operator-lifecycle-manager/subscription.tsx index 8344511506b..e1eea83ad50 100644 --- a/frontend/public/components/operator-lifecycle-manager/subscription.tsx +++ b/frontend/public/components/operator-lifecycle-manager/subscription.tsx @@ -38,10 +38,14 @@ const menuActions = [ label: 'Remove Subscription...', callback: () => createDisableApplicationModal({k8sKill, k8sGet, k8sPatch, subscription: obj}), }), - (kind, obj) => ({ - label: `View ${ClusterServiceVersionModel.kind}...`, - href: `/k8s/ns/${obj.metadata.namespace}/${ClusterServiceVersionModel.plural}/${_.get(obj.status, 'installedCSV')}`, - }), + (kind, obj) => { + const installedCSV = _.get(obj, 'status.installedCSV'); + return { + label: `View ${ClusterServiceVersionModel.kind}...`, + href: `/k8s/ns/${obj.metadata.namespace}/${ClusterServiceVersionModel.plural}/${installedCSV}`, + hidden: !installedCSV, + }; + }, ]; export const SubscriptionRow: React.SFC = (props) => { @@ -62,7 +66,7 @@ export const SubscriptionRow: React.SFC = (props) => { {props.obj.spec.installPlanApproval || 'Automatic'}
- +
; }; diff --git a/frontend/public/components/utils/dropdown.jsx b/frontend/public/components/utils/dropdown.jsx index 7f97642ea1b..e3ce48dea1a 100644 --- a/frontend/public/components/utils/dropdown.jsx +++ b/frontend/public/components/utils/dropdown.jsx @@ -379,7 +379,7 @@ Dropdown.propTypes = { export const ActionsMenu = (props) => { const {actions, title = undefined, menuClassName = undefined, buttonClassName = undefined} = props; - const shownActions = _.reject(actions, o => _.get(o, 'hidden', false)); + const shownActions = _.reject(actions, 'hidden'); const items = _.fromPairs(_.map(shownActions, (v, k) => [k, v.label])); const btnTitle = title || Actions; const onChange = (key, e) => { diff --git a/frontend/public/components/utils/kebab.tsx b/frontend/public/components/utils/kebab.tsx index 7b8a719a23a..e1f6336dac8 100644 --- a/frontend/public/components/utils/kebab.tsx +++ b/frontend/public/components/utils/kebab.tsx @@ -95,8 +95,9 @@ export const ResourceKebab = connectToModel((props: ResourceKebabProps) => { if (!kindObj) { return null; } + const options = _.reject(actions.map(a => a(kindObj, resource)), 'hidden'); return a(kindObj, resource))} + options={options} key={resource.metadata.uid} isDisabled={isDisabled !== undefined ? isDisabled : _.get(resource.metadata, 'deletionTimestamp')} />;