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

ISW - Add Start Input Step #21163

Merged
merged 30 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
804ef40
first batch of start input step
grotlue Dec 3, 2024
623c933
remove obsolete state update
grotlue Dec 3, 2024
940a4b5
Add own hooks for calls and progress messages
grotlue Dec 5, 2024
6ff2d68
Use icons for sucess and error messages
grotlue Dec 5, 2024
9fb56a7
Add more Icon styles
grotlue Dec 5, 2024
4960eda
Split contexts and move provider into component
grotlue Dec 5, 2024
58531c3
Remove effect to set next step enabled
grotlue Dec 9, 2024
4ecd3b3
Fix copy on routing step
grotlue Dec 9, 2024
5bd16e4
small typo improvement for start input step
grotlue Dec 9, 2024
baec5f5
Remove obsolete routing parameter
grotlue Dec 9, 2024
abdef2d
Only set default values when stream type is not yet set
grotlue Dec 9, 2024
af39cd6
Fix alert not disappearing
grotlue Dec 9, 2024
3df7ca0
Fix logic for input diagnosis button disabled
grotlue Dec 9, 2024
e4522af
Show entity in progress message if available
grotlue Dec 9, 2024
64415fb
Merge branch 'master' into feat/20567/isw-start-input
grotlue Dec 10, 2024
d15351e
Add rollback strategy
grotlue Dec 10, 2024
d57e7cc
show start input button after rollback
grotlue Dec 10, 2024
23167f3
Add slightly better copy
grotlue Dec 10, 2024
8b85f03
Use new remove routing call
grotlue Dec 11, 2024
34b175f
Use call to delete rule
grotlue Dec 11, 2024
585b084
Add initial start input tests
grotlue Dec 11, 2024
1bf1ba7
Merge branch 'master' into feat/20567/isw-start-input
gally47 Dec 11, 2024
39a7c0f
Add missing license header
grotlue Dec 11, 2024
24bfb4d
Add more test cases
grotlue Dec 11, 2024
a8a585b
Add test case for starting the stream
grotlue Dec 11, 2024
8637e52
Merge branch 'master' into feat/20567/isw-start-input
gally47 Dec 11, 2024
48315b8
Fix typescript errors
grotlue Dec 12, 2024
127f82f
Fix review comments
grotlue Dec 12, 2024
92234ee
Dont close wizard on backdrop click but add close button
grotlue Dec 12, 2024
dab3cb7
Merge branch 'master' into feat/20567/isw-start-input
gally47 Dec 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions graylog2-web-interface/src/components/inputs/InputListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import { TELEMETRY_EVENT_TYPE } from 'logic/telemetry/Constants';
import useSendTelemetry from 'logic/telemetry/useSendTelemetry';
import useLocation from 'routing/useLocation';
import useFeature from 'hooks/useFeature';
import { INPUT_SETUP_MODE_FEATURE_FLAG } from 'components/inputs/InputSetupWizard';
import { INPUT_SETUP_MODE_FEATURE_FLAG, InputSetupWizard } from 'components/inputs/InputSetupWizard';

type Props = {
input: Input,
Expand All @@ -68,12 +68,21 @@ const InputListItem = ({ input, currentNode, permissions }: Props) => {
const [showConfirmDeleteDialog, setShowConfirmDeleteDialog] = useState<boolean>(false);
const [showStaticFieldForm, setShowStaticFieldForm] = useState<boolean>(false);
const [showConfigurationForm, setShowConfigurationForm] = useState<boolean>(false);
const [showWizard, setShowWizard] = useState<boolean>(false);
const sendTelemetry = useSendTelemetry();
const { pathname } = useLocation();
const { inputTypes, inputDescriptions } = useStore(InputTypesStore);
const { inputStates } = useStore(InputStatesStore) as { inputStates: InputStates };
const inputSetupFeatureFlagIsEnabled = useFeature(INPUT_SETUP_MODE_FEATURE_FLAG);

const openWizard = () => {
setShowWizard(true);
};

const closeWizard = () => {
setShowWizard(false);
};

const deleteInput = () => {
setShowConfirmDeleteDialog(true);
};
Expand Down Expand Up @@ -187,7 +196,7 @@ const InputListItem = ({ input, currentNode, permissions }: Props) => {
);
}

actions.push(<InputStateControl key={`input-state-control-${input.id}`} input={input} />);
actions.push(<InputStateControl key={`input-state-control-${input.id}`} input={input} openWizard={openWizard} />);
}

