Skip to content

Commit

Permalink
Merge branch 'main' into maximizing-serverless-coverage/explore/dashb…
Browse files Browse the repository at this point in the history
…oards
  • Loading branch information
MadameSheema authored Oct 13, 2023
2 parents da68c62 + 3f061a5 commit 40d9253
Show file tree
Hide file tree
Showing 15 changed files with 100 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@
* 2.0.
*/

import { ELASTIC_MODEL_DEFINITIONS } from '@kbn/ml-trained-models-utils';

import {
ElasticsearchResponseError,
isNotFoundException,
isResourceNotFoundException,
} from '../../utils/identify_exceptions';

export const acceptableModelNames = Object.keys(ELASTIC_MODEL_DEFINITIONS);

export function isNotFoundExceptionError(error: unknown): boolean {
return (
isResourceNotFoundException(error as ElasticsearchResponseError) ||
Expand All @@ -23,20 +19,3 @@ export function isNotFoundExceptionError(error: unknown): boolean {
error?.statusCode === 404
);
}

export function throwIfNotAcceptableModelName(modelName: string) {
if (!acceptableModelNames.includes(modelName)) {
const notFoundError: ElasticsearchResponseError = {
meta: {
body: {
error: {
type: 'resource_not_found_exception',
},
},
statusCode: 404,
},
name: 'ResponseError',
};
throw notFoundError;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ import { MlTrainedModels } from '@kbn/ml-plugin/server';
import { MlModelDeploymentStatus, MlModelDeploymentState } from '../../../common/types/ml';

import { getMlModelDeploymentStatus } from './get_ml_model_deployment_status';
import {
isNotFoundExceptionError,
throwIfNotAcceptableModelName,
} from './ml_model_deployment_common';
import { isNotFoundExceptionError } from './ml_model_deployment_common';

export const startMlModelDeployment = async (
modelName: string,
Expand All @@ -25,10 +22,6 @@ export const startMlModelDeployment = async (
throw new Error('Machine Learning is not enabled');
}

// before anything else, check our model name
// to ensure we only allow those names we want
throwIfNotAcceptableModelName(modelName);

try {
// try and get the deployment status of the model first
// and see if it's already deployed or deploying...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ import { MlTrainedModels } from '@kbn/ml-plugin/server';
import { MlModelDeploymentState, MlModelDeploymentStatus } from '../../../common/types/ml';

import { getMlModelDeploymentStatus } from './get_ml_model_deployment_status';
import {
isNotFoundExceptionError,
throwIfNotAcceptableModelName,
} from './ml_model_deployment_common';
import { isNotFoundExceptionError } from './ml_model_deployment_common';

export const startMlModelDownload = async (
modelName: string,
Expand All @@ -24,10 +21,6 @@ export const startMlModelDownload = async (
throw new Error('Machine Learning is not enabled');
}

// before anything else, check our model name
// to ensure we only allow those names we want
throwIfNotAcceptableModelName(modelName);

try {
// try and get the deployment status of the model first
// and see if it's already deployed or deploying...
Expand Down
6 changes: 3 additions & 3 deletions x-pack/plugins/observability/public/application/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ import { Router, Routes, Route } from '@kbn/shared-ux-router';
import { AppMountParameters, APP_WRAPPER_CLASS, CoreStart } from '@kbn/core/public';
import { EuiThemeProvider } from '@kbn/kibana-react-plugin/common';
import type { LazyObservabilityPageTemplateProps } from '@kbn/observability-shared-plugin/public';
import { KibanaContextProvider, RedirectAppLinks } from '@kbn/kibana-react-plugin/public';
import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public';
import { KibanaThemeProvider } from '@kbn/react-kibana-context-theme';
import { RedirectAppLinks } from '@kbn/shared-ux-link-redirect-app';
import { Storage } from '@kbn/kibana-utils-plugin/public';
import { UsageCollectionSetup } from '@kbn/usage-collection-plugin/public';
import { ObservabilityAIAssistantProvider } from '@kbn/observability-ai-assistant-plugin/public';
Expand Down Expand Up @@ -111,8 +112,7 @@ export const renderApp = ({
<EuiThemeProvider darkMode={isDarkMode}>
<i18nCore.Context>
<RedirectAppLinks
application={core.application}
className={APP_WRAPPER_CLASS}
coreStart={core}
data-test-subj="observabilityMainContainer"
>
<QueryClientProvider client={queryClient}>
Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/observability/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@
"@kbn/deeplinks-observability",
"@kbn/core-application-common",
"@kbn/react-kibana-mount",
"@kbn/react-kibana-context-theme"
"@kbn/react-kibana-context-theme",
"@kbn/shared-ux-link-redirect-app"
],
"exclude": [
"target/**/*"
Expand Down
27 changes: 10 additions & 17 deletions x-pack/plugins/observability_onboarding/public/application/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { Router, Routes, Route } from '@kbn/shared-ux-router';
import { euiDarkVars, euiLightVars } from '@kbn/ui-theme';
import React from 'react';
import ReactDOM from 'react-dom';
import { RouteComponentProps, RouteProps } from 'react-router-dom';
import { ConfigSchema } from '..';
import { customLogsRoutes } from '../components/app/custom_logs';
import { systemLogsRoutes } from '../components/app/system_logs';
Expand All @@ -37,16 +36,6 @@ import { baseRoutes, routes } from '../routes';
import { CustomLogs } from '../routes/templates/custom_logs';
import { SystemLogs } from '../routes/templates/system_logs';

export type BreadcrumbTitle<
T extends { [K in keyof T]?: string | undefined } = {}
> = string | ((props: RouteComponentProps<T>) => string) | null;

export interface RouteDefinition<
T extends { [K in keyof T]?: string | undefined } = any
> extends RouteProps {
breadcrumb: BreadcrumbTitle<T>;
}

export const onBoardingTitle = i18n.translate(
'xpack.observability_onboarding.breadcrumbs.onboarding',
{
Expand Down Expand Up @@ -157,6 +146,8 @@ export function ObservabilityOnboardingAppRoot({
const i18nCore = core.i18n;
const plugins = { ...deps };

const renderFeedbackLinkAsPortal = !config.serverless.enabled;

return (
<RedirectAppLinks
className={APP_WRAPPER_CLASS}
Expand All @@ -183,12 +174,14 @@ export function ObservabilityOnboardingAppRoot({
<i18nCore.Context>
<Router history={history}>
<EuiErrorBoundary>
<HeaderMenuPortal
setHeaderActionMenu={setHeaderActionMenu}
theme$={theme$}
>
<ObservabilityOnboardingHeaderActionMenu />
</HeaderMenuPortal>
{renderFeedbackLinkAsPortal && (
<HeaderMenuPortal
setHeaderActionMenu={setHeaderActionMenu}
theme$={theme$}
>
<ObservabilityOnboardingHeaderActionMenu />
</HeaderMenuPortal>
)}
<ObservabilityOnboardingApp />
</EuiErrorBoundary>
</Router>
Expand Down
9 changes: 9 additions & 0 deletions x-pack/plugins/observability_onboarding/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import type { ObservabilityOnboardingConfig } from '../server';
import { PLUGIN_ID } from '../common';
import { ObservabilityOnboardingLocatorDefinition } from './locators/onboarding_locator/locator_definition';
import { ObservabilityOnboardingPluginLocators } from './locators';
import { ConfigSchema } from '.';

export type ObservabilityOnboardingPluginSetup = void;
export type ObservabilityOnboardingPluginStart = void;
Expand All @@ -44,6 +45,14 @@ export interface ObservabilityOnboardingPluginStartDeps {
observability: ObservabilityPublicStart;
}

export interface ObservabilityOnboardingPluginContextValue {
core: CoreStart;
plugins: ObservabilityOnboardingPluginSetupDeps;
data: DataPublicPluginStart;
observability: ObservabilityPublicStart;
config: ConfigSchema;
}

export class ObservabilityOnboardingPlugin
implements
Plugin<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ import { EuiFlexGroup, EuiFlexItem, EuiSpacer, EuiTitle } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { useBreadcrumbs } from '@kbn/observability-shared-plugin/public';
import React, { ComponentType, useRef, useState } from 'react';
import { useKibana } from '@kbn/kibana-react-plugin/public';
import { ObservabilityOnboardingPluginContextValue } from '../../plugin';
import { breadcrumbsApp } from '../../application/app';
import { Provider as WizardProvider } from '../../components/app/custom_logs';
import {
FilmstripFrame,
FilmstripTransition,
TransitionState,
} from '../../components/shared/filmstrip_transition';
import { ObservabilityOnboardingHeaderActionMenu } from '../../components/app/header_action_menu';

interface Props {
children: React.ReactNode;
Expand Down Expand Up @@ -43,6 +46,12 @@ function AnimatedTransitionsWizard({ children }: Props) {
const [title, setTitle] = useState<string>();
const TransitionComponent = useRef<ComponentType>(() => null);

const {
services: { config },
} = useKibana<ObservabilityOnboardingPluginContextValue>();

const isServerless = config.serverless.enabled;

function onChangeStep({
direction,
stepTitle,
Expand All @@ -68,21 +77,33 @@ function AnimatedTransitionsWizard({ children }: Props) {
<EuiFlexGroup direction="column" alignItems="center">
<EuiFlexItem grow={false}>
<EuiSpacer size="l" />
<EuiTitle
size="l"
data-test-subj="obltOnboardingStreamLogFilePageHeader"
>
<h1>
{title
? title
: i18n.translate(
'xpack.observability_onboarding.title.collectCustomLogs',
{
defaultMessage: 'Stream log files to Elastic',
}
)}
</h1>
</EuiTitle>
<EuiFlexGroup direction="row">
<EuiFlexItem grow={false}>
<EuiTitle
size="l"
data-test-subj="obltOnboardingStreamLogFilePageHeader"
>
<h1>
{title
? title
: i18n.translate(
'xpack.observability_onboarding.title.collectCustomLogs',
{
defaultMessage: 'Stream log files to Elastic',
}
)}
</h1>
</EuiTitle>
</EuiFlexItem>
{isServerless && (
<EuiFlexItem
grow={false}
css={{ position: 'absolute', right: 10 }}
>
<ObservabilityOnboardingHeaderActionMenu />
</EuiFlexItem>
)}
</EuiFlexGroup>
</EuiFlexItem>
<EuiFlexItem grow={1} style={{ width: '50%' }}>
<FilmstripTransition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ import { EuiFlexGroup, EuiFlexItem, EuiSpacer, EuiTitle } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { useBreadcrumbs } from '@kbn/observability-shared-plugin/public';
import React from 'react';
import { useKibana } from '@kbn/kibana-react-plugin/public';
import { breadcrumbsApp } from '../../application/app';
import { Provider as WizardProvider } from '../../components/app/system_logs';
import { ObservabilityOnboardingHeaderActionMenu } from '../../components/app/header_action_menu';
import { ObservabilityOnboardingPluginContextValue } from '../../plugin';

interface Props {
children: React.ReactNode;
Expand All @@ -28,22 +31,40 @@ export function SystemLogs({ children }: Props) {
],
breadcrumbsApp
);

const {
services: { config },
} = useKibana<ObservabilityOnboardingPluginContextValue>();

const isServerless = config.serverless.enabled;
return (
<WizardProvider>
<EuiFlexGroup direction="column" alignItems="center">
<EuiFlexItem grow={false}>
<EuiSpacer size="l" />
<EuiTitle
size="l"
data-test-subj="obltOnboardingSystemLogsFilePageHeader"
>
<h1>
{i18n.translate(
'xpack.observability_onboarding.title.collectSystemLogs',
{ defaultMessage: 'Install shipper to collect system logs' }
)}
</h1>
</EuiTitle>
<EuiFlexGroup direction="row">
<EuiFlexItem grow={false}>
<EuiTitle
size="l"
data-test-subj="obltOnboardingSystemLogsFilePageHeader"
>
<h1>
{i18n.translate(
'xpack.observability_onboarding.title.collectSystemLogs',
{ defaultMessage: 'Install shipper to collect system logs' }
)}
</h1>
</EuiTitle>
</EuiFlexItem>
{isServerless && (
<EuiFlexItem
grow={false}
css={{ position: 'absolute', right: 10 }}
>
<ObservabilityOnboardingHeaderActionMenu />
</EuiFlexItem>
)}
</EuiFlexGroup>
</EuiFlexItem>
<EuiFlexItem grow={1} style={{ width: '50%' }}>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ export default createTestConfig({

// include settings from project controller
// https://github.com/elastic/project-controller/blob/main/internal/project/esproject/config/elasticsearch.yml
esServerArgs: ['xpack.ml.ad.enabled=false', 'xpack.ml.dfa.enabled=false'],
esServerArgs: [],
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ export default createTestConfig({

// include settings from project controller
// https://github.com/elastic/project-controller/blob/main/internal/project/esproject/config/elasticsearch.yml
esServerArgs: ['xpack.ml.ad.enabled=false', 'xpack.ml.dfa.enabled=false'],
esServerArgs: [],
});
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ export default createTestConfig({

// include settings from project controller
// https://github.com/elastic/project-controller/blob/main/internal/project/esproject/config/elasticsearch.yml
esServerArgs: ['xpack.ml.ad.enabled=false', 'xpack.ml.dfa.enabled=false'],
esServerArgs: [],
});
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ export default createTestConfig({

// include settings from project controller
// https://github.com/elastic/project-controller/blob/main/internal/project/esproject/config/elasticsearch.yml
esServerArgs: ['xpack.ml.ad.enabled=false', 'xpack.ml.dfa.enabled=false'],
esServerArgs: [],
});
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ export default createTestConfig({

// include settings from project controller
// https://github.com/elastic/project-controller/blob/main/internal/project/esproject/config/elasticsearch.yml
esServerArgs: ['xpack.ml.ad.enabled=false', 'xpack.ml.dfa.enabled=false'],
esServerArgs: [],
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ export default createTestConfig({

// include settings from project controller
// https://github.com/elastic/project-controller/blob/main/internal/project/esproject/config/elasticsearch.yml
esServerArgs: ['xpack.ml.ad.enabled=false', 'xpack.ml.dfa.enabled=false'],
esServerArgs: [],
});

0 comments on commit 40d9253

Please sign in to comment.