mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-14 11:45:58 +08:00
feat: select tags key and value are updated to autocomplete filtering (#1267)
* feat: select tags key and value are updated to autocomplete filtering Co-authored-by: Palash gupta <palash@signoz.io>
This commit is contained in:
parent
4ed3295b80
commit
1ebf3dbf65
@ -73,11 +73,24 @@ function TagsKey(props: TagsKeysProps): JSX.Element {
|
|||||||
<AutoComplete
|
<AutoComplete
|
||||||
dropdownClassName="certain-category-search-dropdown"
|
dropdownClassName="certain-category-search-dropdown"
|
||||||
dropdownMatchSelectWidth={500}
|
dropdownMatchSelectWidth={500}
|
||||||
style={{ width: 300 }}
|
style={{ width: '100%' }}
|
||||||
options={options}
|
|
||||||
value={selectedKey}
|
value={selectedKey}
|
||||||
onChange={(value): void => {
|
allowClear
|
||||||
if (options && options.find((option) => option.value === value)) {
|
showSearch
|
||||||
|
options={options?.map((e) => ({
|
||||||
|
label: e.label?.toString(),
|
||||||
|
value: e.value,
|
||||||
|
}))}
|
||||||
|
filterOption={(inputValue, option): boolean =>
|
||||||
|
option?.label?.toUpperCase().indexOf(inputValue.toUpperCase()) !== -1
|
||||||
|
}
|
||||||
|
onChange={(e): void => setSelectedKey(e)}
|
||||||
|
onSelect={(value: unknown): void => {
|
||||||
|
if (
|
||||||
|
typeof value === 'string' &&
|
||||||
|
options &&
|
||||||
|
options.find((option) => option.value === value)
|
||||||
|
) {
|
||||||
setSelectedKey(value);
|
setSelectedKey(value);
|
||||||
|
|
||||||
setLocalSelectedTags((tags) => [
|
setLocalSelectedTags((tags) => [
|
||||||
@ -89,8 +102,6 @@ function TagsKey(props: TagsKeysProps): JSX.Element {
|
|||||||
},
|
},
|
||||||
...tags.slice(index + 1, tags.length),
|
...tags.slice(index + 1, tags.length),
|
||||||
]);
|
]);
|
||||||
} else {
|
|
||||||
setSelectedKey('');
|
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import { Select } from 'antd';
|
import { Select } from 'antd';
|
||||||
import getTagValue from 'api/trace/getTagValue';
|
import getTagValue from 'api/trace/getTagValue';
|
||||||
import React from 'react';
|
import React, { useState } from 'react';
|
||||||
import { useQuery } from 'react-query';
|
import { useQuery } from 'react-query';
|
||||||
import { useSelector } from 'react-redux';
|
import { useSelector } from 'react-redux';
|
||||||
import { AppState } from 'store/reducers';
|
import { AppState } from 'store/reducers';
|
||||||
import { GlobalReducer } from 'types/reducer/globalTime';
|
import { GlobalReducer } from 'types/reducer/globalTime';
|
||||||
import { TraceReducer } from 'types/reducer/trace';
|
import { TraceReducer } from 'types/reducer/trace';
|
||||||
|
|
||||||
import { SelectComponent } from './styles';
|
import { AutoCompleteComponent } from './styles';
|
||||||
|
|
||||||
function TagValue(props: TagValueProps): JSX.Element {
|
function TagValue(props: TagValueProps): JSX.Element {
|
||||||
const { tag, setLocalSelectedTags, index, tagKey } = props;
|
const { tag, setLocalSelectedTags, index, tagKey } = props;
|
||||||
@ -16,6 +16,7 @@ function TagValue(props: TagValueProps): JSX.Element {
|
|||||||
Operator: selectedOperator,
|
Operator: selectedOperator,
|
||||||
Values: selectedValues,
|
Values: selectedValues,
|
||||||
} = tag;
|
} = tag;
|
||||||
|
const [localValue, setLocalValue] = useState<string>(selectedValues[0]);
|
||||||
|
|
||||||
const globalReducer = useSelector<AppState, GlobalReducer>(
|
const globalReducer = useSelector<AppState, GlobalReducer>(
|
||||||
(state) => state.globalTime,
|
(state) => state.globalTime,
|
||||||
@ -34,22 +35,38 @@ function TagValue(props: TagValueProps): JSX.Element {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SelectComponent
|
<AutoCompleteComponent
|
||||||
value={selectedValues[0]}
|
options={data?.payload?.map((e) => ({
|
||||||
|
label: e.tagValues,
|
||||||
|
value: e.tagValues,
|
||||||
|
}))}
|
||||||
|
allowClear
|
||||||
|
defaultOpen
|
||||||
|
showSearch
|
||||||
|
filterOption={(inputValue, option): boolean =>
|
||||||
|
option?.label.toUpperCase().indexOf(inputValue.toUpperCase()) !== -1
|
||||||
|
}
|
||||||
|
disabled={isLoading}
|
||||||
|
value={localValue}
|
||||||
|
onChange={(values): void => {
|
||||||
|
if (typeof values === 'string') {
|
||||||
|
setLocalValue(values);
|
||||||
|
}
|
||||||
|
}}
|
||||||
onSelect={(value: unknown): void => {
|
onSelect={(value: unknown): void => {
|
||||||
if (typeof value === 'string') {
|
if (typeof value === 'string') {
|
||||||
|
setLocalValue(value);
|
||||||
setLocalSelectedTags((tags) => [
|
setLocalSelectedTags((tags) => [
|
||||||
...tags.slice(0, index),
|
...tags.slice(0, index),
|
||||||
{
|
{
|
||||||
Key: selectedKey,
|
Key: selectedKey,
|
||||||
Operator: selectedOperator,
|
Operator: selectedOperator,
|
||||||
Values: [...selectedValues, value],
|
Values: [value],
|
||||||
},
|
},
|
||||||
...tags.slice(index + 1, tags.length),
|
...tags.slice(index + 1, tags.length),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
loading={isLoading || false}
|
|
||||||
>
|
>
|
||||||
{data &&
|
{data &&
|
||||||
data.payload &&
|
data.payload &&
|
||||||
@ -58,7 +75,7 @@ function TagValue(props: TagValueProps): JSX.Element {
|
|||||||
{suggestion.tagValues}
|
{suggestion.tagValues}
|
||||||
</Select.Option>
|
</Select.Option>
|
||||||
))}
|
))}
|
||||||
</SelectComponent>
|
</AutoCompleteComponent>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Select, Space } from 'antd';
|
import { AutoComplete, Select, Space } from 'antd';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
|
||||||
export const SpaceComponent = styled(Space)`
|
export const SpaceComponent = styled(Space)`
|
||||||
@ -9,18 +9,23 @@ export const SpaceComponent = styled(Space)`
|
|||||||
|
|
||||||
export const SelectComponent = styled(Select)`
|
export const SelectComponent = styled(Select)`
|
||||||
&&& {
|
&&& {
|
||||||
min-width: 170px;
|
width: 100%;
|
||||||
margin-right: 21.91px;
|
|
||||||
margin-left: 21.92px;
|
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const Container = styled.div`
|
export const Container = styled(Space)`
|
||||||
&&& {
|
&&& {
|
||||||
display: flex;
|
display: flex;
|
||||||
margin-top: 1rem;
|
margin-top: 1rem;
|
||||||
margin-bottom: 1rem;
|
margin-bottom: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ant-space-item:not(:last-child, :nth-child(2)) {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.ant-space-item:nth-child(2) {
|
||||||
|
width: 50%;
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const IconContainer = styled.div`
|
export const IconContainer = styled.div`
|
||||||
@ -31,3 +36,9 @@ export const IconContainer = styled.div`
|
|||||||
|
|
||||||
margin-left: 1.125rem;
|
margin-left: 1.125rem;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
export const AutoCompleteComponent = styled(AutoComplete)`
|
||||||
|
&&& {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user