Skip to content

Commit

Permalink
[#6084] Platform UI: disable STOP and REMOVE actions for kubernetes pods
Browse files Browse the repository at this point in the history
Summary:
Disable STOP and REMOVE actions for kubernetes pods as there's no way to do these actions in current deployment model
{F14938}

Test Plan:
1) Run UI
2) Open any valid kubernetes universe
3) Go to the Pods tab
4) Click on the Actions button and observe Stop Process and Remove Node actions in the dropdown menu are disabled and non-clickable

Reviewers: andrew

Reviewed By: andrew

Subscribers: yugaware, ui

Differential Revision: https://phabricator.dev.yugabyte.com/D10513
  • Loading branch information
sshev committed Feb 2, 2021
1 parent e6c0cfc commit b1b5001
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 14 deletions.
31 changes: 21 additions & 10 deletions managed/ui/src/components/universes/NodeDetails/NodeAction.js
Expand Up @@ -26,19 +26,19 @@ export default class NodeAction extends Component {
actionType: PropTypes.oneOf(['STOP', 'REMOVE'])
};

openModal(actionType) {
openModal = (actionType) => {
this.setState((prevState, props) => {
return {
selectedRow: props.row,
actionType: actionType,
showModal: true
};
});
}
};

closeModal() {
this.setState({
showModal: false
showModal: false
});
}

Expand Down Expand Up @@ -85,7 +85,7 @@ export default class NodeAction extends Component {
btnIcon = 'fa fa-link';
} else if (actionType === 'START_MASTER') {
btnIcon = 'fa fa-play-circle';
} else if (actionType === 'QUERIES') {
} else if (actionType === 'QUERIES') {
btnIcon = 'fa fa-search';
}

Expand All @@ -101,19 +101,30 @@ export default class NodeAction extends Component {
} else {
universeUrl = path.substring(0, path.lastIndexOf('/'));
}
browserHistory.push(`${universeUrl}/queries?nodeName=${currentRow.name}`);
browserHistory.push(`${universeUrl}/queries?nodeName=${currentRow.name}`);
}

render() {
const { currentRow, providerUUID, disableConnect, disableQueries, disabled } = this.props;
const {
currentRow,
providerUUID,
hideConnect,
hideQueries,
disableStop,
disableRemove,
disabled
} = this.props;
const actionButtons = currentRow.allowedActions.map((actionType, idx) => {
const btnId = _.uniqueId('node_action_btn_');
const isDisabled = disabled ||
(actionType === 'STOP' && disableStop) ||
(actionType === 'REMOVE' && disableRemove);
return (
<MenuItem
key={btnId}
eventKey={btnId}
disabled={disabled}
onClick={disabled ? null : this.openModal.bind(this, actionType)}
disabled={isDisabled}
onClick={() => isDisabled || this.openModal(actionType)}
>
{this.getLabel(actionType)}
</MenuItem>
Expand All @@ -122,7 +133,7 @@ export default class NodeAction extends Component {

return (
<DropdownButton className="btn btn-default" title="Actions" id="bg-nested-dropdown" pullRight>
{!disableConnect && (
{!hideConnect && (
<NodeConnectModal
currentRow={currentRow}
providerUUID={providerUUID}
Expand All @@ -140,7 +151,7 @@ export default class NodeAction extends Component {
/>
</Fragment>
) : null}
{!disableQueries &&
{!hideQueries &&
<MenuItem key="queries_action_btn" eventKey="queries_action_btn"
disabled={disabled} onClick={this.handleLiveQueryClick}>
{this.getLabel('QUERIES')}
Expand Down
Expand Up @@ -4,9 +4,12 @@ import React, { Component, Fragment } from 'react';
import { BootstrapTable, TableHeaderColumn } from 'react-bootstrap-table';
import 'react-bootstrap-table/css/react-bootstrap-table.css';
import { YBLoadingCircleIcon } from '../../common/indicators';
import { IN_DEVELOPMENT_MODE } from '../../../config';
import { isDefinedNotNull, isNonEmptyString } from '../../../utils/ObjectUtils';
import { getProxyNodeAddress } from '../../../utils/UniverseUtils';
import {
getPrimaryCluster,
getProxyNodeAddress,
getReadOnlyCluster
} from '../../../utils/UniverseUtils';
import { isNotHidden, isDisabled } from '../../../utils/LayoutUtils';
import { YBPanelItem } from '../../panels';
import { NodeAction } from '../../universes';
Expand Down Expand Up @@ -154,12 +157,21 @@ export default class NodeDetailsTable extends Component {
row.allowedActions.splice(index, 1);
}
}

// get universe provider type to disable STOP and REMOVE actions for kubernetes pods (GH #6084)
const cluster = clusterType === 'primary'
? getPrimaryCluster(currentUniverse.data?.universeDetails?.clusters)
: getReadOnlyCluster(currentUniverse.data?.universeDetails?.clusters);
const isKubernetes = cluster?.userIntent?.providerType === 'kubernetes';

return (
<NodeAction
currentRow={row}
providerUUID={providerUUID}
disableConnect={hideIP}
disableQueries={hideQueries}
disableStop={isKubernetes}
disableRemove={isKubernetes}
hideConnect={hideIP}
hideQueries={hideQueries}
disabled={actions_disabled}
/>
);
Expand Down

0 comments on commit b1b5001

Please sign in to comment.