forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Alerts] Create UI for alerting tabs navigation elastic#47754
- Loading branch information
1 parent
ac28c98
commit 001a3e8
Showing
16 changed files
with
509 additions
and
193 deletions.
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
112 changes: 112 additions & 0 deletions
112
x-pack/legacy/plugins/alerting_ui/np_ready/public/application/home.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,112 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React, { useEffect } from 'react'; | ||
import { Route, RouteComponentProps, Switch } from 'react-router-dom'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
import { EuiPageBody, EuiPageContent, EuiSpacer, EuiTab, EuiTabs } from '@elastic/eui'; | ||
import { BASE_PATH, Section } from '../../../np_ready/public/application/constants'; | ||
import { useAppDependencies } from './index'; | ||
import { breadcrumbService } from './lib/breadcrumb'; | ||
import { docTitleService } from './lib/doc_title'; | ||
|
||
import { ActionsList } from './sections/actions_list/components/actions_list'; | ||
import { AlertsList } from './sections/alerts_list/components/alerts_list'; | ||
|
||
interface MatchParams { | ||
section: Section; | ||
} | ||
|
||
export const AlertsUIHome: React.FunctionComponent<RouteComponentProps<MatchParams>> = ({ | ||
match: { | ||
params: { section }, | ||
}, | ||
history, | ||
}) => { | ||
const { | ||
core: { chrome }, | ||
} = useAppDependencies(); | ||
|
||
const notificationsUiEnabled = chrome.getIsVisible$(); | ||
|
||
const tabs: Array<{ | ||
id: Section; | ||
name: React.ReactNode; | ||
}> = [ | ||
{ | ||
id: 'alerts', | ||
name: ( | ||
<FormattedMessage id="xpack.alertingUI.home.snapshotsTabTitle" defaultMessage="Alerts" /> | ||
), | ||
}, | ||
{ | ||
id: 'actions', | ||
name: ( | ||
<FormattedMessage | ||
id="xpack.alertingUI.home.repositoriesTabTitle" | ||
defaultMessage="Actions" | ||
/> | ||
), | ||
}, | ||
{ | ||
id: 'activity_logs', | ||
name: ( | ||
<FormattedMessage | ||
id="xpack.alertingUI.home.restoreTabTitle" | ||
defaultMessage="Activity Log" | ||
/> | ||
), | ||
}, | ||
]; | ||
|
||
// Just example of Enable/Disable some UI tabs | ||
if (notificationsUiEnabled) { | ||
tabs.splice(2, 0, { | ||
id: 'notifications', | ||
name: ( | ||
<FormattedMessage id="xpack.alertingUI.home.policiesTabTitle" defaultMessage="Policies" /> | ||
), | ||
}); | ||
} | ||
|
||
const onSectionChange = (newSection: Section) => { | ||
history.push(`${BASE_PATH}/${newSection}`); | ||
}; | ||
|
||
// Set breadcrumb and page title | ||
useEffect(() => { | ||
breadcrumbService.setBreadcrumbs(section || 'home'); | ||
docTitleService.setTitle(section || 'home'); | ||
}, [section]); | ||
|
||
return ( | ||
<EuiPageBody> | ||
<EuiPageContent> | ||
<EuiTabs> | ||
{tabs.map(tab => ( | ||
<EuiTab | ||
onClick={() => onSectionChange(tab.id)} | ||
isSelected={tab.id === section} | ||
key={tab.id} | ||
data-test-subj="tab" | ||
> | ||
{tab.name} | ||
</EuiTab> | ||
))} | ||
</EuiTabs> | ||
|
||
<EuiSpacer size="s" /> | ||
|
||
<Switch> | ||
<Route exact path={`${BASE_PATH}/actions`} component={ActionsList} /> | ||
<Route exact path={`${BASE_PATH}/alerts`} component={AlertsList} /> | ||
<Route exact path={`${BASE_PATH}/notifications`} /> | ||
<Route exact path={`${BASE_PATH}/activitylog`} /> | ||
</Switch> | ||
</EuiPageContent> | ||
</EuiPageBody> | ||
); | ||
}; |
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
Oops, something went wrong.