From 43a0b808ae37dbbf7611772b87225433006ce49a Mon Sep 17 00:00:00 2001 From: Salah Aldeen Al Saleh Date: Wed, 27 Sep 2023 23:54:36 +0000 Subject: [PATCH] fix lint issues --- .../components/snapshots/SnapshotSettings.tsx | 61 ++++++++++--------- .../snapshots/SnapshotStorageDestination.tsx | 27 ++++---- 2 files changed, 47 insertions(+), 41 deletions(-) diff --git a/web/src/components/snapshots/SnapshotSettings.tsx b/web/src/components/snapshots/SnapshotSettings.tsx index 3c44cbfafc..7b7bb990e1 100644 --- a/web/src/components/snapshots/SnapshotSettings.tsx +++ b/web/src/components/snapshots/SnapshotSettings.tsx @@ -19,32 +19,37 @@ type Props = { } & RouterProps; type State = { - snapshotSettings: any | null, - isLoadingSnapshotSettings: boolean, - snapshotSettingsErr: boolean, - snapshotSettingsErrMsg: string, - toggleSnapshotView: boolean, - hideCheckVeleroButton: boolean, - updateConfirm: boolean, - updatingSettings: boolean, - updateErrorMsg: string, - showConfigureSnapshotsModal: boolean, - kotsadmRequiresVeleroAccess: boolean, - minimalRBACKotsadmNamespace: string, - showResetFileSystemWarningModal: boolean, - resetFileSystemWarningMessage: string, - snapshotSettingsJob: Repeater, - checkForVeleroAndNodeAgent: boolean, - isEmptyView?: boolean, - veleroUpdated?: boolean, - nodeAgentUpdated?: boolean, + snapshotSettings?: { + isVeleroRunning: boolean; + veleroVersion: string; + veleroPod?: object; + nodeAgentPods?: object[]; + }; + isLoadingSnapshotSettings: boolean; + snapshotSettingsErr: boolean; + snapshotSettingsErrMsg: string; + toggleSnapshotView: boolean; + hideCheckVeleroButton: boolean; + updateConfirm: boolean; + updatingSettings: boolean; + updateErrorMsg: string; + showConfigureSnapshotsModal: boolean; + kotsadmRequiresVeleroAccess: boolean; + minimalRBACKotsadmNamespace: string; + showResetFileSystemWarningModal: boolean; + resetFileSystemWarningMessage: string; + snapshotSettingsJob: Repeater; + checkForVeleroAndNodeAgent: boolean; + isEmptyView?: boolean; + veleroUpdated?: boolean; + nodeAgentUpdated?: boolean; }; class SnapshotSettings extends Component { constructor(props: Props) { super(props); this.state = { - snapshotSettings: null, + snapshotSettings: undefined, isLoadingSnapshotSettings: true, snapshotSettingsErr: false, snapshotSettingsErrMsg: "", @@ -167,15 +172,15 @@ class SnapshotSettings extends Component { this.setState({ veleroUpdated: true }); } - let sortedStateNodeAgentPods = []; - let sortedLastStateNodeAgentPods = []; + let sortedStateNodeAgentPods: object[] | undefined = []; + let sortedLastStateNodeAgentPods: object[] | undefined = []; if (!isEmpty(this.state.snapshotSettings?.nodeAgentPods)) { sortedStateNodeAgentPods = - this.state.snapshotSettings?.nodeAgentPods.sort(); + this.state.snapshotSettings?.nodeAgentPods?.sort(); } if (!isEmpty(lastState.snapshotSettings?.nodeAgentPods)) { sortedLastStateNodeAgentPods = - lastState.snapshotSettings?.nodeAgentPods.sort(); + lastState.snapshotSettings?.nodeAgentPods?.sort(); } if ( !isEqual(sortedStateNodeAgentPods, sortedLastStateNodeAgentPods) && @@ -205,7 +210,7 @@ class SnapshotSettings extends Component { } } } - } + }; toggleSnapshotView = (isEmptyView?: boolean) => { this.setState({ @@ -214,7 +219,7 @@ class SnapshotSettings extends Component { }); }; - updateSettings = (payload: any) => { + updateSettings = (payload: object) => { this.setState({ updatingSettings: true, updateErrorMsg: "", @@ -350,8 +355,6 @@ class SnapshotSettings extends Component { ); } - console.log("this.props", this.props) - return (
@@ -404,4 +407,4 @@ class SnapshotSettings extends Component { } } -export default withRouter(SnapshotSettings); \ No newline at end of file +export default withRouter(SnapshotSettings); diff --git a/web/src/components/snapshots/SnapshotStorageDestination.tsx b/web/src/components/snapshots/SnapshotStorageDestination.tsx index 47c6874533..96cb2c71c7 100644 --- a/web/src/components/snapshots/SnapshotStorageDestination.tsx +++ b/web/src/components/snapshots/SnapshotStorageDestination.tsx @@ -207,17 +207,20 @@ type Props = { isKurlEnabled?: boolean; kotsadmRequiresVeleroAccess: boolean; minimalRBACKotsadmNamespace: string; - openConfigureSnapshotsMinimalRBACModal: (kotsadmRequiresVeleroAccess: boolean, minimalRBACKotsadmNamespace: string) => void; + openConfigureSnapshotsMinimalRBACModal: ( + kotsadmRequiresVeleroAccess: boolean, + minimalRBACKotsadmNamespace: string + ) => void; renderNotVeleroMessage: () => void; resetFileSystemWarningMessage: string; showConfigureSnapshotsModal: boolean; showResetFileSystemWarningModal: boolean; - snapshotSettings: { + snapshotSettings?: { fileSystemConfig?: FileSystemConfig; isKurl?: boolean; isMinioDisabled?: boolean; isVeleroRunning?: boolean; - store: StoreProvider; + store?: StoreProvider; veleroPlugins?: string[]; veleroVersion?: string; }; @@ -370,22 +373,22 @@ class SnapshotStorageDestination extends Component { const { snapshotSettings } = this.props; if (provider === "aws") { - if (snapshotSettings.store?.aws) { + if (snapshotSettings?.store?.aws) { return ( - snapshotSettings.store?.aws.region !== s3Region || - snapshotSettings.store?.aws.accessKeyID !== s3KeyId || - snapshotSettings.store?.aws.secretAccessKey !== s3KeySecret || - snapshotSettings.store?.aws.useInstanceRole !== useIamAws + snapshotSettings?.store?.aws.region !== s3Region || + snapshotSettings?.store?.aws.accessKeyID !== s3KeyId || + snapshotSettings?.store?.aws.secretAccessKey !== s3KeySecret || + snapshotSettings?.store?.aws.useInstanceRole !== useIamAws ); } return true; } if (provider === "gcp") { - if (snapshotSettings.store?.gcp) { + if (snapshotSettings?.store?.gcp) { return ( - snapshotSettings.store?.gcp.useInstanceRole !== gcsUseIam || - snapshotSettings.store?.gcp.serviceAccount !== gcsServiceAccount || - snapshotSettings.store?.gcp.jsonFile !== gcsJsonFile + snapshotSettings?.store?.gcp.useInstanceRole !== gcsUseIam || + snapshotSettings?.store?.gcp.serviceAccount !== gcsServiceAccount || + snapshotSettings?.store?.gcp.jsonFile !== gcsJsonFile ); } return true;