-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* cherry picked new datanode page * initial setup for datanode page navigation * added DataNodesPageNavigation to pages * DataNodeList component initial setup * fix build * datanode list initial prototype * fix eslint issues * add datanode list components * fix eslint issues * add new data node button * prepare column components * DataNodeStatusCell component * useDataNodes return type * fix build * fix build errors * fix eslint issues * initial api integration * refetch on change * added removeDataNode & rejoinDataNode endpoints * datanode actions integration progress * cleanup DataNodeStatusCell * DataNodeStatusCell using data_node_status * refetch list every 5s * cleanup * add datanode details page * update datanode page * add todo * add license header * fix linter * fix linter * Updating yarn lockfile (#17528) Co-authored-by: Gary Bot <[email protected]> * replace quotes * add confirm dialog for actions * cleanup status cell * handle certificate renewal * remove bulk actions * add start/stop datanode * show leader and add cert info to details * remove is_master * use correct action on start button * fix spelling * fix review * update Datatable QueryHelper example to use ReactNode * remove DataNodeBulkActions * fix query by name * add check for removal of running nodes * remove done todo * fix reset to do a complete restart * make status and cert_valid_until not sortable * update spelling * Update graylog2-web-interface/src/components/datanode/DataNodeList/DataNodeActions.tsx * Update graylog2-web-interface/src/components/datanode/hooks/useDataNodes.ts * show remove and rejoin for relevant state --------- Co-authored-by: Ousmane Samba <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Gary Bot <[email protected]> Co-authored-by: Matthias Oesterheld <[email protected]> Co-authored-by: Laura <[email protected]>
- Loading branch information
1 parent
16f3d66
commit f0a9ca2
Showing
25 changed files
with
775 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
146 changes: 146 additions & 0 deletions
146
graylog2-web-interface/src/components/datanode/DataNodeList/DataNodeActions.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
/* | ||
* Copyright (C) 2020 Graylog, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the Server Side Public License, version 1, | ||
* as published by MongoDB, Inc. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* Server Side Public License for more details. | ||
* | ||
* You should have received a copy of the Server Side Public License | ||
* along with this program. If not, see | ||
* <http://www.mongodb.com/licensing/server-side-public-license>. | ||
*/ | ||
import * as React from 'react'; | ||
import { useState } from 'react'; | ||
|
||
import type { DataNode } from 'preflight/types'; | ||
import { ConfirmDialog } from 'components/common'; | ||
import { MenuItem } from 'components/bootstrap'; | ||
import OverlayDropdownButton from 'components/common/OverlayDropdownButton'; | ||
import { MORE_ACTIONS_TITLE, MORE_ACTIONS_HOVER_TITLE } from 'components/common/EntityDataTable/Constants'; | ||
|
||
import { | ||
rejoinDataNode, | ||
removeDataNode, | ||
renewDatanodeCertificate, | ||
stopDataNode, | ||
startDataNode, | ||
} from '../hooks/useDataNodes'; | ||
|
||
type Props = { | ||
dataNode: DataNode, | ||
}; | ||
|
||
const DIALOG_TYPES = { | ||
STOP: 'stop', | ||
REJOIN: 'rejoin', | ||
REMOVE: 'remove', | ||
RENEW_CERT: 'renew', | ||
}; | ||
|
||
const DIALOG_TEXT = { | ||
[DIALOG_TYPES.REJOIN]: { | ||
dialogTitle: 'Rejoin Data Node', | ||
dialogBody: (datanode: string) => `Are you sure you want to rejoin Data Node "${datanode}"?`, | ||
}, | ||
[DIALOG_TYPES.REMOVE]: { | ||
dialogTitle: 'Remove Data Node', | ||
dialogBody: (datanode: string) => `Are you sure you want to remove Data Node "${datanode}"?`, | ||
}, | ||
[DIALOG_TYPES.STOP]: { | ||
dialogTitle: 'Stop Data Node', | ||
dialogBody: (datanode: string) => `Are you sure you want to stop Data Node "${datanode}"?`, | ||
}, | ||
}; | ||
|
||
const DataNodeActions = ({ dataNode }: Props) => { | ||
const [showDialog, setShowDialog] = useState(false); | ||
const [dialogType, setDialogType] = useState(null); | ||
|
||
const updateState = ({ show, type }) => { | ||
setShowDialog(show); | ||
setDialogType(type); | ||
}; | ||
|
||
const handleAction = (action) => { | ||
switch (action) { | ||
case DIALOG_TYPES.REJOIN: | ||
updateState({ show: true, type: DIALOG_TYPES.REJOIN }); | ||
|
||
break; | ||
case DIALOG_TYPES.REMOVE: | ||
updateState({ show: true, type: DIALOG_TYPES.REMOVE }); | ||
|
||
break; | ||
case DIALOG_TYPES.STOP: | ||
updateState({ show: true, type: DIALOG_TYPES.STOP }); | ||
|
||
break; | ||
default: | ||
break; | ||
} | ||
}; | ||
|
||
const handleClearState = () => { | ||
updateState({ show: false, type: null }); | ||
}; | ||
|
||
const handleConfirm = () => { | ||
switch (dialogType) { | ||
case 'rejoin': | ||
rejoinDataNode(dataNode.node_id).then(() => { | ||
handleClearState(); | ||
}); | ||
|
||
break; | ||
case 'remove': | ||
removeDataNode(dataNode.node_id).then(() => { | ||
handleClearState(); | ||
}); | ||
|
||
break; | ||
case 'stop': | ||
stopDataNode(dataNode.node_id).then(() => { | ||
handleClearState(); | ||
}); | ||
|
||
break; | ||
default: | ||
break; | ||
} | ||
}; | ||
|
||
const isDatanodeRunning = dataNode.data_node_status === 'AVAILABLE'; | ||
const isDatanodeRemoved = dataNode.data_node_status === 'REMOVED'; | ||
const isRemovingDatanode = dataNode.data_node_status === 'REMOVING'; | ||
|
||
return ( | ||
<> | ||
<OverlayDropdownButton title={MORE_ACTIONS_TITLE} | ||
bsSize="xsmall" | ||
buttonTitle={MORE_ACTIONS_HOVER_TITLE} | ||
disabled={false} | ||
dropdownZIndex={1000}> | ||
<MenuItem onSelect={() => renewDatanodeCertificate(dataNode.node_id)}>Renew certificate</MenuItem> | ||
{!isDatanodeRunning && <MenuItem onSelect={() => startDataNode(dataNode.node_id)}>Start</MenuItem>} | ||
{isDatanodeRunning && <MenuItem onSelect={() => handleAction(DIALOG_TYPES.STOP)}>Stop</MenuItem>} | ||
{isDatanodeRemoved && <MenuItem onSelect={() => handleAction(DIALOG_TYPES.REJOIN)}>Rejoin</MenuItem>} | ||
{(!isDatanodeRemoved || isRemovingDatanode) && <MenuItem onSelect={() => handleAction(DIALOG_TYPES.REMOVE)}>Remove</MenuItem>} | ||
</OverlayDropdownButton> | ||
{showDialog && ( | ||
<ConfirmDialog title={DIALOG_TEXT[dialogType].dialogTitle} | ||
show | ||
onConfirm={handleConfirm} | ||
onCancel={handleClearState}> | ||
{DIALOG_TEXT[dialogType].dialogBody(dataNode.hostname)} | ||
</ConfirmDialog> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default DataNodeActions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.