mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
Hide Analyze Data button if no dashboard access (#106020)
Fixes #105476.
This commit is contained in:
parent
00d8f05f2e
commit
c0528f263f
3 changed files with 23 additions and 6 deletions
|
@ -13,12 +13,9 @@ import { APMServiceContext } from '../../../../context/apm_service/apm_service_c
|
|||
import { MockUrlParamsContextProvider } from '../../../../context/url_params_context/mock_url_params_context_provider';
|
||||
import { AnalyzeDataButton } from './analyze_data_button';
|
||||
|
||||
const KibanaContext = createKibanaReactContext(({
|
||||
http: { basePath: { get: () => '' } },
|
||||
} as unknown) as Partial<CoreStart>);
|
||||
|
||||
interface Args {
|
||||
agentName: string;
|
||||
canShowDashboard: boolean;
|
||||
environment?: string;
|
||||
serviceName: string;
|
||||
}
|
||||
|
@ -28,7 +25,14 @@ export default {
|
|||
component: AnalyzeDataButton,
|
||||
decorators: [
|
||||
(StoryComponent: ComponentType, { args }: StoryContext) => {
|
||||
const { agentName, environment, serviceName } = args;
|
||||
const { agentName, canShowDashboard, environment, serviceName } = args;
|
||||
|
||||
const KibanaContext = createKibanaReactContext(({
|
||||
application: {
|
||||
capabilities: { dashboard: { show: canShowDashboard } },
|
||||
},
|
||||
http: { basePath: { get: () => '' } },
|
||||
} as unknown) as Partial<CoreStart>);
|
||||
|
||||
return (
|
||||
<MockUrlParamsContextProvider
|
||||
|
@ -52,6 +56,7 @@ export const Example: Story<Args> = () => {
|
|||
};
|
||||
Example.args = {
|
||||
agentName: 'iOS/swift',
|
||||
canShowDashboard: true,
|
||||
environment: 'testEnvironment',
|
||||
serviceName: 'testServiceName',
|
||||
};
|
||||
|
|
|
@ -25,6 +25,14 @@ describe('AnalyzeDataButton', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('with no dashboard show capabilities', () => {
|
||||
it('renders nothing', () => {
|
||||
render(<Example canShowDashboard={false} />);
|
||||
|
||||
expect(screen.queryByRole('link')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe('with a RUM agent', () => {
|
||||
it('uses a ux dataType', () => {
|
||||
render(<Example agentName="rum-js" />);
|
||||
|
|
|
@ -47,8 +47,12 @@ export function AnalyzeDataButton() {
|
|||
const { urlParams } = useUrlParams();
|
||||
const { rangeTo, rangeFrom, environment } = urlParams;
|
||||
const basepath = services.http?.basePath.get();
|
||||
const canShowDashboard = services.application?.capabilities.dashboard.show;
|
||||
|
||||
if (isRumAgentName(agentName) || isIosAgentName(agentName)) {
|
||||
if (
|
||||
(isRumAgentName(agentName) || isIosAgentName(agentName)) &&
|
||||
canShowDashboard
|
||||
) {
|
||||
const href = createExploratoryViewUrl(
|
||||
{
|
||||
'apm-series': {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue