Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Inventory] Adding feedback button #195716

Merged
merged 10 commits into from
Oct 14, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"share"
],
"requiredBundles": ["kibanaReact"],
"optionalPlugins": [],
"optionalPlugins": ["cloud",],
cauemarcondes marked this conversation as resolved.
Show resolved Hide resolved
cauemarcondes marked this conversation as resolved.
Show resolved Hide resolved
"extraPublicDirs": []
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,16 @@ import { css } from '@emotion/css';
import type { InventoryStartDependencies } from './types';
import { InventoryServices } from './services/types';
import { AppRoot } from './components/app_root';
import { KibanaEnvironment } from './hooks/use_kibana';

export const renderApp = ({
coreStart,
pluginsStart,
services,
appMountParameters,
}: {
export const renderApp = (props: {
coreStart: CoreStart;
pluginsStart: InventoryStartDependencies;
services: InventoryServices;
} & { appMountParameters: AppMountParameters }) => {
appMountParameters: AppMountParameters;
kibanaEnvironment: KibanaEnvironment;
}) => {
const { appMountParameters, coreStart } = props;
const { element } = appMountParameters;

const appWrapperClassName = css`
Expand All @@ -33,12 +32,7 @@ export const renderApp = ({

ReactDOM.render(
<KibanaRenderContextProvider {...coreStart}>
<AppRoot
appMountParameters={appMountParameters}
coreStart={coreStart}
pluginsStart={pluginsStart}
services={services}
/>
<AppRoot {...props} />
</KibanaRenderContextProvider>,
element
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,27 @@ import { inventoryRouter } from '../../routes/config';
import { InventoryServices } from '../../services/types';
import { InventoryStartDependencies } from '../../types';
import { HeaderActionMenuItems } from './header_action_menu';
import { KibanaEnvironment } from '../../hooks/use_kibana';

export function AppRoot({
coreStart,
pluginsStart,
services,
appMountParameters,
kibanaEnvironment,
}: {
coreStart: CoreStart;
pluginsStart: InventoryStartDependencies;
services: InventoryServices;
kibanaEnvironment: KibanaEnvironment;
} & { appMountParameters: AppMountParameters }) {
const { history } = appMountParameters;

const context = {
...coreStart,
...pluginsStart,
...services,
kibanaEnvironment,
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
import { i18n } from '@kbn/i18n';
import React from 'react';
import { EuiFlexGroup, EuiFlexItem, EuiEmptyPrompt, EuiLoadingLogo } from '@elastic/eui';
import { TechnicalPreviewBadge } from '@kbn/observability-shared-plugin/public';
import {
FeatureFeedbackButton,
TechnicalPreviewBadge,
} from '@kbn/observability-shared-plugin/public';
import { useKibana } from '../../hooks/use_kibana';
import { SearchBar } from '../search_bar';
import { getEntityManagerEnablement } from './no_data_config';
Expand All @@ -29,9 +32,11 @@ const pageTitle = (
</EuiFlexGroup>
);

const INVENTORY_FEEDBACK_LINK = 'https://ela.st/feedback-new-inventory';

export function InventoryPageTemplate({ children }: { children: React.ReactNode }) {
const {
services: { observabilityShared, inventoryAPIClient },
services: { observabilityShared, inventoryAPIClient, kibanaEnvironment },
} = useKibana();

const { PageTemplate: ObservabilityPageTemplate } = observabilityShared.navigation;
Expand Down Expand Up @@ -73,6 +78,15 @@ export function InventoryPageTemplate({ children }: { children: React.ReactNode
<ObservabilityPageTemplate
pageHeader={{
pageTitle,
rightSideItems: [
<FeatureFeedbackButton
data-test-subj="inventoryFeedbackButton"
formUrl={INVENTORY_FEEDBACK_LINK}
kibanaVersion={kibanaEnvironment.kibanaVersion}
isCloudEnv={kibanaEnvironment.isCloudEnv}
isServerlessEnv={kibanaEnvironment.isServerlessEnv}
/>,
],
}}
noDataConfig={getEntityManagerEnablement({
enabled: isEntityManagerEnabled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,15 @@ import { type KibanaReactContextValue, useKibana } from '@kbn/kibana-react-plugi
import type { InventoryStartDependencies } from '../types';
import type { InventoryServices } from '../services/types';

export type InventoryKibanaContext = CoreStart & InventoryStartDependencies & InventoryServices;
export interface KibanaEnvironment {
kibanaVersion?: string;
isCloudEnv?: boolean;
isServerlessEnv?: boolean;
}

export type InventoryKibanaContext = CoreStart &
InventoryStartDependencies &
InventoryServices & { kibanaEnvironment: KibanaEnvironment };

const useTypedKibana = useKibana as () => KibanaReactContextValue<InventoryKibanaContext>;

Expand Down
14 changes: 13 additions & 1 deletion x-pack/plugins/observability_solution/inventory/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

import {
AppMountParameters,
AppStatus,
CoreSetup,
CoreStart,
DEFAULT_APP_CATEGORIES,
Plugin,
PluginInitializerContext,
AppStatus,
} from '@kbn/core/public';
import { INVENTORY_APP_ID } from '@kbn/deeplinks-observability/constants';
import { i18n } from '@kbn/i18n';
Expand Down Expand Up @@ -40,10 +40,14 @@ export class InventoryPlugin
{
logger: Logger;
telemetry: TelemetryService;
kibanaVersion: string;
isServerlessEnv: boolean;

constructor(context: PluginInitializerContext<ConfigSchema>) {
this.logger = context.logger.get();
this.telemetry = new TelemetryService();
this.kibanaVersion = context.env.packageInfo.version;
this.isServerlessEnv = context.env.packageInfo.buildFlavor === 'serverless';
}
setup(
coreSetup: CoreSetup<InventoryStartDependencies, InventoryPublicStart>,
Expand Down Expand Up @@ -85,6 +89,9 @@ export class InventoryPlugin
this.telemetry.setup({ analytics: coreSetup.analytics });
const telemetry = this.telemetry.start();

const isCloudEnv = !!pluginsSetup.cloud?.isCloudEnabled;
const isServerlessEnv = pluginsSetup.cloud?.isServerlessEnabled || this.isServerlessEnv;

coreSetup.application.register({
id: INVENTORY_APP_ID,
title: i18n.translate('xpack.inventory.appTitle', {
Expand Down Expand Up @@ -115,6 +122,11 @@ export class InventoryPlugin
pluginsStart,
services,
appMountParameters,
kibanaEnvironment: {
isCloudEnv,
isServerlessEnv,
kibanaVersion: this.kibanaVersion,
},
});
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import type { SharePluginSetup, SharePluginStart } from '@kbn/share-plugin/publi
import type { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/public';
import type { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public';
import type { DataPublicPluginSetup, DataPublicPluginStart } from '@kbn/data-plugin/public';
import type { CloudSetup } from '@kbn/cloud-plugin/public';

/* eslint-disable @typescript-eslint/no-empty-interface*/

Expand All @@ -28,6 +29,7 @@ export interface InventorySetupDependencies {
share: SharePluginSetup;
data: DataPublicPluginSetup;
entityManager: EntityManagerPublicPluginSetup;
cloud?: CloudSetup;
}

export interface InventoryStartDependencies {
Expand Down