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

[Logs Explorer] Fix Privileges Accessibility #193894

Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -19,6 +19,7 @@ import { InfraClientStartDeps, InfraClientStartExports } from '../types';
import { CommonInfraProviders, CoreProviders } from './common_providers';
import { prepareMountElement } from './common_styles';
import { KbnUrlStateStorageFromRouterProvider } from '../containers/kbn_url_state_context';
import { RedirectWithQueryParams } from '../utils/redirect_with_query_params';

export const renderApp = (
core: CoreStart,
Expand Down Expand Up @@ -57,7 +58,26 @@ const LogsApp: React.FC<{
storage: Storage;
theme$: AppMountParameters['theme$'];
}> = ({ core, history, pluginStart, plugins, setHeaderActionMenu, storage, theme$ }) => {
const uiCapabilities = core.application.capabilities;
const { logs, discover, fleet } = core.application.capabilities;

const LogsRouteComponent =
discover?.show && fleet?.read ? (
<Route
path="/"
exact
render={() => {
plugins.share.url.locators
.get<AllDatasetsLocatorParams>(ALL_DATASETS_LOCATOR_ID)
?.navigate({});

return null;
}}
/>
) : (
// This needs to redirect to /categories once stream is deprecated when the below ticket is implemented
// https://github.com/elastic/kibana/issues/193321
<RedirectWithQueryParams from={'/'} to={'/stream'} exact />
mohamedhamed-ahmed marked this conversation as resolved.
Show resolved Hide resolved
);

return (
<CoreProviders core={core} pluginStart={pluginStart} plugins={plugins} theme$={theme$}>
Expand All @@ -74,19 +94,9 @@ const LogsApp: React.FC<{
toastsService={core.notifications.toasts}
>
<Routes>
<Route
path="/"
exact
render={() => {
plugins.share.url.locators
.get<AllDatasetsLocatorParams>(ALL_DATASETS_LOCATOR_ID)
?.navigate({});

return null;
}}
/>
{LogsRouteComponent}
<Route path="/link-to" component={LinkToLogsPage} />
{uiCapabilities?.logs?.show && <Route path="/" component={LogsPage} />}
{logs?.show && <Route path="/" component={LogsPage} />}
</Routes>
</KbnUrlStateStorageFromRouterProvider>
</Router>
Expand Down
21 changes: 13 additions & 8 deletions x-pack/plugins/observability_solution/infra/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,19 +137,24 @@ export class Plugin implements InfraClientPluginClass {
],
isInfrastructureHostsViewEnabled,
]) => {
const { infrastructure, logs, discover, fleet } = capabilities;
return [
...(capabilities.logs.show
...(logs.show
? [
{
label: 'Logs',
sortKey: 200,
entries: [
{
label: 'Explorer',
app: 'observability-logs-explorer',
path: '/',
isBetaFeature: true,
},
...(discover?.show && fleet?.read
? [
{
label: 'Explorer',
app: 'observability-logs-explorer',
path: '/',
isBetaFeature: true,
},
]
: []),
...(this.config.featureFlags.logsUIEnabled
? [
{ label: 'Stream', app: 'logs', path: '/stream' },
Expand All @@ -161,7 +166,7 @@ export class Plugin implements InfraClientPluginClass {
},
]
: []),
...(capabilities.infrastructure.show
...(infrastructure.show
? [
{
label: metricsTitle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@

import {
AppMountParameters,
AppStatus,
AppUpdater,
CoreSetup,
CoreStart,
DEFAULT_APP_CATEGORIES,
Plugin,
PluginInitializerContext,
} from '@kbn/core/public';
import { OBSERVABILITY_LOGS_EXPLORER_APP_ID } from '@kbn/deeplinks-observability';
import { BehaviorSubject } from 'rxjs';
import {
AllDatasetsLocatorDefinition,
ObservabilityLogsExplorerLocators,
Expand All @@ -35,6 +38,7 @@ export class ObservabilityLogsExplorerPlugin
{
private config: ObservabilityLogsExplorerConfig;
private locators?: ObservabilityLogsExplorerLocators;
private appStateUpdater = new BehaviorSubject<AppUpdater>(() => ({}));

constructor(context: PluginInitializerContext<ObservabilityLogsExplorerConfig>) {
this.config = context.config.get();
Expand All @@ -56,6 +60,7 @@ export class ObservabilityLogsExplorerPlugin
? ['globalSearch', 'sideNav']
: ['globalSearch'],
keywords: ['logs', 'log', 'explorer', 'logs explorer'],
updater$: this.appStateUpdater,
mount: async (appMountParams: ObservabilityLogsExplorerAppMountParameters) => {
const [coreStart, pluginsStart, ownPluginStart] = await core.getStartServices();
const { renderObservabilityLogsExplorer } = await import(
Expand Down Expand Up @@ -123,7 +128,16 @@ export class ObservabilityLogsExplorerPlugin
};
}

public start(_core: CoreStart, _pluginsStart: ObservabilityLogsExplorerStartDeps) {
public start(core: CoreStart, _pluginsStart: ObservabilityLogsExplorerStartDeps) {
const { discover, fleet, logs } = core.application.capabilities;

if (!(discover?.show && fleet?.read && logs?.show)) {
this.appStateUpdater.next(() => ({
tonyghiani marked this conversation as resolved.
Show resolved Hide resolved
status: AppStatus.inaccessible,
visibleIn: [],
}));
}

return {};
}
}