diff --git a/flux-plugin/src/actions/index.tsx b/flux-plugin/src/actions/index.tsx index 8315662..e8a549e 100644 --- a/flux-plugin/src/actions/index.tsx +++ b/flux-plugin/src/actions/index.tsx @@ -1,11 +1,10 @@ import { ActionButton, ConfirmDialog, - Dialog, } from '@kinvolk/headlamp-plugin/lib/components/common'; +import { KubeObject } from '@kinvolk/headlamp-plugin/lib/lib/k8s/cluster'; import { useSnackbar } from 'notistack'; import React from 'react'; -import { KubeObject } from '@kinvolk/headlamp-plugin/lib/lib/k8s/cluster'; function SuspendAction(props) { //const dispatch = useDispatch(); diff --git a/flux-plugin/src/checkflux/index.tsx b/flux-plugin/src/checkflux/index.tsx index c16b63e..8f8bf2b 100644 --- a/flux-plugin/src/checkflux/index.tsx +++ b/flux-plugin/src/checkflux/index.tsx @@ -1,11 +1,10 @@ -import { Box, Link } from '@mui/material'; import { K8s } from '@kinvolk/headlamp-plugin/lib'; -import { SectionBox } from '@kinvolk/headlamp-plugin/lib/components/common'; +import { Box, Link } from '@mui/material'; import { useTheme } from '@mui/material'; export default function CheckIfFluxInstalled() { const theme = useTheme(); - const [pods, error] = K8s.ResourceClasses.Pod.useList(); + const [pods] = K8s.ResourceClasses.Pod.useList(); const helmController = pods?.filter(pod => pod.metadata.labels['app'] === 'helm-controller') || []; diff --git a/flux-plugin/src/flux-applications/application.tsx b/flux-plugin/src/flux-applications/application.tsx index b9f560f..bb7bf0e 100644 --- a/flux-plugin/src/flux-applications/application.tsx +++ b/flux-plugin/src/flux-applications/application.tsx @@ -1,3 +1,4 @@ +import { K8s } from '@kinvolk/headlamp-plugin/lib'; import { ConditionsTable, DateLabel, @@ -6,25 +7,19 @@ import { SectionBox, Table, } from '@kinvolk/headlamp-plugin/lib/components/common'; -import { useLocation } from 'react-router'; import Event, { KubeEvent } from '@kinvolk/headlamp-plugin/lib/K8s/event'; +import { KubeObject } from '@kinvolk/headlamp-plugin/lib/lib/k8s/cluster'; +import Editor from '@monaco-editor/react'; import React from 'react'; -import { K8s } from '@kinvolk/headlamp-plugin/lib'; +import { useLocation } from 'react-router'; +import YAML from 'yaml'; import { - SuspendAction, ResumeAction, - SyncWithSourceAction, + SuspendAction, SyncWithoutSourceAction, + SyncWithSourceAction, } from '../actions/index'; -import { KubeObject } from '@kinvolk/headlamp-plugin/lib/lib/k8s/cluster'; -import YAML from 'yaml'; -import { - getSourceNameAndType, - ObjectEvents, - prepareNameLink, - prepareTimePassedString, -} from '../helpers/index'; -import Editor from '@monaco-editor/react'; +import { getSourceNameAndType, ObjectEvents, prepareNameLink, prepareTimePassedString } from '../helpers/index'; const KUSTOMIZE_CRD = 'kustomizations.kustomize.toolkit.fluxcd.io'; const HELMRELEASE_CRD = 'helmreleases.helm.toolkit.fluxcd.io'; @@ -96,12 +91,12 @@ function GetSource(props: { item: KubeObject | null; setSource: (...args) => voi ); } -export default function FluxApplicationDetailView(props) { +export default function FluxApplicationDetailView() { const location = useLocation(); const segments = location.pathname.split('/'); const [namespace, type, name] = segments.slice(-3); - const [events, error] = Event?.default.useList({ + const [events] = Event?.default.useList({ namespace, fieldSelector: `involvedObject.name=${name},involvedObject.kind=${ type === 'helmreleases' ? 'HelmRelease' : 'Kustomization' diff --git a/flux-plugin/src/flux-applications/applications.tsx b/flux-plugin/src/flux-applications/applications.tsx index dd9507e..002999d 100644 --- a/flux-plugin/src/flux-applications/applications.tsx +++ b/flux-plugin/src/flux-applications/applications.tsx @@ -1,7 +1,7 @@ -import React from 'react'; import { K8s } from '@kinvolk/headlamp-plugin/lib'; -import FluxApplicationCustomResource from '../flux-applications/applicationcustomresource'; +import React from 'react'; import CheckIfFluxInstalled from '../checkflux'; +import FluxApplicationCustomResource from '../flux-applications/applicationcustomresource'; export default function FluxApplications() { const [helmReleases] = K8s.ResourceClasses.CustomResourceDefinition.useGet( diff --git a/flux-plugin/src/flux-image-automation/image-automation.tsx b/flux-plugin/src/flux-image-automation/image-automation.tsx index a1bf3ee..0638255 100644 --- a/flux-plugin/src/flux-image-automation/image-automation.tsx +++ b/flux-plugin/src/flux-image-automation/image-automation.tsx @@ -1,16 +1,16 @@ import { K8s } from '@kinvolk/headlamp-plugin/lib'; -import Event from '@kinvolk/headlamp-plugin/lib/k8s/event'; import { apiFactory } from '@kinvolk/headlamp-plugin/lib/ApiProxy'; -import React from 'react'; -import { useLocation } from 'react-router'; import { ConditionsTable, MainInfoSection, SectionBox, } from '@kinvolk/headlamp-plugin/lib/components/common'; -import { SuspendAction, ResumeAction, SyncAction } from '../actions/index'; -import YAML from 'yaml'; +import Event from '@kinvolk/headlamp-plugin/lib/k8s/event'; import Editor from '@monaco-editor/react'; +import React from 'react'; +import { useLocation } from 'react-router'; +import YAML from 'yaml'; +import { ResumeAction, SuspendAction, SyncAction } from '../actions/index'; import { ObjectEvents, prepareTimePassedString } from '../helpers/index'; const fluxImageInfo = { @@ -48,8 +48,8 @@ export function FluxImageAutomationDetailView() { ); if (!isVersionAvailable) { CRD.apiEndpoint = apiFactory( - ...CRD.apiEndpoint.apiInfo.map(apiInfo => { - let params = []; + ...CRD.apiEndpoint.apiInfo.map((apiInfo) => { + const params = []; params.push(apiInfo.group); params.push(apiInfo.version); params.push(apiInfo.resource); @@ -61,7 +61,7 @@ export function FluxImageAutomationDetailView() { const [resource] = CRD.useGet(getType()); - const [events, error] = Event?.default.useList({ + const [events] = Event?.default.useList({ namespace, fieldSelector: `involvedObject.name=${name},involvedObject.kind=${getKind()}`, }); diff --git a/flux-plugin/src/flux-image-automation/image-automations.tsx b/flux-plugin/src/flux-image-automation/image-automations.tsx index fccc2a3..88a5974 100644 --- a/flux-plugin/src/flux-image-automation/image-automations.tsx +++ b/flux-plugin/src/flux-image-automation/image-automations.tsx @@ -1,3 +1,5 @@ +import { K8s } from '@kinvolk/headlamp-plugin/lib'; +import { apiFactory } from '@kinvolk/headlamp-plugin/lib/ApiProxy'; import { DateLabel, Link, @@ -5,10 +7,8 @@ import { ShowHideLabel, Table, } from '@kinvolk/headlamp-plugin/lib/components/common'; -import { K8s } from '@kinvolk/headlamp-plugin/lib'; -import { apiFactory } from '@kinvolk/headlamp-plugin/lib/ApiProxy'; -import React from 'react'; import { KubeObject } from '@kinvolk/headlamp-plugin/lib/lib/k8s/cluster'; +import React from 'react'; import CheckIfFluxInstalled from '../checkflux'; const IMAGE_AUTOMATION_BETA_VERSION = 'v1beta2'; @@ -20,8 +20,8 @@ export default function ImageAutomation() { ); if (!isVersionAvailable) { CRD.apiEndpoint = apiFactory( - ...CRD.apiEndpoint.apiInfo.map(apiInfo => { - let params = []; + ...CRD.apiEndpoint.apiInfo.map((apiInfo) => { + const params = []; params.push(apiInfo.group); params.push(apiInfo.version); params.push(apiInfo.resource); diff --git a/flux-plugin/src/flux-notifications/notification.tsx b/flux-plugin/src/flux-notifications/notification.tsx index cf83ed2..ad71ab7 100644 --- a/flux-plugin/src/flux-notifications/notification.tsx +++ b/flux-plugin/src/flux-notifications/notification.tsx @@ -1,16 +1,14 @@ -import { useLocation } from 'react-router'; -import { apiFactory } from '@kinvolk/headlamp-plugin/lib/ApiProxy'; import { K8s } from '@kinvolk/headlamp-plugin/lib'; +import { apiFactory } from '@kinvolk/headlamp-plugin/lib/ApiProxy'; import { ConditionsTable, - DateLabel, MainInfoSection, SectionBox, } from '@kinvolk/headlamp-plugin/lib/components/common'; -import { Table } from '@kinvolk/headlamp-plugin/lib/components/common'; -import React from 'react'; import Event from '@kinvolk/headlamp-plugin/lib/k8s/event'; -import { SyncAction, SuspendAction, ResumeAction } from '../actions/index'; +import React from 'react'; +import { useLocation } from 'react-router'; +import { ResumeAction,SuspendAction, SyncAction } from '../actions/index'; import { ObjectEvents, prepareTimePassedString } from '../helpers/index'; const ALERT = 'alerts.notification.toolkit.fluxcd.io'; @@ -50,8 +48,8 @@ export default function Notification() { ); if (!isVersionAvailable) { CRD.apiEndpoint = apiFactory( - ...CRD.apiEndpoint.apiInfo.map(apiInfo => { - let params = []; + ...CRD.apiEndpoint.apiInfo.map((apiInfo) => { + const params = []; params.push(apiInfo.group); params.push(apiInfo.version); params.push(apiInfo.resource); @@ -61,7 +59,7 @@ export default function Notification() { ); } - const [events, error] = Event?.default.useList({ + const [events] = Event?.default.useList({ namespace, fieldSelector: `involvedObject.name=${name},involvedObject.kind=${getKind()}`, }); diff --git a/flux-plugin/src/flux-notifications/notifications.tsx b/flux-plugin/src/flux-notifications/notifications.tsx index 38ce143..499dc77 100644 --- a/flux-plugin/src/flux-notifications/notifications.tsx +++ b/flux-plugin/src/flux-notifications/notifications.tsx @@ -1,7 +1,7 @@ -import React from 'react'; import { K8s } from '@kinvolk/headlamp-plugin/lib'; import { Link, SectionBox, Table } from '@kinvolk/headlamp-plugin/lib/components/common'; import { Box } from '@mui/material'; +import React from 'react'; import CheckIfFluxInstalled from '../checkflux'; export default function Notifications() { diff --git a/flux-plugin/src/flux-runtime/runtime.tsx b/flux-plugin/src/flux-runtime/runtime.tsx index 414accc..742ca93 100644 --- a/flux-plugin/src/flux-runtime/runtime.tsx +++ b/flux-plugin/src/flux-runtime/runtime.tsx @@ -13,8 +13,8 @@ import { K8s } from '@kinvolk/headlamp-plugin/lib'; import { Link, SectionBox, Table } from '@kinvolk/headlamp-plugin/lib/components/common'; import { Link as MuiLink } from '@mui/material'; -export default function FluxRunTime(props) { - const [pods, error] = K8s.ResourceClasses.Pod.useList(); +export default function FluxRunTime() { + const [pods] = K8s.ResourceClasses.Pod.useList(); const [crds] = K8s.ResourceClasses.CustomResourceDefinition.useList(); const helmController = pods?.filter(pod => pod.metadata.labels['app'] === 'helm-controller'); const kustomizeController = pods?.filter( diff --git a/flux-plugin/src/flux-sources/source.tsx b/flux-plugin/src/flux-sources/source.tsx index dca6ae8..7391f4a 100644 --- a/flux-plugin/src/flux-sources/source.tsx +++ b/flux-plugin/src/flux-sources/source.tsx @@ -1,20 +1,19 @@ -import { useLocation } from 'react-router'; import { K8s } from '@kinvolk/headlamp-plugin/lib'; -import React from 'react'; import { ConditionsTable, DateLabel, MainInfoSection, NameValueTable, SectionBox, - Table, } from '@kinvolk/headlamp-plugin/lib/components/common'; +import Event from '@kinvolk/headlamp-plugin/lib/K8s/event'; import { Link } from '@mui/material'; -import { SuspendAction, ResumeAction, SyncAction } from '../actions/index'; +import React from 'react'; +import { useLocation } from 'react-router'; +import { ResumeAction, SuspendAction, SyncAction } from '../actions/index'; import { ObjectEvents, prepareTimePassedString } from '../helpers/index'; -import Event from '@kinvolk/headlamp-plugin/lib/K8s/event'; -export default function FluxSourceDetailView(props) { +export default function FluxSourceDetailView() { const location = useLocation(); const segments = location.pathname.split('/'); const [namespace, type, name] = segments.slice(-3); @@ -38,7 +37,7 @@ function CustomResourceDetailView(props) { resourceClass.useApiGet(setCr, name, namespace); function prepareExtraInfo() { - let interval = cr?.jsonData.spec?.interval; + const interval = cr?.jsonData.spec?.interval const extraInfo = [ { name: 'Interval', @@ -117,7 +116,7 @@ function CustomResourceDetailView(props) { function Events(props) { const { cr } = props; - const [events, error] = Event?.default.useList({ + const [events] = Event?.default.useList({ namespace: cr?.jsonData.metadata.namespace, fieldSelector: `involvedObject.name=${cr?.jsonData.metadata.name},involvedObject.kind=${cr?.jsonData.kind}`, }); diff --git a/flux-plugin/src/flux-sources/sources.tsx b/flux-plugin/src/flux-sources/sources.tsx index 3822486..c3c79d4 100644 --- a/flux-plugin/src/flux-sources/sources.tsx +++ b/flux-plugin/src/flux-sources/sources.tsx @@ -1,7 +1,7 @@ -import React from 'react'; import { K8s } from '@kinvolk/headlamp-plugin/lib'; -import FluxSourceCustomResource from '../flux-sources/sourcecustomresource'; +import React from 'react'; import CheckIfFluxInstalled from '../checkflux'; +import FluxSourceCustomResource from '../flux-sources/sourcecustomresource'; export default function FluxSources() { const [gitRepoCRD] = K8s.ResourceClasses.CustomResourceDefinition.useGet( diff --git a/flux-plugin/src/helpers/index.tsx b/flux-plugin/src/helpers/index.tsx index 1c4f81c..342e689 100644 --- a/flux-plugin/src/helpers/index.tsx +++ b/flux-plugin/src/helpers/index.tsx @@ -1,5 +1,4 @@ -import { KubeObject } from '@kinvolk/headlamp-plugin/lib/lib/k8s/cluster'; -import { KubeEvent } from '@kinvolk/headlamp-plugin/lib/k8s/event'; +import { K8s } from '@kinvolk/headlamp-plugin/lib'; import { HoverInfoLabel, Link, @@ -7,7 +6,7 @@ import { ShowHideLabel, Table, } from '@kinvolk/headlamp-plugin/lib/components/common'; -import { K8s } from '@kinvolk/headlamp-plugin/lib'; +import { KubeObject } from '@kinvolk/headlamp-plugin/lib/lib/k8s/cluster'; import { localeDate, timeAgo } from '@kinvolk/headlamp-plugin/lib/Utils'; export function getSourceNameAndType(item: KubeObject) { diff --git a/flux-plugin/src/index.tsx b/flux-plugin/src/index.tsx index 10c8c39..ba13a03 100644 --- a/flux-plugin/src/index.tsx +++ b/flux-plugin/src/index.tsx @@ -1,13 +1,13 @@ import { registerRoute, registerSidebarEntry } from '@kinvolk/headlamp-plugin/lib'; -import FluxSources from './flux-sources/sources'; -import FluxApplications from './flux-applications/applications'; import FluxApplicationDetailView from './flux-applications/application'; -import FluxSourceDetailView from './flux-sources/source'; -import Notifications from './flux-notifications/notifications'; -import FluxRunTime from './flux-runtime/runtime'; -import ImageAutomation from './flux-image-automation/image-automations'; +import FluxApplications from './flux-applications/applications'; import { FluxImageAutomationDetailView } from './flux-image-automation/image-automation'; +import ImageAutomation from './flux-image-automation/image-automations'; import Notification from './flux-notifications/notification'; +import Notifications from './flux-notifications/notifications'; +import FluxRunTime from './flux-runtime/runtime'; +import FluxSourceDetailView from './flux-sources/source'; +import FluxSources from './flux-sources/sources'; registerSidebarEntry({ parent: null,