Skip to content

Commit

Permalink
chore(Filters): add record type to filter value
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagostn committed Sep 11, 2023
1 parent 849fb0c commit 72dee5c
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 1 deletion.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/components/Filters/Filters.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export interface Filter {
isApplied: boolean;
isLoading: boolean;
isCanceled: boolean;
value?: string | string[] | Date | BaseDateRange;
value?: string | string[] | Date | BaseDateRange | Record<string, unknown>;
}

export interface FiltersProps {
Expand Down
46 changes: 46 additions & 0 deletions src/components/Filters/mocks/MockObjectFilter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import React from 'react';

import { SpaceSizes } from '../../../theme';
import { Inline, Padbox, Stack } from '../../layout';
import { SelectFilter } from '../components';
import Input from '../components/Input/Input';

type MockObject = {
inputValue: string;
includeAssets: string[];
};

interface MockObjectFilterProps {
value: MockObject;
}

const MockObjectFilter: React.FC<MockObjectFilterProps> = ({ value }) => {
const options = [
{
label: 'Include associated subdomains',
value: 'include_domains',
},
{
label: 'Include associated IPs',
value: 'include_ips',
},
];

const handleFilterOnChange = () => {
throw new Error('Not implemented');
};

return (
<Padbox>
<Inline gap={SpaceSizes.sm} stretch="start">
<Stack>
<Input value={value.inputValue} onChange={handleFilterOnChange} />
</Stack>
<Stack style={{ width: 330 }}>
<SelectFilter options={options} isMulti />
</Stack>
</Inline>
</Padbox>
);
};
export default MockObjectFilter;
22 changes: 22 additions & 0 deletions src/components/Filters/mocks/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
import { Field, Filter } from '../Filters.types';
import { Operators } from '../Filters.enums';
import { patterns, validateDomains, validateIPs } from './validations';
import MockObjectFilter from './MockObjectFilter';

export const mockTestFields: Field[] = [
{
Expand Down Expand Up @@ -324,6 +325,18 @@ export const fields: Field[] = [
value: 'detection method',
label: 'Detection Method',
},
{
conditions: [
{ component: MockObjectFilter, value: 'is', label: 'is' },
{
component: MockObjectFilter,
value: 'is not',
label: 'is not',
},
],
value: 'ip and assets',
label: 'IP and Assets',
},
];

export const state: Filter[] = [
Expand Down Expand Up @@ -404,6 +417,15 @@ export const state: Filter[] = [
isLoading: false,
isCanceled: false,
},
{
operator: Operators.and,
field: 'ip and assets',
condition: 'is',
value: { inputValue: '1.1.1.1', includeAsset: ['include_domains'] },
isApplied: true,
isLoading: false,
isCanceled: false,
},
];

export const stateWithUnappliedFilters: Filter[] = [
Expand Down

0 comments on commit 72dee5c

Please sign in to comment.