Skip to content

Commit

Permalink
Merge branch 'main' into elasticsearch-integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Vadim Yakhin authored Mar 24, 2022
2 parents ab0e65b + 83117a4 commit 2003a01
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
*/

export { SolutionToolbar } from './solution_toolbar';
/** @deprecated QuickButtonGroup - use `IconButtonGroup` from `@kbn/shared-ux-components */
export * from './items';
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export { SolutionToolbarButton } from './button';
export { SolutionToolbarPopover } from './popover';
export { AddFromLibraryButton } from './add_from_library';
export type { QuickButtonProps } from './quick_group';
/** @deprecated use `IconButtonGroup` from `@kbn/shared-ux-components */
export { QuickButtonGroup } from './quick_group';
export { PrimaryActionButton } from './primary_button';
export { PrimaryActionPopover } from './primary_popover';
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { EuiContextMenu } from '@elastic/eui';

import { SolutionToolbar } from './solution_toolbar';
import { SolutionToolbarPopover } from './items';

import { AddFromLibraryButton, PrimaryActionButton, QuickButtonGroup } from './items';

const quickButtons = [
Expand Down
1 change: 1 addition & 0 deletions src/plugins/presentation_util/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export {
AddFromLibraryButton,
PrimaryActionButton,
PrimaryActionPopover,
/** @deprecated QuickButtonGroup - use `IconButtonGroup` from `@kbn/shared-ux-components */
QuickButtonGroup,
SolutionToolbar,
SolutionToolbarButton,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import PropTypes from 'prop-types';
import { Shortcuts } from 'react-shortcuts';
import { EuiFlexItem, EuiFlexGroup, EuiButtonIcon, EuiToolTip } from '@elastic/eui';
import { i18n } from '@kbn/i18n';

import {
AddFromLibraryButton,
QuickButtonGroup,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { useMlKibana, useMlApiContext } from '../../../contexts/kibana';
import { MlPageHeader } from '../../../components/page_header';
import { AnalyticsIdSelector, AnalyticsSelectorIds } from '../components/analytics_selector';
import { AnalyticsEmptyPrompt } from '../analytics_management/components/empty_prompt';
import { useUrlState } from '../../../util/url_state';

export const Page: FC<{
jobId: string;
Expand All @@ -37,6 +38,8 @@ export const Page: FC<{
const jobIdToUse = jobId ?? analyticsId?.job_id;
const analysisTypeToUse = analysisType || analyticsId?.analysis_type;

const [, setGlobalState] = useUrlState('_g');

const checkJobsExist = async () => {
try {
const { count } = await getDataFrameAnalytics(undefined, undefined, 0);
Expand All @@ -51,6 +54,20 @@ export const Page: FC<{
checkJobsExist();
}, []);

useEffect(
function updateUrl() {
if (analyticsId !== undefined) {
setGlobalState({
ml: {
...(analyticsId.analysis_type ? { analysisType: analyticsId.analysis_type } : {}),
...(analyticsId.job_id ? { jobId: analyticsId.job_id } : {}),
},
});
}
},
[analyticsId?.job_id, analyticsId?.model_id]
);

const getEmptyState = () => {
if (jobsExist === false) {
return <AnalyticsEmptyPrompt />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,13 @@ export function AnalyticsIdSelector({ setAnalyticsId, jobsOnly = false }: Props)

const selectionValue = {
selectable: (item: TableItem) => {
const selectedId = selected?.job_id ?? selected?.model_id;
const isDFA = isDataFrameAnalyticsConfigs(item);
const itemId = isDFA ? item.id : item.model_id;
const isBuiltInModel = isDFA ? false : item.tags.includes(BUILT_IN_MODEL_TAG);
return (selected === undefined || selectedId === itemId) && !isBuiltInModel;
return (
(selected === undefined || selected?.job_id === itemId || selected?.model_id === itemId) &&
!isBuiltInModel
);
},
onSelectionChange: (selectedItem: TableItem[]) => {
const item = selectedItem[0];
Expand All @@ -208,7 +210,7 @@ export function AnalyticsIdSelector({ setAnalyticsId, jobsOnly = false }: Props)

setSelected({
model_id: isDFA ? undefined : item.model_id,
job_id: isDFA ? item.id : undefined,
job_id: isDFA ? item.id : item.metadata?.analytics_config.id,
analysis_type: analysisType,
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { AnalyticsIdSelector, AnalyticsSelectorIds } from '../components/analyti
import { AnalyticsEmptyPrompt } from '../analytics_management/components/empty_prompt';

export const Page: FC = () => {
const [globalState] = useUrlState('_g');
const [globalState, setGlobalState] = useUrlState('_g');
const [isLoading, setIsLoading] = useState(false);
const [jobsExist, setJobsExist] = useState(true);
const { refresh } = useRefreshAnalyticsList({ isLoading: setIsLoading });
Expand Down Expand Up @@ -51,6 +51,20 @@ export const Page: FC = () => {
checkJobsExist();
}, []);

useEffect(
function updateUrl() {
if (analyticsId !== undefined) {
setGlobalState({
ml: {
...(analyticsId.job_id && !analyticsId.model_id ? { jobId: analyticsId.job_id } : {}),
...(analyticsId.model_id ? { modelId: analyticsId.model_id } : {}),
},
});
}
},
[analyticsId?.job_id, analyticsId?.model_id]
);

const getEmptyState = () => {
if (jobsExist === false) {
return <AnalyticsEmptyPrompt />;
Expand Down

0 comments on commit 2003a01

Please sign in to comment.