From 4b6b80ece3585ba9e4f981fa55d94cda782882c5 Mon Sep 17 00:00:00 2001 From: atu Date: Thu, 6 Aug 2020 15:34:16 -0700 Subject: [PATCH] extra components into ts --- ...containersPanel.js => containersPanel.tsx} | 9 +++-- client/src/components/{menu.js => menu.tsx} | 40 ++++++++++++++----- 2 files changed, 34 insertions(+), 15 deletions(-) rename client/src/components/{containersPanel.js => containersPanel.tsx} (89%) rename client/src/components/{menu.js => menu.tsx} (87%) diff --git a/client/src/components/containersPanel.js b/client/src/components/containersPanel.tsx similarity index 89% rename from client/src/components/containersPanel.js rename to client/src/components/containersPanel.tsx index 43c85d1..7ee15c1 100644 --- a/client/src/components/containersPanel.js +++ b/client/src/components/containersPanel.tsx @@ -1,8 +1,9 @@ import _ from 'lodash'; import React, {Fragment} from 'react'; import Field from './field'; +import {TODO} from "../utils/types"; -const ContainersPanel = ({spec}) => ( +const ContainersPanel = ({spec}: {spec: TODO}) => ( <> {spec && _.map(spec.containers, item => ( @@ -18,7 +19,7 @@ const ContainersPanel = ({spec}) => ( {item.env && ( - {item.env.map(x => ( + {item.env.map((x: TODO) => (
{x.name}: {getVariableValue(x)}
@@ -42,7 +43,7 @@ const ContainersPanel = ({spec}) => ( {item.ports && ( - {item.ports.map((x, i) => ( + {item.ports.map((x: TODO, i: number) => (
{[x.name, x.containerPort, x.hostPort, x.protocol].filter(y => !!y).join(' • ')}
@@ -55,7 +56,7 @@ const ContainersPanel = ({spec}) => ( ); -function getVariableValue(item) { +function getVariableValue(item: TODO) { if (item.value) return item.value; if (!item.valueFrom) return null; if (item.valueFrom.secretKeyRef) return item.valueFrom.secretKeyRef.key; diff --git a/client/src/components/menu.js b/client/src/components/menu.tsx similarity index 87% rename from client/src/components/menu.js rename to client/src/components/menu.tsx index fb49163..46273e9 100644 --- a/client/src/components/menu.js +++ b/client/src/components/menu.tsx @@ -7,9 +7,27 @@ import api from '../services/api'; import {addHandler} from '../services/auth'; import ResourceSvg from '../art/resourceSvg'; import AddSvg from '../art/addSvg'; +import {TODO} from "../utils/types"; +interface MenuProps { + onClick: TODO; + toggled: boolean; +} -export default class Menu extends Base { +interface MenuStates { + rules: TODO[]; + showAdd: boolean; +} + +interface MenuItemProps { + path: string; + title: string; + resource: string; + onClick: TODO; + additionalPaths?: string[]; +} + +export default class Menu extends Base { componentDidMount() { this.getRules(); @@ -29,7 +47,7 @@ export default class Menu extends Base { return ( <> -
+