Skip to content

Commit

Permalink
fix review
Browse files Browse the repository at this point in the history
  • Loading branch information
ousmaneo committed Oct 1, 2024
1 parent eee2e67 commit be1ef4f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import type { StreamRule } from 'stores/streams/StreamsStore';
import { StreamRulesStore } from 'stores/streams/StreamRulesStore';
import UserNotification from 'util/UserNotification';
import { IfPermitted } from 'components/common';
import { TELEMETRY_EVENT_TYPE } from 'logic/telemetry/Constants';
import useSendTelemetry from 'logic/telemetry/useSendTelemetry';

import StreamRuleModal from './StreamRuleModal';

Expand All @@ -42,19 +44,26 @@ const CreateStreamRuleButton = ({ bsSize, bsStyle, buttonText, className, disabl
const [showCreateModal, setShowCreateModal] = useState(false);
const queryClient = useQueryClient();
const toggleCreateModal = useCallback(() => setShowCreateModal((cur) => !cur), []);
const sendTelemetry = useSendTelemetry();

const onSaveStreamRule = useCallback((_streamRuleId: string, streamRule: StreamRule) => StreamRulesStore.create(streamId, streamRule, () => {
UserNotification.success('Stream rule was created successfully.', 'Success');
queryClient.invalidateQueries(['stream', streamId]);
}), [streamId, queryClient]);
const onCreateStreamRule = () => {
sendTelemetry(TELEMETRY_EVENT_TYPE.STREAMS.STREAM_ITEM_DATA_ROUTING_INTAKE_CREATE_RULE_OPENED, {
app_pathname: 'streams',
});
toggleCreateModal();

Check warning on line 57 in graylog2-web-interface/src/components/streamrules/CreateStreamRuleButton.tsx

View workflow job for this annotation

GitHub Actions / Reviewbot

Expected blank line before this statement.

See https://eslint.org/docs/rules/padding-line-between-statements for details.
};

Check warning on line 58 in graylog2-web-interface/src/components/streamrules/CreateStreamRuleButton.tsx

View workflow job for this annotation

GitHub Actions / Reviewbot

Expected blank line before this statement.

See https://eslint.org/docs/rules/padding-line-between-statements for details.

return (
<IfPermitted permissions={`streams:edit:${streamId}`}>
<Button bsSize={bsSize}
bsStyle={bsStyle}
disabled={disabled}
className={className}
onClick={toggleCreateModal}>
onClick={onCreateStreamRule}>
{buttonText}
</Button>
{showCreateModal && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ const StreamDetails = ({ stream }: Props) => {
sendTelemetry(TELEMETRY_EVENT_TYPE.STREAMS.STREAM_ITEM_DATA_ROUTING_UPDATE_CLICKED, {
app_pathname: 'streams',
});
}, []);
}, [sendTelemetry]);
const onUpdate = useCallback((newStream: Stream) => StreamsStore.update(stream.id, newStream, (response) => {
UserNotification.success(`Stream '${newStream.title}' was updated successfully.`, 'Success');
queryClient.invalidateQueries(['stream', stream.id]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import { isPermitted } from 'util/PermissionsMixin';
import useCurrentUser from 'hooks/useCurrentUser';
import type { PipelineType } from 'stores/pipelines/PipelinesStore';
import useStreamPipelinesConnectionMutation from 'components/streams/hooks/useStreamPipelinesConnections';
import useSendTelemetry from 'logic/telemetry/useSendTelemetry';
import { TELEMETRY_EVENT_TYPE } from 'logic/telemetry/Constants';

type Props = {
streamId: string,
Expand All @@ -51,13 +53,17 @@ const StreamPipelinesConnectionForm = ({ streamId, pipelines, connectedPipelines
const formattedConnectedPipelines = formatPipelines(connectedPipelines);
const [updatedPipelines, setUpdatePipelines] = useState<Array<FormattedPipelines>>(formattedConnectedPipelines);
const notConnectedPipelines = useMemo(() => pipelines.filter((s) => !updatedPipelines.some((cs) => cs.value.toLowerCase() === s.id.toLowerCase())), [pipelines, updatedPipelines]);
const sendTelemetry = useSendTelemetry();

useEffect(() => {
setUpdatePipelines(formatPipelines(connectedPipelines));
}, [connectedPipelines]);

const openModal = () => {
setShowModal(true);
sendTelemetry(TELEMETRY_EVENT_TYPE.STREAMS.STREAM_ITEM_DATA_ROUTING_PROCESSING_EDIT_PIPELINES_CONNECTION, {
app_pathname: 'streams',
});

Check warning on line 66 in graylog2-web-interface/src/components/streams/StreamDetails/StreamPipelinesConnectionForm.tsx

View workflow job for this annotation

GitHub Actions / Reviewbot

Expected blank line before this statement.

See https://eslint.org/docs/rules/padding-line-between-statements for details.
};

const onPipelineChange = (newPipelines: Array<FormattedPipelines>) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
* along with this program. If not, see
* <http://www.mongodb.com/licensing/server-side-public-license>.
*/
import HideOnCloud from 'util/conditional/HideOnCloud';
import UserNotification from 'util/UserNotification';

import * as React from 'react';
import { useState, useCallback } from 'react';

Expand All @@ -36,9 +33,10 @@ import { TELEMETRY_EVENT_TYPE } from 'logic/telemetry/Constants';
import useSelectedEntities from 'components/common/EntityDataTable/hooks/useSelectedEntities';
import { MoreActions } from 'components/common/EntityDataTable';
import { LinkContainer } from 'components/common/router';
import HideOnCloud from 'util/conditional/HideOnCloud';
import UserNotification from 'util/UserNotification';

import StreamDeleteModal from './StreamDeleteModal';

Check warning on line 39 in graylog2-web-interface/src/components/streams/StreamsOverview/StreamActions.tsx

View workflow job for this annotation

GitHub Actions / Reviewbot

There should be at least one empty line between import groups

No further rule information available.

import StreamModal from '../StreamModal';

const DefaultStreamHelp = () => (
Expand Down

0 comments on commit be1ef4f

Please sign in to comment.