mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-17 12:56:29 +00:00
Add eslint rule and fix as many issues as possible
This commit is contained in:
@@ -1,49 +1,50 @@
|
||||
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 { useState } from "react";
|
||||
import { useRouter } from "next/router";
|
||||
|
||||
import { Button, Card, CardTitle, FormControl, Input } from "../../../components/v2";
|
||||
import saveIntegrationAccessToken from "../../api/integrations/saveIntegrationAccessToken";
|
||||
|
||||
export default function HashiCorpVaultAuthorizeIntegrationPage() {
|
||||
const router = useRouter();
|
||||
|
||||
const [vaultURL, setVaultURL] = useState('');
|
||||
const [vaultURLErrorText, setVaultURLErrorText] = useState('');
|
||||
const [vaultURL, setVaultURL] = useState("");
|
||||
const [vaultURLErrorText, setVaultURLErrorText] = useState("");
|
||||
|
||||
const [vaultNamespace, setVaultNamespace] = useState('');
|
||||
const [vaultNamespaceErrorText, setVaultNamespaceErrorText] = useState('');
|
||||
const [vaultNamespace, setVaultNamespace] = useState("");
|
||||
const [vaultNamespaceErrorText, setVaultNamespaceErrorText] = useState("");
|
||||
|
||||
const [vaultRoleID, setVaultRoleID] = useState('');
|
||||
const [vaultRoleIDErrorText, setVaultRoleIDErrorText] = useState('');
|
||||
const [vaultRoleID, setVaultRoleID] = useState("");
|
||||
const [vaultRoleIDErrorText, setVaultRoleIDErrorText] = useState("");
|
||||
|
||||
const [vaultSecretID, setVaultSecretID] = useState('');
|
||||
const [vaultSecretIDErrorText, setVaultSecretIDErrorText] = useState('');
|
||||
const [vaultSecretID, setVaultSecretID] = useState("");
|
||||
const [vaultSecretIDErrorText, setVaultSecretIDErrorText] = useState("");
|
||||
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
const handleButtonClick = async () => {
|
||||
try {
|
||||
if (vaultURL.length === 0) {
|
||||
setVaultURLErrorText('Vault Cluster URL cannot be blank');
|
||||
setVaultURLErrorText("Vault Cluster URL cannot be blank");
|
||||
} else {
|
||||
setVaultURLErrorText('');
|
||||
setVaultURLErrorText("");
|
||||
}
|
||||
|
||||
if (vaultNamespace.length === 0) {
|
||||
setVaultNamespaceErrorText('Vault Namespace cannot be blank');
|
||||
setVaultNamespaceErrorText("Vault Namespace cannot be blank");
|
||||
} else {
|
||||
setVaultNamespaceErrorText('');
|
||||
setVaultNamespaceErrorText("");
|
||||
}
|
||||
|
||||
if (vaultRoleID.length === 0) {
|
||||
setVaultRoleIDErrorText('Vault Role ID cannot be blank');
|
||||
setVaultRoleIDErrorText("Vault Role ID cannot be blank");
|
||||
} else {
|
||||
setVaultRoleIDErrorText('');
|
||||
setVaultRoleIDErrorText("");
|
||||
}
|
||||
|
||||
if (vaultSecretID.length === 0) {
|
||||
setVaultSecretIDErrorText('Vault Secret ID cannot be blank');
|
||||
setVaultSecretIDErrorText("Vault Secret ID cannot be blank");
|
||||
} else {
|
||||
setVaultSecretIDErrorText('');
|
||||
setVaultSecretIDErrorText("");
|
||||
}
|
||||
if (
|
||||
vaultURL.length === 0 ||
|
||||
@@ -57,8 +58,8 @@ export default function HashiCorpVaultAuthorizeIntegrationPage() {
|
||||
setIsLoading(true);
|
||||
|
||||
const integrationAuth = await saveIntegrationAccessToken({
|
||||
workspaceId: localStorage.getItem('projectData.id'),
|
||||
integration: 'hashicorp-vault',
|
||||
workspaceId: localStorage.getItem("projectData.id"),
|
||||
integration: "hashicorp-vault",
|
||||
accessId: vaultRoleID,
|
||||
accessToken: vaultSecretID,
|
||||
url: vaultURL,
|
||||
@@ -80,14 +81,14 @@ export default function HashiCorpVaultAuthorizeIntegrationPage() {
|
||||
<FormControl
|
||||
label="Vault Cluster URL"
|
||||
errorText={vaultURLErrorText}
|
||||
isError={vaultURLErrorText !== '' ?? false}
|
||||
isError={vaultURLErrorText !== "" ?? false}
|
||||
>
|
||||
<Input placeholder="" value={vaultURL} onChange={(e) => setVaultURL(e.target.value)} />
|
||||
</FormControl>
|
||||
<FormControl
|
||||
label="Vault Namespace"
|
||||
errorText={vaultNamespaceErrorText}
|
||||
isError={vaultNamespaceErrorText !== '' ?? false}
|
||||
isError={vaultNamespaceErrorText !== "" ?? false}
|
||||
>
|
||||
<Input
|
||||
placeholder="admin/education"
|
||||
@@ -98,14 +99,14 @@ export default function HashiCorpVaultAuthorizeIntegrationPage() {
|
||||
<FormControl
|
||||
label="Vault RoleID"
|
||||
errorText={vaultRoleIDErrorText}
|
||||
isError={vaultRoleIDErrorText !== '' ?? false}
|
||||
isError={vaultRoleIDErrorText !== "" ?? false}
|
||||
>
|
||||
<Input placeholder="" value={vaultRoleID} onChange={(e) => setVaultRoleID(e.target.value)} />
|
||||
</FormControl>
|
||||
<FormControl
|
||||
label="Vault SecretID"
|
||||
errorText={vaultSecretIDErrorText}
|
||||
isError={vaultSecretIDErrorText !== '' ?? false}
|
||||
isError={vaultSecretIDErrorText !== "" ?? false}
|
||||
>
|
||||
<Input
|
||||
placeholder=""
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useState } from 'react';
|
||||
import { useRouter } from 'next/router';
|
||||
import queryString from 'query-string';
|
||||
import { useState } from "react";
|
||||
import { useRouter } from "next/router";
|
||||
import queryString from "query-string";
|
||||
|
||||
import {
|
||||
Button,
|
||||
@@ -10,31 +10,31 @@ 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";
|
||||
|
||||
export default function HashiCorpVaultCreateIntegrationPage() {
|
||||
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 [vaultEnginePath, setVaultEnginePath] = useState('');
|
||||
const [vaultEnginePathErrorText, setVaultEnginePathErrorText] = useState('');
|
||||
const [vaultEnginePath, setVaultEnginePath] = useState("");
|
||||
const [vaultEnginePathErrorText, setVaultEnginePathErrorText] = useState("");
|
||||
|
||||
const [vaultSecretPath, setVaultSecretPath] = useState('');
|
||||
const [vaultSecretPathErrorText, setVaultSecretPathErrorText] = useState('');
|
||||
const [vaultSecretPath, setVaultSecretPath] = useState("");
|
||||
const [vaultSecretPathErrorText, setVaultSecretPathErrorText] = useState("");
|
||||
|
||||
const [selectedSourceEnvironment, setSelectedSourceEnvironment] = useState('');
|
||||
const [secretPath, setSecretPath] = useState('/');
|
||||
const [selectedSourceEnvironment, setSelectedSourceEnvironment] = useState("");
|
||||
const [secretPath, setSecretPath] = useState("/");
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
const isValidVaultPath = (vaultPath: string) => {
|
||||
return !(vaultPath.length === 0 || vaultPath.startsWith('/') || vaultPath.endsWith('/'));
|
||||
return !(vaultPath.length === 0 || vaultPath.startsWith("/") || vaultPath.endsWith("/"));
|
||||
};
|
||||
|
||||
const handleButtonClick = async () => {
|
||||
@@ -42,15 +42,15 @@ export default function HashiCorpVaultCreateIntegrationPage() {
|
||||
if (!integrationAuth?._id) return;
|
||||
|
||||
if (!isValidVaultPath(vaultEnginePath)) {
|
||||
setVaultEnginePathErrorText('Vault KV Secrets Engine Path must be valid like kv');
|
||||
setVaultEnginePathErrorText("Vault KV Secrets Engine Path must be valid like kv");
|
||||
} else {
|
||||
setVaultEnginePathErrorText('');
|
||||
setVaultEnginePathErrorText("");
|
||||
}
|
||||
|
||||
if (!isValidVaultPath(vaultSecretPath)) {
|
||||
setVaultSecretPathErrorText('Vault Secret(s) Path must be valid like machine/dev');
|
||||
setVaultSecretPathErrorText("Vault Secret(s) Path must be valid like machine/dev");
|
||||
} else {
|
||||
setVaultSecretPathErrorText('');
|
||||
setVaultSecretPathErrorText("");
|
||||
}
|
||||
|
||||
if (!isValidVaultPath || !isValidVaultPath(vaultSecretPath)) return;
|
||||
@@ -75,7 +75,7 @@ export default function HashiCorpVaultCreateIntegrationPage() {
|
||||
|
||||
setIsLoading(false);
|
||||
|
||||
router.push(`/integrations/${localStorage.getItem('projectData.id')}`);
|
||||
router.push(`/integrations/${localStorage.getItem("projectData.id")}`);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
@@ -111,7 +111,7 @@ export default function HashiCorpVaultCreateIntegrationPage() {
|
||||
<FormControl
|
||||
label="Vault KV Secrets Engine Path"
|
||||
errorText={vaultEnginePathErrorText}
|
||||
isError={vaultEnginePathErrorText !== '' ?? false}
|
||||
isError={vaultEnginePathErrorText !== "" ?? false}
|
||||
>
|
||||
<Input
|
||||
placeholder="kv"
|
||||
@@ -122,7 +122,7 @@ export default function HashiCorpVaultCreateIntegrationPage() {
|
||||
<FormControl
|
||||
label="Vault Secret(s) Path"
|
||||
errorText={vaultSecretPathErrorText}
|
||||
isError={vaultSecretPathErrorText !== '' ?? false}
|
||||
isError={vaultSecretPathErrorText !== "" ?? false}
|
||||
>
|
||||
<Input
|
||||
placeholder="machine/dev"
|
||||
|
||||
Reference in New Issue
Block a user