Skip to content
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
45 changes: 0 additions & 45 deletions x-pack/plugins/apm/public/components/app/Main/UpdateBadge.tsx

This file was deleted.

34 changes: 16 additions & 18 deletions x-pack/plugins/apm/public/components/app/Main/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@
import React from 'react';
import { Route, Switch } from 'react-router-dom';
import styled from 'styled-components';
import { UICapabilitiesProvider } from 'ui/capabilities/react';
import { px, topNavHeight, unit, units } from '../../../style/variables';
import { GlobalFetchIndicator } from './GlobalFetchIndicator';
import { LicenseCheck } from './LicenseCheck';
import { routes } from './routeConfig';
import { ScrollToTopOnPathChange } from './ScrollToTopOnPathChange';
import { UpdateBadge } from './UpdateBadge';
import { useUpdateBadgeEffect } from './useUpdateBadgeEffect';
import { UpdateBreadcrumbs } from './UpdateBreadcrumbs';

const MainContainer = styled.div`
Expand All @@ -23,22 +22,21 @@ const MainContainer = styled.div`
`;

export function Main() {
useUpdateBadgeEffect();

return (
<UICapabilitiesProvider>
<GlobalFetchIndicator>
<MainContainer data-test-subj="apmMainContainer">
<UpdateBreadcrumbs />
<UpdateBadge />
<Route component={ScrollToTopOnPathChange} />
<LicenseCheck>
<Switch>
{routes.map((route, i) => (
<Route key={i} {...route} />
))}
</Switch>
</LicenseCheck>
</MainContainer>
</GlobalFetchIndicator>
</UICapabilitiesProvider>
<GlobalFetchIndicator>
<MainContainer data-test-subj="apmMainContainer">
<UpdateBreadcrumbs />
<Route component={ScrollToTopOnPathChange} />
<LicenseCheck>
<Switch>
{routes.map((route, i) => (
<Route key={i} {...route} />
))}
</Switch>
</LicenseCheck>
</MainContainer>
</GlobalFetchIndicator>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { i18n } from '@kbn/i18n';
import { useEffect } from 'react';
import { capabilities } from 'ui/capabilities';
import chrome from 'ui/chrome';

export const useUpdateBadgeEffect = () => {
useEffect(() => {
const uiCapabilities = capabilities.get();
chrome.badge.set(
!uiCapabilities.apm.save
? {
text: i18n.translate('xpack.apm.header.badge.readOnly.text', {
defaultMessage: 'Read only'
}),
tooltip: i18n.translate('xpack.apm.header.badge.readOnly.tooltip', {
defaultMessage: 'Unable to save'
}),
iconType: 'glasses'
}
: undefined
);
}, []);
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this component specific to APM? If not, perhaps it should be in ui/capabilities.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The read-only badges are currently application specific