From d3295d3ae9b19d3c29ca909ba63d9588b7ede0f2 Mon Sep 17 00:00:00 2001 From: cauemarcondes Date: Wed, 23 Jun 2021 17:13:56 -0400 Subject: [PATCH] adding storybook --- .../config_agent/config_agent.stories.tsx | 117 ++++++++++++++++++ .../tutorial_fleet_instructions.stories.tsx | 5 +- 2 files changed, 119 insertions(+), 3 deletions(-) create mode 100644 x-pack/plugins/apm/public/tutorial/config_agent/config_agent.stories.tsx diff --git a/x-pack/plugins/apm/public/tutorial/config_agent/config_agent.stories.tsx b/x-pack/plugins/apm/public/tutorial/config_agent/config_agent.stories.tsx new file mode 100644 index 0000000000000..69bc425374dc4 --- /dev/null +++ b/x-pack/plugins/apm/public/tutorial/config_agent/config_agent.stories.tsx @@ -0,0 +1,117 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +/* eslint-disable react/function-component-definition */ + +import { Story } from '@storybook/react'; +import { HttpStart } from 'kibana/public'; +import React from 'react'; +import TutorialConfigAgent from './'; +import { APIReturnType } from '../..//services/rest/createCallApmApi'; + +export type APIResponseType = APIReturnType<'GET /api/apm/fleet/agents'>; + +interface Args { + variantId: string; + environment: 'cloud' | 'onprem'; + addAgents: boolean; + addPolicyOnCloudAgent: boolean; +} + +const policyElasticAgentOnCloudAgent: APIResponseType['agents'][0] = { + id: 'policy-elastic-agent-on-cloud', + name: 'Elastic Cloud agent policy', + apmServerUrl: 'apm_cloud_url', + secretToken: 'apm_cloud_token', +}; + +const _agents: APIResponseType['agents'] = [ + { + id: '1', + name: 'agent foo', + apmServerUrl: 'foo', + secretToken: 'foo', + }, + { + id: '2', + name: 'agent bar', + apmServerUrl: 'bar', + secretToken: 'bar', + }, +]; + +function Wrapper({ + addAgents, + variantId, + environment, + addPolicyOnCloudAgent, +}: Args) { + const http = ({ + get: () => ({ + agents: [ + ...(addAgents ? _agents : []), + ...(addPolicyOnCloudAgent ? [policyElasticAgentOnCloudAgent] : []), + ], + cloudStandaloneSetup: { + apmServerUrl: 'cloud_url', + secretToken: 'foo', + }, + }), + } as unknown) as HttpStart; + return ( + + ); +} +export const Integration: Story = (_args) => { + return ; +}; + +Integration.args = { + variantId: 'java', + environment: 'onprem', + addAgents: false, + addPolicyOnCloudAgent: false, +}; + +export default { + title: 'app/Tutorial/AgentConfig', + component: TutorialConfigAgent, + argTypes: { + variantId: { + control: { + type: 'select', + options: [ + 'java', + 'node', + 'django', + 'flask', + 'rails', + 'rack', + 'go', + 'dotnet', + 'php', + 'js', + 'js_script', + ], + }, + }, + environment: { + control: { type: 'select', options: ['onprem', 'cloud'] }, + }, + addAgents: { + control: { type: 'inline-radio', options: [true, false] }, + }, + addPolicyOnCloudAgent: { + control: { type: 'inline-radio', options: [true, false] }, + }, + }, +}; diff --git a/x-pack/plugins/apm/public/tutorial/tutorial_fleet_instructions/tutorial_fleet_instructions.stories.tsx b/x-pack/plugins/apm/public/tutorial/tutorial_fleet_instructions/tutorial_fleet_instructions.stories.tsx index 6e97edd68554f..80e742295fade 100644 --- a/x-pack/plugins/apm/public/tutorial/tutorial_fleet_instructions/tutorial_fleet_instructions.stories.tsx +++ b/x-pack/plugins/apm/public/tutorial/tutorial_fleet_instructions/tutorial_fleet_instructions.stories.tsx @@ -17,7 +17,6 @@ interface Args { } function Wrapper({ hasFleetPolicyWithApmIntegration }: Args) { - // TODO mock http const http = ({ get: () => ({ hasData: hasFleetPolicyWithApmIntegration }), } as unknown) as HttpStart; @@ -40,10 +39,10 @@ export default { }, }; -export const WithApmIntegration: Story = (_args) => { +export const Instructions: Story = (_args) => { return ; }; -WithApmIntegration.args = { +Instructions.args = { hasFleetPolicyWithApmIntegration: true, };