mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Enterprise Search] Fix bug saving edited field rules (#156259)
## Summary This fixes a bug causing edited field rules to always overwrite the first rule in the list when saved.
This commit is contained in:
parent
6e190499e4
commit
83ca5a7823
3 changed files with 2 additions and 13 deletions
|
@ -103,7 +103,7 @@ export const EditExtractionRule: React.FC<EditExtractionRuleProps> = ({
|
|||
saveRule,
|
||||
}) => {
|
||||
const { closeEditRuleFlyout, openEditRuleFlyout } = useActions(ExtractionRulesLogic);
|
||||
const { fieldRuleFlyoutVisible, fieldRuleToEdit, fieldRuleToEditIndex, fieldRuleToEditIsNew } =
|
||||
const { fieldRuleFlyoutVisible, fieldRuleToEdit, fieldRuleToEditIsNew } =
|
||||
useValues(ExtractionRulesLogic);
|
||||
const [urlToggle, setUrlToggle] = useState<UrlState>(UrlState.ALL);
|
||||
const { control, formState, getValues, handleSubmit, reset, setValue } =
|
||||
|
@ -437,6 +437,7 @@ export const EditExtractionRule: React.FC<EditExtractionRuleProps> = ({
|
|||
if (fieldRuleToEditIsNew) {
|
||||
appendRule(fieldRule);
|
||||
} else {
|
||||
const fieldRuleToEditIndex = rulesFields.findIndex(({ id: ruleId }) => ruleId === id);
|
||||
updateRule(fieldRuleToEditIndex ?? 0, fieldRule);
|
||||
}
|
||||
closeEditRuleFlyout();
|
||||
|
|
|
@ -57,15 +57,12 @@ interface ExtractionRulesActions {
|
|||
hideDeleteModal: () => void;
|
||||
openEditRuleFlyout({
|
||||
fieldRule,
|
||||
fieldRuleIndex,
|
||||
isNewRule,
|
||||
}: {
|
||||
fieldRule?: ExtractionRuleFieldRule;
|
||||
fieldRuleIndex?: number;
|
||||
isNewRule: boolean;
|
||||
}): {
|
||||
fieldRule: ExtractionRuleFieldRule;
|
||||
fieldRuleIndex?: number;
|
||||
isNewRule: boolean;
|
||||
};
|
||||
fetchDomainData: CrawlerDomainDetailActions['fetchDomainData'];
|
||||
|
@ -101,7 +98,6 @@ interface ExtractionRulesValues {
|
|||
fieldRuleFlyoutVisible: boolean;
|
||||
fieldRuleToDelete: { extractionRuleId?: string; fieldRuleIndex?: number };
|
||||
fieldRuleToEdit: ExtractionRuleFieldRule | null;
|
||||
fieldRuleToEditIndex: number | null;
|
||||
fieldRuleToEditIsNew: boolean;
|
||||
indexName: string;
|
||||
isLoading: boolean;
|
||||
|
@ -289,13 +285,6 @@ export const ExtractionRulesLogic = kea<
|
|||
openEditRuleFlyout: (_, { fieldRule }) => fieldRule ?? null,
|
||||
},
|
||||
],
|
||||
fieldRuleToEditIndex: [
|
||||
null,
|
||||
{
|
||||
closeEditRuleFlyout: () => null,
|
||||
openEditRuleFlyout: (_, { fieldRuleIndex }) => fieldRuleIndex ?? null,
|
||||
},
|
||||
],
|
||||
fieldRuleToEditIsNew: [
|
||||
true,
|
||||
{
|
||||
|
|
|
@ -66,7 +66,6 @@ export const ExtractionRulesTable: React.FC = () => {
|
|||
if (rule) {
|
||||
openEditRuleFlyout({
|
||||
fieldRule: rule,
|
||||
fieldRuleIndex: rule.index,
|
||||
isNewRule: false,
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue