Skip to content

Commit

Permalink
show failed Subscriptions in 'Installed Operators' list view
Browse files Browse the repository at this point in the history
  • Loading branch information
alecmerdler committed Jul 19, 2019
1 parent aacb90d commit 88653c5
Show file tree
Hide file tree
Showing 14 changed files with 181 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import {
CSVConditionReason,
copiedLabelKey,
} from '../../../public/components/operator-lifecycle-manager';
import { DetailsPage, ListPage, TableInnerProps, Table, TableRow } from '../../../public/components/factory';
import { testClusterServiceVersion } from '../../../__mocks__/k8sResourcesMocks';
import { DetailsPage, TableInnerProps, Table, TableRow, MultiListPage } from '../../../public/components/factory';
import { testClusterServiceVersion, testSubscription } from '../../../__mocks__/k8sResourcesMocks';
import {
Timestamp,
ResourceLink,
Expand All @@ -37,6 +37,7 @@ import {
ScrollToTopOnMount,
SectionHeading,
Firehose,
resourceObjPath,
} from '../../../public/components/utils';
import { referenceForModel } from '../../../public/module/k8s';
import { ClusterServiceVersionModel, SubscriptionModel, PackageManifestModel } from '../../../public/models';
Expand All @@ -53,11 +54,11 @@ describe(ClusterServiceVersionTableRow.displayName, () => {
let wrapper: ShallowWrapper<ClusterServiceVersionTableRowProps>;

beforeEach(() => {
wrapper = shallow(<ClusterServiceVersionTableRow obj={testClusterServiceVersion} index={0} style={{}} />).childAt(0).shallow();
wrapper = shallow(<ClusterServiceVersionTableRow obj={testClusterServiceVersion} subscription={testSubscription} index={0} style={{}} />).childAt(0).shallow();
});

it('renders a component wrapped in an `ErrorBoundary', () => {
wrapper = shallow(<ClusterServiceVersionTableRow obj={testClusterServiceVersion} index={0} style={{}} />);
wrapper = shallow(<ClusterServiceVersionTableRow obj={testClusterServiceVersion} subscription={testSubscription} index={0} style={{}} />);

expect(wrapper.find(ErrorBoundary).exists()).toBe(true);
});
Expand All @@ -67,13 +68,13 @@ describe(ClusterServiceVersionTableRow.displayName, () => {

expect(col.find(ResourceKebab).props().resource).toEqual(testClusterServiceVersion);
expect(col.find(ResourceKebab).props().kind).toEqual(referenceForModel(ClusterServiceVersionModel));
expect(col.find(ResourceKebab).props().actions.length).toEqual(1);
expect(col.find(ResourceKebab).props().actions.length).toEqual(3);
});

it('renders clickable column for app logo and name', () => {
const col = wrapper.find(TableRow).childAt(0);

expect(col.find(Link).props().to).toEqual(`/k8s/ns/${testClusterServiceVersion.metadata.namespace}/${ClusterServiceVersionModel.plural}/${testClusterServiceVersion.metadata.name}`);
expect(col.find(Link).props().to).toEqual(resourceObjPath(testClusterServiceVersion, referenceForModel(ClusterServiceVersionModel)));
expect(col.find(Link).find(ClusterServiceVersionLogo).exists()).toBe(true);
});

Expand Down Expand Up @@ -110,7 +111,7 @@ describe(ClusterServiceVersionTableRow.displayName, () => {
const col = wrapper.find(TableRow).childAt(4);
testClusterServiceVersion.spec.customresourcedefinitions.owned.forEach((desc, i) => {
expect(col.find(Link).at(i).props().title).toEqual(desc.name);
expect(col.find(Link).at(i).props().to).toEqual(`/k8s/ns/default/clusterserviceversions/testapp/${referenceForProvidedAPI(desc)}`);
expect(col.find(Link).at(i).props().to).toEqual(`${resourceObjPath(testClusterServiceVersion, referenceForModel(ClusterServiceVersionModel))}/${referenceForProvidedAPI(desc)}`);
});
});
});
Expand Down Expand Up @@ -145,8 +146,8 @@ describe(ClusterServiceVersionLogo.displayName, () => {
describe(ClusterServiceVersionList.displayName, () => {

it('renders `List` with correct props', () => {
const wrapper = shallow(<ClusterServiceVersionList data={[]} loaded={true} />);
expect(wrapper.find<TableInnerProps>(Table).props().Row).toEqual(ClusterServiceVersionTableRow);
const wrapper = shallow(<ClusterServiceVersionList data={[]} subscription={{loaded: true, data: [testSubscription], loadError: null}} loaded={true} />);

expect(wrapper.find<TableInnerProps>(Table).props().Header).toEqual(ClusterServiceVersionTableHeader);
});
});
Expand All @@ -158,10 +159,13 @@ describe(ClusterServiceVersionsPage.displayName, () => {
wrapper = shallow(<ClusterServiceVersionsPage kind={referenceForModel(ClusterServiceVersionModel)} resourceDescriptions={[]} namespace="foo" />);
});

it('renders a `ListPage` with correct props', () => {
const listPage = wrapper.find(ListPage);
it('renders a `MultiListPage` with correct props', () => {
const listPage = wrapper.find(MultiListPage);

expect(listPage.props().kind).toEqual(referenceForModel(ClusterServiceVersionModel));
expect(listPage.props().resources).toEqual([
{kind: referenceForModel(ClusterServiceVersionModel), namespace: 'foo', prop: 'clusterServiceVersion'},
{kind: referenceForModel(SubscriptionModel), prop: 'subscription'},
]);
expect(listPage.props().ListComponent).toEqual(ClusterServiceVersionList);
expect(listPage.props().showTitle).toBe(false);
});
Expand Down
5 changes: 2 additions & 3 deletions frontend/integration-tests/tests/login.scenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ describe('Auth test', () => {
expect(sidenavView.navSectionFor('Administration')).not.toContain('Custom Resource Definitions');
});

it('does not show admin nav items in Catalog to htpasswd user', async() => {
await browser.wait(until.visibilityOf(sidenavView.navSectionFor('Operators')));
expect(sidenavView.navSectionFor('Operators')).not.toContain('OperatorHub');
it('does not show admin nav items in Operators to htpasswd user', async() => {
expect(sidenavView.navSectionFor('Operators').isPresent()).toBe(false);
});

it('does not show admin nav items in Storage to htpasswd user', async() => {
Expand Down
1 change: 0 additions & 1 deletion frontend/integration-tests/tests/performance.scenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import * as crudView from '../views/crud.view';
import * as yamlView from '../views/yaml.view';

const chunkedRoutes = OrderedMap<string, {section: string, name: string}>()
.set('operator-management', {section: 'Operators', name: 'Operator Management'})
.set('daemon-set', {section: 'Workloads', name: 'Daemon Sets'})
.set('deployment', {section: 'Workloads', name: 'Deployments'})
.set('deployment-config', {section: 'Workloads', name: 'Deployment Configs'})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,13 @@ export const menuActions = [
Kebab.factory.Delete,
];

export const menuActionsCreator = (kindObj: K8sKind, vm: VMKind, { vmi, pods, migrations }) => {
type ExtraResources = { vmi: VMIKind; pods: K8sResourceKind[]; migrations: K8sResourceKind[] };

export const menuActionsCreator = (
kindObj: K8sKind,
vm: VMKind,
{ vmi, pods, migrations }: ExtraResources,
) => {
const vmStatus = getVmStatus(vm, pods, migrations);
const migration = findVMIMigration(migrations, vmi);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { asAccessReview, KebabOption } from '@console/internal/components/utils';
import { k8sKill, K8sKind, K8sResourceKind } from '@console/internal/module/k8s';
import { k8sKill, K8sKind, K8sResourceKind, MachineKind } from '@console/internal/module/k8s';
import { getMachineNodeName, getName } from '@console/shared';
import { confirmModal } from '@console/internal/components/modals';
import { findNodeMaintenance, getHostMachine, getNodeMaintenanceReason } from '../selectors';
Expand Down Expand Up @@ -58,10 +58,12 @@ export const RemoveNodeMaintanance = (

export const menuActions = [SetNodeMaintanance, RemoveNodeMaintanance];

type ExtraResources = { machines: MachineKind[]; nodeMaintenances: K8sResourceKind[] };

export const menuActionsCreator = (
kindObj: K8sKind,
host: K8sResourceKind,
{ machines, nodeMaintenances },
{ machines, nodeMaintenances }: ExtraResources,
{ hasNodeMaintenanceCapability },
) => {
const machine = getHostMachine(host, machines);
Expand Down
4 changes: 0 additions & 4 deletions frontend/public/components/app-contents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,6 @@ const AppContents = connect((state: RootState) => ({
<LazyRoute path="/provisionedservices/ns/:ns" loader={() => import('./provisioned-services' /* webpackChunkName: "provisionedservices" */).then(m => m.ProvisionedServicesPage)} />
<Route path="/provisionedservices" component={NamespaceRedirect} />

<LazyRoute path="/operatormanagement/all-namespaces" loader={() => import('./operator-management' /* webpackChunkName: "operator-management" */).then(m => m.OperatorManagementPage)} />
<LazyRoute path="/operatormanagement/ns/:ns" loader={() => import('./operator-management' /* webpackChunkName: "operator-management" */).then(m => m.OperatorManagementPage)} />
<Route path="/operatormanagement" component={NamespaceRedirect} />

<LazyRoute path="/brokermanagement" loader={() => import('./broker-management' /* webpackChunkName: "brokermanagment" */).then(m => m.BrokerManagementPage)} />

<LazyRoute path={`/k8s/ns/:ns/${SubscriptionModel.plural}/~new`} exact loader={() => import('./operator-lifecycle-manager' /* webpackChunkName: "create-subscription-yaml" */).then(m => NamespaceFromURL(m.CreateSubscriptionYAML))} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { history, resourceListPathFromModel, withHandlePromise } from '../utils'
import { ClusterServiceVersionKind, SubscriptionKind } from '../operator-lifecycle-manager';
import { K8sKind, K8sResourceKind } from '../../module/k8s';
import { ClusterServiceVersionModel, SubscriptionModel } from '../../models';
import { getActiveNamespace } from '../../actions/ui';

export const DisableApplicationModal = withHandlePromise((props: DisableApplicationModalProps) => {
const [deleteCSV, setDeleteCSV] = React.useState(true);
Expand All @@ -23,8 +24,9 @@ export const DisableApplicationModal = withHandlePromise((props: DisableApplicat
props.handlePromise(Promise.all(promises)).then(() => {
props.close();

if (new RegExp(`/${subscription.metadata.name}(/|$)`).test(window.location.pathname)) {
history.push(resourceListPathFromModel(SubscriptionModel, subscription.metadata.namespace));
if (window.location.pathname.split('/').includes(subscription.metadata.name)
|| window.location.pathname.split('/').includes(subscription.status.installedCSV)) {
history.push(resourceListPathFromModel(ClusterServiceVersionModel, getActiveNamespace()));
}
});
};
Expand Down
22 changes: 0 additions & 22 deletions frontend/public/components/nav/admin-nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,15 @@ import { monitoringReducerName, MonitoringRoutes } from '../../reducers/monitori
import {
BuildConfigModel,
BuildModel,
CatalogSourceModel,
ChargebackReportModel,
ClusterServiceVersionModel,
DeploymentConfigModel,
ImageStreamModel,
InstallPlanModel,
MachineAutoscalerModel,
MachineConfigModel,
MachineConfigPoolModel,
MachineModel,
MachineSetModel,
PackageManifestModel,
SubscriptionModel,
} from '../../models';

import { referenceForModel } from '../../module/k8s';
Expand All @@ -35,18 +31,6 @@ type SeparatorProps = {
const Separator: React.FC<SeparatorProps> = () => <NavItemSeparator />;

const searchStartsWith = ['search'];
const operatorManagementStartsWith = [
referenceForModel(PackageManifestModel),
PackageManifestModel.plural,
// FIXME(alecmerdler): Needed for backwards-compatibility with new API groups
'packages.apps.redhat.com~v1alpha1~PackageManifest',
referenceForModel(SubscriptionModel),
SubscriptionModel.plural,
referenceForModel(InstallPlanModel),
InstallPlanModel.plural,
referenceForModel(CatalogSourceModel),
CatalogSourceModel.plural,
];
const provisionedServicesStartsWith = ['serviceinstances', 'servicebindings'];
const brokerManagementStartsWith = ['clusterservicebrokers', 'clusterserviceclasses'];
const rolesStartsWith = ['roles', 'clusterroles'];
Expand Down Expand Up @@ -103,12 +87,6 @@ const AdminNav = () => (
required={FLAGS.CAN_LIST_PACKAGE_MANIFEST}
name="Installed Operators"
/>
<HrefLink
href="/operatormanagement"
name="Operator Management"
activePath="/operatormanagement/"
startsWith={operatorManagementStartsWith}
/>
</NavSection>

<NavSection title="Workloads">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { Helmet } from 'react-helmet';
import { match } from 'react-router';
import { Alert } from '@patternfly/react-core';

import { Firehose, history, NsDropdown, resourcePathFromModel, BreadCrumbs, StatusBox } from '../utils';
import { Firehose, history, NsDropdown, BreadCrumbs, StatusBox, resourceListPathFromModel } from '../utils';
import { referenceForModel, k8sCreate, apiVersionForModel, kindForReference, apiVersionForReference, k8sListPartialMetadata } from '../../module/k8s';
import { SubscriptionModel, OperatorGroupModel, PackageManifestModel } from '../../models';
import { SubscriptionModel, OperatorGroupModel, PackageManifestModel, ClusterServiceVersionModel } from '../../models';
import {
OperatorGroupKind,
PackageManifestKind,
Expand Down Expand Up @@ -125,7 +125,7 @@ export const OperatorHubSubscribeForm: React.FC<OperatorHubSubscribeFormProps> =
? Promise.resolve()
: k8sCreate(OperatorGroupModel, operatorGroup))
.then(() => k8sCreate(SubscriptionModel, subscription))
.then(() => history.push(resourcePathFromModel(SubscriptionModel, packageName, subscription.metadata.namespace)));
.then(() => history.push(resourceListPathFromModel(ClusterServiceVersionModel, targetNamespace || props.targetNamespace || selectedTargetNamespace)));
};

const formValid = () => [selectedUpdateChannel, selectedInstallMode, selectedTargetNamespace, selectedApproval].some(v => _.isNil(v) || _.isEmpty(v))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,9 @@
margin-bottom: 20px;
}

.co-clusterserviceversion-list__disabled-icon {
margin: 10px;
width: 100px;
height: 100px;
filter: grayscale(100%);
.co-clusterserviceversion-row__status {
display: flex;
flex-direction: column;
}

.co-spec-descriptor--resource-requirements {
Expand Down
Loading

0 comments on commit 88653c5

Please sign in to comment.