Skip to content

Commit

Permalink
Set dashboard container functions and fix license headers (#4540)
Browse files Browse the repository at this point in the history
* Set dashboard container after defining functions
  * renderEmpty was not being set prior to the current container was being dispatched.
* fix up license headers for new files
* add TODOs from PR

Signed-off-by: Kawika Avilla <[email protected]>
  • Loading branch information
kavilla authored Jul 11, 2023
1 parent 2358bf3 commit 5c1a419
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 45 deletions.
8 changes: 1 addition & 7 deletions src/plugins/dashboard/public/application/app.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +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.
*/

import './app.scss';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ export const DashboardListing = () => {
[history, application]
);

// TODO: Currently, dashboard listing is using a href to view items.
// Dashboard listing should utilize a callback to take us away from using a href in favor
// of using onClick.
//
// https://github.com/opensearch-project/OpenSearch-Dashboards/issues/3365
//
// const viewItem = useCallback(
// ({ appId, viewUrl }: any) => {
// if (appId === 'dashboard') {
Expand Down
8 changes: 1 addition & 7 deletions src/plugins/dashboard/public/application/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +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.
*/

import React from 'react';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +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.
*/

import { i18n } from '@osd/i18n';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,18 @@ export const createDashboardGlobalAndAppState = ({
...state,
});
} else {
// TODO: This logic was ported over this but can be handled more gracefully and intentionally
// Sync from state url should be refactored within this application. The app is syncing from
// the query state and the dashboard in different locations which can be handled better.
// https://github.com/opensearch-project/OpenSearch-Dashboards/issues/3365
//
// Do nothing in case when state from url is empty,
// this fixes: https://github.com/elastic/kibana/issues/57789
// There are not much cases when state in url could become empty:
// 1. User manually removed `_a` from the url
// 2. Browser is navigating away from the page and most likely there is no `_a` in the url.
// In this case we don't want to do any state updates
// and just allow $scope.$on('destroy') fire later and clean up everything
// and just unmount later and clean up everything
}
},
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +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.
*/

import { Dashboard, DashboardParams } from '../../dashboard';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +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.
*/

import { useState, useEffect } from 'react';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@ export const useDashboardAppAndGlobalState = ({
savedDashboard: savedDashboardInstance,
appState: stateContainer,
});
setCurrentContainer(dashboardContainer);

if (!dashboardContainer) {
return;
}

// Ensure empty state is attached to current container being dispatched
dashboardContainer.renderEmpty = () =>
renderEmpty(dashboardContainer, stateContainer, services);

// Ensure update app state in url is attached to current container being dispatched
dashboardContainer.updateAppStateUrl = ({
replace,
pathname,
Expand All @@ -147,6 +147,8 @@ export const useDashboardAppAndGlobalState = ({
}
};

setCurrentContainer(dashboardContainer);

const stopSyncingDashboardContainerOutputs = handleDashboardContainerOutputs(
services,
dashboardContainer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ export const useSavedDashboardInstance = ({
history.replace(DashboardConstants.LANDING_PAGE_PATH);
};

// TODO: handle try/catch as expected workflows instead of catching as an error
// https://github.com/opensearch-project/OpenSearch-Dashboards/issues/3365
const getSavedDashboardInstance = async () => {
try {
let dashboardInstance: {
Expand Down
8 changes: 1 addition & 7 deletions src/plugins/dashboard/public/dashboard.ts
Original file line number Diff line number Diff line change
@@ -1,12 +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.
*/

/**
Expand Down

0 comments on commit 5c1a419

Please sign in to comment.