Skip to content

Commit

Permalink
Lint fixes and remove unused vars
Browse files Browse the repository at this point in the history
Signed-off-by: ashu8912 <aghildiyal@microsoft.com>
  • Loading branch information
ashu8912 committed Oct 15, 2024
1 parent 6338a4c commit 5774f3c
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 66 deletions.
3 changes: 1 addition & 2 deletions flux-plugin/src/actions/index.tsx
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
5 changes: 2 additions & 3 deletions flux-plugin/src/checkflux/index.tsx
Original file line number Diff line number Diff line change
@@ -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') || [];
Expand Down
25 changes: 10 additions & 15 deletions flux-plugin/src/flux-applications/application.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { K8s } from '@kinvolk/headlamp-plugin/lib';
import {
ConditionsTable,
DateLabel,
Expand All @@ -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';
Expand Down Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions flux-plugin/src/flux-applications/applications.tsx
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
16 changes: 8 additions & 8 deletions flux-plugin/src/flux-image-automation/image-automation.tsx
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down Expand Up @@ -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);
Expand All @@ -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()}`,
});
Expand Down
10 changes: 5 additions & 5 deletions flux-plugin/src/flux-image-automation/image-automations.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { K8s } from '@kinvolk/headlamp-plugin/lib';
import { apiFactory } from '@kinvolk/headlamp-plugin/lib/ApiProxy';
import {
DateLabel,
Link,
SectionBox,
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';
Expand All @@ -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);
Expand Down
16 changes: 7 additions & 9 deletions flux-plugin/src/flux-notifications/notification.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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);
Expand All @@ -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()}`,
});
Expand Down
2 changes: 1 addition & 1 deletion flux-plugin/src/flux-notifications/notifications.tsx
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions flux-plugin/src/flux-runtime/runtime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
15 changes: 7 additions & 8 deletions flux-plugin/src/flux-sources/source.tsx
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -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',
Expand Down Expand Up @@ -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}`,
});
Expand Down
4 changes: 2 additions & 2 deletions flux-plugin/src/flux-sources/sources.tsx
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
5 changes: 2 additions & 3 deletions flux-plugin/src/helpers/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
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,
SectionBox,
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) {
Expand Down
12 changes: 6 additions & 6 deletions flux-plugin/src/index.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand Down

0 comments on commit 5774f3c

Please sign in to comment.