Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1838922: Show BC dropdown only for Noobaa Provisioners #5440

Merged
merged 1 commit into from May 22, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -25,7 +25,7 @@ import {
import { ActionGroup, Button } from '@patternfly/react-core';
import { getName, ResourceDropdown, isObjectSC } from '@console/shared';
import { commonReducer, defaultState } from '../object-bucket-page/state';
import { OCS_NS } from '../../constants';
import { OCS_NS, NB_PROVISIONER } from '../../constants';
import './create-obc.scss';

export const CreateOBCPage: React.FC<CreateOBCPageProps> = (props) => {
Expand Down Expand Up @@ -74,6 +74,11 @@ export const CreateOBCPage: React.FC<CreateOBCPageProps> = (props) => {
});
};

const onScChange = (sc) => {
dispatch({ type: 'setStorage', name: getName(sc) });
dispatch({ type: 'setProvisioner', name: sc?.provisioner });
};

return (
<div className="co-m-pane__body co-m-pane__form">
<Helmet>
Expand Down Expand Up @@ -113,7 +118,7 @@ export const CreateOBCPage: React.FC<CreateOBCPageProps> = (props) => {
</div>
<div className="form-group">
<StorageClassDropdown
onChange={(sc) => dispatch({ type: 'setStorage', name: getName(sc) })}
onChange={onScChange}
required
name="storageClass"
hideClassName="co-required"
Expand All @@ -124,31 +129,33 @@ export const CreateOBCPage: React.FC<CreateOBCPageProps> = (props) => {
Defines the object-store service and the bucket provisioner.
</p>
</div>
<div className="form-group">
<label className="control-label co-required" htmlFor="obc-name">
Bucket Class
</label>
<Firehose
resources={[
{
isList: true,
kind: referenceForModel(NooBaaBucketClassModel),
namespace: OCS_NS,
prop: 'bucketClass',
},
]}
>
<ResourceDropdown
onChange={(sc) => dispatch({ type: 'setBucketClass', name: sc })}
dataSelector={['metadata', 'name']}
selectedKey={state.bucketClass}
placeholder="Select Bucket Class"
dropDownClassName="dropdown--full-width"
className="nb-create-obc__bc-dropdown"
id="bc-dropdown"
/>
</Firehose>
</div>
{state.scProvisioner.includes(NB_PROVISIONER) && !_.isEmpty(state.scProvisioner) && (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{state.scProvisioner.includes(NB_PROVISIONER) && !_.isEmpty(state.scProvisioner) && (
{state.scProvisioner === NB_PROVISIONER && !_.isEmpty(state.scProvisioner) && (

<div className="form-group">
<label className="control-label co-required" htmlFor="obc-name">
Bucket Class
</label>
<Firehose
resources={[
{
isList: true,
kind: referenceForModel(NooBaaBucketClassModel),
namespace: OCS_NS,
prop: 'bucketClass',
},
]}
>
<ResourceDropdown
onChange={(sc) => dispatch({ type: 'setBucketClass', name: sc })}
dataSelector={['metadata', 'name']}
selectedKey={state.bucketClass}
placeholder="Select Bucket Class"
dropDownClassName="dropdown--full-width"
className="nb-create-obc__bc-dropdown"
id="bc-dropdown"
/>
</Firehose>
</div>
)}
</div>
</div>
<ButtonBar errorMessage={state.error} inProgress={state.progress}>
Expand Down
Expand Up @@ -3,6 +3,7 @@ import { K8sResourceKind } from '@console/internal/module/k8s';
type State = {
name: string;
scName: string;
scProvisioner: string;
sizeValue: string;
sizeUnit: string;
progress: boolean;
Expand All @@ -14,6 +15,7 @@ type State = {
export const defaultState = {
name: '',
scName: '',
scProvisioner: '',
progress: false,
error: '',
payload: {},
Expand All @@ -25,6 +27,7 @@ export const defaultState = {
type Action =
| { type: 'setName'; name: string }
| { type: 'setStorage'; name: string }
| { type: 'setProvisioner'; name: string }
| { type: 'setProgress' }
| { type: 'unsetProgress' }
| { type: 'setError'; message: string }
Expand All @@ -38,6 +41,8 @@ export const commonReducer = (state: State, action: Action) => {
return Object.assign({}, state, { name: action.name });
case 'setStorage':
return Object.assign({}, state, { scName: action.name });
case 'setProvisioner':
return Object.assign({}, state, { scProvisioner: action.name });
case 'setProgress':
return Object.assign({}, state, { progress: true });
case 'unsetProgress':
Expand Down
Expand Up @@ -7,6 +7,7 @@ export const BY_EGRESS = 'Egress';
export const PROJECTS = 'Projects';
export const BUCKET_CLASS = 'Bucket Class';
export const OCS_NS = 'openshift-storage';
export const NB_PROVISIONER = 'noobaa.io/obc';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export const NB_PROVISIONER = 'noobaa.io/obc';
export const NB_PROVISIONER = 'openshift-storage.noobaa.io/obc;


export const CHART_LABELS = {
[BY_LOGICAL_USAGE]: 'Logical used capacity per account',
Expand Down
3 changes: 3 additions & 0 deletions frontend/packages/noobaa-storage-plugin/src/utils.ts
Expand Up @@ -2,6 +2,7 @@ import * as _ from 'lodash';
import { Alert } from '@console/internal/components/monitoring';
import { PrometheusResponse } from '@console/internal/components/graphs';
import { K8sResourceKind } from '@console/internal/module/k8s';
import { StorageClass } from '@console/internal/components/storage-class-form';

export const filterNooBaaAlerts = (alerts: Alert[]): Alert[] =>
alerts.filter((alert) => _.get(alert, 'annotations.storage_type') === 'NooBaa');
Expand All @@ -21,3 +22,5 @@ export const getPhase = (obj: K8sResourceKind): string => {
};

export const isBound = (obj: K8sResourceKind): boolean => getPhase(obj) === 'Bound';

export const getSCProvisioner = (obj: StorageClass) => obj.provisioner;