Skip to content

Commit

Permalink
[Dashboards] restructure folder to be more cohesive with the project
Browse files Browse the repository at this point in the history
Fast follow to:
opensearch-project#4502

* Cleanup to just use `utils`
* Move empty screen into embeddables folder with related features
* Get rid of the export file in favor matching other plugins
* Combine folders of components that are related, e.g., top_nav

Issue:
opensearch-project#4574

Signed-off-by: Kawika Avilla <[email protected]>
  • Loading branch information
kavilla committed Jul 14, 2023
1 parent 0ab3233 commit 4f54a47
Show file tree
Hide file tree
Showing 91 changed files with 297 additions and 1,138 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [Vis colors] Update legacy mapped colors in charts plugin to use `ouiPaletteColorBlind()`, Update default color in legacy visualizations to use `ouiPaletteColorBlind()[0]` ([#4398](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4398))
- [Saved Objects Management] Add new or remove extra tags and styles ([#4069](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4069))
- [Console] Migrate `/lib/mappings/` module to TypeScript ([#4008](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4008))
- [Dashboard] Restructure the `Dashboard` plugin folder to be more cohesive with the project ([#4575](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4575))

### 🔩 Tests

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,22 @@ import {
IContainer,
ReferenceOrValueEmbeddable,
EmbeddableInput,
} from '../../embeddable_plugin';
import { DashboardContainer } from '../embeddable';
import { getSampleDashboardInput } from '../test_helpers';
ErrorEmbeddable,
ViewMode,
} from '../../../../embeddable/public';
import { embeddablePluginMock } from '../../../../embeddable/public/mocks';
import {
CONTACT_CARD_EMBEDDABLE,
ContactCardEmbeddableFactory,
ContactCardEmbeddable,
ContactCardEmbeddableInput,
ContactCardEmbeddableOutput,
} from '../../embeddable_plugin_test_samples';
} from '../../../../embeddable/public/lib/test_samples';
import { DashboardContainer } from '../embeddable';
import { getSampleDashboardInput } from '../test_helpers';
import { coreMock } from '../../../../../core/public/mocks';
import { CoreStart } from 'opensearch-dashboards/public';
import { AddToLibraryAction } from '.';
import { embeddablePluginMock } from 'src/plugins/embeddable/public/mocks';
import { ErrorEmbeddable, ViewMode } from '../../../../embeddable/public';

const { setup, doStart } = embeddablePluginMock.createInstance();
setup.registerEmbeddableFactory(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ import { i18n } from '@osd/i18n';
import _ from 'lodash';
import uuid from 'uuid';
import { EuiIconType } from '@elastic/eui/src/components/icon/icon';
import { ActionByType, IncompatibleActionError } from '../../ui_actions_plugin';
import { ViewMode, PanelState, IEmbeddable } from '../../embeddable_plugin';
import { ActionByType, IncompatibleActionError } from '../../../../ui_actions/public';
import {
PanelNotFoundError,
EmbeddableInput,
isReferenceOrValueEmbeddable,
isErrorEmbeddable,
ViewMode,
PanelState,
IEmbeddable,
} from '../../../../embeddable/public';
import { DashboardPanelState, DASHBOARD_CONTAINER_TYPE, DashboardContainer } from '..';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,20 @@
* under the License.
*/

import { isErrorEmbeddable, IContainer, ErrorEmbeddable } from '../../embeddable_plugin';
import { DashboardContainer, DashboardPanelState } from '../embeddable';
import { getSampleDashboardInput, getSampleDashboardPanel } from '../test_helpers';
import { isErrorEmbeddable, IContainer, ErrorEmbeddable } from '../../../../embeddable/public';
import {
CONTACT_CARD_EMBEDDABLE,
ContactCardEmbeddableFactory,
ContactCardEmbeddable,
ContactCardEmbeddableInput,
ContactCardEmbeddableOutput,
} from '../../embeddable_plugin_test_samples';
} from '../../../../embeddable/public/lib/test_samples';
import { embeddablePluginMock } from '../../../../embeddable/public/mocks';
import { DashboardContainer, DashboardPanelState } from '../embeddable';
import { getSampleDashboardInput, getSampleDashboardPanel } from '../test_helpers';
import { coreMock } from '../../../../../core/public/mocks';
import { CoreStart } from 'opensearch-dashboards/public';
import { ClonePanelAction } from '.';
import { embeddablePluginMock } from 'src/plugins/embeddable/public/mocks';

const { setup, doStart } = embeddablePluginMock.createInstance();
setup.registerEmbeddableFactory(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,16 @@ import { CoreStart } from 'src/core/public';
import uuid from 'uuid';
import _ from 'lodash';
import { EuiIconType } from '@elastic/eui/src/components/icon/icon';
import { ActionByType, IncompatibleActionError } from '../../ui_actions_plugin';
import { ViewMode, PanelState, IEmbeddable } from '../../embeddable_plugin';
import { ActionByType, IncompatibleActionError } from '../../../../ui_actions/public';
import { SavedObject } from '../../../../saved_objects/public';
import {
PanelNotFoundError,
EmbeddableInput,
SavedObjectEmbeddableInput,
isErrorEmbeddable,
ViewMode,
PanelState,
IEmbeddable,
} from '../../../../embeddable/public';
import {
placePanelBeside,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@
* under the License.
*/

import { isErrorEmbeddable } from '../../embeddable_plugin';
import { ExpandPanelAction } from './expand_panel_action';
import { DashboardContainer } from '../embeddable';
import { getSampleDashboardInput, getSampleDashboardPanel } from '../test_helpers';
import { isErrorEmbeddable } from '../../../../embeddable/public';
import {
CONTACT_CARD_EMBEDDABLE,
ContactCardEmbeddableFactory,
ContactCardEmbeddable,
ContactCardEmbeddableInput,
ContactCardEmbeddableOutput,
} from '../../embeddable_plugin_test_samples';
import { embeddablePluginMock } from 'src/plugins/embeddable/public/mocks';
} from '../../../../embeddable/public/lib/test_samples';
import { embeddablePluginMock } from '../../../../embeddable/public/mocks';
import { ExpandPanelAction } from './expand_panel_action';
import { DashboardContainer } from '../embeddable';
import { getSampleDashboardInput, getSampleDashboardPanel } from '../test_helpers';

const { setup, doStart } = embeddablePluginMock.createInstance();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@

import { EuiIconType } from '@elastic/eui/src/components/icon/icon';
import { i18n } from '@osd/i18n';
import { IEmbeddable } from '../../embeddable_plugin';
import { ActionByType, IncompatibleActionError } from '../../ui_actions_plugin';
import { IEmbeddable } from '../../../../embeddable/public';
import { ActionByType, IncompatibleActionError } from '../../../../ui_actions/public';
import { DASHBOARD_CONTAINER_TYPE, DashboardContainer } from '../embeddable';

export const ACTION_EXPAND_PANEL = 'togglePanel';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,26 @@
* under the License.
*/

import { isErrorEmbeddable, ReferenceOrValueEmbeddable } from '../../embeddable_plugin';
import { DashboardContainer } from '../embeddable';
import { getSampleDashboardInput } from '../test_helpers';
import {
isErrorEmbeddable,
ReferenceOrValueEmbeddable,
ErrorEmbeddable,
IContainer,
ViewMode,
} from '../../../../embeddable/public';
import {
CONTACT_CARD_EMBEDDABLE,
ContactCardEmbeddableFactory,
ContactCardEmbeddable,
ContactCardEmbeddableInput,
ContactCardEmbeddableOutput,
} from '../../embeddable_plugin_test_samples';
} from '../../../../embeddable/public/lib/test_samples';
import { embeddablePluginMock } from '../../../../embeddable/public/mocks';
import { DashboardContainer } from '../embeddable';
import { getSampleDashboardInput } from '../test_helpers';
import { coreMock } from '../../../../../core/public/mocks';
import { CoreStart } from 'opensearch-dashboards/public';
import { LibraryNotificationAction } from '.';
import { embeddablePluginMock } from 'src/plugins/embeddable/public/mocks';
import { ErrorEmbeddable, IContainer, ViewMode } from '../../../../embeddable/public';

const { setup, doStart } = embeddablePluginMock.createInstance();
setup.registerEmbeddableFactory(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ import {
ViewMode,
isReferenceOrValueEmbeddable,
isErrorEmbeddable,
} from '../../embeddable_plugin';
import { ActionByType, IncompatibleActionError } from '../../ui_actions_plugin';
} from '../../../../embeddable/public';
import { ActionByType, IncompatibleActionError } from '../../../../ui_actions/public';
import { reactToUiComponent } from '../../../../opensearch_dashboards_react/public';

export const ACTION_LIBRARY_NOTIFICATION = 'ACTION_LIBRARY_NOTIFICATION';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import {
EmbeddableOutput,
EmbeddableStart,
IContainer,
} from '../../embeddable_plugin';
} from '../../../../embeddable/public';

export async function openReplacePanelFlyout(options: {
embeddable: IContainer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,20 @@
* under the License.
*/

import { isErrorEmbeddable } from '../../embeddable_plugin';
import { ReplacePanelAction } from './replace_panel_action';
import { DashboardContainer } from '../embeddable';
import { getSampleDashboardInput, getSampleDashboardPanel } from '../test_helpers';
import { isErrorEmbeddable } from '../../../../embeddable/public';
import {
CONTACT_CARD_EMBEDDABLE,
ContactCardEmbeddableFactory,
ContactCardEmbeddable,
ContactCardEmbeddableInput,
ContactCardEmbeddableOutput,
} from '../../embeddable_plugin_test_samples';
} from '../../../../embeddable/public/lib/test_samples';
import { embeddablePluginMock } from '../../../../embeddable/public/mocks';
import { ReplacePanelAction } from './replace_panel_action';
import { DashboardContainer } from '../embeddable';
import { getSampleDashboardInput, getSampleDashboardPanel } from '../test_helpers';
import { coreMock } from '../../../../../core/public/mocks';
import { CoreStart } from 'opensearch-dashboards/public';
import { embeddablePluginMock } from 'src/plugins/embeddable/public/mocks';

const { setup, doStart } = embeddablePluginMock.createInstance();
setup.registerEmbeddableFactory(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
import { i18n } from '@osd/i18n';
import { CoreStart } from 'src/core/public';
import { EuiIconType } from '@elastic/eui/src/components/icon/icon';
import { IEmbeddable, ViewMode, EmbeddableStart } from '../../embeddable_plugin';
import { IEmbeddable, ViewMode, EmbeddableStart } from '../../../../embeddable/public';
import { DASHBOARD_CONTAINER_TYPE, DashboardContainer } from '../embeddable';
import { ActionByType, IncompatibleActionError } from '../../ui_actions_plugin';
import { ActionByType, IncompatibleActionError } from '../../../../ui_actions/public';
import { openReplacePanelFlyout } from './open_replace_panel_flyout';

export const ACTION_REPLACE_PANEL = 'replacePanel';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import {
IContainer,
IEmbeddable,
SavedObjectEmbeddableInput,
} from '../../embeddable_plugin';
} from '../../../../embeddable/public';

interface Props {
container: IContainer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,27 @@
* under the License.
*/

import { isErrorEmbeddable, IContainer, ReferenceOrValueEmbeddable } from '../../embeddable_plugin';
import { DashboardContainer } from '../embeddable';
import { getSampleDashboardInput } from '../test_helpers';
import {
isErrorEmbeddable,
IContainer,
ReferenceOrValueEmbeddable,
ViewMode,
SavedObjectEmbeddableInput,
ErrorEmbeddable,
} from '../../../../embeddable/public';
import {
CONTACT_CARD_EMBEDDABLE,
ContactCardEmbeddableFactory,
ContactCardEmbeddable,
ContactCardEmbeddableInput,
ContactCardEmbeddableOutput,
} from '../../embeddable_plugin_test_samples';
} from '../../../../embeddable/public/lib/test_samples';
import { embeddablePluginMock } from '../../../../embeddable/public/mocks';
import { DashboardContainer } from '../embeddable';
import { getSampleDashboardInput } from '../test_helpers';
import { coreMock } from '../../../../../core/public/mocks';
import { CoreStart } from 'opensearch-dashboards/public';
import { UnlinkFromLibraryAction } from '.';
import { embeddablePluginMock } from 'src/plugins/embeddable/public/mocks';
import {
ViewMode,
SavedObjectEmbeddableInput,
ErrorEmbeddable,
} from '../../../../embeddable/public';

const { setup, doStart } = embeddablePluginMock.createInstance();
setup.registerEmbeddableFactory(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ import { i18n } from '@osd/i18n';
import _ from 'lodash';
import uuid from 'uuid';
import { EuiIconType } from '@elastic/eui/src/components/icon/icon';
import { ActionByType, IncompatibleActionError } from '../../ui_actions_plugin';
import { ViewMode, PanelState, IEmbeddable } from '../../embeddable_plugin';
import { ActionByType, IncompatibleActionError } from '../../../../ui_actions/public';
import {
PanelNotFoundError,
EmbeddableInput,
isReferenceOrValueEmbeddable,
isErrorEmbeddable,
ViewMode,
PanelState,
IEmbeddable,
} from '../../../../embeddable/public';
import { DashboardPanelState, DASHBOARD_CONTAINER_TYPE, DashboardContainer } from '..';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { findTestSubject } from '@elastic/eui/lib/test';
import React from 'react';

import { CreateButton } from './create_button';
import { DashboardProvider } from '../../types';
import { DashboardProvider } from '../../../types';

const provider = (type?: string, url?: string, text?: string): DashboardProvider => {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
EuiFlexItem,
EuiPopover,
} from '@elastic/eui';
import type { DashboardProvider } from '../../types';
import type { DashboardProvider } from '../../../types';

interface CreateButtonProps {
dashboardProviders?: { [key: string]: DashboardProvider };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ jest.mock(
() => ({
...jest.requireActual('lodash'),
// mock debounce to fire immediately with no internal timer
debounce: (func) => {
function debounced(...args) {
debounce: (func: any) => {
function debounced(this: any, ...args: any[]) {
return func.apply(this, args);
}
return debounced;
Expand All @@ -49,9 +49,9 @@ jest.mock(
import React from 'react';
import { shallow } from 'enzyme';

import { DashboardListing } from '../components/dashboard_listing';
import { DashboardListing } from './dashboard_listing';

const find = (num) => {
const find = (num: number) => {
const hits = [];
for (let i = 0; i < num; i++) {
hits.push({
Expand All @@ -62,7 +62,7 @@ const find = (num) => {
}
return Promise.resolve({
total: num,
hits: hits,
hits,
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import { useLocation } from 'react-router-dom';
import {
useOpenSearchDashboards,
TableListView,
} from '../../../../opensearch_dashboards_react/public';
import { CreateButton } from '../listing/create_button';
import { DashboardConstants, createDashboardEditUrl } from '../../dashboard_constants';
import { DashboardServices } from '../../types';
import { getTableColumns } from '../utils/get_table_columns';
import { getNoItemsMessage } from '../utils/get_no_items_message';
import { syncQueryStateWithUrl } from '../../../../data/public';
} from '../../../../../opensearch_dashboards_react/public';
import { CreateButton } from './create_button';
import { DashboardConstants, createDashboardEditUrl } from '../../../dashboard_constants';
import { DashboardServices } from '../../../types';
import { getTableColumns } from '../../utils/get_table_columns';
import { getNoItemsMessage } from '../../utils/get_no_items_message';
import { syncQueryStateWithUrl } from '../../../../../data/public';

export const EMPTY_FILTER = '';

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

export { CreateButton } from './create_button';
export { DashboardListing } from './dashboard_listing';
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import React, { memo, useState, useEffect } from 'react';
import { IndexPattern } from 'src/plugins/data/public';
import { useCallback } from 'react';
import { useLocation } from 'react-router-dom';
import { useOpenSearchDashboards } from '../../../../opensearch_dashboards_react/public';
import { getTopNavConfig } from '../top_nav/get_top_nav_config';
import { DashboardAppStateContainer, DashboardAppState, DashboardServices } from '../../types';
import { getNavActions } from '../utils/get_nav_actions';
import { DashboardContainer } from '../embeddable';
import { Dashboard } from '../../dashboard';
import { useOpenSearchDashboards } from '../../../../../opensearch_dashboards_react/public';
import { getTopNavConfig } from './top_nav';
import { DashboardAppStateContainer, DashboardAppState, DashboardServices } from '../../../types';
import { getNavActions } from '../../utils/get_nav_actions';
import { DashboardContainer } from '../../embeddable';
import { Dashboard } from '../../../dashboard';

interface DashboardTopNavProps {
isChromeVisible: boolean;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

export * from './top_nav';
export { DashboardTopNav, UrlParams } from './dashboard_top_nav';
Loading

0 comments on commit 4f54a47

Please sign in to comment.