Skip to content

Commit

Permalink
[Vis Augmenter] Minor follow up improvements (#4503)
Browse files Browse the repository at this point in the history
* Minor naming changes & comments

Signed-off-by: Tyler Ohlsen <[email protected]>

* More nits

Signed-off-by: Tyler Ohlsen <[email protected]>

* Few more comments

Signed-off-by: Tyler Ohlsen <[email protected]>

* Expose saved objects common settings values

Signed-off-by: Tyler Ohlsen <[email protected]>

* Add changelog entry

Signed-off-by: Tyler Ohlsen <[email protected]>

---------

Signed-off-by: Tyler Ohlsen <[email protected]>
  • Loading branch information
ohltyler authored Jul 5, 2023
1 parent c3a64d7 commit 1cdc0f6
Show file tree
Hide file tree
Showing 19 changed files with 46 additions and 62 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Bump OUI to `1.1.2` to make `anomalyDetection` icon available ([#4408](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4408))
- Add `color-scheme` to the root styling ([#4477](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4477))
- [Multiple DataSource] Frontend support for adding sample data ([#4412](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4412))
- Enable plugins to augment visualizations with additional data and context ([#4361](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4361))

### 🐛 Bug Fixes

Expand Down
2 changes: 2 additions & 0 deletions src/plugins/embeddable/public/lib/panel/embeddable_panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ interface Props {
SavedObjectFinder: React.ComponentType<any>;
stateTransfer?: EmbeddableStateTransfer;
hideHeader?: boolean;
// TODO: the below hasBorder and hasShadow fields may be removed as part of
// https://github.com/opensearch-project/OpenSearch-Dashboards/issues/4483
hasBorder?: boolean;
hasShadow?: boolean;
}
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/saved_objects/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,7 @@
*/

export const PER_PAGE_SETTING = 'savedObjects:perPage';
export const PER_PAGE_VALUE = 20;

export const LISTING_LIMIT_SETTING = 'savedObjects:listingLimit';
export const LISTING_LIMIT_VALUE = 1000;
11 changes: 8 additions & 3 deletions src/plugins/saved_objects/server/ui_settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,19 @@ import { i18n } from '@osd/i18n';
import { schema } from '@osd/config-schema';

import { UiSettingsParams } from 'opensearch-dashboards/server';
import { PER_PAGE_SETTING, LISTING_LIMIT_SETTING } from '../common';
import {
PER_PAGE_SETTING,
PER_PAGE_VALUE,
LISTING_LIMIT_SETTING,
LISTING_LIMIT_VALUE,
} from '../common';

export const uiSettings: Record<string, UiSettingsParams> = {
[PER_PAGE_SETTING]: {
name: i18n.translate('savedObjects.advancedSettings.perPageTitle', {
defaultMessage: 'Objects per page',
}),
value: 20,
value: PER_PAGE_VALUE,
type: 'number',
description: i18n.translate('savedObjects.advancedSettings.perPageText', {
defaultMessage: 'Number of objects to show per page in the load dialog',
Expand All @@ -51,7 +56,7 @@ export const uiSettings: Record<string, UiSettingsParams> = {
defaultMessage: 'Objects listing limit',
}),
type: 'number',
value: 1000,
value: LISTING_LIMIT_VALUE,
description: i18n.translate('savedObjects.advancedSettings.listingLimitText', {
defaultMessage: 'Number of objects to fetch for the listing pages',
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export class SavedObjectEdition extends Component<
};

formatTitle = (object: SimpleSavedObject<any> | undefined) => {
return object?.attributes?.title ? `'${object.attributes.title}'` : '';
return object?.attributes?.title ?? '';
};

redirectToListing() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
import { i18n } from '@osd/i18n';
import { Trigger } from '../../../ui_actions/public';

/**
* This action is currently being used behind-the-scenes in the vis_augmenter plugin
* to clean up related augment-vis saved objects when a visualization is deleted.
* This could be improved upon by potentially moving and maintaining this in the
* saved_objects plugin, expanding to other situations where automatic cleanup may
* be helpful, and communicating this better on the UI (modals, callouts, etc.)
*/
export const SAVED_OBJECT_DELETE_TRIGGER = 'SAVED_OBJECT_DELETE_TRIGGER';
export const savedObjectDeleteTrigger: Trigger<'SAVED_OBJECT_DELETE_TRIGGER'> = {
id: SAVED_OBJECT_DELETE_TRIGGER,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,6 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Any modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { i18n } from '@osd/i18n';
Expand Down
2 changes: 0 additions & 2 deletions src/plugins/vis_augmenter/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ export const APP_PATH = {
};
export const APP_API = '/api/vis_augmenter';

// used for limiting results received from the stats API
export const PER_PAGE_REQUEST_NUMBER = 50;
export const PLUGIN_AUGMENTATION_ENABLE_SETTING = 'visualization:enablePluginAugmentation';
export const PLUGIN_AUGMENTATION_MAX_OBJECTS_SETTING =
'visualization:enablePluginAugmentation.maxPluginObjects';
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class SavedObjectDeleteAction implements Action<SavedObjectDeleteContext>
}

public async isCompatible({ type, savedObjectId }: SavedObjectDeleteContext) {
return type === 'visualization' && (savedObjectId ? true : false);
return type === 'visualization' && !!savedObjectId;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,11 @@ $base-vis-min-height: 25vh; // Visualizations require the container to have a va

overflow: auto;
overflow-x: hidden;
overflow-y: hidden;
scrollbar-gutter: stable both-edges;
}
}

.hide-y-scroll {
overflow-y: hidden;
}

.show-y-scroll {
overflow-y: scroll;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@ export function ViewEventsFlyout(props: Props) {
<EuiFlyoutBody>
<EuiFlexGroup className="view-events-flyout__content" direction="column">
<EuiFlexItem
className="view-events-flyout__contentPanel hide-y-scroll date-range-panel-height"
className="view-events-flyout__contentPanel date-range-panel-height"
grow={false}
>
<DateRangeItem timeRange={timeRange as TimeRange} reload={reload} />
</EuiFlexItem>
<EuiFlexItem className="view-events-flyout__contentPanel hide-y-scroll" grow={5}>
<EuiFlexItem className="view-events-flyout__contentPanel" grow={5}>
<BaseVisItem embeddable={visEmbeddable as VisualizeEmbeddable} />
</EuiFlexItem>
<EuiFlexItem className="view-events-flyout__contentPanel show-y-scroll" grow={5}>
Expand All @@ -137,7 +137,7 @@ export function ViewEventsFlyout(props: Props) {
/>
</EuiFlexItem>
<EuiFlexItem
className="view-events-flyout__contentPanel hide-y-scroll timeline-panel-height"
className="view-events-flyout__contentPanel timeline-panel-height"
grow={false}
>
<TimelinePanel embeddable={timelineVisEmbeddable as VisualizeEmbeddable} />
Expand Down
10 changes: 3 additions & 7 deletions src/plugins/vis_augmenter/server/routes/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,8 @@ import {
IRouter,
SavedObjectsFindResponse,
} from '../../../../core/server';
import {
APP_API,
APP_PATH,
PER_PAGE_REQUEST_NUMBER,
AugmentVisSavedObjectAttributes,
} from '../../common';
import { APP_API, APP_PATH, AugmentVisSavedObjectAttributes } from '../../common';
import { PER_PAGE_VALUE } from '../../../saved_objects/common';
import { getAugmentVisSavedObjects, getStats } from './stats_helpers';

export const registerStatsRoute = (router: IRouter, logger: Logger) => {
Expand All @@ -33,7 +29,7 @@ export const registerStatsRoute = (router: IRouter, logger: Logger) => {
const savedObjectsClient = context.core.savedObjects.client;
const augmentVisSavedObjects: SavedObjectsFindResponse<AugmentVisSavedObjectAttributes> = await getAugmentVisSavedObjects(
savedObjectsClient,
PER_PAGE_REQUEST_NUMBER
PER_PAGE_VALUE
);
const stats = getStats(augmentVisSavedObjects);
return response.ok({
Expand Down
Loading

0 comments on commit 1cdc0f6

Please sign in to comment.