Skip to content

Commit

Permalink
Fix dataproviders
Browse files Browse the repository at this point in the history
  • Loading branch information
patrykkopycinski committed Jul 17, 2020
1 parent 4605896 commit 12f1761
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export const reformatDataProviderWithNewValue = <T extends DataProvider | DataPr
timelineType: TimelineType = TimelineType.default
): T => {
// Support for legacy "template-like" timeline behavior that is using hardcoded list of templateFields
if (timelineType === TimelineType.default) {
if (timelineType !== TimelineType.template) {
if (templateFields.includes(dataProvider.queryMatch.field)) {
const newValue = getStringArray(dataProvider.queryMatch.field, ecsData);
if (newValue.length) {
Expand Down
6 changes: 6 additions & 0 deletions x-pack/plugins/security_solution/public/graphql/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5654,6 +5654,8 @@ export namespace GetOneTimeline {

kqlQuery: Maybe<string>;

type: Maybe<DataProviderType>;

queryMatch: Maybe<_QueryMatch>;
};

Expand Down Expand Up @@ -5932,6 +5934,8 @@ export namespace PersistTimelineMutation {

kqlQuery: Maybe<string>;

type: Maybe<DataProviderType>;

queryMatch: Maybe<QueryMatch>;

and: Maybe<And[]>;
Expand Down Expand Up @@ -5964,6 +5968,8 @@ export namespace PersistTimelineMutation {

kqlQuery: Maybe<string>;

type: Maybe<DataProviderType>;

queryMatch: Maybe<_QueryMatch>;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,20 @@ const getTemplateTimelineId = (
return uuid.v4();
};

const convertToDefaultField = ({ and, ...dataProvider }: DataProviderResult) =>
deepMerge(dataProvider, {
type: DataProviderType.default,
queryMatch: {
value:
dataProvider.queryMatch!.operator === IS_OPERATOR ? '' : dataProvider.queryMatch!.value,
},
});
const convertToDefaultField = ({ and, ...dataProvider }: DataProviderResult) => {
if (dataProvider.type === DataProviderType.template) {
return deepMerge(dataProvider, {
type: DataProviderType.default,
enabled: dataProvider.queryMatch!.operator !== IS_OPERATOR,
queryMatch: {
value:
dataProvider.queryMatch!.operator === IS_OPERATOR ? '' : dataProvider.queryMatch!.value,
},
});
}

return dataProvider;
};

const getDataProviders = (
duplicate: boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const ConvertFieldBadge = styled(ProviderFieldBadge)`
`;

const TemplateFieldBadge: React.FC<TemplateFieldBadgeProps> = ({ type, toggleType }) => {
if (type === DataProviderType.default) {
if (type !== DataProviderType.template) {
return (
<ConvertFieldBadge onClick={toggleType}>{i18n.CONVERT_TO_TEMPLATE_FIELD}</ConvertFieldBadge>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const oneTimelineQuery = gql`
enabled
excluded
kqlQuery
type
queryMatch {
field
displayField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const persistTimelineMutation = gql`
enabled
excluded
kqlQuery
type
queryMatch {
field
displayField
Expand All @@ -45,6 +46,7 @@ export const persistTimelineMutation = gql`
enabled
excluded
kqlQuery
type
queryMatch {
field
displayField
Expand Down

0 comments on commit 12f1761

Please sign in to comment.