-
Notifications
You must be signed in to change notification settings - Fork 8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dashboard] fix Upgraded dashboard with image embeddable shows 'unsav…
…ed changes' badge when opening editor (#183539) Fixes #183524 --------- Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
- Loading branch information
1 parent
8e91181
commit 076e32d
Showing
3 changed files
with
59 additions
and
2 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
x-pack/plugins/embeddable_enhanced/public/get_dynamic_actions_state.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { SerializedEvent } from '@kbn/ui-actions-enhanced-plugin/common/types'; | ||
import { getDynamicActionsState } from './get_dynamic_actions_state'; | ||
|
||
describe('getDynamicActionsState', () => { | ||
test('should return empty state when enhancements is undefined', () => { | ||
expect(getDynamicActionsState()).toEqual({ dynamicActions: { events: [] } }); | ||
}); | ||
|
||
test('should return empty state when enhancements is empty object', () => { | ||
expect(getDynamicActionsState({})).toEqual({ dynamicActions: { events: [] } }); | ||
}); | ||
|
||
test('should return empty state when enhancements.dynamicActions is undefined', () => { | ||
expect(getDynamicActionsState({ dynamicActions: undefined })).toEqual({ | ||
dynamicActions: { events: [] }, | ||
}); | ||
}); | ||
|
||
test('should return empty state when enhancements.dynamicActions is empty object', () => { | ||
expect(getDynamicActionsState({ dynamicActions: {} })).toEqual({ | ||
dynamicActions: { events: [] }, | ||
}); | ||
}); | ||
|
||
test('should return state when enhancements.dynamicActions is provided', () => { | ||
expect( | ||
getDynamicActionsState({ dynamicActions: { events: [{} as unknown as SerializedEvent] } }) | ||
).toEqual({ dynamicActions: { events: [{}] } }); | ||
}); | ||
}); |
19 changes: 19 additions & 0 deletions
19
x-pack/plugins/embeddable_enhanced/public/get_dynamic_actions_state.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import type { DynamicActionsState } from '@kbn/ui-actions-enhanced-plugin/public'; | ||
|
||
export function getDynamicActionsState(enhancements?: { | ||
dynamicActions?: Partial<DynamicActionsState>; | ||
}) { | ||
return { | ||
dynamicActions: { | ||
events: [], | ||
...(enhancements?.dynamicActions ?? {}), | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters