-
Notifications
You must be signed in to change notification settings - Fork 893
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
Refactor app state and cleanup unused imports #4504
Changes from all commits
7c4d7d3
a4ef964
6439487
056874e
abcef81
3b246fa
30cdb44
9335611
562ab2c
0810963
5aad98d
27bdac8
83ecf46
049159b
d329964
a0d6492
f2b3cd4
5d1f17d
2c5dff2
be82c17
3cfddca
c9a0828
2532263
ff6e3da
7b47c09
c1f8cfa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,6 @@ | |
* under the License. | ||
*/ | ||
|
||
import 'react-grid-layout/css/styles.css'; | ||
import 'react-resizable/css/styles.css'; | ||
|
||
// @ts-ignore | ||
|
@@ -39,7 +38,7 @@ import classNames from 'classnames'; | |
import _ from 'lodash'; | ||
import React from 'react'; | ||
import { Subscription } from 'rxjs'; | ||
import ReactGridLayout, { Layout } from 'react-grid-layout'; | ||
import ReactGridLayout, { Layout, ReactGridLayoutProps } from 'react-grid-layout'; | ||
import { GridData } from '../../../../common'; | ||
import { ViewMode, EmbeddableChildPanel, EmbeddableStart } from '../../../embeddable_plugin'; | ||
import { DASHBOARD_GRID_COLUMN_COUNT, DASHBOARD_GRID_HEIGHT } from '../dashboard_constants'; | ||
|
@@ -76,9 +75,9 @@ function ResponsiveGrid({ | |
size: { width: number }; | ||
isViewMode: boolean; | ||
layout: Layout[]; | ||
onLayoutChange: () => void; | ||
onLayoutChange: ReactGridLayoutProps['onLayoutChange']; | ||
children: JSX.Element[]; | ||
maximizedPanelId: string; | ||
maximizedPanelId?: string; | ||
useMargins: boolean; | ||
}) { | ||
// This is to prevent a bug where view mode changes when the panel is expanded. View mode changes will trigger | ||
|
@@ -171,7 +170,7 @@ class DashboardGridUi extends React.Component<DashboardGridProps, State> { | |
let layout; | ||
try { | ||
layout = this.buildLayoutFromPanels(); | ||
} catch (error) { | ||
} catch (error: any) { | ||
console.error(error); // eslint-disable-line no-console | ||
|
||
isLayoutInvalid = true; | ||
|
@@ -283,6 +282,7 @@ class DashboardGridUi extends React.Component<DashboardGridProps, State> { | |
}} | ||
> | ||
<EmbeddableChildPanel | ||
key={panel.type} | ||
embeddableId={panel.explicitInput.id} | ||
container={this.props.container} | ||
PanelComponent={this.props.PanelComponent} | ||
|
@@ -304,7 +304,7 @@ class DashboardGridUi extends React.Component<DashboardGridProps, State> { | |
isViewMode={isViewMode} | ||
layout={this.buildLayoutFromPanels()} | ||
onLayoutChange={this.onLayoutChange} | ||
maximizedPanelId={this.state.expandedPanelId} | ||
maximizedPanelId={this.state.expandedPanelId!} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is the |
||
useMargins={this.state.useMargins} | ||
> | ||
{this.renderPanels()} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,9 +106,9 @@ export function migrateAppState( | |
delete appState.uiState; | ||
} | ||
|
||
appState.panels.forEach((panel) => { | ||
panel.version = opensearchDashboardsVersion; | ||
}); | ||
// appState.panels.forEach((panel) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets either remove this if its not necessary or add a comment here with a tracking issue that mentions how this can be removed. |
||
// panel.version = opensearchDashboardsVersion; | ||
// }); | ||
|
||
return appState; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ import { updateSavedDashboard } from './update_saved_dashboard'; | |
|
||
import { DashboardAppStateContainer } from '../../types'; | ||
import { Dashboard } from '../../dashboard'; | ||
import { SavedObjectDashboard } from '../../saved_dashboards'; | ||
|
||
/** | ||
* Saves the dashboard. | ||
|
@@ -43,7 +44,7 @@ import { Dashboard } from '../../dashboard'; | |
export function saveDashboard( | ||
timeFilter: TimefilterContract, | ||
stateContainer: DashboardAppStateContainer, | ||
savedDashboard: any, | ||
savedDashboard: SavedObjectDashboard, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice |
||
saveOptions: SavedObjectSaveOpts, | ||
dashboard: Dashboard | ||
): Promise<string> { | ||
|
@@ -54,7 +55,9 @@ export function saveDashboard( | |
// TODO: should update Dashboard class in the if(id) block | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this TODO still necessary? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's worth it to keep as we as a fast follow we should look into using redux slice to keep track of a dashboard and should be updated in this block. |
||
return savedDashboard.save(saveOptions).then((id: string) => { | ||
if (id) { | ||
dashboard.id = id; | ||
return id; | ||
} | ||
return id; | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: You dont need this when you already have the
?