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

Hide Analyze Data button if no dashboard access #106020

Merged
merged 3 commits into from
Jul 19, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -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;
}
Expand All @@ -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
Expand All @@ -52,6 +56,7 @@ export const Example: Story<Args> = () => {
};
Example.args = {
agentName: 'iOS/swift',
canShowDashboard: true,
environment: 'testEnvironment',
serviceName: 'testServiceName',
};
Original file line number Diff line number Diff line change
Expand Up @@ -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" />);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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': {
Expand Down