Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.9] Dashboard De-Angularization #4543

Merged
merged 1 commit into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@
"dns-sync": "^0.2.1",
"elastic-apm-node": "^3.43.0",
"elasticsearch": "^16.7.0",
"http-aws-es": "npm:@zhongnansu/http-aws-es@6.0.1",
"execa": "^4.0.2",
"expiry-js": "0.1.7",
"fast-deep-equal": "^3.1.1",
Expand All @@ -185,6 +184,7 @@
"globby": "^11.1.0",
"handlebars": "4.7.7",
"hjson": "3.2.1",
"http-aws-es": "npm:@zhongnansu/http-aws-es@6.0.1",
"http-proxy-agent": "^2.1.0",
"https-proxy-agent": "^5.0.0",
"inline-style": "^2.0.0",
Expand Down Expand Up @@ -293,6 +293,7 @@
"@types/has-ansi": "^3.0.0",
"@types/history": "^4.7.3",
"@types/hjson": "^2.4.2",
"@types/http-aws-es": "6.0.2",
"@types/jest": "^27.4.0",
"@types/joi": "^13.4.2",
"@types/jquery": "^3.3.31",
Expand Down Expand Up @@ -345,7 +346,6 @@
"@types/zen-observable": "^0.8.0",
"@typescript-eslint/eslint-plugin": "^3.10.0",
"@typescript-eslint/parser": "^3.10.0",
"@types/http-aws-es": "6.0.2",
"angular-aria": "^1.8.0",
"angular-mocks": "^1.8.2",
"angular-recursion": "^1.0.5",
Expand Down
9 changes: 7 additions & 2 deletions src/plugins/dashboard/common/migrate_to_730_panels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,11 @@ function is640To720Panel(
panel: unknown | RawSavedDashboardPanel640To720
): panel is RawSavedDashboardPanel640To720 {
return (
semver.satisfies((panel as RawSavedDashboardPanel630).version, '>6.3') &&
semver.satisfies((panel as RawSavedDashboardPanel630).version, '<7.3')
semver.satisfies(
semver.coerce((panel as RawSavedDashboardPanel630).version)!.version,
'>6.3'
) &&
semver.satisfies(semver.coerce((panel as RawSavedDashboardPanel630).version)!.version, '<7.3')
);
}

Expand Down Expand Up @@ -273,10 +276,12 @@ function migrate640To720PanelsToLatest(
version: string
): RawSavedDashboardPanel730ToLatest {
const panelIndex = panel.panelIndex ? panel.panelIndex.toString() : uuid.v4();
const embeddableConfig = panel.embeddableConfig ?? {};
return {
...panel,
version,
panelIndex,
embeddableConfig,
};
}

Expand Down
14 changes: 0 additions & 14 deletions src/plugins/dashboard/public/application/_hacks.scss

This file was deleted.

11 changes: 11 additions & 0 deletions src/plugins/dashboard/public/application/app.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.dshAppContainer {
display: flex;
flex-direction: column;
flex-grow: 1;
}

#dashboardViewport {
display: flex;
flex-direction: column;
flex: 1;
}
27 changes: 27 additions & 0 deletions src/plugins/dashboard/public/application/app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import './app.scss';
import React from 'react';
import { Route, Switch } from 'react-router-dom';
import { DashboardConstants, createDashboardEditUrl } from '../dashboard_constants';
import { DashboardEditor, DashboardListing, DashboardNoMatch } from './components';

export const DashboardApp = () => {
return (

Check warning on line 13 in src/plugins/dashboard/public/application/app.tsx

View check run for this annotation

Codecov / codecov/patch

src/plugins/dashboard/public/application/app.tsx#L13

Added line #L13 was not covered by tests
<Switch>
<Route path={[DashboardConstants.CREATE_NEW_DASHBOARD_URL, createDashboardEditUrl(':id')]}>
<div className="app-container dshAppContainer">
<DashboardEditor />
<div id="dashboardViewport" />
</div>
</Route>
<Route exact path={['/', DashboardConstants.LANDING_PAGE_PATH]}>
<DashboardListing />
</Route>
<DashboardNoMatch />
</Switch>
);
};
167 changes: 0 additions & 167 deletions src/plugins/dashboard/public/application/application.ts

This file was deleted.

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

import React, { useState } from 'react';
import { useParams } from 'react-router-dom';
import { EventEmitter } from 'events';
import { DashboardTopNav } from '../components/dashboard_top_nav';
import { useChromeVisibility } from '../utils/use/use_chrome_visibility';
import { useOpenSearchDashboards } from '../../../../opensearch_dashboards_react/public';
import { useSavedDashboardInstance } from '../utils/use/use_saved_dashboard_instance';
import { DashboardServices } from '../../types';
import { useDashboardAppAndGlobalState } from '../utils/use/use_dashboard_app_state';
import { useEditorUpdates } from '../utils/use/use_editor_updates';

export const DashboardEditor = () => {
const { id: dashboardIdFromUrl } = useParams<{ id: string }>();
const { services } = useOpenSearchDashboards<DashboardServices>();
const { chrome } = services;
const isChromeVisible = useChromeVisibility({ chrome });
const [eventEmitter] = useState(new EventEmitter());

Check warning on line 22 in src/plugins/dashboard/public/application/components/dashboard_editor.tsx

View check run for this annotation

Codecov / codecov/patch

src/plugins/dashboard/public/application/components/dashboard_editor.tsx#L18-L22

Added lines #L18 - L22 were not covered by tests

const { savedDashboard: savedDashboardInstance, dashboard } = useSavedDashboardInstance({

Check warning on line 24 in src/plugins/dashboard/public/application/components/dashboard_editor.tsx

View check run for this annotation

Codecov / codecov/patch

src/plugins/dashboard/public/application/components/dashboard_editor.tsx#L24

Added line #L24 was not covered by tests
services,
eventEmitter,
isChromeVisible,
dashboardIdFromUrl,
});

const { appState, currentContainer, indexPatterns } = useDashboardAppAndGlobalState({

Check warning on line 31 in src/plugins/dashboard/public/application/components/dashboard_editor.tsx

View check run for this annotation

Codecov / codecov/patch

src/plugins/dashboard/public/application/components/dashboard_editor.tsx#L31

Added line #L31 was not covered by tests
services,
eventEmitter,
savedDashboardInstance,
dashboard,
});

const { isEmbeddableRendered, currentAppState } = useEditorUpdates({

Check warning on line 38 in src/plugins/dashboard/public/application/components/dashboard_editor.tsx

View check run for this annotation

Codecov / codecov/patch

src/plugins/dashboard/public/application/components/dashboard_editor.tsx#L38

Added line #L38 was not covered by tests
services,
eventEmitter,
savedDashboardInstance,
dashboard,
dashboardContainer: currentContainer,
appState,
});

return (

Check warning on line 47 in src/plugins/dashboard/public/application/components/dashboard_editor.tsx

View check run for this annotation

Codecov / codecov/patch

src/plugins/dashboard/public/application/components/dashboard_editor.tsx#L47

Added line #L47 was not covered by tests
<div>
<div>
{savedDashboardInstance && appState && currentAppState && currentContainer && dashboard && (
<DashboardTopNav
isChromeVisible={isChromeVisible}
savedDashboardInstance={savedDashboardInstance}
appState={appState!}
dashboard={dashboard}
currentAppState={currentAppState}
isEmbeddableRendered={isEmbeddableRendered}
indexPatterns={indexPatterns}
currentContainer={currentContainer}
dashboardIdFromUrl={dashboardIdFromUrl}
/>
)}
</div>
</div>
);
};
Loading
Loading