-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…45517) * Add main nav tabs with sub tabs for new nav * move transforms to top level main nav * Make top nav normal font weight * Update breadcrumbs to take top nav into account * proper spacing when settings selected * fix localization error * Fix functional tests. Update breadcrumbs * revert analytics breadcrumb update. save for follow up * ensure main/sub tabs align left * update dataVisualizer breadcrumbs * update typescript for tabs
- Loading branch information
1 parent
a60b6a0
commit af52ef0
Showing
15 changed files
with
298 additions
and
106 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
17 changes: 17 additions & 0 deletions
17
x-pack/legacy/plugins/ml/public/components/navigation_menu/_navigation_menu.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 |
---|---|---|
@@ -1,7 +1,24 @@ | ||
.mlNavigationMenu__tab { | ||
padding-bottom: 0; | ||
padding-left: 0px; | ||
padding-right: 0px; | ||
margin-left: $euiSizeM; | ||
} | ||
|
||
.mlNavigationMenu__mainTab { | ||
margin-left: $euiSizeM; | ||
padding-bottom: 0; | ||
font-weight: normal; | ||
} | ||
|
||
.mlNavigationMenu__topNav { | ||
padding-top: $euiSizeS; | ||
} | ||
|
||
.mlNavHorizontalRule { | ||
margin: $euiSizeM 0 0 0; | ||
} | ||
|
||
.mlSubTabs { | ||
margin-top: $euiSizeS; | ||
} |
110 changes: 110 additions & 0 deletions
110
x-pack/legacy/plugins/ml/public/components/navigation_menu/main_tabs.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,110 @@ | ||
/* | ||
* 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, { FC, useState } from 'react'; | ||
import { EuiTabs, EuiTab, EuiLink } from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
import chrome from 'ui/chrome'; | ||
import { TabId } from './navigation_menu'; | ||
|
||
export interface Tab { | ||
id: TabId; | ||
name: any; | ||
disabled: boolean; | ||
} | ||
|
||
interface Props { | ||
disableLinks: boolean; | ||
tabId: TabId; | ||
} | ||
|
||
function getTabs(disableLinks: boolean): Tab[] { | ||
return [ | ||
// { | ||
// id: 'overview', | ||
// name: i18n.translate('xpack.ml.navMenu.overviewTabLinkText', { | ||
// defaultMessage: 'Overview', | ||
// }), | ||
// disabled: disableLinks, | ||
// }, | ||
{ | ||
id: 'anomaly_detection', | ||
name: i18n.translate('xpack.ml.navMenu.anomalyDetectionTabLinkText', { | ||
defaultMessage: 'Anomaly Detection', | ||
}), | ||
disabled: disableLinks, | ||
}, | ||
{ | ||
id: 'data_frames', | ||
name: i18n.translate('xpack.ml.navMenu.dataFrameTabLinkText', { | ||
defaultMessage: 'Transforms', | ||
}), | ||
disabled: false, | ||
}, | ||
{ | ||
id: 'data_frame_analytics', | ||
name: i18n.translate('xpack.ml.navMenu.dataFrameAnalyticsTabLinkText', { | ||
defaultMessage: 'Data Frame Analytics', | ||
}), | ||
disabled: disableLinks, | ||
}, | ||
{ | ||
id: 'datavisualizer', | ||
name: i18n.translate('xpack.ml.navMenu.dataVisualizerTabLinkText', { | ||
defaultMessage: 'Data Visualizer', | ||
}), | ||
disabled: false, | ||
}, | ||
]; | ||
} | ||
interface TabData { | ||
testSubject: string; | ||
pathId?: string; | ||
} | ||
|
||
const TAB_DATA: Record<TabId, TabData> = { | ||
// overview: { testSubject: 'mlTabOverview', pathId: 'overview' }, | ||
anomaly_detection: { testSubject: 'mlTabAnomalyDetection', pathId: 'jobs' }, | ||
data_frames: { testSubject: 'mlTabDataFrames' }, | ||
data_frame_analytics: { testSubject: 'mlTabDataFrameAnalytics' }, | ||
datavisualizer: { testSubject: 'mlTabDataVisualizer' }, | ||
}; | ||
|
||
export const MainTabs: FC<Props> = ({ tabId, disableLinks }) => { | ||
const [selectedTabId, setSelectedTabId] = useState(tabId); | ||
function onSelectedTabChanged(id: string) { | ||
setSelectedTabId(id); | ||
} | ||
|
||
const tabs = getTabs(disableLinks); | ||
|
||
return ( | ||
<EuiTabs display="condensed"> | ||
{tabs.map((tab: Tab) => { | ||
const id = tab.id; | ||
const testSubject = TAB_DATA[id].testSubject; | ||
const defaultPathId = TAB_DATA[id].pathId || id; | ||
return ( | ||
<EuiLink | ||
data-test-subj={testSubject} | ||
href={`${chrome.getBasePath()}/app/ml#/${defaultPathId}`} | ||
key={`${id}-key`} | ||
color="text" | ||
> | ||
<EuiTab | ||
className={'mlNavigationMenu__mainTab'} | ||
onClick={() => onSelectedTabChanged(id)} | ||
isSelected={id === selectedTabId} | ||
disabled={tab.disabled} | ||
> | ||
{tab.name} | ||
</EuiTab> | ||
</EuiLink> | ||
); | ||
})} | ||
</EuiTabs> | ||
); | ||
}; |
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
Oops, something went wrong.