Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ describe(ClusterServiceVersionsPage.displayName, () => {
let wrapper: ShallowWrapper<ClusterServiceVersionsPageProps>;

beforeEach(() => {
wrapper = shallow(<ClusterServiceVersionsPage.WrappedComponent kind={referenceForModel(ClusterServiceVersionModel)} namespaceEnabled={true} resourceDescriptions={[]} match={{params: {ns: 'foo'}, isExact: true, path: '', url: ''}} />);
wrapper = shallow(<ClusterServiceVersionsPage.WrappedComponent kind={referenceForModel(ClusterServiceVersionModel)} resourceDescriptions={[]} match={{params: {ns: 'foo'}, isExact: true, path: '', url: ''}} />);
});

it('renders a `ListPage` with correct props', () => {
Expand All @@ -166,17 +166,8 @@ describe(ClusterServiceVersionsPage.displayName, () => {
expect(listPage.props().showTitle).toBe(false);
});

it('renders an error page if the namespace is not enabled', () => {
wrapper = wrapper.setProps({namespaceEnabled: false});
const msgBox = wrapper.find(MsgBox);
const listPage = wrapper.find(ListPage);

expect(listPage.exists()).toBe(false);
expect(msgBox.exists()).toBe(true);
});

it('renders `LoadingBox` if still detecting OpenShift or namespaces/projects are loading', () => {
wrapper = wrapper.setProps({namespaceEnabled: false, loading: true});
wrapper = wrapper.setProps({loading: true});
const msgBox = wrapper.find(MsgBox);
const listPage = wrapper.find(ListPage);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/* eslint-disable no-undef */
/* eslint-disable no-undef, no-unused-vars */

import * as React from 'react';
import { Link, match as RouterMatch } from 'react-router-dom';
import * as _ from 'lodash-es';
import { Map as ImmutableMap } from 'immutable';
import { connect } from 'react-redux';
import { Alert } from 'patternfly-react';

Expand All @@ -24,7 +23,6 @@ import {
referenceForCRDDesc
} from './index';
import {
Box,
Cog,
LoadingBox,
MsgBox,
Expand All @@ -39,8 +37,6 @@ import {
ScrollToTopOnMount,
} from '../utils';

import * as operatorLogo from '../../imgs/operator.svg';

export const ClusterServiceVersionHeader: React.SFC = () => <ListHeader>
<ColHead className="col-lg-3 col-md-4 col-sm-4 col-xs-6" sortField="metadata.name">Name</ColHead>
<ColHead className="col-lg-2 col-md-2 col-sm-4 col-xs-6">Namespace</ColHead>
Expand Down Expand Up @@ -96,9 +92,7 @@ export const ClusterServiceVersionList: React.SFC<ClusterServiceVersionListProps
};

const stateToProps = ({k8s, FLAGS}, {match}) => ({
loading: FLAGS.get(featureFlags.OPENSHIFT) === undefined || !k8s.getIn([FLAGS.get(featureFlags.OPENSHIFT) ? 'projects' : 'namespaces', 'loaded']),
namespaceEnabled: k8s.getIn([FLAGS.get(featureFlags.OPENSHIFT) ? 'projects' : 'namespaces', 'data'], ImmutableMap())
.find((objMap) => objMap.getIn(['metadata', 'name']) === match.params.ns && objMap.getIn(['metadata', 'annotations', 'alm-manager'])) !== undefined,
loading: FLAGS.get(featureFlags.OPENSHIFT) === undefined || !k8s.getIn([FLAGS.get(featureFlags.OPENSHIFT) ? 'projects' : 'namespaces', 'loaded'])
});

export const ClusterServiceVersionsPage = connect(stateToProps)((props: ClusterServiceVersionsPageProps) => {
Expand All @@ -107,22 +101,17 @@ export const ClusterServiceVersionsPage = connect(stateToProps)((props: ClusterS
return <LoadingBox />;
}

return props.match.params.ns && !props.namespaceEnabled
? <Box className="text-center">
<img className="co-clusterserviceversion-list__disabled-icon" src={operatorLogo} />
<MsgBox title="Operator Lifecycle Manager not enabled for this namespace" detail="Please contact a system administrator and ask them to enable Operator Lifecycle Manager to continue." />
</Box>
: <React.Fragment>
<PageHeading title="Cluster Service Versions" />
<ListPage
{...props}
namespace={props.match.params.ns}
kind={referenceForModel(ClusterServiceVersionModel)}
ListComponent={ClusterServiceVersionList}
helpText={helpText}
filterLabel="Cluster Service Versions by name"
showTitle={false} />
</React.Fragment>;
return <React.Fragment>
<PageHeading title="Cluster Service Versions" />
<ListPage
{...props}
namespace={props.match.params.ns}
kind={referenceForModel(ClusterServiceVersionModel)}
ListComponent={ClusterServiceVersionList}
helpText={helpText}
filterLabel="Cluster Service Versions by name"
showTitle={false} />
</React.Fragment>;
});

export const MarkdownView = (props: {content: string}) => {
Expand Down Expand Up @@ -257,7 +246,6 @@ export const ClusterServiceVersionsDetailsPage: React.StatelessComponent<Cluster
export type ClusterServiceVersionsPageProps = {
kind: string;
loading?: boolean;
namespaceEnabled: boolean;
match: RouterMatch<{ns?: string}>;
resourceDescriptions: CRDDescription[];
};
Expand Down