actions.push(
Expand Down Expand Up @@ -261,6 +270,7 @@ const InputListItem = ({ input, currentNode, permissions }: Props) => {

const additionalContent = (
<div>
{inputSetupFeatureFlagIsEnabled && showWizard && (<InputSetupWizard input={input} show={showWizard} onClose={closeWizard} />)}
<Col md={8}>
<ConfigurationWell id={input.id}
configuration={input.attributes}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,32 @@ import * as React from 'react';
import { render, screen, fireEvent, waitFor } from 'wrappedTestingLibrary';
import selectEvent from 'react-select-event';

import { Button } from 'components/bootstrap';
import { asMock } from 'helpers/mocking';
import usePipelinesConnectedStream from 'hooks/usePipelinesConnectedStream';
import { useInputSetupWizard, InputSetupWizardProvider, INPUT_WIZARD_STEPS } from 'components/inputs/InputSetupWizard';
import type { WizardData } from 'components/inputs/InputSetupWizard';
import useStreams from 'components/streams/hooks/useStreams';
import useIndexSetsList from 'components/indices/hooks/useIndexSetsList';

import InputSetupWizard from './InputSetupWizard';

const OpenWizardTestButton = ({ wizardData } : { wizardData: WizardData}) => {
const { openWizard, setActiveStep } = useInputSetupWizard();

const open = () => {
setActiveStep(INPUT_WIZARD_STEPS.SETUP_ROUTING);
openWizard(wizardData);
};

return (<Button onClick={() => open()}>Open Wizard!</Button>);
import InputSetupWizardProvider from './contexts/InputSetupWizardProvider';
import InputSetupWizard from './Wizard';

const input = {
id: 'inputId',
title: 'inputTitle',
type: 'type',
global: false,
name: 'inputName',
created_at: '',
creator_user_id: 'creatorId',
static_fields: { },
attributes: { },
};

const renderWizard = (wizardData: WizardData = {}) => (
const onClose = jest.fn();

const renderWizard = () => (
render(
<InputSetupWizardProvider>
<OpenWizardTestButton wizardData={wizardData} />
<InputSetupWizard />
<InputSetupWizard show input={input} onClose={onClose} />
</InputSetupWizardProvider>,
)
);
Expand Down Expand Up @@ -170,12 +170,6 @@ const getStreamCreateFormFields = async () => {
};
};

const openWizard = async () => {
const openButton = await screen.findByRole('button', { name: /Open Wizard!/ });

fireEvent.click(openButton);
};

beforeEach(() => {
asMock(useStreams).mockReturnValue(useStreamsResult());
asMock(usePipelinesConnectedStream).mockReturnValue(pipelinesConnectedMock());
Expand All @@ -185,11 +179,10 @@ beforeEach(() => {
describe('InputSetupWizard Setup Routing', () => {
it('should render the Setup Routing step', async () => {
renderWizard();
openWizard();

const wizard = await screen.findByText('Setup Routing');
const routingStepText = await screen.findByText(/Choose a Destination Stream to route Messages from this Input to./i);

expect(wizard).toBeInTheDocument();
expect(routingStepText).toBeInTheDocument();
});

it('should only show editable existing streams', async () => {
Expand All @@ -201,7 +194,6 @@ describe('InputSetupWizard Setup Routing', () => {
));

renderWizard();
openWizard();

const streamSelect = await screen.findByLabelText(/All messages \(Default\)/i);

Expand All @@ -223,7 +215,6 @@ describe('InputSetupWizard Setup Routing', () => {
));

renderWizard();
openWizard();

const streamSelect = await screen.findByLabelText(/All messages \(Default\)/i);

Expand All @@ -245,7 +236,6 @@ describe('InputSetupWizard Setup Routing', () => {
));

renderWizard();
openWizard();

const streamSelect = await screen.findByLabelText(/All messages \(Default\)/i);

Expand All @@ -268,7 +258,6 @@ describe('InputSetupWizard Setup Routing', () => {
]));

renderWizard();
openWizard();

const streamSelect = await screen.findByLabelText(/All messages \(Default\)/i);

Expand All @@ -290,7 +279,6 @@ describe('InputSetupWizard Setup Routing', () => {
asMock(useIndexSetsList).mockReturnValue(useIndexSetsListResult);

renderWizard();
openWizard();

const createStreamButton = await screen.findByRole('button', {
name: /Create Stream/i,
Expand Down Expand Up @@ -328,7 +316,6 @@ describe('InputSetupWizard Setup Routing', () => {
asMock(useIndexSetsList).mockReturnValue(useIndexSetsListResult);

renderWizard();
openWizard();

const createStreamButton = await screen.findByRole('button', {
name: /Create Stream/i,
Expand Down Expand Up @@ -369,7 +356,6 @@ describe('InputSetupWizard Setup Routing', () => {
asMock(useIndexSetsList).mockReturnValue(useIndexSetsListResult);

renderWizard();
openWizard();

const createStreamButton = await screen.findByRole('button', {
name: /Create Stream/i,
Expand Down
Loading
Loading