-
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.
Add option in context menu; add error handling when fetching embeddab…
…les in flyout Signed-off-by: Tyler Ohlsen <[email protected]>
- Loading branch information
Showing
8 changed files
with
145 additions
and
27 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
53 changes: 53 additions & 0 deletions
53
src/plugins/vis_augmenter/public/actions/view_events_option_action.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,53 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { i18n } from '@osd/i18n'; | ||
import { get } from 'lodash'; | ||
import { CoreStart } from 'opensearch-dashboards/public'; | ||
import { VisualizeEmbeddable } from '../../../visualizations/public'; | ||
import { EmbeddableContext } from '../../../embeddable/public'; | ||
import { EuiIconType } from '@elastic/eui/src/components/icon/icon'; | ||
import { Action, IncompatibleActionError } from '../../../ui_actions/public'; | ||
import { openViewEventsFlyout } from './open_events_flyout'; | ||
|
||
export const VIEW_EVENTS_OPTION_ACTION = 'VIEW_EVENTS_OPTION_ACTION'; | ||
|
||
export class ViewEventsOptionAction implements Action<EmbeddableContext> { | ||
public readonly type = VIEW_EVENTS_OPTION_ACTION; | ||
public readonly id = VIEW_EVENTS_OPTION_ACTION; | ||
public order = 1; | ||
|
||
constructor(private core: CoreStart) {} | ||
|
||
public getIconType(): EuiIconType { | ||
return 'apmTrace'; | ||
} | ||
|
||
public getDisplayName() { | ||
return i18n.translate('dashboard.actions.viewEvents.displayName', { | ||
defaultMessage: 'View Events', | ||
}); | ||
} | ||
|
||
public async isCompatible({ embeddable }: EmbeddableContext) { | ||
// TODO: add the logic for compatibility here, probably from some helper fn. | ||
// see https://github.com/opensearch-project/OpenSearch-Dashboards/issues/3268 | ||
return true; | ||
} | ||
|
||
public async execute({ embeddable }: EmbeddableContext) { | ||
if (!(await this.isCompatible({ embeddable }))) { | ||
throw new IncompatibleActionError(); | ||
} | ||
|
||
const visEmbeddable = embeddable as VisualizeEmbeddable; | ||
const savedObjectId = get(visEmbeddable.getInput(), 'savedObjectId', ''); | ||
|
||
openViewEventsFlyout({ | ||
core: this.core, | ||
savedObjectId, | ||
}); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/plugins/vis_augmenter/public/components/error_flyout_body.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,25 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { EuiFlyoutBody, EuiFlexGroup, EuiFlexItem, EuiCallOut } from '@elastic/eui'; | ||
|
||
interface Props { | ||
errorMessage: string; | ||
} | ||
|
||
export function ErrorFlyoutBody(props: Props) { | ||
return ( | ||
<EuiFlyoutBody> | ||
<EuiFlexGroup> | ||
<EuiFlexItem grow={true}> | ||
<EuiCallOut color="danger" iconType="alert"> | ||
{props.errorMessage} | ||
</EuiCallOut> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</EuiFlyoutBody> | ||
); | ||
} |
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