Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
patrykkopycinski committed Oct 14, 2021
1 parent 778158a commit 1e76283
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
17 changes: 17 additions & 0 deletions x-pack/plugins/osquery/public/agents/agents_table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
generateSelectedAgentsMessage,
ALL_AGENTS_LABEL,
AGENT_POLICY_LABEL,
AGENT_SELECTION_LABEL,
} from './translations';

import {
Expand Down Expand Up @@ -108,6 +109,22 @@ const AgentsTableComponent: React.FC<AgentsTableProps> = ({ agentSelection, onCh
}
}
}

if (agentSelection.agents.length) {
const agentOptions = find(['label', AGENT_SELECTION_LABEL], options);

if (agentOptions) {
const defaultOptions = agentOptions.options?.filter((option) =>
// @ts-expect-error update types
agentSelection.agents.includes(option.key)
);

if (defaultOptions?.length) {
setSelectedOptions(defaultOptions);
defaultValueInitialized.current = true;
}
}
}
}
}, [agentSelection, options, selectedOptions]);

Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/osquery/public/live_queries/form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ const LiveQueryFormComponent: React.FC<LiveQueryFormProps> = ({
options: {
stripEmptyFields: false,
},
serializer: (formData) => pickBy(formData),
serializer: ({ savedQueryId, ...formData }) =>
pickBy({ ...formData, saved_query_id: savedQueryId }),
defaultValue: deepMerge(
{
agentSelection: {
Expand Down

0 comments on commit 1e76283

Please sign in to comment.