-
Notifications
You must be signed in to change notification settings - Fork 918
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
41 changed files
with
1,125 additions
and
25 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
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/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, | ||
} | ||
); | ||
} |
52 changes: 52 additions & 0 deletions
52
src/plugins/vis_augmenter/public/actions/open_events_flyout_action.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,52 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { i18n } from '@osd/i18n'; | ||
import { CoreStart } from 'opensearch-dashboards/public'; | ||
import { Action, IncompatibleActionError } from '../../../ui_actions/public'; | ||
import { AugmentVisContext } from '../triggers'; | ||
import { openViewEventsFlyout } from './open_events_flyout'; | ||
|
||
export const OPEN_EVENTS_FLYOUT_ACTION = 'OPEN_EVENTS_FLYOUT_ACTION'; | ||
|
||
/** | ||
* This action is identical to VIEW_EVENTS_OPTION_ACTION, but with different context. | ||
* This is because the chart doesn't persist the embeddable, which is the default | ||
* context used by the CONTEXT_MENU_TRIGGER. Because of that, we need a separate | ||
* one that can be persisted in the chart - in this case, the AugmentVisContext, | ||
* which is just a saved object ID. | ||
*/ | ||
|
||
export class OpenEventsFlyoutAction implements Action<AugmentVisContext> { | ||
public readonly type = OPEN_EVENTS_FLYOUT_ACTION; | ||
public readonly id = OPEN_EVENTS_FLYOUT_ACTION; | ||
public order = 1; | ||
|
||
constructor(private core: CoreStart) {} | ||
|
||
public getIconType() { | ||
return undefined; | ||
} | ||
|
||
public getDisplayName() { | ||
return i18n.translate('visAugmenter.displayName', { | ||
defaultMessage: 'Open View Events flyout', | ||
}); | ||
} | ||
|
||
public async isCompatible({ savedObjectId }: AugmentVisContext) { | ||
return true; | ||
} | ||
|
||
public async execute({ savedObjectId }: AugmentVisContext) { | ||
if (!(await this.isCompatible({ savedObjectId }))) { | ||
throw new IncompatibleActionError(); | ||
} | ||
openViewEventsFlyout({ | ||
core: this.core, | ||
savedObjectId, | ||
}); | ||
} | ||
} |
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, | ||
}); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/plugins/vis_augmenter/public/components/base_vis_item.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 { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; | ||
import { getEmbeddable } from '../services'; | ||
import { VisualizeEmbeddable } from '../../../visualizations/public'; | ||
import './styles.scss'; | ||
|
||
interface Props { | ||
embeddable: VisualizeEmbeddable; | ||
} | ||
|
||
export function BaseVisItem(props: Props) { | ||
const PanelComponent = getEmbeddable().getEmbeddablePanel(); | ||
|
||
return ( | ||
<EuiFlexGroup direction="row" gutterSize="s"> | ||
<EuiFlexItem className="view-events-flyout__visDescription" grow={false} /> | ||
<EuiFlexItem grow={true} className="view-events-flyout__baseVis"> | ||
<PanelComponent | ||
embeddable={props.embeddable} | ||
hideHeader={true} | ||
hasBorder={false} | ||
hasShadow={false} | ||
/> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
); | ||
} |
64 changes: 64 additions & 0 deletions
64
src/plugins/vis_augmenter/public/components/date_range_item.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,64 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React, { useState } from 'react'; | ||
import moment from 'moment'; | ||
import { | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiText, | ||
EuiIcon, | ||
prettyDuration, | ||
EuiButton, | ||
} from '@elastic/eui'; | ||
import { TimeRange } from '../../../data/common'; | ||
import { DATE_RANGE_FORMAT } from './view_events_flyout'; | ||
|
||
interface Props { | ||
timeRange: TimeRange; | ||
reload: () => void; | ||
} | ||
|
||
export function DateRangeItem(props: Props) { | ||
const [lastUpdatedTime, setLastUpdatedTime] = useState<string>( | ||
moment(Date.now()).format(DATE_RANGE_FORMAT) | ||
); | ||
|
||
const durationText = prettyDuration( | ||
props.timeRange.from, | ||
props.timeRange.to, | ||
[], | ||
DATE_RANGE_FORMAT | ||
); | ||
|
||
return ( | ||
<EuiFlexGroup direction="row" gutterSize="m" alignItems="center"> | ||
<EuiFlexItem grow={false}> | ||
<EuiIcon type="calendar" /> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiText>{durationText}</EuiText> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiButton | ||
iconType={'refresh'} | ||
isDisabled={false} | ||
onClick={() => { | ||
props.reload(); | ||
setLastUpdatedTime(moment(Date.now()).format(DATE_RANGE_FORMAT)); | ||
}} | ||
> | ||
Refresh | ||
</EuiButton> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiText size="s" color="subdued" style={{ whiteSpace: 'pre-line' }}> | ||
{`This view is not updated to load the latest events automatically. | ||
Last updated: ${lastUpdatedTime}`} | ||
</EuiText> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
); | ||
} |
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> | ||
); | ||
} |
Oops, something went wrong.