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

[8.x] [Inventory] Adding feedback button (#195716) #196080

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,10 @@ export function getMockInventoryContext(): InventoryKibanaContext {
stream: jest.fn(),
},
spaces: {} as unknown as SpacesPluginStart,
kibanaEnvironment: {
isCloudEnv: false,
isServerlessEnv: false,
kibanaVersion: '9.0.0',
},
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"share"
],
"requiredBundles": ["kibanaReact"],
"optionalPlugins": ["spaces"],
"optionalPlugins": ["spaces", "cloud"],
"extraPublicDirs": []
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,21 @@ import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render';
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;

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
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 @@ -104,6 +108,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 @@ -134,6 +141,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';
import type { SpacesPluginStart } from '@kbn/spaces-plugin/public';

/* eslint-disable @typescript-eslint/no-empty-interface*/
Expand All @@ -29,6 +30,7 @@ export interface InventorySetupDependencies {
share: SharePluginSetup;
data: DataPublicPluginSetup;
entityManager: EntityManagerPublicPluginSetup;
cloud?: CloudSetup;
}

export interface InventoryStartDependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"@kbn/elastic-agent-utils",
"@kbn/custom-icons",
"@kbn/ui-theme",
"@kbn/spaces-plugin"
"@kbn/spaces-plugin",
"@kbn/cloud-plugin"
]
}
Loading