Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
cauemarcondes committed Jun 24, 2021
1 parent 44613d6 commit cb93335
Show file tree
Hide file tree
Showing 9 changed files with 298 additions and 297 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,6 @@ export function Instruction({

{post}

{LazyCustomComponent && (
<Suspense fallback={<EuiLoadingSpinner />}>
<LazyCustomComponent
basePath={getBasePath()}
isDarkTheme={uiSettings.get('theme:darkMode')}
http={http}
/>
</Suspense>
)}

<EuiSpacer />
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ 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;
apmAgent: string;
onPrem: boolean;
hasFleetPoliciesWithApmIntegration: boolean;
hasCloudPolicyWithApmIntegration: boolean;
}

const policyElasticAgentOnCloudAgent: APIResponseType['agents'][0] = {
const policyElasticAgentOnCloudAgent: APIResponseType['fleetAgents'][0] = {
id: 'policy-elastic-agent-on-cloud',
name: 'Elastic Cloud agent policy',
apmServerUrl: 'apm_cloud_url',
secretToken: 'apm_cloud_token',
};

const _agents: APIResponseType['agents'] = [
const fleetAgents: APIResponseType['fleetAgents'] = [
{
id: '1',
name: 'agent foo',
Expand All @@ -45,16 +45,18 @@ const _agents: APIResponseType['agents'] = [
];

function Wrapper({
addAgents,
variantId,
environment,
addPolicyOnCloudAgent,
hasFleetPoliciesWithApmIntegration,
apmAgent,
onPrem,
hasCloudPolicyWithApmIntegration,
}: Args) {
const http = ({
get: () => ({
agents: [
...(addAgents ? _agents : []),
...(addPolicyOnCloudAgent ? [policyElasticAgentOnCloudAgent] : []),
fleetAgents: [
...(hasFleetPoliciesWithApmIntegration ? fleetAgents : []),
...(hasCloudPolicyWithApmIntegration
? [policyElasticAgentOnCloudAgent]
: []),
],
cloudStandaloneSetup: {
apmServerUrl: 'cloud_url',
Expand All @@ -66,8 +68,8 @@ function Wrapper({
<TutorialConfigAgent
http={http}
basePath="http://localhost:5601"
isCloudEnabled={environment === 'cloud'}
variantId={variantId}
isCloudEnabled={!onPrem}
variantId={apmAgent}
/>
);
}
Expand All @@ -76,17 +78,17 @@ export const Integration: Story<Args> = (_args) => {
};

Integration.args = {
variantId: 'java',
environment: 'onprem',
addAgents: false,
addPolicyOnCloudAgent: false,
apmAgent: 'java',
onPrem: true,
hasFleetPoliciesWithApmIntegration: false,
hasCloudPolicyWithApmIntegration: false,
};

export default {
title: 'app/Tutorial/AgentConfig',
component: TutorialConfigAgent,
argTypes: {
variantId: {
apmAgent: {
control: {
type: 'select',
options: [
Expand All @@ -104,14 +106,14 @@ export default {
],
},
},
environment: {
control: { type: 'select', options: ['onprem', 'cloud'] },
onPrem: {
control: { type: 'boolean', options: [true, false] },
},
addAgents: {
control: { type: 'inline-radio', options: [true, false] },
hasFleetPoliciesWithApmIntegration: {
control: { type: 'boolean', options: [true, false] },
},
addPolicyOnCloudAgent: {
control: { type: 'inline-radio', options: [true, false] },
hasCloudPolicyWithApmIntegration: {
control: { type: 'boolean', options: [true, false] },
},
},
};
Loading

0 comments on commit cb93335

Please sign in to comment.