Skip to content

Commit

Permalink
refactor: icons use named exports (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
manusa authored May 10, 2024
1 parent 7258282 commit 655aebc
Show file tree
Hide file tree
Showing 36 changed files with 191 additions and 238 deletions.
79 changes: 53 additions & 26 deletions src/main/frontend/src/components/Link.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,33 @@
import React from 'react';
import {Link as OriginalRouterLink} from 'react-router-dom';
import {uid} from '../metadata';
import {Icon} from './';
import i from './icons';
import {
Icon,
EndpointsIcon,
ClusterRoleIcon,
ClusterRoleBindingIcon,
ConfigMapIcon,
CronJobIcon,
CustomResourceDefinitionIcon,
DaemonSetIcon,
DeploymentIcon,
DeploymentConfigIcon,
HorizontalPodAutoscalerIcon,
IngressIcon,
JobIcon,
NamespaceIcon,
NodeIcon,
PersistentVolumeIcon,
PersistentVolumeClaimIcon,
PodIcon,
ReplicaSetIcon,
RoleIcon,
RouteIcon,
SecretIcon,
ServiceIcon,
ServiceAccountIcon,
StatefulSetIcon
} from './';

const variants = {
none: '',
Expand Down Expand Up @@ -95,64 +120,66 @@ Link.ResourceLink = ({
);

Link.ClusterRole = ({...props}) => (
<Link.ResourceLink Icon={i.ClusterRole} {...props} />
<Link.ResourceLink Icon={ClusterRoleIcon} {...props} />
);
Link.ClusterRoleBinding = ({...props}) => (
<Link.ResourceLink Icon={i.ClusterRoleBinding} {...props} />
<Link.ResourceLink Icon={ClusterRoleBindingIcon} {...props} />
);
Link.ConfigMap = ({...props}) => (
<Link.ResourceLink Icon={i.ConfigMap} {...props} />
<Link.ResourceLink Icon={ConfigMapIcon} {...props} />
);
Link.CronJob = ({...props}) => (
<Link.ResourceLink Icon={i.CronJob} {...props} />
<Link.ResourceLink Icon={CronJobIcon} {...props} />
);
Link.CustomResourceDefinition = ({...props}) => (
<Link.ResourceLink Icon={i.CustomResourceDefinition} {...props} />
<Link.ResourceLink Icon={CustomResourceDefinitionIcon} {...props} />
);
Link.DaemonSet = ({...props}) => (
<Link.ResourceLink Icon={i.DaemonSet} {...props} />
<Link.ResourceLink Icon={DaemonSetIcon} {...props} />
);
Link.DeploymentConfig = ({...props}) => (
<Link.ResourceLink Icon={i.DeploymentConfig} {...props} />
<Link.ResourceLink Icon={DeploymentConfigIcon} {...props} />
);
Link.Deployment = ({...props}) => (
<Link.ResourceLink Icon={i.Deployment} {...props} />
<Link.ResourceLink Icon={DeploymentIcon} {...props} />
);
Link.Endpoints = ({...props}) => (
<Link.ResourceLink Icon={i.Endpoints} {...props} />
<Link.ResourceLink Icon={EndpointsIcon} {...props} />
);
Link.HorizontalPodAutoscaler = ({...props}) => (
<Link.ResourceLink Icon={i.HorizontalPodAutoscaler} {...props} />
<Link.ResourceLink Icon={HorizontalPodAutoscalerIcon} {...props} />
);
Link.Ingress = ({...props}) => (
<Link.ResourceLink Icon={i.Ingress} {...props} />
<Link.ResourceLink Icon={IngressIcon} {...props} />
);
Link.Job = ({...props}) => <Link.ResourceLink Icon={i.Job} {...props} />;
Link.Job = ({...props}) => <Link.ResourceLink Icon={JobIcon} {...props} />;
Link.Namespace = ({...props}) => (
<Link.ResourceLink Icon={i.Namespace} {...props} />
<Link.ResourceLink Icon={NamespaceIcon} {...props} />
);
Link.Node = ({...props}) => <Link.ResourceLink Icon={i.Node} {...props} />;
Link.Node = ({...props}) => <Link.ResourceLink Icon={NodeIcon} {...props} />;
Link.PersistentVolume = ({...props}) => (
<Link.ResourceLink Icon={i.PersistentVolume} {...props} />
<Link.ResourceLink Icon={PersistentVolumeIcon} {...props} />
);
Link.PersistentVolumeClaim = ({...props}) => (
<Link.ResourceLink Icon={i.PersistentVolumeClaim} {...props} />
<Link.ResourceLink Icon={PersistentVolumeClaimIcon} {...props} />
);
Link.Pod = ({...props}) => <Link.ResourceLink Icon={i.Pod} {...props} />;
Link.Pod = ({...props}) => <Link.ResourceLink Icon={PodIcon} {...props} />;
Link.ReplicationController = ({...props}) => (
<Link.ResourceLink Icon={i.ReplicaSet} {...props} />
<Link.ResourceLink Icon={ReplicaSetIcon} {...props} />
);
Link.Role = ({...props}) => <Link.ResourceLink Icon={RoleIcon} {...props} />;
Link.Route = ({...props}) => <Link.ResourceLink Icon={RouteIcon} {...props} />;
Link.Secret = ({...props}) => (
<Link.ResourceLink Icon={SecretIcon} {...props} />
);
Link.Role = ({...props}) => <Link.ResourceLink Icon={i.Role} {...props} />;
Link.Route = ({...props}) => <Link.ResourceLink Icon={i.Route} {...props} />;
Link.Secret = ({...props}) => <Link.ResourceLink Icon={i.Secret} {...props} />;
Link.Service = ({...props}) => (
<Link.ResourceLink Icon={i.Service} {...props} />
<Link.ResourceLink Icon={ServiceIcon} {...props} />
);
Link.ServiceAccount = ({...props}) => (
<Link.ResourceLink Icon={i.ServiceAccount} {...props} />
<Link.ResourceLink Icon={ServiceAccountIcon} {...props} />
);
Link.StatefulSet = ({...props}) => (
<Link.ResourceLink Icon={i.StatefulSet} {...props} />
<Link.ResourceLink Icon={StatefulSetIcon} {...props} />
);

Link.EditLink = ({path, resource, ...props}) => (
Expand Down
5 changes: 2 additions & 3 deletions src/main/frontend/src/components/StatusCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
*/
import React from 'react';
import {useNavigate} from 'react-router-dom';
import {Tooltip} from './';
import icons from '../components/icons';
import {Tooltip, KubernetesIcon} from './';

const Progress = ({
bg = 'bg-orange-400',
Expand Down Expand Up @@ -50,7 +49,7 @@ const Progress = ({

export const StatusCard = ({
header,
Icon = icons.k8s,
Icon = KubernetesIcon,
ready = 0,
succeeded = 0,
total = 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
import React from 'react';

const ClusterRoleBinding = ({...props}) => (
export const ClusterRoleBindingIcon = ({...props}) => (
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18.035 17.5' {...props}>
<path
d='M8.958.463a1.136 1.126 0 00-.435.11l-5.94 2.838a1.136 1.126 0 00-.614.764L.504 10.55a1.136 1.126 0 00.154.864 1.136 1.126 0 00.064.09l4.112 5.111a1.136 1.126 0 00.888.424l6.592-.001a1.136 1.126 0 00.888-.424l4.11-5.112a1.136 1.126 0 00.22-.953l-1.468-6.375a1.136 1.126 0 00-.615-.764L9.51.573a1.136 1.126 0 00-.55-.11z'
Expand Down Expand Up @@ -45,5 +45,3 @@ const ClusterRoleBinding = ({...props}) => (
/>
</svg>
);

export default ClusterRoleBinding;
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
import React from 'react';

const ClusterRole = ({...props}) => (
export const ClusterRoleIcon = ({...props}) => (
<svg viewBox='0 0 18.035 17.5' {...props}>
<path
d='M8.958.463a1.136 1.126 0 00-.435.11l-5.94 2.838a1.136 1.126 0 00-.614.764L.504 10.55a1.136 1.126 0 00.154.864 1.136 1.126 0 00.064.09l4.112 5.111a1.136 1.126 0 00.888.424l6.592-.001a1.136 1.126 0 00.888-.424l4.11-5.112a1.136 1.126 0 00.22-.953l-1.468-6.375a1.136 1.126 0 00-.615-.764L9.51.573a1.136 1.126 0 00-.55-.11z'
Expand Down Expand Up @@ -46,5 +46,3 @@ const ClusterRole = ({...props}) => (
</g>
</svg>
);

export default ClusterRole;
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
import React from 'react';

const ConfigMap = ({...props}) => (
export const ConfigMapIcon = ({...props}) => (
<svg viewBox='0 0 18.035 17.5' {...props}>
<path
d='M8.958.463a1.136 1.126 0 00-.435.11l-5.94 2.838a1.136 1.126 0 00-.614.764L.504 10.55a1.136 1.126 0 00.154.864 1.136 1.126 0 00.064.09l4.112 5.111a1.136 1.126 0 00.888.424l6.592-.001a1.136 1.126 0 00.888-.424l4.11-5.112a1.136 1.126 0 00.22-.953l-1.468-6.375a1.136 1.126 0 00-.615-.764L9.51.573a1.136 1.126 0 00-.55-.11z'
Expand Down Expand Up @@ -67,5 +67,3 @@ const ConfigMap = ({...props}) => (
</g>
</svg>
);

export default ConfigMap;
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
import React from 'react';

const CronJob = ({...props}) => (
export const CronJobIcon = ({...props}) => (
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18.035 17.5' {...props}>
<path
d='M8.958.463a1.136 1.126 0 00-.435.11l-5.94 2.838a1.136 1.126 0 00-.614.764L.504 10.55a1.136 1.126 0 00.154.864 1.136 1.126 0 00.064.09l4.112 5.111a1.136 1.126 0 00.888.424l6.592-.001a1.136 1.126 0 00.888-.424l4.11-5.112a1.136 1.126 0 00.22-.953l-1.468-6.375a1.136 1.126 0 00-.615-.764L9.51.573a1.136 1.126 0 00-.55-.11z'
Expand Down Expand Up @@ -49,5 +49,3 @@ const CronJob = ({...props}) => (
</g>
</svg>
);

export default CronJob;
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
import React from 'react';

const CustomResourceDefinition = ({...props}) => (
export const CustomResourceDefinitionIcon = ({...props}) => (
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18.035 17.5' {...props}>
<path
d='M8.958.463a1.136 1.126 0 00-.435.11l-5.94 2.838a1.136 1.126 0 00-.614.764L.504 10.55a1.136 1.126 0 00.154.864 1.136 1.126 0 00.064.09l4.112 5.111a1.136 1.126 0 00.888.424l6.592-.001a1.136 1.126 0 00.888-.424l4.11-5.112a1.136 1.126 0 00.22-.953l-1.468-6.375a1.136 1.126 0 00-.615-.764L9.51.573a1.136 1.126 0 00-.55-.11z'
Expand Down Expand Up @@ -45,5 +45,3 @@ const CustomResourceDefinition = ({...props}) => (
/>
</svg>
);

export default CustomResourceDefinition;
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
import React from 'react';

const DaemonSet = ({...props}) => (
export const DaemonSetIcon = ({...props}) => (
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18.035 17.5' {...props}>
<path
d='M8.958.463a1.136 1.126 0 00-.435.11l-5.94 2.838a1.136 1.126 0 00-.614.764L.504 10.55a1.136 1.126 0 00.154.864 1.136 1.126 0 00.064.09l4.112 5.111a1.136 1.126 0 00.888.424l6.592-.001a1.136 1.126 0 00.888-.424l4.11-5.112a1.136 1.126 0 00.22-.953l-1.468-6.375a1.136 1.126 0 00-.615-.764L9.51.573a1.136 1.126 0 00-.55-.11z'
Expand Down Expand Up @@ -81,5 +81,3 @@ const DaemonSet = ({...props}) => (
</g>
</svg>
);

export default DaemonSet;
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
import React from 'react';

const Deployment = ({kubernetesColor = '#326ce5', ...props}) => (
export const DeploymentIcon = ({kubernetesColor = '#326ce5', ...props}) => (
<svg viewBox='0 0 18.035 17.5' {...props}>
<path
d='M8.958.463a1.136 1.126 0 00-.435.11l-5.94 2.838a1.136 1.126 0 00-.614.764L.504 10.55a1.136 1.126 0 00.154.864 1.136 1.126 0 00.064.09l4.112 5.111a1.136 1.126 0 00.888.424l6.592-.001a1.136 1.126 0 00.888-.424l4.11-5.112a1.136 1.126 0 00.22-.953l-1.468-6.375a1.136 1.126 0 00-.615-.764L9.51.573a1.136 1.126 0 00-.55-.11z'
Expand Down Expand Up @@ -45,5 +45,3 @@ const Deployment = ({kubernetesColor = '#326ce5', ...props}) => (
</g>
</svg>
);

export default Deployment;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';

export const Endpoints = props => (
export const EndpointsIcon = props => (
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18.035 17.5' {...props}>
<path
d='M-6.85 4.272a1.12 1.11 0 0 0-.428.109l-5.852 2.796a1.12 1.11 0 0 0-.606.753l-1.444 6.282a1.12 1.11 0 0 0 .152.85 1.12 1.11 0 0 0 .064.089l4.05 5.037a1.12 1.11 0 0 0 .876.417l6.496-.001a1.12 1.11 0 0 0 .875-.417l4.049-5.038a1.12 1.11 0 0 0 .216-.939L.152 7.93a1.12 1.11 0 0 0-.605-.753L-6.307 4.38a1.12 1.11 0 0 0-.542-.109Z'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
import React from 'react';

const HorizontalPodAutoscaler = ({...props}) => (
export const HorizontalPodAutoscalerIcon = ({...props}) => (
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18.035 17.5' {...props}>
<path
d='M8.958.463a1.136 1.126 0 00-.435.11l-5.94 2.838a1.136 1.126 0 00-.614.764L.504 10.55a1.136 1.126 0 00.154.864 1.136 1.126 0 00.064.09l4.112 5.111a1.136 1.126 0 00.888.424l6.592-.001a1.136 1.126 0 00.888-.424l4.11-5.112a1.136 1.126 0 00.22-.953l-1.468-6.375a1.136 1.126 0 00-.615-.764L9.51.573a1.136 1.126 0 00-.55-.11z'
Expand Down Expand Up @@ -51,5 +51,3 @@ const HorizontalPodAutoscaler = ({...props}) => (
</g>
</svg>
);

export default HorizontalPodAutoscaler;
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
import React from 'react';

const Ingress = ({kubernetesColor = '#326ce5', ...props}) => (
export const IngressIcon = ({kubernetesColor = '#326ce5', ...props}) => (
<svg viewBox='0 0 18.035 17.5' {...props}>
<path
d='M8.958.463a1.136 1.126 0 00-.435.11l-5.94 2.838a1.136 1.126 0 00-.614.764L.504 10.55a1.136 1.126 0 00.154.864 1.136 1.126 0 00.064.09l4.112 5.111a1.136 1.126 0 00.888.424l6.592-.001a1.136 1.126 0 00.888-.424l4.11-5.112a1.136 1.126 0 00.22-.953l-1.468-6.375a1.136 1.126 0 00-.615-.764L9.51.573a1.136 1.126 0 00-.55-.11z'
Expand Down Expand Up @@ -46,5 +46,3 @@ const Ingress = ({kubernetesColor = '#326ce5', ...props}) => (
/>
</svg>
);

export default Ingress;
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
import React from 'react';

const Job = ({...props}) => (
export const JobIcon = ({...props}) => (
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18.035 17.5' {...props}>
<path
d='M8.958.463a1.136 1.126 0 00-.435.11l-5.94 2.838a1.136 1.126 0 00-.614.764L.504 10.55a1.136 1.126 0 00.154.864 1.136 1.126 0 00.064.09l4.112 5.111a1.136 1.126 0 00.888.424l6.592-.001a1.136 1.126 0 00.888-.424l4.11-5.112a1.136 1.126 0 00.22-.953l-1.468-6.375a1.136 1.126 0 00-.615-.764L9.51.573a1.136 1.126 0 00-.55-.11z'
Expand Down Expand Up @@ -44,5 +44,3 @@ const Job = ({...props}) => (
</g>
</svg>
);

export default Job;

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
import React from 'react';

const Minikube = ({...props}) => (
export const MinikubeIcon = ({...props}) => (
<svg viewBox='0 0 702 683' {...props}>
<defs>
<path id='prefix__a' d='M701.06 684.263V1.593H0v682.67z' />
Expand Down Expand Up @@ -47,5 +47,3 @@ const Minikube = ({...props}) => (
</g>
</svg>
);

export default Minikube;
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
import React from 'react';

const Namespace = ({kubernetesColor = '#326ce5', ...props}) => (
export const NamespaceIcon = ({kubernetesColor = '#326ce5', ...props}) => (
<svg viewBox='0 0 18.035 17.5' {...props}>
<path
d='M8.958.463a1.136 1.126 0 00-.435.11l-5.94 2.838a1.136 1.126 0 00-.614.764L.504 10.55a1.136 1.126 0 00.154.864 1.136 1.126 0 00.064.09l4.112 5.111a1.136 1.126 0 00.888.424l6.592-.001a1.136 1.126 0 00.888-.424l4.11-5.112a1.136 1.126 0 00.22-.953l-1.468-6.375a1.136 1.126 0 00-.615-.764L9.51.573a1.136 1.126 0 00-.55-.11z'
Expand Down Expand Up @@ -51,5 +51,3 @@ const Namespace = ({kubernetesColor = '#326ce5', ...props}) => (
/>
</svg>
);

export default Namespace;
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
import React from 'react';

const Node = ({...props}) => (
export const NodeIcon = ({...props}) => (
<svg viewBox='0 0 18.035 17.5' {...props}>
<path
d='M8.958.463a1.136 1.126 0 00-.435.11l-5.94 2.838a1.136 1.126 0 00-.614.764L.504 10.55a1.136 1.126 0 00.154.864 1.136 1.126 0 00.064.09l4.112 5.111a1.136 1.126 0 00.888.424l6.592-.001a1.136 1.126 0 00.888-.424l4.11-5.112a1.136 1.126 0 00.22-.953l-1.468-6.375a1.136 1.126 0 00-.615-.764L9.51.573a1.136 1.126 0 00-.55-.11z'
Expand Down Expand Up @@ -45,5 +45,3 @@ const Node = ({...props}) => (
/>
</svg>
);

export default Node;
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
import React from 'react';

const OpenShift = ({...props}) => (
export const OpenShiftIcon = ({...props}) => (
<svg
id='prefix__svg45453'
xmlns='http://www.w3.org/2000/svg'
Expand Down Expand Up @@ -57,5 +57,3 @@ const OpenShift = ({...props}) => (
/>
</svg>
);

export default OpenShift;
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
import React from 'react';

const PersistentVolumeClaim = ({...props}) => (
export const PersistentVolumeClaimIcon = ({...props}) => (
<svg viewBox='0 0 18.035 17.5' {...props}>
<path
d='M8.958.463a1.136 1.126 0 00-.435.11l-5.94 2.838a1.136 1.126 0 00-.614.764L.504 10.55a1.136 1.126 0 00.154.864 1.136 1.126 0 00.064.09l4.112 5.111a1.136 1.126 0 00.888.424l6.592-.001a1.136 1.126 0 00.888-.424l4.11-5.112a1.136 1.126 0 00.22-.953l-1.468-6.375a1.136 1.126 0 00-.615-.764L9.51.573a1.136 1.126 0 00-.55-.11z'
Expand Down Expand Up @@ -50,5 +50,3 @@ const PersistentVolumeClaim = ({...props}) => (
/>
</svg>
);

export default PersistentVolumeClaim;
Loading

0 comments on commit 655aebc

Please sign in to comment.