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

[APM] Add AWS and Azure icons for additional services #101901

Merged
merged 3 commits into from
Jun 14, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

import { maybe } from '../../../../common/utils/maybe';
import awsIcon from './icons/aws.svg';
import cassandraIcon from './icons/cassandra.svg';
import databaseIcon from './icons/database.svg';
import defaultIcon from './icons/default.svg';
Expand All @@ -33,12 +32,14 @@ const defaultTypeIcons: { [key: string]: string } = {
resource: globeIcon,
};

const typeIcons: { [key: string]: { [key: string]: string } } = {
export const typeIcons: { [type: string]: { [subType: string]: string } } = {
aws: {
servicename: awsIcon,
servicename: 'logoAWS',
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe since you're repeating logoAWS and logoAzure multiple times, would be a good idea to create a constant for them.

Suggested change
servicename: 'logoAWS',
servicename: LOGO_AWS,

Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to invert it like:

Suggested change
servicename: 'logoAWS',
servicename: {
aws: LOGO_AWS
}

So we'd call <SpanIcon type="servicename" subtype="aws" />

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the better solution is that EUI exports this as a constant, so it can be used like:

servicename: ICONS.AWS

I've created an issue for this in the eui repo elastic/eui#4877

},
db: {
cassandra: cassandraIcon,
cosmosdb: 'logoAzure',
dynamodb: 'logoAWS',
elasticsearch: elasticsearchIcon,
mongodb: mongodbIcon,
mysql: mysqlIcon,
Expand All @@ -51,8 +52,18 @@ const typeIcons: { [key: string]: { [key: string]: string } } = {
websocket: websocketIcon,
},
messaging: {
azurequeue: 'logoAzure',
azureservicebus: 'logoAzure',
jms: javaIcon,
kafka: kafkaIcon,
sns: 'logoAWS',
sqs: 'logoAWS',
},
storage: {
azureblob: 'logoAzure',
azurefile: 'logoAzure',
azuretable: 'logoAzure',
s3: 'logoAWS',
},
template: {
handlebars: handlebarsIcon,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* 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.
*/

import {
EuiFlexGrid,
EuiFlexItem,
EuiCopy,
EuiPanel,
EuiSpacer,
EuiCodeBlock,
} from '@elastic/eui';
import React from 'react';
import { storiesOf } from '@storybook/react';
import { EuiThemeProvider } from '../../../../../../../src/plugins/kibana_react/common';
import { SpanIcon } from './index';
import { typeIcons } from './get_span_icon';

const types = Object.keys(typeIcons);

storiesOf('shared/span_icon/span_icon', module)
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

From the Cytoscape story, I can't tell if we are show-casing the span icons (in which case it should just be deleted), or it's meant to show how it looks in the service map, in which case we should keep it.

It also looks like it's showing the agent icons via iconForNode so seems like it's covering more than the pure "span_icons" story.

Perhaps we can trim the cytoscape story down to not include every icon but just a few important ones.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, I see now that's it's simply a grid, similar to the one I made

image

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, notice how "aws" is empty. It works under the story I added:
image

There seems to be a bug here. Interesting!

.addDecorator((storyFn) => <EuiThemeProvider>{storyFn()}</EuiThemeProvider>)
.add(
'Span icon',
() => {
return (
<>
<EuiCodeBlock language="html" isCopyable paddingSize="m">
{'<SpanIcon type="db" subtype="cassandra" />'}
</EuiCodeBlock>

<EuiSpacer />
<EuiFlexGrid direction="column" columns={3}>
{types.map((type) => {
const subTypes = Object.keys(typeIcons[type]);
return (
<>
{subTypes.map((subType) => {
const id = `${type}.${subType}`;
return (
<EuiFlexItem key={id}>
<EuiCopy
display="block"
textToCopy={id}
afterMessage={`${id} copied`}
>
{(copy) => (
<EuiPanel
hasShadow={false}
hasBorder={false}
onClick={copy}
paddingSize="s"
>
<SpanIcon type={type} subType={subType} /> &emsp;{' '}
<small>{id}</small>
</EuiPanel>
)}
</EuiCopy>
</EuiFlexItem>
);
})}
</>
);
})}
</EuiFlexGrid>
</>
);
},
{}
);