diff --git a/src/main/frontend/src/App.js b/src/main/frontend/src/App.js index dde2698..6716899 100644 --- a/src/main/frontend/src/App.js +++ b/src/main/frontend/src/App.js @@ -78,7 +78,13 @@ import { PersistentVolumesEditPage, PersistentVolumesDetailPage } from './persistentvolumes'; -import pods from './pods'; +import { + PodsPage, + PodsDetailPage, + PodsEditPage, + PodsExecPage, + PodsLogsPage +} from './pods'; import { ReplicationControllersPage, ReplicationControllersDetailPage, @@ -312,11 +318,11 @@ export const App = () => { path='/persistentvolumes/:uid/edit' element={} /> - } /> - } /> - } /> - } /> - } /> + } /> + } /> + } /> + } /> + } /> { responsiveClassName={cardResponsiveClass} className={cardClass} /> - diff --git a/src/main/frontend/src/daemonsets/DaemonSetsDetailPage.js b/src/main/frontend/src/daemonsets/DaemonSetsDetailPage.js index a6bed19..6668548 100644 --- a/src/main/frontend/src/daemonsets/DaemonSetsDetailPage.js +++ b/src/main/frontend/src/daemonsets/DaemonSetsDetailPage.js @@ -20,7 +20,7 @@ import {withParams} from '../router'; import {Details, uid} from '../metadata'; import {ContainerList} from '../containers'; import {api, selectors} from './'; -import pods from '../pods'; +import {PodsList} from '../pods'; import {Card, Form, Icon, Link} from '../components'; import {ResourceDetailPage} from '../dashboard'; @@ -71,7 +71,7 @@ export const DaemonSetsDetailPage = withParams( className='mt-2' containers={selectors.containers(daemonSet)} /> - - - { @@ -25,7 +25,7 @@ export const EndpointsPage = () => { return ( - + ); }; diff --git a/src/main/frontend/src/endpoints/index.js b/src/main/frontend/src/endpoints/index.js index 3168462..88abba5 100644 --- a/src/main/frontend/src/endpoints/index.js +++ b/src/main/frontend/src/endpoints/index.js @@ -18,4 +18,4 @@ export * as api from './api'; export * as selectors from './selectors'; export {EndpointsDetailPage} from './EndpointsDetailPage'; export {EndpointsPage} from './EndpointsPage'; -export {List} from './List'; +export {List as EndpointsList} from './List'; diff --git a/src/main/frontend/src/jobs/JobsDetailPage.js b/src/main/frontend/src/jobs/JobsDetailPage.js index d969476..db2c05e 100644 --- a/src/main/frontend/src/jobs/JobsDetailPage.js +++ b/src/main/frontend/src/jobs/JobsDetailPage.js @@ -20,7 +20,7 @@ import {withParams} from '../router'; import {Details, namespace, uid} from '../metadata'; import {api, selectors} from './'; import {ContainerList} from '../containers'; -import pods from '../pods'; +import {PodsList} from '../pods'; import {Card, Form} from '../components'; import {DashboardPage, ResourceDetailPage} from '../dashboard'; @@ -74,7 +74,7 @@ export const JobsDetailPage = withParams( className='mt-2' containers={selectors.containers(job)} /> - { const nodeName = name(node); - const podsForNode = Object.values(p.selectors.podsBy(pods, {nodeName})); + const podsForNode = Object.values(podSelectors.podsBy(pods, {nodeName})); const requests = podsForNode - .flatMap(p.selectors.containers) + .flatMap(podSelectors.containers) .map(c => c.resources.requests ?? {}); const requestedCpu = requests .map(r => r.cpu ?? 0) @@ -130,7 +130,7 @@ export const NodesDetailPage = withParams( } > - { - const deletePod = pod => async () => await p.api.delete(pod); + const deletePod = pod => async () => await api.deletePod(pod); return pods.sort(sortByCreationTimeStamp).map(pod => ( { - - {p.selectors.statusPhase(pod)} + + {selectors.statusPhase(pod)} - {p.selectors.restartCount(pod)} + {selectors.restartCount(pod)} { )); }; -const List = ({ - resources, - nodeName, - ownerUids, - ownerUid, - crudDelete, - loadedResources, - ...properties -}) => ( - - - -); - -List.propTypes = { - nodeName: PropTypes.string, - ownerUids: PropTypes.arrayOf(PropTypes.string), - namespace: PropTypes.string -}; - const mergeProps = (stateProps, dispatchProps, ownProps) => ({ ...stateProps, ...dispatchProps, ...ownProps, - resources: Object.values(p.selectors.podsBy(stateProps.resources, ownProps)) + resources: Object.values(selectors.podsBy(stateProps.resources, ownProps)) }); -export default connect( +export const List = connect( ResourceList.mapStateToProps('pods'), null, mergeProps -)(List); +)( + ({ + resources, + nodeName, + ownerUids, + ownerUid, + crudDelete, + loadedResources, + ...properties + }) => ( + + + + ) +); + +List.propTypes = { + nodeName: PropTypes.string, + ownerUids: PropTypes.arrayOf(PropTypes.string), + namespace: PropTypes.string +}; diff --git a/src/main/frontend/src/pods/PodsCard.js b/src/main/frontend/src/pods/PodsCard.js index 2681a82..bce3bb9 100644 --- a/src/main/frontend/src/pods/PodsCard.js +++ b/src/main/frontend/src/pods/PodsCard.js @@ -18,12 +18,16 @@ import React from 'react'; import {connect} from 'react-redux'; import {StatusCard} from '../components'; import icons from '../components/icons'; -import podsModule from './'; +import {selectors} from './'; -const PodsCard = ({pods, ...properties}) => { +const mapStateToProps = ({pods}) => ({ + pods +}); + +export const PodsCard = connect(mapStateToProps)(({pods, ...properties}) => { const podObjects = Object.values(pods); - const ready = podsModule.selectors.readyCount(podObjects); - const succeeded = podsModule.selectors.succeededCount(podObjects); + const ready = selectors.readyCount(podObjects); + const succeeded = selectors.succeededCount(podObjects); const total = podObjects.length; return ( { {...properties} /> ); -}; - -const mapStateToProps = ({pods}) => ({ - pods }); - -export default connect(mapStateToProps)(PodsCard); diff --git a/src/main/frontend/src/pods/PodsDetailPage.js b/src/main/frontend/src/pods/PodsDetailPage.js index 8f33d6b..bce3038 100644 --- a/src/main/frontend/src/pods/PodsDetailPage.js +++ b/src/main/frontend/src/pods/PodsDetailPage.js @@ -22,7 +22,7 @@ import {ContainerList} from '../containers'; import {bytesToHumanReadable, podMetrics} from '../metrics'; import {Card, Form, Icon, Link} from '../components'; import {ResourceDetailPage} from '../dashboard'; -import p from './'; +import {api, selectors, StatusIcon} from './'; const useMetrics = pod => { const [metrics, setMetrics] = useState(null); @@ -31,7 +31,7 @@ const useMetrics = pod => { if (!timeoutHandle && pod) { const updateMetrics = async () => { try { - const metrics = await p.api.metrics(pod); + const metrics = await api.metrics(pod); setMetrics(metrics); } catch (e) { setMetrics(null); @@ -63,77 +63,6 @@ const ActionLink = ({to, title, stylePrefix, icon}) => ( ); -const PodsDetailPage = ({pod}) => { - const metrics = useMetrics(pod); - const currentPodMetrics = metrics && podMetrics(metrics); - return ( - - - - > - } - body={ - - - - - {p.selectors.nodeName(pod)} - - - - - {p.selectors.statusPhase(pod)} - - - {p.selectors.restartPolicy(pod)} - - {p.selectors.statusPodIP(pod)} - {currentPodMetrics && ( - <> - - - {currentPodMetrics.totalCpu().toFixed(3)} - - - - {bytesToHumanReadable(currentPodMetrics.totalMemory())} - - > - )} - - } - > - - - ); -}; - const mapStateToProps = ({pods}) => ({ pods }); @@ -145,6 +74,79 @@ const mergeProps = (stateProps, dispatchProps, ownProps) => ({ pod: stateProps.pods[ownProps.params.uid] }); -export default withParams( - connect(mapStateToProps, null, mergeProps)(PodsDetailPage) +export const PodsDetailPage = withParams( + connect( + mapStateToProps, + null, + mergeProps + )(({pod}) => { + const metrics = useMetrics(pod); + const currentPodMetrics = metrics && podMetrics(metrics); + return ( + + + + > + } + body={ + + + + + {selectors.nodeName(pod)} + + + + + {selectors.statusPhase(pod)} + + + {selectors.restartPolicy(pod)} + + {selectors.statusPodIP(pod)} + {currentPodMetrics && ( + <> + + + {currentPodMetrics.totalCpu().toFixed(3)} + + + + {bytesToHumanReadable(currentPodMetrics.totalMemory())} + + > + )} + + } + > + + + ); + }) ); diff --git a/src/main/frontend/src/pods/PodsEditPage.js b/src/main/frontend/src/pods/PodsEditPage.js index 68452a8..7eda4ca 100644 --- a/src/main/frontend/src/pods/PodsEditPage.js +++ b/src/main/frontend/src/pods/PodsEditPage.js @@ -17,20 +17,18 @@ import React from 'react'; import {withParams} from '../router'; import {name} from '../metadata'; -import p from './'; import {Link} from '../components'; import {ResourceEditPage} from '../editor'; +import {api} from './'; -const PodsEditPage = ({params: {uid}}) => ( +export const PodsEditPage = withParams(({params: {uid}}) => ( ( {name(resource)} )} - save={async resource => await p.api.update(resource)} + save={async resource => await api.update(resource)} resourceFromState={state => state.pods[uid]} /> -); - -export default withParams(PodsEditPage); +)); diff --git a/src/main/frontend/src/pods/PodsExecPage.js b/src/main/frontend/src/pods/PodsExecPage.js index 2db3825..fff91cd 100644 --- a/src/main/frontend/src/pods/PodsExecPage.js +++ b/src/main/frontend/src/pods/PodsExecPage.js @@ -19,62 +19,12 @@ import {connect} from 'react-redux'; import {withParams} from '../router'; import {name, namespace} from '../metadata'; import {ContainerDropdown} from '../containers'; -import p from './index'; import {Card, Link} from '../components'; import {DashboardPage} from '../dashboard'; +import {selectors, useExec} from './'; import 'xterm/css/xterm.css'; -const PodsExecPage = ({uid, namespace, name, containers}) => { - const {ref, selectedContainer, setSelectedContainer} = p.useExec( - namespace, - name, - containers - ); - return ( - - - Terminal - - } - className='pods-logs-page' - > - - - - - - Terminal - - {name} - - - - - - - - - - - - ); -}; - const mapStateToProps = ({pods}) => ({pods}); const mergeProps = ({pods}, dispatchProps, {params: {uid}}) => ({ @@ -82,9 +32,66 @@ const mergeProps = ({pods}, dispatchProps, {params: {uid}}) => ({ uid, namespace: namespace(pods[uid]), name: name(pods[uid]), - containers: p.selectors.containers(pods[uid]) + containers: selectors.containers(pods[uid]) }); -export default withParams( - connect(mapStateToProps, null, mergeProps)(PodsExecPage) +export const PodsExecPage = withParams( + connect( + mapStateToProps, + null, + mergeProps + )(({uid, namespace, name, containers}) => { + const {ref, selectedContainer, setSelectedContainer} = useExec( + namespace, + name, + containers + ); + return ( + + - Terminal + + } + className='pods-logs-page' + > + + + + + + Terminal + + {name} + + + + + + + + + + + + ); + }) ); diff --git a/src/main/frontend/src/pods/PodsLogsPage.js b/src/main/frontend/src/pods/PodsLogsPage.js index 0b8ce87..e3a1f94 100644 --- a/src/main/frontend/src/pods/PodsLogsPage.js +++ b/src/main/frontend/src/pods/PodsLogsPage.js @@ -22,9 +22,9 @@ import dompurify from 'dompurify'; import {withParams} from '../router'; import {name, namespace} from '../metadata'; import {ContainerDropdown} from '../containers'; -import p from '../pods'; import {Card, Icon, Link, Switch} from '../components'; import {DashboardPage} from '../dashboard'; +import {selectors, useLogs} from './'; import './PodsLogsPage.css'; @@ -45,93 +45,6 @@ const downloadLogs = (log, name, selectedContainer) => { URL.revokeObjectURL(url); }; -const PodsLogsPage = ({uid, namespace, name, containers}) => { - const { - listRef, - log, - follow, - setFollow, - selectedContainer, - setSelectedContainer - } = p.useLogs(namespace, name, containers); - const rowRenderer = ({key, index, style}) => ( - - ); - return ( - - - Logs - - } - className='pods-logs-page' - > - - - - - - Logs - - {name} - - - - - - setFollow(!follow)} - /> - downloadLogs(log, name, selectedContainer)} - className='ml-2' - variant={Link.variants.outline} - title='Download logs' - > - - Download - - - - - - {({height, width}) => ( - - )} - - - - - - ); -}; - const mapStateToProps = ({pods}) => ({pods}); const mergeProps = ({pods}, dispatchProps, {params: {uid}}) => ({ @@ -139,9 +52,98 @@ const mergeProps = ({pods}, dispatchProps, {params: {uid}}) => ({ uid, namespace: namespace(pods[uid]), name: name(pods[uid]), - containers: p.selectors.containers(pods[uid]) + containers: selectors.containers(pods[uid]) }); -export default withParams( - connect(mapStateToProps, null, mergeProps)(PodsLogsPage) +export const PodsLogsPage = withParams( + connect( + mapStateToProps, + null, + mergeProps + )(({uid, namespace, name, containers}) => { + const { + listRef, + log, + follow, + setFollow, + selectedContainer, + setSelectedContainer + } = useLogs(namespace, name, containers); + const rowRenderer = ({key, index, style}) => ( + + ); + return ( + + - Logs + + } + className='pods-logs-page' + > + + + + + + Logs + + {name} + + + + + + setFollow(!follow)} + /> + downloadLogs(log, name, selectedContainer)} + className='ml-2' + variant={Link.variants.outline} + title='Download logs' + > + + Download + + + + + + {({height, width}) => ( + + )} + + + + + + ); + }) ); diff --git a/src/main/frontend/src/pods/PodsPage.js b/src/main/frontend/src/pods/PodsPage.js index a56bfad..34db80e 100644 --- a/src/main/frontend/src/pods/PodsPage.js +++ b/src/main/frontend/src/pods/PodsPage.js @@ -17,18 +17,16 @@ import React from 'react'; import {FilterBar} from '../components'; import {DashboardPage} from '../dashboard'; -import pods from './'; import {useUiNamespace} from '../redux'; +import {PodsCard, PodsList} from './'; -const PodsPage = () => { +export const PodsPage = () => { const {selectedNamespace} = useUiNamespace(); return ( - + - + ); }; - -export default PodsPage; diff --git a/src/main/frontend/src/pods/StatusIcon.js b/src/main/frontend/src/pods/StatusIcon.js index 4755925..0648f2c 100644 --- a/src/main/frontend/src/pods/StatusIcon.js +++ b/src/main/frontend/src/pods/StatusIcon.js @@ -24,11 +24,9 @@ const iconMap = { Terminated: 'fa-ban' }; -const StatusIcon = ({statusPhase, className}) => ( +export const StatusIcon = ({statusPhase, className}) => ( ); - -export default StatusIcon; diff --git a/src/main/frontend/src/pods/__test__/api.test.js b/src/main/frontend/src/pods/__test__/api.test.js index de7b46d..dc352de 100644 --- a/src/main/frontend/src/pods/__test__/api.test.js +++ b/src/main/frontend/src/pods/__test__/api.test.js @@ -26,7 +26,7 @@ describe('API test suite', () => { })); WebSocket = jest.fn(); global.WebSocket = WebSocket; - api = require('../api').default; + api = require('../api'); }); describe('exec', () => { describe('With absolute API url', () => { diff --git a/src/main/frontend/src/pods/api.js b/src/main/frontend/src/pods/api.js index 9b7f356..439f2c9 100644 --- a/src/main/frontend/src/pods/api.js +++ b/src/main/frontend/src/pods/api.js @@ -22,10 +22,10 @@ import { } from '../fetch'; import {name, namespace} from '../metadata'; -const logs = (namespace, name, container) => +export const logs = (namespace, name, container) => new EventSource(`${getApiURL()}/pods/${namespace}/${name}/logs/${container}`); -const metrics = async pod => { +export const metrics = async pod => { const response = await fetch( `${getApiURL()}/pods/${namespace(pod)}/${name(pod)}/metrics` ); @@ -41,15 +41,8 @@ const getWsUrl = () => { const wsOrigin = window.location.origin.replace(/^http/i, 'ws'); return `${wsOrigin}/${apiURL.replace(/^\//, '')}`; }; -const exec = (namespace, name, container) => +export const exec = (namespace, name, container) => new WebSocket(`${getWsUrl()}/pods/${namespace}/${name}/exec/${container}`); -const api = { - exec, - logs, - metrics, - delete: deleteNamespacedResource('pods'), - update: updateNamespacedResource('pods') -}; - -export default api; +export const deletePod = deleteNamespacedResource('pods'); +export const update = updateNamespacedResource('pods'); diff --git a/src/main/frontend/src/pods/index.js b/src/main/frontend/src/pods/index.js index ad566d5..32812d9 100644 --- a/src/main/frontend/src/pods/index.js +++ b/src/main/frontend/src/pods/index.js @@ -14,34 +14,16 @@ * limitations under the License. * */ -import api from './api'; -import selectors from './selectors'; -import useContainers from './useContainers'; -import useExec from './useExec'; -import useLogs from './useLogs'; -import List from './List'; -import PodsCard from './PodsCard'; -import PodsDetailPage from './PodsDetailPage'; -import PodsEditPage from './PodsEditPage'; -import PodsExecPage from './PodsExecPage'; -import PodsLogsPage from './PodsLogsPage'; -import PodsPage from './PodsPage'; -import StatusIcon from './StatusIcon'; - -const pods = {}; - -pods.api = api; -pods.selectors = selectors; -pods.useContainers = useContainers; -pods.useExec = useExec; -pods.useLogs = useLogs; -pods.List = List; -pods.PodsCard = PodsCard; -pods.PodsDetailPage = PodsDetailPage; -pods.PodsEditPage = PodsEditPage; -pods.PodsExecPage = PodsExecPage; -pods.PodsLogsPage = PodsLogsPage; -pods.PodsPage = PodsPage; -pods.StatusIcon = StatusIcon; - -export default pods; +export * as api from './api'; +export * as selectors from './selectors'; +export {useContainers} from './useContainers'; +export {useExec} from './useExec'; +export {useLogs} from './useLogs'; +export {List as PodsList} from './List'; +export {PodsCard} from './PodsCard'; +export {PodsDetailPage} from './PodsDetailPage'; +export {PodsEditPage} from './PodsEditPage'; +export {PodsExecPage} from './PodsExecPage'; +export {PodsLogsPage} from './PodsLogsPage'; +export {PodsPage} from './PodsPage'; +export {StatusIcon} from './StatusIcon'; diff --git a/src/main/frontend/src/pods/selectors.js b/src/main/frontend/src/pods/selectors.js index 0bde91f..1e1cef5 100644 --- a/src/main/frontend/src/pods/selectors.js +++ b/src/main/frontend/src/pods/selectors.js @@ -16,57 +16,51 @@ */ import {resourcesBy, toObjectReducer} from '../redux'; -const selectors = {}; +export const statusPhase = pod => pod?.status?.phase ?? ''; -selectors.statusPhase = pod => pod?.status?.phase ?? ''; +export const statusPodIP = pod => pod?.status?.podIP ?? ''; -selectors.statusPodIP = pod => pod?.status?.podIP ?? ''; +export const nodeName = pod => pod?.spec?.nodeName ?? ''; -selectors.nodeName = pod => pod?.spec?.nodeName ?? ''; +export const restartPolicy = pod => pod?.spec?.restartPolicy ?? ''; -selectors.restartPolicy = pod => pod?.spec?.restartPolicy ?? ''; +export const containers = pod => pod?.spec?.containers ?? []; -selectors.containers = pod => pod?.spec?.containers ?? []; +export const containerStatuses = pod => pod?.status?.containerStatuses ?? []; -selectors.containerStatuses = pod => pod?.status?.containerStatuses ?? []; - -selectors.containersReady = pod => { - const css = selectors.containerStatuses(pod); +export const containersReady = pod => { + const css = containerStatuses(pod); return css.length > 0 && css.every(cs => cs.ready); }; -selectors.isSucceded = pod => selectors.statusPhase(pod) === 'Succeeded'; +export const isSucceded = pod => statusPhase(pod) === 'Succeeded'; -selectors.succeededOrContainersReady = pod => - selectors.isSucceded(pod) || selectors.containersReady(pod); +export const succeededOrContainersReady = pod => + isSucceded(pod) || containersReady(pod); -selectors.restartCount = pod => - selectors - .containerStatuses(pod) - .reduce((acc, containerStatus) => acc + containerStatus.restartCount, 0); +export const restartCount = pod => + containerStatuses(pod).reduce( + (acc, containerStatus) => acc + containerStatus.restartCount, + 0 + ); // Selectors for array of Pods -selectors.succeededCount = pods => - pods.reduce( - (count, pod) => (selectors.isSucceded(pod) ? count + 1 : count), - 0 - ); +export const succeededCount = pods => + pods.reduce((count, pod) => (isSucceded(pod) ? count + 1 : count), 0); -selectors.readyCount = pods => - pods.reduce( - (count, pod) => (selectors.containersReady(pod) ? count + 1 : count), - 0 - ); +export const readyCount = pods => + pods.reduce((count, pod) => (containersReady(pod) ? count + 1 : count), 0); -selectors.podsBy = (pods = {}, {nodeName, ...filters} = undefined) => +export const podsBy = ( + pods = {}, + {nodeName: filterNodeName, ...filters} = undefined +) => Object.entries(resourcesBy(pods, filters)) .filter(([, pod]) => { - if (nodeName) { - return selectors.nodeName(pod) === nodeName; + if (filterNodeName) { + return nodeName(pod) === filterNodeName; } return true; }) .reduce(toObjectReducer, {}); - -export default selectors; diff --git a/src/main/frontend/src/pods/useContainers.js b/src/main/frontend/src/pods/useContainers.js index c5e1fa2..d6b6078 100644 --- a/src/main/frontend/src/pods/useContainers.js +++ b/src/main/frontend/src/pods/useContainers.js @@ -16,7 +16,7 @@ */ import {useEffect, useState} from 'react'; -const useContainers = containers => { +export const useContainers = containers => { const [selectedContainer, setSelectedContainer] = useState(null); useEffect(() => { if (selectedContainer === null && containers && containers.length > 0) { @@ -25,5 +25,3 @@ const useContainers = containers => { }, [containers, selectedContainer, setSelectedContainer]); return {selectedContainer, setSelectedContainer}; }; - -export default useContainers; diff --git a/src/main/frontend/src/pods/useExec.js b/src/main/frontend/src/pods/useExec.js index d99e4f2..fdb2905 100644 --- a/src/main/frontend/src/pods/useExec.js +++ b/src/main/frontend/src/pods/useExec.js @@ -19,7 +19,7 @@ import {Terminal} from 'xterm'; import {AttachAddon} from 'xterm-addon-attach'; import {FitAddon} from 'xterm-addon-fit'; import {WebLinksAddon} from 'xterm-addon-web-links'; -import p from './index'; +import {api, useContainers} from './'; const startTerminal = (ref, namespace, name, selectedContainer) => { const xterm = new Terminal(); @@ -28,7 +28,7 @@ const startTerminal = (ref, namespace, name, selectedContainer) => { xterm.loadAddon(new WebLinksAddon()); xterm.open(ref.current); fitAddon.fit(); - xterm.webSocket = p.api.exec(namespace, name, selectedContainer?.name); + xterm.webSocket = api.exec(namespace, name, selectedContainer?.name); const attachAddon = new AttachAddon(xterm.webSocket); xterm.loadAddon(attachAddon); xterm.focus(); @@ -40,9 +40,9 @@ const startTerminal = (ref, namespace, name, selectedContainer) => { return xterm; }; -const useExec = (namespace, name, containers) => { +export const useExec = (namespace, name, containers) => { const ref = useRef(null); - const {selectedContainer, setSelectedContainer} = p.useContainers(containers); + const {selectedContainer, setSelectedContainer} = useContainers(containers); const [terminal, setTerminal] = useState(null); useEffect(() => { if (!terminal && ref.current && namespace && name && selectedContainer) { @@ -68,5 +68,3 @@ const useExec = (namespace, name, containers) => { ); return {ref, selectedContainer, setSelectedContainer}; }; - -export default useExec; diff --git a/src/main/frontend/src/pods/useLogs.js b/src/main/frontend/src/pods/useLogs.js index 4c7514d..6a57264 100644 --- a/src/main/frontend/src/pods/useLogs.js +++ b/src/main/frontend/src/pods/useLogs.js @@ -16,7 +16,7 @@ */ import {useEffect, useRef, useState} from 'react'; import throttle from 'lodash/throttle'; -import p from './index'; +import {api, useContainers} from './'; const LOADING_MESSAGE = 'Loading logs...'; @@ -26,7 +26,7 @@ const initEventSource = ( selectedContainer, throttledSetLog ) => { - const es = p.api.logs(namespace, name, selectedContainer.name); + const es = api.logs(namespace, name, selectedContainer.name); es.onopen = () => { es.currentLog = []; throttledSetLog(['Waiting for container to log messages...']); @@ -42,9 +42,9 @@ const initEventSource = ( return es; }; -const useLogs = (namespace, name, containers) => { +export const useLogs = (namespace, name, containers) => { const listRef = useRef(); - const {selectedContainer, setSelectedContainer} = p.useContainers(containers); + const {selectedContainer, setSelectedContainer} = useContainers(containers); const [log, setLog] = useState([LOADING_MESSAGE]); const [follow, setFollow] = useState(true); const throttledSetLog = throttle(setLog, 100, {trailing: true}); @@ -81,5 +81,3 @@ const useLogs = (namespace, name, containers) => { setSelectedContainer }; }; - -export default useLogs; diff --git a/src/main/frontend/src/replicationcontrollers/ReplicationControllersDetailPage.js b/src/main/frontend/src/replicationcontrollers/ReplicationControllersDetailPage.js index 49cfdac..2dd990d 100644 --- a/src/main/frontend/src/replicationcontrollers/ReplicationControllersDetailPage.js +++ b/src/main/frontend/src/replicationcontrollers/ReplicationControllersDetailPage.js @@ -19,7 +19,7 @@ import {connect} from 'react-redux'; import {withParams} from '../router'; import {Details, uid} from '../metadata'; import {ContainerList} from '../containers'; -import pods from '../pods'; +import {PodsList} from '../pods'; import {Card, Form} from '../components'; import {ResourceDetailPage} from '../dashboard'; import {api, selectors} from './'; @@ -60,7 +60,7 @@ export const ReplicationControllersDetailPage = withParams( className='mt-2' containers={selectors.containers(replicationController)} /> - { }; return ( <> - { nameLike={query} namespace={selectedNamespace} /> - -