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

Add map as embeddable to dashboard #231

Merged
merged 9 commits into from
Feb 20, 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 common/constants/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ export const MAX_FILE_PAYLOAD_SIZE_IN_MB = 25;
export const MAX_FILE_PAYLOAD_SIZE = fromMBtoBytes(MAX_FILE_PAYLOAD_SIZE_IN_MB);
export const PLUGIN_ID = 'customImportMap';
export const PLUGIN_NAME = 'customImportMap';
export const PLUGIN_NAVIGATION_BAR_TILE = 'Maps';
export const PLUGIN_NAVIGATION_BAR_ID = 'maps-dashboards';
export const MAPS_APP_DISPLAY_NAME = 'Maps';
export const MAPS_APP_ID = 'maps-dashboards';
8 changes: 6 additions & 2 deletions common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
MAX_FILE_PAYLOAD_SIZE,
MAX_FILE_PAYLOAD_SIZE_IN_MB,
PLUGIN_ID,
PLUGIN_NAVIGATION_BAR_ID,
MAPS_APP_ID,
PLUGIN_NAME,
} from './constants/shared';

Expand All @@ -19,7 +19,7 @@ export {
MAX_FILE_PAYLOAD_SIZE,
MAX_FILE_PAYLOAD_SIZE_IN_MB,
PLUGIN_ID,
PLUGIN_NAVIGATION_BAR_ID,
MAPS_APP_ID,
PLUGIN_NAME,
};

Expand All @@ -44,6 +44,10 @@ export const MAX_LAYER_NAME_LIMIT = 35;
export const MAX_LONGITUDE = 180;
export const MIN_LONGITUDE = -180;
export const NEW_MAP_LAYER_DEFAULT_PREFIX = 'New layer';
export const MAP_SAVED_OBJECT_TYPE = 'map';
// TODO: Replace with actual app icon
export const MAPS_APP_ICON = 'gisApp';
export const MAPS_VISUALIZATION_DESCRIPTION = 'Create map visualization with multiple layers';

// Starting position [lng, lat] and zoom
export const MAP_INITIAL_STATE = {
Expand Down
36 changes: 36 additions & 0 deletions cypress/integration/add_map_to_dashboard.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { BASE_PATH } from '../utils/constants';

describe('Add map to dashboard', () => {
before(() => {
cy.visit(`${BASE_PATH}/app/home#/tutorial_directory/sampleData`, {
retryOnStatusCodeFailure: true,
timeout: 60000,
});
cy.get('div[data-test-subj="sampleDataSetCardflights"]', { timeout: 60000 })
.contains(/(Add|View) data/)
.click();
cy.wait(60000);
});

it('Add new map to dashboard', () => {
const testMapName = 'saved-map-' + Date.now().toString();
cy.visit(`${BASE_PATH}/app/dashboards`);
cy.get('button[data-test-subj="newItemButton"]').click();
cy.get('button[data-test-subj="dashboardAddNewPanelButton"]').click();
cy.get('button[data-test-subj="visType-customImportMap"]').click();
cy.wait(5000).get('button[data-test-subj="mapSaveButton"]').click();
cy.wait(5000).get('[data-test-subj="savedObjectTitle"]').type(testMapName);
cy.wait(5000).get('[data-test-subj="confirmSaveSavedObjectButton"]').click();
cy.get('.embPanel__titleText').should('contain', testMapName);
});

after(() => {
cy.visit(`${BASE_PATH}/app/home#/tutorial_directory`);
cy.get('button[data-test-subj="removeSampleDataSetflights"]').should('be.visible').click();
});
});
2 changes: 1 addition & 1 deletion opensearch_dashboards.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"opensearchDashboardsVersion": "3.0.0",
"server": true,
"ui": true,
"requiredPlugins": ["regionMap", "opensearchDashboardsReact", "navigation", "savedObjects", "data"],
"requiredPlugins": ["regionMap", "opensearchDashboardsReact", "opensearchDashboardsUtils", "navigation", "savedObjects", "data", "embeddable", "visualizations"],
"optionalPlugins": ["home"]
}
249 changes: 249 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 7 additions & 9 deletions public/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@ export const MapsDashboardsApp = ({ mapConfig }: Props) => {
return (
<Router history={appBasePath}>
<I18nProvider>
<div>
<Switch>
<Route
path={[APP_PATH.CREATE_MAP, APP_PATH.EDIT_MAP]}
render={() => <MapPage mapConfig={mapConfig} />}
/>
<Route exact path={APP_PATH.LANDING_PAGE_PATH} render={() => <MapsList />} />
</Switch>
</div>
<Switch>
<Route
path={[APP_PATH.CREATE_MAP, APP_PATH.EDIT_MAP]}
render={() => <MapPage mapConfig={mapConfig} />}
/>
<Route exact path={APP_PATH.LANDING_PAGE_PATH} render={() => <MapsList />} />
</Switch>
</I18nProvider>
</Router>
);
Expand Down
Loading