[Transform] Hide node information and callout banner in serverless (#165886)

## Summary

Part of https://github.com/elastic/ml-team/issues/1019. This PR removes
references to "nodes" in the UI.

- Nodes: # of nodes are removed in the bar stats
- Callout warning are removed
- Node column in Message are removed
- Nodes.name in Details tab are removed

Before

<img width="1382" alt="Screen Shot 2023-09-06 at 11 29 13"
src="4bc2f97a-db3a-4bdc-b9c3-c9530e68eafd">


![image](69c2439b-255b-4177-8d99-aa5723c45647)

![image](5e4ace68-5df0-4d38-bf53-9eb9d4c83358)

After
<img width="1355" alt="Screen Shot 2023-09-06 at 11 50 31"
src="d5ce59de-87af-45ad-9186-d6cbdf300366">


### Checklist

Delete any items that are not applicable to this PR.

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [ ] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)


### Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to
identify risks that should be tested prior to the change/feature
release.

When forming the risk matrix, consider some of the following examples
and how they may potentially impact the change:

| Risk | Probability | Severity | Mitigation/Notes |

|---------------------------|-------------|----------|-------------------------|
| Multiple Spaces&mdash;unexpected behavior in non-default Kibana Space.
| Low | High | Integration tests will verify that all features are still
supported in non-default Kibana Space and when user switches between
spaces. |
| Multiple nodes&mdash;Elasticsearch polling might have race conditions
when multiple Kibana nodes are polling for the same tasks. | High | Low
| Tasks are idempotent, so executing them multiple times will not result
in logical error, but will degrade performance. To test for this case we
add plenty of unit tests around this logic and document manual testing
procedure. |
| Code should gracefully handle cases when feature X or plugin Y are
disabled. | Medium | High | Unit tests will verify that any feature flag
or plugin combination still results in our service operational. |
| [See more potential risk
examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) |


### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Quynh Nguyen (Quinn) 2023-09-08 12:25:26 -05:00 committed by GitHub
parent a8dc12981e
commit b5966246e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 115 additions and 41 deletions

View file

