-
Notifications
You must be signed in to change notification settings - Fork 915
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Tyler Ohlsen <[email protected]>
- Loading branch information
Showing
55 changed files
with
1,630 additions
and
30 deletions.
There are no files selected for viewing
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
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
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
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
6 changes: 6 additions & 0 deletions
6
src/plugins/ui_actions/public/triggers/open_events_flyout_trigger.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,6 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
export const OPEN_EVENTS_FLYOUT_TRIGGER = 'OPEN_EVENTS_FLYOUT_TRIGGER'; |
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
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
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,116 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { VisualizeEmbeddable, Vis } from '../../visualizations/public'; | ||
import { ErrorEmbeddable } from '../../embeddable/public'; | ||
// eslint-disable-next-line @osd/eslint/no-restricted-paths | ||
import { timefilterServiceMock } from '../../data/public/query/timefilter/timefilter_service.mock'; | ||
import { EventVisEmbeddableItem } from './view_events_flyout'; | ||
import { | ||
VisLayerTypes, | ||
PointInTimeEventsVisLayer, | ||
PluginResource, | ||
PointInTimeEvent, | ||
} from './types'; | ||
|
||
const SAVED_OBJ_ID = 'test-saved-obj-id'; | ||
const VIS_TITLE = 'test-vis-title'; | ||
const ORIGIN_PLUGIN = 'test-plugin'; | ||
const PLUGIN_RESOURCE = { | ||
type: 'test-type', | ||
id: 'test-resource-id', | ||
name: 'test-resource-name', | ||
urlPath: 'test-url-path', | ||
} as PluginResource; | ||
const EVENT_COUNT = 3; | ||
|
||
export const createPluginResource = ( | ||
type: string = PLUGIN_RESOURCE.type, | ||
id: string = PLUGIN_RESOURCE.id, | ||
name: string = PLUGIN_RESOURCE.name, | ||
urlPath: string = PLUGIN_RESOURCE.urlPath | ||
): PluginResource => { | ||
return { | ||
type, | ||
id, | ||
name, | ||
urlPath, | ||
}; | ||
}; | ||
|
||
export const createMockErrorEmbeddable = (): ErrorEmbeddable => { | ||
return new ErrorEmbeddable('Oh no something has gone wrong', { id: ' 404' }); | ||
}; | ||
|
||
export const createMockVisEmbeddable = ( | ||
savedObjectId: string = SAVED_OBJ_ID, | ||
title: string = VIS_TITLE | ||
): VisualizeEmbeddable => { | ||
const mockTimeFilterService = timefilterServiceMock.createStartContract(); | ||
const mockTimeFilter = mockTimeFilterService.timefilter; | ||
const mockVis = ({ | ||
type: {}, | ||
data: {}, | ||
uiState: { | ||
on: jest.fn(), | ||
}, | ||
} as unknown) as Vis; | ||
const mockDeps = { | ||
start: jest.fn(), | ||
}; | ||
const mockConfiguration = { | ||
vis: mockVis, | ||
editPath: 'test-edit-path', | ||
editUrl: 'test-edit-url', | ||
editable: true, | ||
deps: mockDeps, | ||
}; | ||
const mockVisualizeInput = { id: 'test-id', savedObjectId }; | ||
|
||
const mockVisEmbeddable = new VisualizeEmbeddable( | ||
mockTimeFilter, | ||
mockConfiguration, | ||
mockVisualizeInput | ||
); | ||
mockVisEmbeddable.getTitle = () => title; | ||
return mockVisEmbeddable; | ||
}; | ||
|
||
export const createPointInTimeEventsVisLayer = ( | ||
originPlugin: string = ORIGIN_PLUGIN, | ||
pluginResource: PluginResource = PLUGIN_RESOURCE, | ||
eventCount: number = EVENT_COUNT | ||
): PointInTimeEventsVisLayer => { | ||
const events = [] as PointInTimeEvent[]; | ||
for (let i = 0; i < eventCount; i++) { | ||
events.push({ | ||
timestamp: i, | ||
metadata: { | ||
pluginResourceId: pluginResource.id, | ||
}, | ||
} as PointInTimeEvent); | ||
} | ||
return { | ||
originPlugin, | ||
type: VisLayerTypes.PointInTimeEvents, | ||
pluginResource, | ||
events, | ||
}; | ||
}; | ||
|
||
export const createMockEventVisEmbeddableItem = ( | ||
savedObjectId: string = SAVED_OBJ_ID, | ||
title: string = VIS_TITLE, | ||
originPlugin: string = ORIGIN_PLUGIN, | ||
pluginResource: PluginResource = PLUGIN_RESOURCE, | ||
eventCount: number = EVENT_COUNT | ||
): EventVisEmbeddableItem => { | ||
const visLayer = createPointInTimeEventsVisLayer(originPlugin, pluginResource, eventCount); | ||
const embeddable = createMockVisEmbeddable(savedObjectId, title); | ||
return { | ||
visLayer, | ||
embeddable, | ||
}; | ||
}; |
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
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
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,42 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { CoreStart } from 'opensearch-dashboards/public'; | ||
import { | ||
OpenEventsFlyoutAction, | ||
ViewEventsOptionAction, | ||
OPEN_EVENTS_FLYOUT_ACTION, | ||
VIEW_EVENTS_OPTION_ACTION, | ||
} from './view_events_flyout'; | ||
import { AugmentVisContext, openEventsFlyoutTrigger } from './view_events_flyout/triggers'; | ||
import { OPEN_EVENTS_FLYOUT_TRIGGER } from '../../ui_actions/public'; | ||
import { CONTEXT_MENU_TRIGGER, EmbeddableContext } from '../../embeddable/public'; | ||
import { getUiActions } from './services'; | ||
|
||
// Overriding the mappings defined in UIActions plugin so that | ||
// the new trigger and action definitions resolve | ||
declare module '../../ui_actions/public' { | ||
export interface TriggerContextMapping { | ||
[OPEN_EVENTS_FLYOUT_TRIGGER]: AugmentVisContext; | ||
} | ||
|
||
export interface ActionContextMapping { | ||
[OPEN_EVENTS_FLYOUT_ACTION]: AugmentVisContext; | ||
[VIEW_EVENTS_OPTION_ACTION]: EmbeddableContext; | ||
} | ||
} | ||
|
||
export const registerTriggersAndActions = (core: CoreStart) => { | ||
const openEventsFlyoutAction = new OpenEventsFlyoutAction(core); | ||
const viewEventsOptionAction = new ViewEventsOptionAction(core); | ||
|
||
getUiActions().registerAction(openEventsFlyoutAction); | ||
getUiActions().registerAction(viewEventsOptionAction); | ||
getUiActions().registerTrigger(openEventsFlyoutTrigger); | ||
// Opening View Events flyout from the chart | ||
getUiActions().addTriggerAction(OPEN_EVENTS_FLYOUT_TRIGGER, openEventsFlyoutAction); | ||
// Opening View Events flyout from the context menu | ||
getUiActions().addTriggerAction(CONTEXT_MENU_TRIGGER, viewEventsOptionAction); | ||
}; |
7 changes: 7 additions & 0 deletions
7
src/plugins/vis_augmenter/public/view_events_flyout/actions/index.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,7 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
export { OPEN_EVENTS_FLYOUT_ACTION, OpenEventsFlyoutAction } from './open_events_flyout_action'; | ||
export { VIEW_EVENTS_OPTION_ACTION, ViewEventsOptionAction } from './view_events_option_action'; |
32 changes: 32 additions & 0 deletions
32
src/plugins/vis_augmenter/public/view_events_flyout/actions/open_events_flyout.tsx
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,32 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
import React from 'react'; | ||
import { CoreStart } from 'src/core/public'; | ||
import { toMountPoint } from '../../../../opensearch_dashboards_react/public'; | ||
import { ViewEventsFlyout } from '../components'; | ||
|
||
interface Props { | ||
core: CoreStart; | ||
savedObjectId: string; | ||
} | ||
|
||
export async function openViewEventsFlyout(props: Props) { | ||
const flyoutSession = props.core.overlays.openFlyout( | ||
toMountPoint( | ||
<ViewEventsFlyout | ||
onClose={() => { | ||
if (flyoutSession) { | ||
flyoutSession.close(); | ||
} | ||
}} | ||
savedObjectId={props.savedObjectId} | ||
/> | ||
), | ||
{ | ||
'data-test-subj': 'viewEventsFlyout', | ||
ownFocus: true, | ||
} | ||
); | ||
} |
Oops, something went wrong.