-
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
[Data Explorer] Merge to main #4806
Merged
ashwin-pc
merged 10 commits into
opensearch-project:main
from
ashwin-pc:merge-data-explorer-to-main
Aug 30, 2023
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5d52668
Squashed commit of the following:
ashwin-pc 196ef57
adds Changelog
ashwin-pc f652a2e
minor fixes before merge to main
ashwin-pc e91fe01
PR comment fixes
ashwin-pc c0d3389
fixes reset search
ashwin-pc 81ad2e6
fix save query management
ashwin-pc fcc7ef9
[Data Explorer][Discover 2.0] Enable sort and cell actions for table …
ananzh 3cd87c2
[Data Explorer][Discover 2.0] Change to inspect icon and update hint …
ananzh 88b2012
updates snapshot
ashwin-pc 6db1271
Allows for more than 2 level path be shared
ashwin-pc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"prefix": "dataExplorer", | ||
"paths": { | ||
"dataExplorer": "." | ||
}, | ||
"translations": ["translations/ja-JP.json"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# dataExplorer | ||
|
||
A OpenSearch Dashboards plugin | ||
|
||
--- | ||
|
||
## Development | ||
|
||
See the [OpenSearch Dashboards contributing | ||
guide](https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/CONTRIBUTING.md) for instructions | ||
setting up your development environment. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
export const PLUGIN_ID = 'data-explorer'; | ||
export const PLUGIN_NAME = 'Data Explorer'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"id": "dataExplorer", | ||
"version": "1.0.0", | ||
"opensearchDashboardsVersion": "opensearchDashboards", | ||
"server": true, | ||
"ui": true, | ||
"requiredPlugins": [ | ||
"data", | ||
"navigation", | ||
"embeddable", | ||
"expressions" | ||
], | ||
"optionalPlugins": [], | ||
"requiredBundles": [ | ||
"opensearchDashboardsReact", | ||
"opensearchDashboardsUtils" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import { Provider as ReduxProvider } from 'react-redux'; | ||
import { Router, Route, Switch } from 'react-router-dom'; | ||
import { AppMountParameters, CoreStart } from '../../../core/public'; | ||
import { OpenSearchDashboardsContextProvider } from '../../opensearch_dashboards_react/public'; | ||
import { DataExplorerServices } from './types'; | ||
import { DataExplorerApp } from './components/app'; | ||
import { Store } from './utils/state_management'; | ||
|
||
export const renderApp = ( | ||
core: CoreStart, | ||
services: DataExplorerServices, | ||
params: AppMountParameters, | ||
store: Store | ||
) => { | ||
const { history, element } = params; | ||
ReactDOM.render( | ||
<Router history={history}> | ||
<OpenSearchDashboardsContextProvider services={services}> | ||
<ReduxProvider store={store}> | ||
<services.i18n.Context> | ||
<Switch> | ||
<Route path={[`/:appId`, '/']} exact={false}> | ||
<DataExplorerApp params={params} /> | ||
</Route> | ||
</Switch> | ||
</services.i18n.Context> | ||
</ReduxProvider> | ||
</OpenSearchDashboardsContextProvider> | ||
</Router>, | ||
element | ||
); | ||
|
||
return () => ReactDOM.unmountComponentAtNode(element); | ||
}; |
13 changes: 13 additions & 0 deletions
13
src/plugins/data_explorer/public/components/__snapshots__/app_container.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React, { useEffect } from 'react'; | ||
import { useLocation } from 'react-router-dom'; | ||
import { AppMountParameters } from '../../../../core/public'; | ||
import { useView } from '../utils/use'; | ||
import { AppContainer } from './app_container'; | ||
import { useOpenSearchDashboards } from '../../../opensearch_dashboards_react/public'; | ||
import { DataExplorerServices } from '../types'; | ||
import { syncQueryStateWithUrl } from '../../../data/public'; | ||
|
||
export const DataExplorerApp = ({ params }: { params: AppMountParameters }) => { | ||
const { view } = useView(); | ||
const { | ||
services: { | ||
data: { query }, | ||
osdUrlStateStorage, | ||
}, | ||
} = useOpenSearchDashboards<DataExplorerServices>(); | ||
const { pathname } = useLocation(); | ||
|
||
useEffect(() => { | ||
// syncs `_g` portion of url with query services | ||
const { stop } = syncQueryStateWithUrl(query, osdUrlStateStorage); | ||
|
||
return () => stop(); | ||
|
||
// this effect should re-run when pathname is changed to preserve querystring part, | ||
// so the global state is always preserved | ||
}, [query, osdUrlStateStorage, pathname]); | ||
|
||
return <AppContainer view={view} params={params} />; | ||
}; |
18 changes: 18 additions & 0 deletions
18
src/plugins/data_explorer/public/components/app_container.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
$osdHeaderOffset: $euiHeaderHeightCompensation; | ||
|
||
.deSidebar { | ||
max-width: 462px; | ||
min-width: 400px; | ||
} | ||
|
||
.deLayout { | ||
height: calc(100vh - #{$osdHeaderOffset}); | ||
|
||
&__canvas { | ||
height: 100%; | ||
} | ||
} | ||
|
||
.headerIsExpanded .deLayout { | ||
height: calc(100vh - #{$osdHeaderOffset * 2}); | ||
} |
45 changes: 45 additions & 0 deletions
45
src/plugins/data_explorer/public/components/app_container.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { AppContainer } from './app_container'; | ||
import { View } from '../services/view_service/view'; | ||
import { AppMountParameters } from '../../../../core/public'; | ||
import { render } from 'test_utils/testing_lib_helpers'; | ||
|
||
describe('DataExplorerApp', () => { | ||
const createView = () => { | ||
return new View({ | ||
id: 'test-view', | ||
title: 'Test View', | ||
defaultPath: '/test-path', | ||
appExtentions: {} as any, | ||
Canvas: (() => <div>canvas</div>) as any, | ||
Panel: (() => <div>panel</div>) as any, | ||
Context: (() => <div>Context</div>) as any, | ||
}); | ||
}; | ||
|
||
const params: AppMountParameters = { | ||
element: document.createElement('div'), | ||
history: {} as any, | ||
onAppLeave: jest.fn(), | ||
setHeaderActionMenu: jest.fn(), | ||
appBasePath: '', | ||
}; | ||
|
||
it('should render NoView when a non existent view is selected', () => { | ||
const { container } = render(<AppContainer params={params} />); | ||
|
||
expect(container).toContainHTML('View not found'); | ||
}); | ||
|
||
it('should render the canvas and panel when selected', () => { | ||
const view = createView(); | ||
const { container } = render(<AppContainer view={view} params={params} />); | ||
|
||
expect(container).toMatchSnapshot(); | ||
}); | ||
}); |
39 changes: 39 additions & 0 deletions
39
src/plugins/data_explorer/public/components/app_container.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { EuiPage, EuiPageBody } from '@elastic/eui'; | ||
import { Suspense } from 'react'; | ||
import { AppMountParameters } from '../../../../core/public'; | ||
import { Sidebar } from './sidebar'; | ||
import { NoView } from './no_view'; | ||
import { View } from '../services/view_service/view'; | ||
import './app_container.scss'; | ||
|
||
export const AppContainer = ({ view, params }: { view?: View; params: AppMountParameters }) => { | ||
// TODO: Make this more robust. | ||
if (!view) { | ||
return <NoView />; | ||
} | ||
|
||
const { Canvas, Panel, Context } = view; | ||
|
||
// Render the application DOM. | ||
return ( | ||
<EuiPage className="deLayout" paddingSize="none"> | ||
{/* TODO: improve fallback state */} | ||
<Suspense fallback={<div>Loading...</div>}> | ||
<Context {...params}> | ||
<Sidebar> | ||
<Panel {...params} /> | ||
</Sidebar> | ||
<EuiPageBody className="deLayout__canvas"> | ||
<Canvas {...params} /> | ||
</EuiPageBody> | ||
</Context> | ||
</Suspense> | ||
</EuiPage> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { EuiPageTemplate, EuiEmptyPrompt } from '@elastic/eui'; | ||
import { FormattedMessage } from '@osd/i18n/react'; | ||
|
||
export const NoView = () => { | ||
return ( | ||
<EuiPageTemplate | ||
template="centeredContent" | ||
className="dePageTemplate" | ||
pageContentProps={{ | ||
role: 'alertdialog', | ||
color: 'plain', | ||
hasBorder: false, | ||
}} | ||
> | ||
<EuiEmptyPrompt | ||
iconType="alert" | ||
iconColor="danger" | ||
title={ | ||
<h2> | ||
<FormattedMessage id="dataExplorer.noView.title" defaultMessage="View not found" /> | ||
</h2> | ||
} | ||
body={ | ||
<p> | ||
<FormattedMessage | ||
id="dataExplorer.noView.body" | ||
defaultMessage="The view you are trying to access does not exist. Please check the URL and try again." | ||
/> | ||
</p> | ||
} | ||
/> | ||
</EuiPageTemplate> | ||
); | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is this always true? irrespective of the branding assets being loaded?
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.
Yes this is the same calc i used for VisBuilder. This works because the height of the top nav is fixed.