Skip to content

Commit ca0a77a

Browse files
authored
Reusable HelpPopover (#22060)
* HelpPopover initial setup * implemented new HelpPopoverButton * add bsStyle prop
1 parent 252fe8b commit ca0a77a

File tree

5 files changed

+42
-90
lines changed

5 files changed

+42
-90
lines changed

graylog2-web-interface/src/components/inputs/InputDiagnosis/DiagnosisHelp.tsx renamed to graylog2-web-interface/src/components/common/HelpPopoverButton.tsx

+15-14
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,34 @@
1717
import type { PropsWithChildren } from 'react';
1818
import React, { useState } from 'react';
1919
import styled, { css } from 'styled-components';
20+
import type { ColorVariant } from '@graylog/sawmill';
2021

2122
import { Button } from 'components/bootstrap';
2223
import { Icon } from 'components/common';
2324
import Popover from 'components/common/Popover';
25+
import type { BsSize } from 'components/bootstrap/types';
2426

2527
type Props = PropsWithChildren<{
26-
helpText: string;
28+
helpText: string|React.ReactNode;
29+
bsStyle?: ColorVariant;
30+
bsSize?: BsSize;
2731
}>;
2832

29-
const StyledButton = styled(Button)(
30-
({ theme }) => css`
31-
padding: 1px 0;
32-
font-size: ${theme.fonts.size.body};
33-
`,
34-
);
33+
const StyledButton = styled(Button)`
34+
padding: 1px 0;
35+
`;
3536

3637
const StyledOverlay = styled(Popover.Dropdown)`
3738
white-space: pre-line;
3839
`;
3940

40-
const HelpIcon = styled(Icon)(
41-
({ theme }) => css`
42-
color: ${theme.colors.variant.info};
41+
const StyledIcon = styled(Icon)<{ $bsStyle: ColorVariant }>(
42+
({ $bsStyle, theme }) => css`
43+
color: ${theme.colors.variant[$bsStyle]};
4344
`,
4445
);
4546

46-
const DiagnosisHelp = ({ helpText, children = null }: Props) => {
47+
const HelpPopoverButton = ({ helpText, bsStyle = "info", bsSize = "medium" }: Props) => {
4748
const [showHelp, setShowHelp] = useState(false);
4849
const toggleHelp = () => setShowHelp((cur) => !cur);
4950

@@ -57,13 +58,13 @@ const DiagnosisHelp = ({ helpText, children = null }: Props) => {
5758
closeOnClickOutside
5859
withinPortal>
5960
<Popover.Target>
60-
<StyledButton bsStyle="transparent" bsSize={children ? 'xs' : 'medium'} onClick={toggleHelp}>
61-
{children || <HelpIcon name="help" />}
61+
<StyledButton bsStyle="transparent" bsSize={bsSize} onClick={toggleHelp}>
62+
<StyledIcon name="help" $bsStyle={bsStyle} />
6263
</StyledButton>
6364
</Popover.Target>
6465
<StyledOverlay>{helpText}</StyledOverlay>
6566
</Popover>
6667
);
6768
};
6869

69-
export default DiagnosisHelp;
70+
export default HelpPopoverButton;

graylog2-web-interface/src/components/datanode/DataNodeUpgrade/DataNodeUpgradeHelp.tsx

-66
This file was deleted.

graylog2-web-interface/src/components/inputs/InputDiagnosis/DiagnosisMessageErrors.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import { Section } from 'components/common';
2121
import StatusColorIndicator from 'components/common/StatusColorIndicator';
2222
import { ListGroup, ListGroupItem } from 'components/bootstrap';
2323
import usePluginEntities from 'hooks/usePluginEntities';
24+
import HelpPopoverButton from 'components/common/HelpPopoverButton';
2425

25-
import DiagnosisHelp from './DiagnosisHelp';
2626
import { DIAGNOSIS_HELP } from './Constants';
2727

2828
type Props = {
@@ -83,7 +83,7 @@ const DiagnosisMessageErrors = ({ messageErrors, inputId }: Props) => {
8383
<Section
8484
preHeaderSection={<StatusColorIndicator radius="50%" bsStyle={hasError ? 'danger' : 'gray'} />}
8585
headerLeftSection={
86-
<DiagnosisHelp
86+
<HelpPopoverButton
8787
helpText={`Message Error at Input:
8888
${DIAGNOSIS_HELP.MESSAGE_ERROR_AT_INPUT}
8989

graylog2-web-interface/src/pages/DataNodeUpgradePage.tsx

+20-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import useDataNodeUpgradeStatus, {
2929
import type { DataNodeInformation } from 'components/datanode/hooks/useDataNodeUpgradeStatus';
3030
import ClusterConfigurationPageNavigation from 'components/cluster-configuration/ClusterConfigurationPageNavigation';
3131
import DocumentationLink from 'components/support/DocumentationLink';
32-
import DataNodeUpgradeHelp from 'components/datanode/DataNodeUpgrade/DataNodeUpgradeHelp';
32+
import HelpPopoverButton from 'components/common/HelpPopoverButton';
3333

3434
const StyledHorizontalDl = styled.dl(
3535
({ theme }) => css`
@@ -186,8 +186,25 @@ const DataNodeUpgradePage = () => {
186186
<h3>
187187
<Label bsStyle={getClusterHealthStyle(data?.cluster_state?.status)} bsSize="xs">
188188
{data?.cluster_state?.cluster_name}: {data?.cluster_state?.status}
189-
</Label>
190-
<DataNodeUpgradeHelp />
189+
</Label>&nbsp;
190+
<HelpPopoverButton helpText={
191+
<>
192+
<p>How does my cluster change state during the rolling upgrade?</p>
193+
<p>
194+
RED - if you are using indices with no replication and upgrade the node hosting the shards of these indices,
195+
the cluster will go to a red state and no data will be ingested into or searchable from these indices.
196+
</p>
197+
<p>
198+
YELLOW - after starting the upgrade of a node, shard allocation will be set to no replication to allow
199+
OpenSearch to use only the available shards.
200+
</p>
201+
<p>
202+
After a node has been upgraded and you click on <em>Confirm Upgrade</em>, shard replication will be re-enabled
203+
and all shards that were unavailable due to the node being upgraded will be re-allocated and the cluster will
204+
return to a GREEN state.
205+
</p>
206+
</>
207+
} />
191208
</h3>
192209
<StyledHorizontalDl>
193210
<dt>Shard Replication:</dt>

graylog2-web-interface/src/pages/InputDiagnosisPage.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ import type { InputState } from 'stores/inputs/InputStatesStore';
3636
import SectionGrid from 'components/common/Section/SectionGrid';
3737
import StatusColorIndicator from 'components/common/StatusColorIndicator';
3838
import DiagnosisMessageErrors from 'components/inputs/InputDiagnosis/DiagnosisMessageErrors';
39-
import DiagnosisHelp from 'components/inputs/InputDiagnosis/DiagnosisHelp';
4039
import { DIAGNOSIS_HELP } from 'components/inputs/InputDiagnosis/Constants';
40+
import HelpPopoverButton from 'components/common/HelpPopoverButton';
4141

4242
const LeftCol = styled.div(
4343
({ theme }) => css`
@@ -250,7 +250,7 @@ const InputDiagnosisPage = () => {
250250
title="Information"
251251
preHeaderSection={<StatusColorIndicator radius="50%" />}
252252
headerLeftSection={
253-
<DiagnosisHelp
253+
<HelpPopoverButton
254254
helpText={`This Input Is Listening On:
255255
${DIAGNOSIS_HELP.INPUT_LISTENING_ON}
256256
@@ -296,7 +296,7 @@ const InputDiagnosisPage = () => {
296296
bsStyle={isInputStateDown ? 'danger' : 'success'}
297297
/>
298298
}
299-
headerLeftSection={<DiagnosisHelp helpText={DIAGNOSIS_HELP.INPUT_STATE} />}>
299+
headerLeftSection={<HelpPopoverButton helpText={DIAGNOSIS_HELP.INPUT_STATE} />}>
300300
<StyledP>
301301
Number of Graylog nodes the Input is configured to run, and on how many it is running. If any are not
302302
running, click to see any associated error messages.
@@ -402,7 +402,7 @@ const InputDiagnosisPage = () => {
402402
<StatusColorIndicator radius="50%" bsStyle={hasReceivedMessageMetrics ? 'success' : 'gray'} />
403403
}
404404
headerLeftSection={
405-
<DiagnosisHelp
405+
<HelpPopoverButton
406406
helpText={`Empty Messages discarded:
407407
${DIAGNOSIS_HELP.EMPTY_MESSAGES_DISCARDED}
408408
@@ -451,7 +451,7 @@ const InputDiagnosisPage = () => {
451451
<Section
452452
preHeaderSection={<StatusColorIndicator radius="50%" bsStyle={hasReceivedMessage ? 'success' : 'gray'} />}
453453
title="Received Message count by Stream"
454-
headerLeftSection={<DiagnosisHelp helpText={DIAGNOSIS_HELP.RECEIVED_MESSAGE_COUNT_BY_STREAM} />}
454+
headerLeftSection={<HelpPopoverButton helpText={DIAGNOSIS_HELP.RECEIVED_MESSAGE_COUNT_BY_STREAM} />}
455455
actions={<ShowReceivedMessagesButton input={input} />}>
456456
<StyledP>
457457
Messages successfully ingested into Graylog from this Input in the last 15 minutes. Click on the Stream to

0 commit comments

Comments
 (0)