Skip to content

Commit

Permalink
Merge branch 'master' into feat/21326/isw-input-diagnosis-improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonEbel authored Jan 21, 2025
2 parents 727d21d + 8b91f4f commit 8cd2250
Show file tree
Hide file tree
Showing 34 changed files with 523 additions and 156 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/issue-19058.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type = "fixed"
message = "Fixing highlighting of message in message table by id."

issues = ["19058"]
pulls = ["21389"]
5 changes: 5 additions & 0 deletions changelog/unreleased/issue-21185.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type = "f"
message = "Fix displaying very small percentages."

issues = ["21185"]
pulls = ["21368"]
5 changes: 5 additions & 0 deletions changelog/unreleased/pr-21367.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type = "fixed"
message = "Adding missing API descriptions on method parameters for Simple Scripting API."

pulls = ["21367"]
issues = ["20821"]
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@ public TabularResponse executeQuery(@ApiParam(name = "queryRequestSpec") @Valid
@ApiOperation(value = "Execute query specified by query parameters", nickname = "messagesByQueryParameters")
@Path("messages")
@NoAuditEvent("Creating audit event manually in method body.")
public TabularResponse executeQuery(@ApiParam(name = "query") @QueryParam("query") String query,
@ApiParam(name = "streams") @QueryParam("streams") Set<String> streams,
@ApiParam(name = "stream_categories") @QueryParam("stream_categories") Set<String> streamCategories,
@ApiParam(name = "timerange") @QueryParam("timerange") String timerangeKeyword,
@ApiParam(name = "fields") @QueryParam("fields") List<String> fields,
@ApiParam(name = "sort") @QueryParam("sort") String sort,
@ApiParam(name = "sort") @QueryParam("sortOrder") SortSpec.Direction sortOrder,
@ApiParam(name = "from") @QueryParam("from") int from,
@ApiParam(name = "size") @QueryParam("size") int size,
public TabularResponse executeQuery(@ApiParam(name = "query", value = "Query (Lucene syntax)", required = true) @QueryParam("query") String query,
@ApiParam(name = "streams", value = "Comma separated list of streams to search in") Set<String> streams,
@ApiParam(name = "stream_categories", value = "Comma separated list of streams categories to search in") @QueryParam("stream_categories") Set<String> streamCategories,
@ApiParam(name = "timerange", value = "Timeframe to search in. See method description.", required = true) @QueryParam("timerange") String timerangeKeyword,
@ApiParam(name = "fields", value = "Fields from the message to show as columns in result") @QueryParam("fields") List<String> fields,
@ApiParam(name = "sort", value = "Field to sort on") @QueryParam("sort") String sort,
@ApiParam(name = "sortOrder", value = "Sort order - asc/desc") @QueryParam("sortOrder") SortSpec.Direction sortOrder,
@ApiParam(name = "from", value = "For paging results. Starting from result") @QueryParam("from") int from,
@ApiParam(name = "size", value = "Page size") @QueryParam("size") int size,
@Context SearchUser searchUser) {

try {
Expand Down Expand Up @@ -171,12 +171,12 @@ public TabularResponse executeQuery(@ApiParam(name = "searchRequestSpec") @Valid
@ApiOperation(value = "Execute aggregation specified by query parameters", nickname = "aggregateForQueryParameters")
@Path("aggregate")
@NoAuditEvent("Creating audit event manually in method body.")
public TabularResponse executeQuery(@ApiParam(name = "query") @QueryParam("query") String query,
@ApiParam(name = "streams") @QueryParam("streams") Set<String> streams,
@ApiParam(name = "stream_categories") @QueryParam("stream_categories") Set<String> streamCategories,
@ApiParam(name = "timerange") @QueryParam("timerange") String timerangeKeyword,
@ApiParam(name = "groups") @QueryParam("groups") List<String> groups,
@ApiParam(name = "metrics") @QueryParam("metrics") List<String> metrics,
public TabularResponse executeQuery(@ApiParam(name = "query", value = "Query (Lucene syntax)", required = true) @QueryParam("query") String query,
@ApiParam(name = "streams", value = "Comma separated list of streams to search in (can be empty)", required = true) @QueryParam("streams") Set<String> streams,
@ApiParam(name = "stream_categories", value = "Comma separated list of streams categories to search in (can be empty)", required = true) @QueryParam("stream_categories") Set<String> streamCategories,
@ApiParam(name = "timerange", value = "Timeframe to search in. See method description.", required = true) @QueryParam("timerange") String timerangeKeyword,
@ApiParam(name = "group_by", value = "Group aggregation by fields/limits.", required = true) @QueryParam("groups") List<String> groups,
@ApiParam(name = "metrics", value = "Metrics to be used.", required = true) @QueryParam("metrics") List<String> metrics,
@Context SearchUser searchUser) {
try {
AggregationRequestSpec aggregationRequestSpec = queryParamsToFullRequestSpecificationMapper.simpleQueryParamsToFullRequestSpecification(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@
*/
package org.graylog2.contentpacks.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;

import java.net.URI;

@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = Versioned.FIELD_META_VERSION, defaultImpl = LegacyContentPack.class)
@JsonSubTypes({
@JsonSubTypes.Type(value = LegacyContentPack.class),
Expand All @@ -27,4 +30,19 @@
public interface ContentPack extends Identified, Revisioned, Versioned {
interface ContentPackBuilder<SELF> extends IdBuilder<SELF>, RevisionBuilder<SELF>, VersionBuilder<SELF> {
}

@JsonProperty
String name();

@JsonProperty
String description();

@JsonProperty
String summary();

@JsonProperty
URI url();

@JsonProperty
String vendor();
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@
"dependencies": {
"@babel/eslint-parser": "7.16.5",
"@tanstack/eslint-plugin-query": "4.36.1",
"@typescript-eslint/eslint-plugin": "8.19.1",
"@typescript-eslint/parser": "8.19.1",
"@typescript-eslint/eslint-plugin": "8.20.0",
"@typescript-eslint/parser": "8.20.0",
"eslint": "8.57.0",
"eslint-config-airbnb": "19.0.4",
"eslint-import-resolver-webpack": "0.13.10",
"eslint-plugin-compat": "4.2.0",
"eslint-plugin-graylog": "file:../eslint-plugin-graylog",
"eslint-plugin-import": "2.25.3",
"eslint-plugin-jest": "28.10.0",
"eslint-plugin-jest": "28.11.0",
"eslint-plugin-jest-dom": "5.5.0",
"eslint-plugin-jest-formatting": "3.1.0",
"eslint-plugin-jsx-a11y": "6.10.2",
"eslint-plugin-react": "7.37.2",
"eslint-plugin-react": "7.37.4",
"eslint-plugin-react-hooks": "4.6.2",
"eslint-plugin-testing-library": "7.1.1"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
"author": "Graylog, Inc. <[email protected]>",
"license": "SSPL-1.0",
"dependencies": {
"postcss-styled-syntax": "0.7.0",
"stylelint": "16.12.0",
"stylelint-config-recommended": "14.0.1",
"postcss-styled-syntax": "0.7.1",
"stylelint": "16.13.2",
"stylelint-config-recommended": "15.0.0",
"stylelint-config-standard": "36.0.1",
"stylelint-config-styled-components": "0.1.1"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ describe('<EntityFilters />', () => {
},
];

const EntityFilters = (props: Optional<React.ComponentProps<typeof OriginalEntityFilters>, 'setUrlQueryFilters' | 'attributes'>) => (
<OriginalEntityFilters setUrlQueryFilters={setUrlQueryFilters} attributes={attributes} {...props} />
const EntityFilters = (props: Optional<React.ComponentProps<typeof OriginalEntityFilters>, 'setUrlQueryFilters' | 'attributes' | 'appSection'>) => (
<OriginalEntityFilters setUrlQueryFilters={setUrlQueryFilters} attributes={attributes} appSection="test-app-section" {...props} />
);

const dropdownIsHidden = (dropdownTitle: string) => expect(screen.queryByRole('heading', { name: new RegExp(dropdownTitle, 'i') })).not.toBeInTheDocument();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ import type { Attributes } from 'stores/PaginationTypes';
import type { Filters, Filter, UrlQueryFilters } from 'components/common/EntityFilters/types';
import ActiveFilters from 'components/common/EntityFilters/ActiveFilters';
import useFiltersWithTitle from 'components/common/EntityFilters/hooks/useFiltersWithTitle';
import useSendTelemetry from 'logic/telemetry/useSendTelemetry';
import useLocation from 'routing/useLocation';
import { TELEMETRY_EVENT_TYPE } from 'logic/telemetry/Constants';
import { getPathnameWithoutId } from 'util/URLUtils';

import { ROW_MIN_HEIGHT } from './Constants';

Expand All @@ -40,13 +44,17 @@ const FilterCreation = styled.div`
`;

type Props = {
attributes: Attributes,
attributes?: Attributes,
urlQueryFilters: UrlQueryFilters | undefined,
setUrlQueryFilters: (urlQueryFilters: UrlQueryFilters) => void,
filterValueRenderers?: { [attributeId: string]: (value: Filter['value'], title: string) => React.ReactNode };
filterValueRenderers?: { [attributeId: string]: (value: Filter['value'], title: string) => React.ReactNode },
appSection: string,
}

const EntityFilters = ({ attributes = [], filterValueRenderers, urlQueryFilters, setUrlQueryFilters }: Props) => {
const EntityFilters = ({ attributes = [], filterValueRenderers = undefined, urlQueryFilters, setUrlQueryFilters, appSection }: Props) => {
const { pathname } = useLocation();
const sendTelemetry = useSendTelemetry();

const {
data: activeFilters,
onChange: onChangeFiltersWithTitle,
Expand All @@ -68,13 +76,27 @@ const EntityFilters = ({ attributes = [], filterValueRenderers, urlQueryFilters,
}, [onChangeFiltersWithTitle, setUrlQueryFilters]);

const onCreateFilter = useCallback((attributeId: string, filter: Filter) => {
sendTelemetry(TELEMETRY_EVENT_TYPE.ENTITY_DATA_TABLE.FILTER_CREATED, {
app_pathname: getPathnameWithoutId(pathname),
app_section: appSection,
app_action_value: 'filter-created',
attribute_id: attributeId,
});

onChangeFilters(OrderedMap(activeFilters).set(
attributeId,
[...(activeFilters?.get(attributeId) ?? []), filter],
));
}, [activeFilters, onChangeFilters]);
}, [activeFilters, appSection, onChangeFilters, pathname, sendTelemetry]);

const onDeleteFilter = useCallback((attributeId: string, filterId: string) => {
sendTelemetry(TELEMETRY_EVENT_TYPE.ENTITY_DATA_TABLE.FILTER_DELETED, {
app_pathname: getPathnameWithoutId(pathname),
app_section: appSection,
app_action_value: 'filter-deleted',
attribute_id: attributeId,
});

const filterGroup = activeFilters.get(attributeId);
const updatedFilterGroup = filterGroup.filter(({ value }) => value !== filterId);

Expand All @@ -83,16 +105,23 @@ const EntityFilters = ({ attributes = [], filterValueRenderers, urlQueryFilters,
}

return onChangeFilters(activeFilters.remove(attributeId));
}, [activeFilters, onChangeFilters]);
}, [activeFilters, appSection, onChangeFilters, pathname, sendTelemetry]);

const onChangeFilter = useCallback((attributeId: string, prevValue: string, newFilter: Filter) => {
sendTelemetry(TELEMETRY_EVENT_TYPE.ENTITY_DATA_TABLE.FILTER_CHANGED, {
app_pathname: getPathnameWithoutId(pathname),
app_section: appSection,
app_action_value: 'filter-value-changed',
attribute_id: attributeId,
});

const filterGroup = activeFilters.get(attributeId);
const targetFilterIndex = filterGroup.findIndex(({ value }) => value === prevValue);
const updatedFilterGroup = [...filterGroup];
updatedFilterGroup[targetFilterIndex] = newFilter;

onChangeFilters(activeFilters.set(attributeId, updatedFilterGroup));
}, [activeFilters, onChangeFilters]);
}, [activeFilters, appSection, onChangeFilters, pathname, sendTelemetry]);

if (!filterableAttributes.length) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,16 @@ const PaginatedEntityTable = <T extends EntityBase, M = unknown>({
setUrlQueryFilters(newUrlQueryFilters);
}, [paginationQueryParameter, setUrlQueryFilters]);

const appSection = `${tableLayout.entityTableId}-list`;

const {
onPageSizeChange,
onSearch,
onSearchReset,
onColumnsChange,
onSortChange,
} = useTableEventHandlers({
appSection: `${tableLayout.entityTableId}-list`,
appSection,
paginationQueryParameter,
updateTableLayout,
setQuery,
Expand Down Expand Up @@ -146,7 +148,8 @@ const PaginatedEntityTable = <T extends EntityBase, M = unknown>({
<EntityFilters attributes={attributes}
urlQueryFilters={urlQueryFilters}
setUrlQueryFilters={onChangeFilters}
filterValueRenderers={filterValueRenderers} />
filterValueRenderers={filterValueRenderers}
appSection={appSection} />
</div>
</SearchForm>
{topRightCol}
Expand Down
2 changes: 1 addition & 1 deletion graylog2-web-interface/src/components/common/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type Props = {
target?: string,
};

const isLeftClickEvent = (e: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => (e.button === 0);
const isLeftClickEvent = (e: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => (e?.button === 0);

const isModifiedEvent = (e: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ import React from 'react';

import Spinner from 'components/common/Spinner';
import { DataTable } from 'components/common';

import 'components/content-packs/ContentPackDetails.css';
import type { InstalledEntity } from 'components/content-packs/Types';

type ContentPackInstallEntityListProps = {
entities?: any[];
entities?: InstalledEntity[];
uninstall?: boolean;
};

const ContentPackInstallEntityList = ({
entities,
entities = undefined,
uninstall = false,
}: ContentPackInstallEntityListProps) => {
const rowFormatter = (entity) => (<tr><td>{entity.title}</td><td>{entity.type.name}</td></tr>);
const rowFormatter = (entity: InstalledEntity) => (<tr><td>{entity.title}</td><td>{entity.type.name}</td></tr>);
const headers = ['Title', 'Type'];
const headerTitle = uninstall ? 'Entites to be uninstalled' : 'Installed Entities';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@ import 'components/content-packs/ContentPackDetails.css';
import ContentPackInstallEntityList from './ContentPackInstallEntityList';

type ContentPackInstallViewProps = {
install: any;
install: {
comment: string,
created_at: string,
created_by: string,
entities: any[],
};
};

const ContentPackInstallView = (props: ContentPackInstallViewProps) => {
const { comment } = props.install;
const createdAt = props.install.created_at;
const createdBy = props.install.created_by;
const ContentPackInstallView = ({ install }: ContentPackInstallViewProps) => {
const { comment, created_at: createdAt, created_by: createdBy, entities } = install;

return (
<div>
Expand All @@ -48,7 +51,7 @@ const ContentPackInstallView = (props: ContentPackInstallViewProps) => {
</Row>
<Row>
<Col smOffset={1} sm={10}>
<ContentPackInstallEntityList entities={props.install.entities} />
<ContentPackInstallEntityList entities={entities} />
</Col>
</Row>
</div>
Expand Down
19 changes: 13 additions & 6 deletions graylog2-web-interface/src/components/content-packs/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@
*/

export type ContentPackInstallation = {
created_at: string,
created_at?: string,
description: string,
entities?: Array<ContentPackEntity>,
id: string,
name: string,
parameters?: Array<any>,
rev: number,
server_version: string,
server_version?: string,
summary: string,
url: string,
v: number,
v: string,
vendor: string,
}

Expand Down Expand Up @@ -70,9 +70,16 @@ export interface Constraint {
}

export type ContentPackMetadata = {
[key: number]: {
[key: number]: {
[key: string]: number,
[string: number]: {
[string: number]: {
installation_count: number,
},
},
}

export type InstalledEntity = {
title: string,
type: {
name: string
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('<ContentPackListItem />', () => {
server_version: '6.0.0-SNAPSHOT',
summary: 'The Open Thread Exchange Lookup Table of the Threat Intel Plugin',
url: 'https://github.com/Graylog2/graylog2-server',
v: 1,
v: '1',
vendor: 'Graylog <[email protected]>',
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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 { useQuery } from '@tanstack/react-query';

import { SystemContentPacks } from '@graylog/server-api';

const useContentPackInstallations = (id: string) => useQuery(
['content-packs', 'installations', id],
() => SystemContentPacks.listContentPackInstallationsById(id),
);
export default useContentPackInstallations;
Loading

0 comments on commit 8cd2250

Please sign in to comment.