Add eslint rule and fix as many issues as possible

This commit is contained in:
Khoa Le
2023-06-19 23:42:04 -04:00
parent e9eacc445d
commit 9d33e4756b
689 changed files with 9446 additions and 21821 deletions
@@ -1,46 +1,46 @@
import { useState } from 'react';
import { useRouter } from 'next/router';
import { useState } from "react";
import { useRouter } from "next/router";
import { Button, Card, CardTitle, FormControl, Input } from '../../../components/v2';
import saveIntegrationAccessToken from '../../api/integrations/saveIntegrationAccessToken';
import { Button, Card, CardTitle, FormControl, Input } from "../../../components/v2";
import saveIntegrationAccessToken from "../../api/integrations/saveIntegrationAccessToken";
export default function AWSParameterStoreAuthorizeIntegrationPage() {
const router = useRouter();
const [isLoading, setIsLoading] = useState(false);
const [accessKey, setAccessKey] = useState('');
const [accessKeyErrorText, setAccessKeyErrorText] = useState('');
const [accessSecretKey, setAccessSecretKey] = useState('');
const [accessSecretKeyErrorText, setAccessSecretKeyErrorText] = useState('');
const [accessKey, setAccessKey] = useState("");
const [accessKeyErrorText, setAccessKeyErrorText] = useState("");
const [accessSecretKey, setAccessSecretKey] = useState("");
const [accessSecretKeyErrorText, setAccessSecretKeyErrorText] = useState("");
const handleButtonClick = async () => {
try {
setAccessKeyErrorText('');
setAccessSecretKeyErrorText('');
setAccessKeyErrorText("");
setAccessSecretKeyErrorText("");
if (accessKey.length === 0) {
setAccessKeyErrorText('Access key cannot be blank');
setAccessKeyErrorText("Access key cannot be blank");
return;
}
if (accessSecretKey.length === 0) {
setAccessSecretKeyErrorText('Secret access key cannot be blank');
setAccessSecretKeyErrorText("Secret access key cannot be blank");
return;
}
setIsLoading(true);
const integrationAuth = await saveIntegrationAccessToken({
workspaceId: localStorage.getItem('projectData.id'),
integration: 'aws-parameter-store',
workspaceId: localStorage.getItem("projectData.id"),
integration: "aws-parameter-store",
accessId: accessKey,
accessToken: accessSecretKey,
url: null,
namespace: null
});
setAccessKey('');
setAccessSecretKey('');
setAccessKey("");
setAccessSecretKey("");
setIsLoading(false);
router.push(
@@ -58,7 +58,7 @@ export default function AWSParameterStoreAuthorizeIntegrationPage() {
<FormControl
label="Access Key ID"
errorText={accessKeyErrorText}
isError={accessKeyErrorText !== '' ?? false}
isError={accessKeyErrorText !== "" ?? false}
>
<Input
placeholder=""
@@ -69,7 +69,7 @@ export default function AWSParameterStoreAuthorizeIntegrationPage() {
<FormControl
label="Secret Access Key"
errorText={accessSecretKeyErrorText}
isError={accessSecretKeyErrorText !== '' ?? false}
isError={accessSecretKeyErrorText !== "" ?? false}
>
<Input
placeholder=""
@@ -1,6 +1,6 @@
import { useEffect, useState } from 'react';
import { useRouter } from 'next/router';
import queryString from 'query-string';
import { useEffect, useState } from "react";
import { useRouter } from "next/router";
import queryString from "query-string";
import {
Button,
@@ -10,56 +10,56 @@ import {
Input,
Select,
SelectItem
} from '../../../components/v2';
import { useGetIntegrationAuthById } from '../../../hooks/api/integrationAuth';
import { useGetWorkspaceById } from '../../../hooks/api/workspace';
import createIntegration from '../../api/integrations/createIntegration';
} from "../../../components/v2";
import { useGetIntegrationAuthById } from "../../../hooks/api/integrationAuth";
import { useGetWorkspaceById } from "../../../hooks/api/workspace";
import createIntegration from "../../api/integrations/createIntegration";
const awsRegions = [
{ name: 'US East (Ohio)', slug: 'us-east-2' },
{ name: 'US East (N. Virginia)', slug: 'us-east-1' },
{ name: 'US West (N. California)', slug: 'us-west-1' },
{ name: 'US West (Oregon)', slug: 'us-west-2' },
{ name: 'Africa (Cape Town)', slug: 'af-south-1' },
{ name: 'Asia Pacific (Hong Kong)', slug: 'ap-east-1' },
{ name: 'Asia Pacific (Hyderabad)', slug: 'ap-south-2' },
{ name: 'Asia Pacific (Jakarta)', slug: 'ap-southeast-3' },
{ name: 'Asia Pacific (Melbourne)', slug: 'ap-southeast-4' },
{ name: 'Asia Pacific (Mumbai)', slug: 'ap-south-1' },
{ name: 'Asia Pacific (Osaka)', slug: 'ap-northeast-3' },
{ name: 'Asia Pacific (Seoul)', slug: 'ap-northeast-2' },
{ name: 'Asia Pacific (Singapore)', slug: 'ap-southeast-1' },
{ name: 'Asia Pacific (Sydney)', slug: 'ap-southeast-2' },
{ name: 'Asia Pacific (Tokyo)', slug: 'ap-northeast-1' },
{ name: 'Canada (Central)', slug: 'ca-central-1' },
{ name: 'Europe (Frankfurt)', slug: 'eu-central-1' },
{ name: 'Europe (Ireland)', slug: 'eu-west-1' },
{ name: 'Europe (London)', slug: 'eu-west-2' },
{ name: 'Europe (Milan)', slug: 'eu-south-1' },
{ name: 'Europe (Paris)', slug: 'eu-west-3' },
{ name: 'Europe (Spain)', slug: 'eu-south-2' },
{ name: 'Europe (Stockholm)', slug: 'eu-north-1' },
{ name: 'Europe (Zurich)', slug: 'eu-central-2' },
{ name: 'Middle East (Bahrain)', slug: 'me-south-1' },
{ name: 'Middle East (UAE)', slug: 'me-central-1' },
{ name: 'South America (Sao Paulo)', slug: 'sa-east-1' },
{ name: 'AWS GovCloud (US-East)', slug: 'us-gov-east-1' },
{ name: 'AWS GovCloud (US-West)', slug: 'us-gov-west-1' }
{ name: "US East (Ohio)", slug: "us-east-2" },
{ name: "US East (N. Virginia)", slug: "us-east-1" },
{ name: "US West (N. California)", slug: "us-west-1" },
{ name: "US West (Oregon)", slug: "us-west-2" },
{ name: "Africa (Cape Town)", slug: "af-south-1" },
{ name: "Asia Pacific (Hong Kong)", slug: "ap-east-1" },
{ name: "Asia Pacific (Hyderabad)", slug: "ap-south-2" },
{ name: "Asia Pacific (Jakarta)", slug: "ap-southeast-3" },
{ name: "Asia Pacific (Melbourne)", slug: "ap-southeast-4" },
{ name: "Asia Pacific (Mumbai)", slug: "ap-south-1" },
{ name: "Asia Pacific (Osaka)", slug: "ap-northeast-3" },
{ name: "Asia Pacific (Seoul)", slug: "ap-northeast-2" },
{ name: "Asia Pacific (Singapore)", slug: "ap-southeast-1" },
{ name: "Asia Pacific (Sydney)", slug: "ap-southeast-2" },
{ name: "Asia Pacific (Tokyo)", slug: "ap-northeast-1" },
{ name: "Canada (Central)", slug: "ca-central-1" },
{ name: "Europe (Frankfurt)", slug: "eu-central-1" },
{ name: "Europe (Ireland)", slug: "eu-west-1" },
{ name: "Europe (London)", slug: "eu-west-2" },
{ name: "Europe (Milan)", slug: "eu-south-1" },
{ name: "Europe (Paris)", slug: "eu-west-3" },
{ name: "Europe (Spain)", slug: "eu-south-2" },
{ name: "Europe (Stockholm)", slug: "eu-north-1" },
{ name: "Europe (Zurich)", slug: "eu-central-2" },
{ name: "Middle East (Bahrain)", slug: "me-south-1" },
{ name: "Middle East (UAE)", slug: "me-central-1" },
{ name: "South America (Sao Paulo)", slug: "sa-east-1" },
{ name: "AWS GovCloud (US-East)", slug: "us-gov-east-1" },
{ name: "AWS GovCloud (US-West)", slug: "us-gov-west-1" }
];
export default function AWSParameterStoreCreateIntegrationPage() {
const router = useRouter();
const { integrationAuthId } = queryString.parse(router.asPath.split('?')[1]);
const { integrationAuthId } = queryString.parse(router.asPath.split("?")[1]);
const { data: workspace } = useGetWorkspaceById(localStorage.getItem('projectData.id') ?? '');
const { data: integrationAuth } = useGetIntegrationAuthById((integrationAuthId as string) ?? '');
const { data: workspace } = useGetWorkspaceById(localStorage.getItem("projectData.id") ?? "");
const { data: integrationAuth } = useGetIntegrationAuthById((integrationAuthId as string) ?? "");
const [selectedSourceEnvironment, setSelectedSourceEnvironment] = useState('');
const [secretPath, setSecretPath] = useState('/');
const [selectedAWSRegion, setSelectedAWSRegion] = useState('');
const [path, setPath] = useState('');
const [pathErrorText, setPathErrorText] = useState('');
const [selectedSourceEnvironment, setSelectedSourceEnvironment] = useState("");
const [secretPath, setSecretPath] = useState("/");
const [selectedAWSRegion, setSelectedAWSRegion] = useState("");
const [path, setPath] = useState("");
const [pathErrorText, setPathErrorText] = useState("");
const [isLoading, setIsLoading] = useState(false);
@@ -77,11 +77,11 @@ export default function AWSParameterStoreCreateIntegrationPage() {
const handleButtonClick = async () => {
try {
if (path !== '') {
if (path !== "") {
// case: path is not empty
if (!isValidAWSParameterStorePath(path)) {
// case: path is not valid for aws parameter store
setPathErrorText('Path must be a valid path for SSM like /project/env/');
setPathErrorText("Path must be a valid path for SSM like /project/env/");
return;
}
}
@@ -107,9 +107,9 @@ export default function AWSParameterStoreCreateIntegrationPage() {
});
setIsLoading(false);
setPathErrorText('');
setPathErrorText("");
router.push(`/integrations/${localStorage.getItem('projectData.id')}`);
router.push(`/integrations/${localStorage.getItem("projectData.id")}`);
} catch (err) {
console.error(err);
}
@@ -155,11 +155,11 @@ export default function AWSParameterStoreCreateIntegrationPage() {
))}
</Select>
</FormControl>
<FormControl label="Path" errorText={pathErrorText} isError={pathErrorText !== '' ?? false}>
<FormControl label="Path" errorText={pathErrorText} isError={pathErrorText !== "" ?? false}>
<Input
placeholder={`/${workspace.name
.toLowerCase()
.replace(/ /g, '-')}/${selectedSourceEnvironment}/`}
.replace(/ /g, "-")}/${selectedSourceEnvironment}/`}
value={path}
onChange={(e) => setPath(e.target.value)}
/>