-
Notifications
You must be signed in to change notification settings - Fork 913
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
Point in time management plugin and empty state #2813
Changes from all commits
4f769c1
5b05bb6
781f1c8
0ddff6c
6435ae0
945fb91
4c38722
101d835
ae3f9d9
efef739
767cb08
4ae722b
da80d55
d0a298e
c48890f
9b8ddf3
959b9cf
5c3d681
3a950f6
6a9193d
669b884
58cb95b
0301add
66afda2
6a0808a
b3a7d74
c632394
34d3d59
87f07b3
d7b9ca3
774d548
0bcafc1
8adba2c
c273e20
0bade4b
e9faa5b
a6ba2f7
0742011
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"id": "pit", | ||
"version": "1.0.0", | ||
"opensearchDashboardsVersion": "opensearchDashboards", | ||
"server": true, | ||
"ui": true, | ||
"requiredPlugins": ["navigation", "management"], | ||
"optionalPlugins": [], | ||
"requiredBundles": ["opensearchDashboardsReact"] | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { EmptyState } from './empty_state'; | ||
import { shallow } from 'enzyme'; | ||
|
||
describe('EmptyState', () => { | ||
it('should render normally', () => { | ||
const component = shallow(<EmptyState />); | ||
|
||
expect(component).toMatchSnapshot(); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { FormattedMessage } from '@osd/i18n/react'; | ||
import { | ||
EuiPageContentHeader, | ||
EuiPageContentHeaderSection, | ||
EuiTitle, | ||
EuiPageContent, | ||
EuiSpacer, | ||
EuiText, | ||
EuiPageContentBody, | ||
EuiFlexItem, | ||
EuiFlexGroup, | ||
EuiButton, | ||
} from '@elastic/eui'; | ||
|
||
export const EmptyState = () => { | ||
return ( | ||
<> | ||
<EuiPageContent | ||
className="pitEmptyState" | ||
grow={false} | ||
style={{ minHeight: '70vh' }} | ||
horizontalPosition="center" | ||
data-test-subj="pointInTimeEmptyState" | ||
> | ||
<EuiPageContentHeader> | ||
<EuiPageContentHeaderSection> | ||
<EuiTitle> | ||
<h1> | ||
<FormattedMessage | ||
id="pointInTimeManagement.header.pointInTimeTitle" | ||
defaultMessage="Point in Time" | ||
/> | ||
</h1> | ||
</EuiTitle> | ||
</EuiPageContentHeaderSection> | ||
<EuiButton fill={true} iconType="plusInCircle" data-test-subj="createPITBtnInHeader"> | ||
<FormattedMessage | ||
id="pointInTimeManagement.header.createPointInTimeButton" | ||
defaultMessage="Create point in time" | ||
/> | ||
</EuiButton> | ||
</EuiPageContentHeader> | ||
<EuiText size="s"> | ||
<p> | ||
<FormattedMessage | ||
id="pointInTimeManagement.pointInTimeDescription" | ||
defaultMessage="Create and manage point in time objects to help you retrieve data from OpenSearch." | ||
/> | ||
</p> | ||
</EuiText> | ||
<EuiSpacer size="m" /> | ||
<EuiPageContentBody> | ||
<EuiFlexGroup | ||
style={{ minHeight: '50vh' }} | ||
alignItems="center" | ||
justifyContent="center" | ||
direction="column" | ||
> | ||
<EuiFlexItem grow={false}>No point in time objects have been created yet.</EuiFlexItem> | ||
<EuiSpacer /> | ||
<EuiButton data-test-subj="createPITBtnInBody"> | ||
<FormattedMessage | ||
id="pointInTimeManagement.createPointInTimeButton" | ||
defaultMessage="Create point in time" | ||
/> | ||
</EuiButton> | ||
</EuiFlexGroup> | ||
</EuiPageContentBody> | ||
</EuiPageContent> | ||
</> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
export { EmptyState } from './empty_state'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
export { EmptyState } from './empty_state'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { PointInTimeManagementPlugin } from './plugin'; | ||
|
||
export function plugin() { | ||
return new PointInTimeManagementPlugin(); | ||
} | ||
|
||
export { PointInTimeManagementPluginSetup, PointInTimeManagementPluginStart } from './types'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
export { mountManagementSection } from './mount_management_section'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import { I18nProvider } from '@osd/i18n/react'; | ||
import { ManagementAppMountParams } from '../../../management/public'; | ||
import { PointInTimeManagementStartDependencies } from '../plugin'; | ||
import { StartServicesAccessor } from '../../../../core/public'; | ||
import { PointInTimeManagementContext } from '../types'; | ||
import { OpenSearchDashboardsContextProvider } from '../../../opensearch_dashboards_react/public'; | ||
import { EmptyState } from '../components'; | ||
|
||
export async function mountManagementSection( | ||
getStartServices: StartServicesAccessor<PointInTimeManagementStartDependencies>, | ||
params: ManagementAppMountParams | ||
) { | ||
const [{ chrome, application }] = await getStartServices(); | ||
const deps: PointInTimeManagementContext = { | ||
chrome, | ||
application, | ||
}; | ||
ReactDOM.render( | ||
<OpenSearchDashboardsContextProvider services={deps}> | ||
<I18nProvider> | ||
<EmptyState /> | ||
</I18nProvider> | ||
</OpenSearchDashboardsContextProvider>, | ||
params.element | ||
); | ||
|
||
return () => { | ||
chrome.docTitle.reset(); | ||
ReactDOM.unmountComponentAtNode(params.element); | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { i18n } from '@osd/i18n'; | ||
import { CoreSetup, CoreStart, Plugin } from '../../../core/public'; | ||
import { PointInTimeManagementPluginSetup, PointInTimeManagementPluginStart } from './types'; | ||
import { ManagementSetup } from '../../management/public'; | ||
|
||
export interface PointInTimeManagementSetupDependencies { | ||
management: ManagementSetup; | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface PointInTimeManagementStartDependencies {} | ||
|
||
const sectionsHeader = i18n.translate('pointInTimeManagement.pointInTime.sectionsHeader', { | ||
defaultMessage: 'Point In Time', | ||
}); | ||
|
||
const PITM_APP_ID = 'pointInTime'; | ||
|
||
export class PointInTimeManagementPlugin | ||
implements | ||
Plugin< | ||
PointInTimeManagementPluginSetup, | ||
PointInTimeManagementPluginStart, | ||
PointInTimeManagementSetupDependencies, | ||
PointInTimeManagementStartDependencies | ||
> { | ||
public setup( | ||
core: CoreSetup<PointInTimeManagementStartDependencies, PointInTimeManagementPluginStart>, | ||
{ management }: PointInTimeManagementSetupDependencies | ||
): PointInTimeManagementPluginSetup { | ||
const opensearchDashboardsSection = management.sections.section.opensearchDashboards; | ||
|
||
if (!opensearchDashboardsSection) { | ||
throw new Error('`opensearchDashboards` management section not found.'); | ||
} | ||
|
||
opensearchDashboardsSection.registerApp({ | ||
id: PITM_APP_ID, | ||
title: sectionsHeader, | ||
order: 1, | ||
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. how come? 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. My understanding is |
||
mount: async (mountParams) => { | ||
const { mountManagementSection } = await import('./management_app'); | ||
return mountManagementSection(core.getStartServices, mountParams); | ||
}, | ||
}); | ||
|
||
return {}; | ||
} | ||
|
||
public start(core: CoreStart): PointInTimeManagementPluginStart { | ||
return {}; | ||
} | ||
|
||
public stop() {} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { ApplicationStart, ChromeStart } from 'opensearch-dashboards/public'; | ||
import { NavigationPublicPluginStart } from '../../navigation/public'; | ||
import { ManagementSetup } from '../../management/public'; | ||
|
||
export interface PointInTimeManagementContext { | ||
chrome: ChromeStart; | ||
application: ApplicationStart; | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface PointInTimeManagementPluginSetup {} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface PointInTimeManagementPluginStart {} | ||
|
||
export interface AppPluginStartDependencies { | ||
navigation: NavigationPublicPluginStart; | ||
} | ||
|
||
export interface SetupDependencies { | ||
management: ManagementSetup; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { schema } from '@osd/config-schema'; | ||
import { PluginInitializerContext } from '../../../core/server'; | ||
import { PointInTimeManagementPlugin } from './plugin'; | ||
|
||
export const config = { | ||
schema: schema.object({ enabled: schema.boolean({ defaultValue: false }) }), | ||
}; | ||
|
||
// This exports static code and TypeScript types, | ||
// as well as the OpenSearch Dashboards Platform `plugin()` initializer. | ||
|
||
export function plugin(initializerContext: PluginInitializerContext) { | ||
return new PointInTimeManagementPlugin(initializerContext); | ||
} | ||
|
||
export { PointInTimeManagementPluginSetup, PointInTimeManagementPluginStart } from './types'; |
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 - these style overrides should be moved to a matching
.scss
file. But why do we need to explicitly setminHeights
at all? My hunch is that the OUI components can be configured to handle this situation without style overrides.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.
This is mainly for adding vertical space in the content body. Should I be using multiple
EuiSpacer
instead?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.
No, I don't think that should be necessary either. If you open a follow-up issue, the dashboards team can help provide a solution here without blocking this PR. But it would be better to remove the style for now so that we remember that it's a fix we need to make.