Skip to content

Commit

Permalink
Merge pull request #5621 from christianvogt/default-ns
Browse files Browse the repository at this point in the history
Bug 1840809: set default namespace to ALL_NAMESPACES_KEY
  • Loading branch information
openshift-merge-robot committed May 29, 2020
2 parents e7d61de + 5c81c29 commit b6abf0e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ describe('<PrometheusGraphLink />', () => {
let wrapper;

store.dispatch(setFlag(FLAGS.CAN_GET_NS, false));
store.dispatch(UIActions.setActiveNamespace('default'));
store.dispatch(UIActions.setActivePerspective('dev'));
wrapper = getWrapper('');
expect(wrapper.find(Link).exists()).toBe(false);
Expand Down
5 changes: 5 additions & 0 deletions frontend/packages/dev-console/src/components/EmptyState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useExtensions } from '@console/plugin-sdk';
import { RootState } from '@console/internal/redux';
import { isAddAction, AddAction } from '../extensions/add-actions';
import './EmptyState.scss';
import { ALL_NAMESPACES_KEY } from '@console/shared';

const navigateTo = (e: React.SyntheticEvent, url: string) => {
history.push(url);
Expand All @@ -29,6 +30,10 @@ const Item: React.FC<ItemProps> = ({
// Defined extensions are immutable. This check will be consistent.
// eslint-disable-next-line react-hooks/rules-of-hooks
accessReview.map((descriptor) => useAccessReview({ namespace, ...descriptor })).every((x) => x);
if (namespace === ALL_NAMESPACES_KEY && url.match(/:namespace\b/)) {
// URL expects namespace scope
return null;
}
const resolvedUrl = url.replace(/:namespace\b/g, namespace);
return access ? (
<GalleryItem>
Expand Down
9 changes: 8 additions & 1 deletion frontend/packages/dev-console/src/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ const plugin: Plugin<ConsumedExtensions> = [
type: 'AddAction',
properties: {
id: 'operator-backed',
url: '/catalog/ns/:namespace?kind=%5B"ClusterServiceVersion"%5D',
url: '/catalog?kind=%5B"ClusterServiceVersion"%5D',
label: 'Operator Backed',
description: 'Browse the catalog to discover and deploy operator managed services',
icon: <BoltIcon />,
Expand All @@ -923,6 +923,13 @@ const plugin: Plugin<ConsumedExtensions> = [
label: 'Pipeline',
description: 'Create a Tekton Pipeline to automate delivery of your application',
icon: pipelineIcon,
accessReview: [
{
group: PipelineModel.apiGroup,
resource: PipelineModel.plural,
verb: 'create',
},
],
},
},
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Link } from 'react-router-dom';
import { shallow, ShallowWrapper } from 'enzyme';
import * as _ from 'lodash';
import { Table, TableRow } from '@console/internal/components/factory';
import * as UIActions from '@console/internal/actions/ui';
import { testPackageManifest, testCatalogSource, testSubscription } from '../../mocks';
import { PackageManifestKind } from '../types';
import {
Expand Down Expand Up @@ -33,6 +34,7 @@ describe(PackageManifestTableRow.displayName, () => {
let wrapper: ShallowWrapper<PackageManifestTableRowProps>;

beforeEach(() => {
jest.spyOn(UIActions, 'getActiveNamespace').mockReturnValue('default');
wrapper = shallow(
<PackageManifestTableRow
index={0}
Expand Down
2 changes: 1 addition & 1 deletion frontend/public/reducers/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export default (state: UIState, action: UIAction): UIState => {
return ImmutableMap({
activeNavSectionId: 'workloads',
location: pathname,
activeNamespace: activeNamespace || 'default',
activeNamespace: activeNamespace || ALL_NAMESPACES_KEY,
activeApplication: ALL_APPLICATIONS_KEY,
activePerspective: getDefaultPerspective(),
createProjectMessage: '',
Expand Down

0 comments on commit b6abf0e

Please sign in to comment.