@ -20,6 +20,7 @@ import { AppDependencies } from './app_dependencies';
import { CloneTransformSection } from './sections/clone_transform';
import { CreateTransformSection } from './sections/create_transform';
import { TransformManagementSection } from './sections/transform_management';
import { ServerlessContextProvider } from './serverless_context';
export const App: FC<{ history: ScopedHistory }> = ({ history }) => (
<Router history={history}>
@ -37,7 +38,11 @@ export const App: FC<{ history: ScopedHistory }> = ({ history }) => (
</Router>
);
export const renderApp = (element: HTMLElement, appDependencies: AppDependencies) => {
export const renderApp = (
element: HTMLElement,
appDependencies: AppDependencies,
isServerless: boolean
) => {
const I18nContext = appDependencies.i18n.Context;
const queryClient = new QueryClient({
@ -55,7 +60,9 @@ export const renderApp = (element: HTMLElement, appDependencies: AppDependencies
<KibanaThemeProvider theme$={appDependencies.theme.theme$}>
<KibanaContextProvider services={appDependencies}>
<I18nContext>
<App history={appDependencies.history} />
<ServerlessContextProvider isServerless={isServerless}>
<App history={appDependencies.history} />
</ServerlessContextProvider>
</I18nContext>
</KibanaContextProvider>
</KibanaThemeProvider>

View file

@ -18,7 +18,7 @@ import {
import { useAppDependencies } from '../app_dependencies';
export const useGetTransformNodes = () => {
export const useGetTransformNodes = ({ enabled } = { enabled: true }) => {
const { http } = useAppDependencies();
return useQuery<number, IHttpFetchError>(
@ -36,6 +36,7 @@ export const useGetTransformNodes = () => {
},
{
refetchInterval: DEFAULT_REFRESH_INTERVAL_MS,
enabled,
}
);
};

View file

@ -22,7 +22,8 @@ const localStorage = new Storage(window.localStorage);
export async function mountManagementSection(
coreSetup: CoreSetup<PluginsDependencies>,
params: ManagementAppMountParams
params: ManagementAppMountParams,
isServerless: boolean
) {
const { element, setBreadcrumbs, history } = params;
const { http, getStartServices } = coreSetup;
@ -92,7 +93,7 @@ export async function mountManagementSection(
contentManagement,
};
const unmountAppCallback = renderApp(element, appDependencies);
const unmountAppCallback = renderApp(element, appDependencies, isServerless);
return () => {
docTitle.reset();

View file

@ -5,7 +5,7 @@
* 2.0.
*/
import React, { type FC } from 'react';
import React, { useMemo, type FC } from 'react';
import { Stat, StatsBarStat } from './stat';
@ -18,10 +18,10 @@ export interface TransformStatsBarStats extends Stats {
batch: StatsBarStat;
continuous: StatsBarStat;
started: StatsBarStat;
nodes?: StatsBarStat;
}
type StatsBarStats = TransformStatsBarStats;
type StatsKey = keyof StatsBarStats;
interface StatsBarProps {
stats: StatsBarStats;
@ -29,7 +29,8 @@ interface StatsBarProps {
}
export const StatsBar: FC<StatsBarProps> = ({ stats, dataTestSub }) => {
const statsList = Object.keys(stats).map((k) => stats[k as StatsKey]);
const statsList = useMemo(() => Object.values(stats), [stats]);
return (
<div className="transformStatsBar" data-test-subj={dataTestSub}>
{statsList

View file

@ -17,6 +17,7 @@ import { formatHumanReadableDateTimeSeconds } from '@kbn/ml-date-utils';
import { stringHash } from '@kbn/ml-string-hash';
import { isDefined } from '@kbn/ml-is-defined';
import { useIsServerless } from '../../../../serverless_context';
import { TransformHealthAlertRule } from '../../../../../../common/types/alerting';
import { TransformListRow } from '../../../../common';
@ -46,6 +47,8 @@ interface Props {
type StateValues = Optional<TransformListRow['stats'], 'stats' | 'checkpointing'>;
export const ExpandedRow: FC<Props> = ({ item, onAlertEdit }) => {
const hideNodeInfo = useIsServerless();
const stateValues: StateValues = { ...item.stats };
delete stateValues.stats;
delete stateValues.checkpointing;
@ -61,7 +64,7 @@ export const ExpandedRow: FC<Props> = ({ item, onAlertEdit }) => {
description: item.stats.state,
}
);
if (item.stats.node !== undefined) {
if (!hideNodeInfo && item.stats.node !== undefined) {
stateItems.push({
title: 'node.name',
description: item.stats.node.name,

View file

@ -19,6 +19,7 @@ import {
import { euiLightVars as theme } from '@kbn/ui-theme';
import { i18n } from '@kbn/i18n';
import { useIsServerless } from '../../../../serverless_context';
import { DEFAULT_MAX_AUDIT_MESSAGE_SIZE, TIME_FORMAT } from '../../../../../../common/constants';
import { TransformMessage } from '../../../../../../common/types/messages';
@ -35,6 +36,8 @@ interface Sorting {
}
export const ExpandedRowMessagesPane: FC<ExpandedRowMessagesPaneProps> = ({ transformId }) => {
const hideNodeInfo = useIsServerless();
const [pageIndex, setPageIndex] = useState(0);
const [pageSize, setPageSize] = useState(10);
const [sorting, setSorting] = useState<{ sort: Sorting }>({
@ -96,16 +99,20 @@ export const ExpandedRowMessagesPane: FC<ExpandedRowMessagesPaneProps> = ({ tran
render: (timestamp: number) => formatDate(timestamp, TIME_FORMAT),
sortable: true,
},
{
field: 'node_name',
name: i18n.translate(
'xpack.transform.transformList.transformDetails.messagesPane.nodeLabel',
{
defaultMessage: 'Node',
}
),
sortable: true,
},
...(!hideNodeInfo
? [
{
field: 'node_name',
name: i18n.translate(
'xpack.transform.transformList.transformDetails.messagesPane.nodeLabel',
{
defaultMessage: 'Node',
}
),
sortable: true,
},
]
: []),
{
field: 'message',
name: i18n.translate(
@ -114,7 +121,7 @@ export const ExpandedRowMessagesPane: FC<ExpandedRowMessagesPaneProps> = ({ tran
defaultMessage: 'Message',
}
),
width: '50%',
width: !hideNodeInfo ? '50%' : '70%',
},
];

View file

@ -12,6 +12,7 @@ import { EuiButton, EuiCallOut, EuiLink, EuiSpacer } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';
import { useIsServerless } from '../../../../serverless_context';
import { TRANSFORM_MODE, TRANSFORM_STATE } from '../../../../../../common/constants';
import { TransformListRow } from '../../../../common';
@ -20,8 +21,12 @@ import { useDocumentationLinks, useRefreshTransformList } from '../../../../hook
import { StatsBar, TransformStatsBarStats } from '../stats_bar';
function createTranformStats(transformNodes: number, transformsList: TransformListRow[]) {
const transformStats = {
function createTranformStats(
transformNodes: number,
transformsList: TransformListRow[],
hideNodeInfo: boolean
): TransformStatsBarStats {
const transformStats: TransformStatsBarStats = {
total: {
label: i18n.translate('xpack.transform.statsBar.totalTransformsLabel', {
defaultMessage: 'Total transforms',
@ -57,14 +62,17 @@ function createTranformStats(transformNodes: number, transformsList: TransformLi
value: 0,
show: true,
},
nodes: {
};
if (!hideNodeInfo) {
transformStats.nodes = {
label: i18n.translate('xpack.transform.statsBar.transformNodesLabel', {
defaultMessage: 'Nodes',
}),
value: transformNodes,
show: true,
},
};
};
}
if (transformsList === undefined) {
return transformStats;
@ -74,9 +82,15 @@ function createTranformStats(transformNodes: number, transformsList: TransformLi
let startedTransforms = 0;
transformsList.forEach((transform) => {
if (transform.mode === TRANSFORM_MODE.CONTINUOUS) {
if (
transform.mode === TRANSFORM_MODE.CONTINUOUS &&
typeof transformStats.continuous.value === 'number'
) {
transformStats.continuous.value++;
} else if (transform.mode === TRANSFORM_MODE.BATCH) {
} else if (
transform.mode === TRANSFORM_MODE.BATCH &&
typeof transformStats.batch.value === 'number'
) {
transformStats.batch.value++;
}
@ -109,17 +123,19 @@ export const TransformStatsBar: FC<TransformStatsBarProps> = ({
transformNodes,
transformsList,
}) => {
const hideNodeInfo = useIsServerless();
const refreshTransformList = useRefreshTransformList();
const { esNodeRoles } = useDocumentationLinks();
const transformStats: TransformStatsBarStats = createTranformStats(
transformNodes,
transformsList
transformsList,
hideNodeInfo
);
return (
<>
{transformNodes === 0 && (
{!hideNodeInfo && transformNodes === 0 && (
<>
<EuiCallOut
title={

View file

@ -21,6 +21,7 @@ import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';
import type { IHttpFetchError } from '@kbn/core-http-browser';
import { useIsServerless } from '../../serverless_context';
import { needsReauthorization } from '../../common/reauthorization_utils';
import { TRANSFORM_STATE } from '../../../../common/constants';
@ -71,6 +72,7 @@ const ErrorMessageCallout: FC<{
export const TransformManagement: FC = () => {
const { esTransform } = useDocumentationLinks();
const hideNodeInfo = useIsServerless();
const deleteTransforms = useDeleteTransforms();
@ -78,7 +80,7 @@ export const TransformManagement: FC = () => {
isInitialLoading: transformNodesInitialLoading,
error: transformNodesErrorMessage,
data: transformNodesData = 0,
} = useGetTransformNodes();
} = useGetTransformNodes({ enabled: true });
const transformNodes = transformNodesErrorMessage === null ? transformNodesData : 0;
const {
@ -86,7 +88,9 @@ export const TransformManagement: FC = () => {
isLoading: transformsLoading,
error: transformsErrorMessage,
data: { transforms, transformIdsWithoutConfig },
} = useGetTransforms({ enabled: !transformNodesInitialLoading && transformNodes > 0 });
} = useGetTransforms({
enabled: !transformNodesInitialLoading && (transformNodes > 0 || hideNodeInfo),
});
const isInitialLoading = transformNodesInitialLoading || transformsInitialLoading;
@ -193,7 +197,7 @@ export const TransformManagement: FC = () => {
<>
{unauthorizedTransformsWarning}
{transformNodesErrorMessage !== null && (
{!hideNodeInfo && transformNodesErrorMessage !== null && (
<ErrorMessageCallout
text={
<FormattedMessage

View file

@ -0,0 +1,26 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import React, { createContext, FC, useContext, useMemo } from 'react';
export const ServerlessContext = createContext({
isServerless: false,
});
export const ServerlessContextProvider: FC<{ isServerless: boolean }> = (props) => {
const { children, isServerless } = props;
return (
<ServerlessContext.Provider value={{ isServerless }}>{children}</ServerlessContext.Provider>
);
};
export function useIsServerless() {
const context = useContext(ServerlessContext);
return useMemo(() => {
return context.isServerless;
}, [context]);
}

View file

@ -6,11 +6,12 @@
*/
import './app/index.scss';
import type { PluginInitializerContext } from '@kbn/core-plugins-server';
import { TransformUiPlugin } from './plugin';
/** @public */
export const plugin = () => {
return new TransformUiPlugin();
export const plugin = (ctx: PluginInitializerContext) => {
return new TransformUiPlugin(ctx);
};
export { getTransformHealthRuleType } from './alerting';

View file

@ -18,11 +18,12 @@ import type { SpacesApi } from '@kbn/spaces-plugin/public';
import type { PluginSetupContract as AlertingSetup } from '@kbn/alerting-plugin/public';
import type { TriggersAndActionsUIPublicPluginStart } from '@kbn/triggers-actions-ui-plugin/public';
import type { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/public';
import { ChartsPluginStart } from '@kbn/charts-plugin/public';
import { FieldFormatsStart } from '@kbn/field-formats-plugin/public';
import { SavedObjectsManagementPluginStart } from '@kbn/saved-objects-management-plugin/public/plugin';
import { ContentManagementPublicStart } from '@kbn/content-management-plugin/public';
import { SavedSearchPublicPluginStart } from '@kbn/saved-search-plugin/public';
import type { ChartsPluginStart } from '@kbn/charts-plugin/public';
import type { FieldFormatsStart } from '@kbn/field-formats-plugin/public';
import type { SavedObjectsManagementPluginStart } from '@kbn/saved-objects-management-plugin/public/plugin';
import type { ContentManagementPublicStart } from '@kbn/content-management-plugin/public';
import type { SavedSearchPublicPluginStart } from '@kbn/saved-search-plugin/public';
import type { PluginInitializerContext } from '@kbn/core/public';
import { registerFeature } from './register_feature';
import { getTransformHealthRuleType } from './alerting';
@ -45,6 +46,11 @@ export interface PluginsDependencies {
}
export class TransformUiPlugin {
private isServerless: boolean = false;
constructor(initializerContext: PluginInitializerContext) {
this.isServerless = initializerContext.env.packageInfo.buildFlavor === 'serverless';
}
public setup(coreSetup: CoreSetup<PluginsDependencies>, pluginsSetup: PluginsDependencies): void {
const { management, home, triggersActionsUi } = pluginsSetup;
@ -58,7 +64,7 @@ export class TransformUiPlugin {
order: 5,
mount: async (params) => {
const { mountManagementSection } = await import('./app/mount_management_section');
return mountManagementSection(coreSetup, params);
return mountManagementSection(coreSetup, params, this.isServerless);
},
});
registerFeature(home);

View file

@ -68,7 +68,8 @@
"@kbn/unified-field-list",
"@kbn/ebt-tools",
"@kbn/content-management-plugin",
"@kbn/react-kibana-mount"
"@kbn/react-kibana-mount",
"@kbn/core-plugins-server"
],
"exclude": [
"target/**/*",