Skip to content

Commit

Permalink
handle certificate renewal
Browse files Browse the repository at this point in the history
  • Loading branch information
ousmaneo committed Dec 1, 2023
1 parent 0ef3d89 commit 1a2db03
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ import OverlayDropdownButton from 'components/common/OverlayDropdownButton';
import { MORE_ACTIONS_TITLE, MORE_ACTIONS_HOVER_TITLE } from 'components/common/EntityDataTable/Constants';
import Routes from 'routing/Routes';

import { rejoinDataNode, removeDataNode } from '../hooks/useDataNodes';
import { rejoinDataNode, removeDataNode, renewDatanodeCertificate } from '../hooks/useDataNodes';

type Props = {
dataNode: DataNode,
};
const DIALOG_TYPES = {
REJOIN: 'rejoin',
REMOVE: 'remove',
RENEW_CERT: 'renew',
};
const DIALOG_TEXT = {
[DIALOG_TYPES.REJOIN]: {
Expand Down Expand Up @@ -101,7 +102,7 @@ const DataNodeActions = ({ dataNode }: Props) => {
disabled={false}
dropdownZIndex={1000}>
<MenuItem onSelect={() => Routes.SYSTEM.DATANODES.SHOW(dataNode.node_id)}>Edit</MenuItem>
<MenuItem onSelect={() => {}}>Renew certificate</MenuItem>
<MenuItem onSelect={() => renewDatanodeCertificate(dataNode.node_id)}>Renew certificate</MenuItem>
<MenuItem onSelect={() => {}}>Restart</MenuItem>
<MenuItem onSelect={() => handleAction(DIALOG_TYPES.REJOIN)}>Rejoin</MenuItem>
<MenuItem onSelect={() => handleAction(DIALOG_TYPES.REMOVE)}>Remove</MenuItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { useQuery } from '@tanstack/react-query';
import { qualifyUrl } from 'util/URLUtils';
import PaginationURL from 'util/PaginationURL';
import type { DataNode } from 'preflight/types';
import UserNotification from 'preflight/util/UserNotification';
import UserNotification from 'util/UserNotification';
import fetch from 'logic/rest/FetchProvider';
import type { Attribute, PaginatedListJSON, SearchParams } from 'stores/PaginationTypes';

Expand Down Expand Up @@ -47,6 +47,14 @@ type Options = {
enabled: boolean,
}

export const renewDatanodeCertificate = (nodeId: string) => fetch('POST', qualifyUrl(`/certrenewal/${nodeId}`))
.then(() => {
UserNotification.success('Certificate renewed successfully');
})
.catch((error) => {
UserNotification.error(`Certificate renewal failed with error: ${error}`);
});

const fetchDataNodes = async (params?: SearchParams) => {
const url = PaginationURL('/system/cluster/datanodes', params?.page, params?.pageSize, params?.query, { sort: params?.sort?.attributeId, order: params?.sort?.direction });

Expand Down
4 changes: 3 additions & 1 deletion graylog2-web-interface/src/pages/DataNodePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import type { SearchParams } from 'stores/PaginationTypes';

const StyledHorizontalDl = styled.dl(({ theme }) => css`
margin: ${theme.spacings.md} 0;
> dt {
clear: left;
float: left;
Expand All @@ -36,6 +37,7 @@ const StyledHorizontalDl = styled.dl(({ theme }) => css`
white-space: nowrap;
width: 150px;
}
> *:not(dt) {
margin-bottom: ${theme.spacings.md};
margin-left: 140px;
Expand Down Expand Up @@ -85,7 +87,7 @@ const DataNodePage = () => {
title={datanode.data_node_status}
aria-label={datanode.data_node_status}
role="button">
{datanode.status || 'N/A'}
{datanode.data_node_status || 'N/A'}
</StatusLabel>
</dd>
</StyledHorizontalDl>
Expand Down

0 comments on commit 1a2db03

Please sign in to comment.