Skip to content

Commit

Permalink
[8.x] [Inventory] Adding feedback button (#195716) (#196080)
Browse files Browse the repository at this point in the history
# Backport

This will backport the following commits from `main` to `8.x`:
- [[Inventory] Adding feedback button
(#195716)](#195716)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Cauê
Marcondes","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-14T10:05:16Z","message":"[Inventory]
Adding feedback button (#195716)\n\n<img width=\"1616\" alt=\"Screenshot
2024-10-10 at 10 04
51\"\r\nsrc=\"https://github.com/user-attachments/assets/b543a156-ea5e-46ba-9460-e86d7ca6e5a1\">\r\n<img
width=\"1600\" alt=\"Screenshot 2024-10-10 at 10 05
24\"\r\nsrc=\"https://github.com/user-attachments/assets/a2d7973f-53b3-4bf9-a917-8ce496d3c943\">\r\n\r\n---------\r\n\r\nCo-authored-by:
jennypavlova <[email protected]>\r\nCo-authored-by: kibanamachine
<[email protected]>","sha":"4428c80189ff2899e86c9d1705d50932814cb29f","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:prev-minor","ci:project-deploy-observability","v8.16.0"],"title":"[Inventory]
Adding feedback
button","number":195716,"url":"https://github.com/elastic/kibana/pull/195716","mergeCommit":{"message":"[Inventory]
Adding feedback button (#195716)\n\n<img width=\"1616\" alt=\"Screenshot
2024-10-10 at 10 04
51\"\r\nsrc=\"https://github.com/user-attachments/assets/b543a156-ea5e-46ba-9460-e86d7ca6e5a1\">\r\n<img
width=\"1600\" alt=\"Screenshot 2024-10-10 at 10 05
24\"\r\nsrc=\"https://github.com/user-attachments/assets/a2d7973f-53b3-4bf9-a917-8ce496d3c943\">\r\n\r\n---------\r\n\r\nCo-authored-by:
jennypavlova <[email protected]>\r\nCo-authored-by: kibanamachine
<[email protected]>","sha":"4428c80189ff2899e86c9d1705d50932814cb29f"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/195716","number":195716,"mergeCommit":{"message":"[Inventory]
Adding feedback button (#195716)\n\n<img width=\"1616\" alt=\"Screenshot
2024-10-10 at 10 04
51\"\r\nsrc=\"https://github.com/user-attachments/assets/b543a156-ea5e-46ba-9460-e86d7ca6e5a1\">\r\n<img
width=\"1600\" alt=\"Screenshot 2024-10-10 at 10 05
24\"\r\nsrc=\"https://github.com/user-attachments/assets/a2d7973f-53b3-4bf9-a917-8ce496d3c943\">\r\n\r\n---------\r\n\r\nCo-authored-by:
jennypavlova <[email protected]>\r\nCo-authored-by: kibanamachine
<[email protected]>","sha":"4428c80189ff2899e86c9d1705d50932814cb29f"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Cauê Marcondes <[email protected]>
  • Loading branch information
kibanamachine and cauemarcondes authored Oct 14, 2024
1 parent ec92845 commit 1c98c7a
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 19 deletions.
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
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 @@ -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"
]
}

0 comments on commit 1c98c7a

Please sign in to comment.