Skip to content

Commit

Permalink
Refactor to use new top-level PackageIcon component (#60628) (#60671)
Browse files Browse the repository at this point in the history
- removes PackageIcon from EPM section
- refactors code to use new top-level `PackageIcon` component
  • Loading branch information
paul-tavares authored Mar 20, 2020
1 parent 78c0c4d commit 546ad07
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const PackageIcon: React.FunctionComponent<{

const usePackageIcon = (packageName: string, version?: string, icons?: Package['icons']) => {
const { toImage } = useLinks();
const [iconType, setIconType] = useState<string>('');
const [iconType, setIconType] = useState<string>(''); // FIXME: use `empty` icon during initialization - see: https://github.com/elastic/kibana/issues/60622
const pkgKey = `${packageName}-${version ?? ''}`;

// Generates an icon path or Eui Icon name based on an icon list from the package
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
} from '@elastic/eui';
import { WithHeaderLayout } from '../../../../layouts';
import { AgentConfig, PackageInfo } from '../../../../types';
import { PackageIcon } from '../../../epm/components';
import { PackageIcon } from '../../../../components/package_icon';
import { CreateDatasourceFrom, CreateDatasourceStep } from '../types';
import { CreateDatasourceStepsNavigation } from './navigation';

Expand Down Expand Up @@ -94,7 +94,12 @@ export const CreateDatasourcePageLayout: React.FunctionComponent<{
<EuiDescriptionListDescription>
<EuiFlexGroup alignItems="center" gutterSize="s">
<EuiFlexItem grow={false}>
<PackageIcon packageName={packageInfo?.name || ''} size="m" />
<PackageIcon
packageName={packageInfo?.name || ''}
version={packageInfo?.version || ''}
icons={packageInfo?.icons}
size="m"
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
{packageInfo?.title || packageInfo?.name || '-'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
import { Error } from '../../../components';
import { AgentConfig, PackageInfo } from '../../../types';
import { useGetOneAgentConfig, useGetPackages, sendGetPackageInfoByKey } from '../../../hooks';
import { PackageIcon } from '../../epm/components';
import { PackageIcon } from '../../../components/package_icon';

export const StepSelectPackage: React.FunctionComponent<{
agentConfigId: string;
Expand Down Expand Up @@ -125,12 +125,12 @@ export const StepSelectPackage: React.FunctionComponent<{
allowExclusions={false}
singleSelection={true}
isLoading={isPackagesLoading}
options={packages.map(({ title, name, version }) => {
options={packages.map(({ title, name, version, icons }) => {
const pkgkey = `${name}-${version}`;
return {
label: title || name,
key: pkgkey,
prepend: <PackageIcon packageName={name} size="m" />,
prepend: <PackageIcon packageName={name} version={version} icons={icons} size="m" />,
checked: selectedPkgKey === pkgkey ? 'on' : undefined,
};
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

export { PackageIcon } from './package_icon';
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import styled from 'styled-components';
import { EuiCard } from '@elastic/eui';
import { PackageInfo, PackageListItem } from '../../../types';
import { useLinks } from '../hooks';
import { PackageIcon } from './package_icon';
import { PackageIcon } from '../../../components/package_icon';

export interface BadgeProps {
showInstalledBadge?: boolean;
Expand Down Expand Up @@ -40,7 +40,7 @@ export function PackageCard({
layout="horizontal"
title={title || ''}
description={description}
icon={<PackageIcon icons={icons} packageName={name} size="l" />}
icon={<PackageIcon icons={icons} packageName={name} version={version} size="l" />}
href={url}
/>
);
Expand Down

This file was deleted.

0 comments on commit 546ad07

Please sign in to comment.