diff --git a/frontend-v2/eslint.config.js b/frontend-v2/eslint.config.js index 33a019fa5..00c024056 100644 --- a/frontend-v2/eslint.config.js +++ b/frontend-v2/eslint.config.js @@ -50,6 +50,7 @@ export default tseslint.config( rules: { ...reactHooks.configs.recommended.rules, "react-refresh/only-export-components": "off", + "@typescript-eslint/only-throw-error": "off", "@typescript-eslint/no-empty-function": "off", quotes: ["error", "double", { avoidEscape: true }], "comma-dangle": ["error", "only-multiline"], diff --git a/frontend-v2/src/components/navigation/NavHeader.tsx b/frontend-v2/src/components/navigation/NavHeader.tsx index 184e0839a..8b669de26 100644 --- a/frontend-v2/src/components/navigation/NavHeader.tsx +++ b/frontend-v2/src/components/navigation/NavHeader.tsx @@ -3,7 +3,7 @@ import { ParsedUrlQuery } from "querystring"; import { useState } from "react"; import { faAngleRight, faCheck, faCopy, faLock } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { Link, useLocation, useNavigate } from "@tanstack/react-router"; +import { Link, useNavigate } from "@tanstack/react-router"; import { twMerge } from "tailwind-merge"; import { useOrganization, useWorkspace } from "@app/context"; diff --git a/frontend-v2/src/components/v2/projects/NewProjectModal.tsx b/frontend-v2/src/components/projects/NewProjectModal.tsx similarity index 93% rename from frontend-v2/src/components/v2/projects/NewProjectModal.tsx rename to frontend-v2/src/components/projects/NewProjectModal.tsx index 25cdb2df2..6906291bf 100644 --- a/frontend-v2/src/components/v2/projects/NewProjectModal.tsx +++ b/frontend-v2/src/components/projects/NewProjectModal.tsx @@ -1,9 +1,9 @@ import { FC, useEffect } from "react"; import { Controller, useForm } from "react-hook-form"; -import { useRouter } from "next/router"; import { faInfoCircle } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { zodResolver } from "@hookform/resolvers/zod"; +import { useNavigate } from "@tanstack/react-router"; import z from "zod"; import { createNotification } from "@app/components/notifications"; @@ -32,6 +32,7 @@ import { useSubscription, useUser } from "@app/context"; +import { getProjectHomePage } from "@app/helpers/project"; import { fetchOrgUsers, useAddUserToWsNonE2EE, @@ -41,6 +42,7 @@ import { } from "@app/hooks/api"; import { INTERNAL_KMS_KEY_ID } from "@app/hooks/api/kms/types"; import { InfisicalProjectTemplate, useListProjectTemplates } from "@app/hooks/api/projectTemplates"; +import { ProjectType } from "@app/hooks/api/workspace/types"; const formSchema = z.object({ name: z.string().trim().min(1, "Required").max(64, "Too long, maximum length is 64 characters"), @@ -59,12 +61,13 @@ type TAddProjectFormData = z.infer; interface NewProjectModalProps { isOpen: boolean; onOpenChange: (isOpen: boolean) => void; + projectType: ProjectType; } -type NewProjectFormProps = Pick; +type NewProjectFormProps = Pick; -const NewProjectForm = ({ onOpenChange }: NewProjectFormProps) => { - const router = useRouter(); +const NewProjectForm = ({ onOpenChange, projectType }: NewProjectFormProps) => { + const navigate = useNavigate(); const { currentOrg } = useOrganization(); const { permission } = useOrgPermission(); const { user } = useUser(); @@ -82,7 +85,7 @@ const NewProjectForm = ({ onOpenChange }: NewProjectFormProps) => { enabled: Boolean(canReadProjectTemplates && subscription?.projectTemplates) }); - const { data: externalKmsList } = useGetExternalKmsList(currentOrg?.id!, { + const { data: externalKmsList } = useGetExternalKmsList(currentOrg.id, { enabled: permission.can(OrgPermissionActions.Read, OrgPermissionSubjects.Kms) }); @@ -117,15 +120,15 @@ const NewProjectForm = ({ onOpenChange }: NewProjectFormProps) => { if (!user) return; try { const { - data: { - project: { id: newProjectId } - } + data: { project } } = await createWs.mutateAsync({ projectName: name, projectDescription: description, kmsKeyId: kmsKeyId !== INTERNAL_KMS_KEY_ID ? kmsKeyId : undefined, - template + template, + type: projectType }); + const { id: newProjectId } = project; if (addMembers) { const orgUsers = await fetchOrgUsers(currentOrg.id); @@ -145,7 +148,8 @@ const NewProjectForm = ({ onOpenChange }: NewProjectFormProps) => { createNotification({ text: "Project created", type: "success" }); reset(); onOpenChange(false); - router.push(`/project/${newProjectId}/secrets/overview`); + // TODO(rbr): make this return constant so this gets typed + navigate({ to: getProjectHomePage(project) }); } catch (err) { console.error(err); createNotification({ text: "Failed to create project", type: "error" }); @@ -316,14 +320,18 @@ const NewProjectForm = ({ onOpenChange }: NewProjectFormProps) => { ); }; -export const NewProjectModal: FC = ({ isOpen, onOpenChange }) => { +export const NewProjectModal: FC = ({ + isOpen, + onOpenChange, + projectType +}) => { return ( - + ); diff --git a/frontend-v2/src/components/v2/projects/index.tsx b/frontend-v2/src/components/projects/index.tsx similarity index 100% rename from frontend-v2/src/components/v2/projects/index.tsx rename to frontend-v2/src/components/projects/index.tsx diff --git a/frontend-v2/src/components/utilities/cryptography/crypto.ts b/frontend-v2/src/components/utilities/cryptography/crypto.ts index 64b2cd486..82bac0ad5 100644 --- a/frontend-v2/src/components/utilities/cryptography/crypto.ts +++ b/frontend-v2/src/components/utilities/cryptography/crypto.ts @@ -1,3 +1,5 @@ +// @ts-expect-error to avoid wasm dependencies +// eslint-disable-next-line import argon2 from "argon2-browser/dist/argon2-bundled.min.js"; import nacl from "tweetnacl"; import { decodeBase64, decodeUTF8, encodeBase64, encodeUTF8 } from "tweetnacl-util"; @@ -148,7 +150,7 @@ const decryptAssymmetric = ({ decodeBase64(privateKey) ); - return encodeUTF8(plaintext); + return encodeUTF8(plaintext!); }; type EncryptSymmetricProps = { diff --git a/frontend-v2/src/components/utilities/cryptography/issueBackupKey.ts b/frontend-v2/src/components/utilities/cryptography/issueBackupKey.ts index e65c53748..52a502e4e 100644 --- a/frontend-v2/src/components/utilities/cryptography/issueBackupKey.ts +++ b/frontend-v2/src/components/utilities/cryptography/issueBackupKey.ts @@ -73,7 +73,7 @@ const issueBackupKey = async ({ }, async () => { clientKey.createVerifier( - async (err: any, result: { salt: string; verifier: string }) => { + async (_err: any, result: { salt: string; verifier: string }) => { const { ciphertext, iv, tag } = Aes256Gcm.encrypt({ text: String(localStorage.getItem("PRIVATE_KEY")), secret: generatedKey @@ -104,7 +104,7 @@ const issueBackupKey = async ({ ); } ); - } catch (error) { + } catch { setBackupKeyError(true); console.log("Failed to issue a backup key"); } diff --git a/frontend-v2/src/components/utilities/secrets/checkOverrides.ts b/frontend-v2/src/components/utilities/secrets/checkOverrides.ts deleted file mode 100644 index 7f311a252..000000000 --- a/frontend-v2/src/components/utilities/secrets/checkOverrides.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { SecretDataProps } from "public/data/frequentInterfaces"; - -import { SecretType } from "@app/hooks/api/types"; - -/** - * This function downloads the secrets as a .env file - * @param {object} obj - * @param {SecretDataProps[]} obj.data - secrets that we want to check for overrides - * @returns - */ -const checkOverrides = async ({ data }: { data: SecretDataProps[] }) => { - let secrets: SecretDataProps[] = data!.map((secret) => Object.create(secret)); - const overridenSecrets = data!.filter((secret) => - secret.valueOverride === undefined || secret?.value !== secret?.valueOverride - ? SecretType.Shared - : SecretType.Personal - ); - if (overridenSecrets.length) { - overridenSecrets.forEach((secret) => { - const index = secrets!.findIndex( - (_secret) => - _secret.key === secret.key && - (secret.valueOverride === undefined || secret?.value !== secret?.valueOverride) - ); - secrets![index].value = secret.value; - }); - secrets = secrets!.filter( - (secret) => secret.valueOverride === undefined || secret?.value !== secret?.valueOverride - ); - } - return secrets; -}; - -export default checkOverrides; diff --git a/frontend-v2/src/components/utilities/secrets/downloadDotEnv.ts b/frontend-v2/src/components/utilities/secrets/downloadDotEnv.ts deleted file mode 100644 index ef71352b8..000000000 --- a/frontend-v2/src/components/utilities/secrets/downloadDotEnv.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { SecretDataProps } from "public/data/frequentInterfaces"; - -import checkOverrides from "./checkOverrides"; - -/** - * This function downloads the secrets as a .env file - * @param {object} obj - * @param {SecretDataProps[]} obj.data - secrets that we want to download - * @param {string} obj.env - the environment which we're downloading (used for naming the file) - */ -const downloadDotEnv = async ({ data, env }: { data: SecretDataProps[]; env: string }) => { - if (!data) return; - const secrets = await checkOverrides({ data }); - - const file = secrets! - .map( - (item: SecretDataProps) => - `${ - item.comment - ? `${item.comment - .split("\n") - .map((comment) => "# ".concat(comment)) - .join("\n")}\n` - : "" - }${[item.key, item.value].join("=")}` - ) - .join("\n"); - - const blob = new Blob([file]); - const fileDownloadUrl = URL.createObjectURL(blob); - const alink = document.createElement("a"); - alink.href = fileDownloadUrl; - alink.download = `${env}.env`; - alink.click(); -}; - -export default downloadDotEnv; diff --git a/frontend-v2/src/components/utilities/secrets/downloadYaml.ts b/frontend-v2/src/components/utilities/secrets/downloadYaml.ts deleted file mode 100644 index e8e6e0ab8..000000000 --- a/frontend-v2/src/components/utilities/secrets/downloadYaml.ts +++ /dev/null @@ -1,43 +0,0 @@ -// import YAML from 'yaml'; -// import { YAMLSeq } from 'yaml/types'; - -import { SecretDataProps } from "public/data/frequentInterfaces"; - -// import { envMapping } from "../../../public/data/frequentConstants"; -// import checkOverrides from './checkOverrides'; - -/** - * This function downloads the secrets as a .yml file - * @param {object} obj - * @param {SecretDataProps[]} obj.data - secrets that we want to download - * @param {string} obj.env - used for naming the file - * @returns - */ -// eslint-disable-next-line @typescript-eslint/no-unused-vars -const downloadYaml = async ({ data, env }: { data: SecretDataProps[]; env: string }) => { - // if (!data) return; - // const doc = new YAML.Document(); - // doc.contents = new YAMLSeq(); - // const secrets = await checkOverrides({ data }); - // secrets.forEach((secret) => { - // const pair = YAML.createNode({ [secret.key]: secret.value }); - // pair.commentBefore = secret.comment - // .split('\n') - // .map((line) => (line ? ' '.concat(line) : '')) - // .join('\n'); - // doc.add(pair); - // }); - // const file = doc - // .toString() - // .split('\n') - // .map((line) => (line.startsWith('-') ? line.replace('- ', '') : line)) - // .join('\n'); - // const blob = new Blob([file]); - // const fileDownloadUrl = URL.createObjectURL(blob); - // const alink = document.createElement('a'); - // alink.href = fileDownloadUrl; - // alink.download = envMapping[env] + '.yml'; - // alink.click(); -}; - -export default downloadYaml; diff --git a/frontend-v2/src/components/utilities/secrets/encryptSecrets.ts b/frontend-v2/src/components/utilities/secrets/encryptSecrets.ts deleted file mode 100644 index 121f3ab73..000000000 --- a/frontend-v2/src/components/utilities/secrets/encryptSecrets.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { SecretDataProps } from "public/data/frequentInterfaces"; -/** - * Encypt secrets before pushing the to the DB - * @param {object} obj - * @param {object} obj.secretsToEncrypt - secrets that we want to encrypt - * @param {object} obj.workspaceId - the id of a project in which we are encrypting secrets - * @returns - */ -const encryptSecrets = async ({ - secretsToEncrypt, - env -}: { - secretsToEncrypt: SecretDataProps[]; - workspaceId: string; - env: string; -}) => { - let secrets; - try { - secrets = secretsToEncrypt.map((secret) => { - const result = { - id: secret.id, - createdAt: "", - environment: env, - secretKey: secret.key, - secretValue: secret.value, - secretComment: secret.comment, - tags: secret.tags - }; - - return result; - }); - } catch (error) { - console.log("Error while encrypting secrets"); - } - - return secrets; -}; - -export default encryptSecrets; diff --git a/frontend-v2/src/context/OrganizationContext/OrganizationContext.tsx b/frontend-v2/src/context/OrganizationContext/OrganizationContext.tsx index b42d42531..2db7a19d7 100644 --- a/frontend-v2/src/context/OrganizationContext/OrganizationContext.tsx +++ b/frontend-v2/src/context/OrganizationContext/OrganizationContext.tsx @@ -1,8 +1,8 @@ import { createContext, ReactNode, useContext, useMemo } from "react"; +import { useRouteContext } from "@tanstack/react-router"; import { useGetOrganizations } from "@app/hooks/api"; import { Organization } from "@app/hooks/api/types"; -import { useRouteContext } from "@tanstack/react-router"; type TOrgContext = { orgs?: Organization[]; diff --git a/frontend-v2/src/context/SubscriptionContext/SubscriptionContext.tsx b/frontend-v2/src/context/SubscriptionContext/SubscriptionContext.tsx index 6444aa26c..21c103081 100644 --- a/frontend-v2/src/context/SubscriptionContext/SubscriptionContext.tsx +++ b/frontend-v2/src/context/SubscriptionContext/SubscriptionContext.tsx @@ -1,10 +1,10 @@ import { createContext, ReactNode, useContext, useMemo } from "react"; +import { useRouteContext } from "@tanstack/react-router"; import { useGetOrgSubscription } from "@app/hooks/api"; import { SubscriptionPlan } from "@app/hooks/api/types"; import { useOrganization } from "../OrganizationContext"; -import { useRouteContext } from "@tanstack/react-router"; type TSubscriptionContext = { subscription?: SubscriptionPlan; diff --git a/frontend-v2/src/context/UserContext/UserContext.tsx b/frontend-v2/src/context/UserContext/UserContext.tsx index d5e217645..58c953470 100644 --- a/frontend-v2/src/context/UserContext/UserContext.tsx +++ b/frontend-v2/src/context/UserContext/UserContext.tsx @@ -1,8 +1,8 @@ import { createContext, ReactNode, useContext, useMemo } from "react"; +import { useRouteContext } from "@tanstack/react-router"; import { useGetUser } from "@app/hooks/api"; import { User, UserEnc } from "@app/hooks/api/types"; -import { useRouteContext } from "@tanstack/react-router"; type TUserContext = { user: User & UserEnc; diff --git a/frontend-v2/src/helpers/key.ts b/frontend-v2/src/helpers/key.ts index 9301bb77b..c516826f1 100644 --- a/frontend-v2/src/helpers/key.ts +++ b/frontend-v2/src/helpers/key.ts @@ -74,7 +74,7 @@ const decryptPrivateKeyHelper = async ({ } else { throw new Error("Insufficient details to decrypt private key"); } - } catch (err) { + } catch { throw new Error("Failed to decrypt private key"); } diff --git a/frontend-v2/src/helpers/project.ts b/frontend-v2/src/helpers/project.ts index b6338ce35..8898f00c9 100644 --- a/frontend-v2/src/helpers/project.ts +++ b/frontend-v2/src/helpers/project.ts @@ -1,5 +1,6 @@ import { apiRequest } from "@app/config/request"; import { createWorkspace } from "@app/hooks/api/workspace/queries"; +import { ProjectType, Workspace } from "@app/hooks/api/workspace/types"; const secretsToBeAdded = [ { @@ -36,12 +37,13 @@ const secretsToBeAdded = [ * Create and initialize a new project in organization with id [organizationId] * Note: current user should be a member of the organization */ -const initProjectHelper = async ({ projectName }: { projectName: string }) => { +export const initProjectHelper = async ({ projectName }: { projectName: string }) => { // create new project const { data: { project } } = await createWorkspace({ - projectName + projectName, + type: ProjectType.SecretManager }); try { @@ -59,4 +61,22 @@ const initProjectHelper = async ({ projectName }: { projectName: string }) => { return project; }; -export { initProjectHelper }; +export const getProjectHomePage = (workspace: Workspace) => { + if (workspace.type === ProjectType.SecretManager) { + return `/${workspace.type}/${workspace.id}/secrets/overview`; + } + if (workspace.type === ProjectType.CertificateManager) { + return `/${workspace.type}/${workspace.id}/certificates`; + } + + return `/${workspace.type}/${workspace.id}/kms`; +}; + +export const getProjectTitle = (type: ProjectType) => { + const titleConvert = { + [ProjectType.SecretManager]: "Secret Management", + [ProjectType.KMS]: "Key Management", + [ProjectType.CertificateManager]: "Cert Management" + }; + return titleConvert[type]; +}; diff --git a/frontend-v2/src/hooks/api/accessApproval/mutation.tsx b/frontend-v2/src/hooks/api/accessApproval/mutation.tsx index 9c3199a99..32cc9c178 100644 --- a/frontend-v2/src/hooks/api/accessApproval/mutation.tsx +++ b/frontend-v2/src/hooks/api/accessApproval/mutation.tsx @@ -15,7 +15,7 @@ import { export const useCreateAccessApprovalPolicy = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, TCreateAccessPolicyDTO>({ + return useMutation({ mutationFn: async ({ environment, projectSlug, @@ -45,7 +45,7 @@ export const useCreateAccessApprovalPolicy = () => { export const useUpdateAccessApprovalPolicy = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, TUpdateAccessPolicyDTO>({ + return useMutation({ mutationFn: async ({ id, approvers, approvals, name, secretPath, enforcementLevel }) => { const { data } = await apiRequest.patch(`/api/v1/access-approvals/policies/${id}`, { approvals, @@ -65,7 +65,7 @@ export const useUpdateAccessApprovalPolicy = () => { export const useDeleteAccessApprovalPolicy = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, TDeleteSecretPolicyDTO>({ + return useMutation({ mutationFn: async ({ id }) => { const { data } = await apiRequest.delete(`/api/v1/access-approvals/policies/${id}`); return data; @@ -78,7 +78,7 @@ export const useDeleteAccessApprovalPolicy = () => { export const useCreateAccessRequest = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, TCreateAccessRequestDTO>({ + return useMutation({ mutationFn: async ({ projectSlug, ...request }) => { const { data } = await apiRequest.post( "/api/v1/access-approvals/requests", @@ -104,8 +104,8 @@ export const useCreateAccessRequest = () => { export const useReviewAccessRequest = () => { const queryClient = useQueryClient(); return useMutation< - {}, - {}, + object, + object, { requestId: string; status: "approved" | "rejected"; diff --git a/frontend-v2/src/hooks/api/admin/mutation.ts b/frontend-v2/src/hooks/api/admin/mutation.ts index 6cd13050e..8c414910d 100644 --- a/frontend-v2/src/hooks/api/admin/mutation.ts +++ b/frontend-v2/src/hooks/api/admin/mutation.ts @@ -18,7 +18,7 @@ export const useCreateAdminUser = () => { return useMutation< { user: User; token: string; organization: { id: string } }, - {}, + object, TCreateAdminUserDTO >({ mutationFn: async (opt) => { @@ -36,7 +36,7 @@ export const useUpdateServerConfig = () => { return useMutation< TServerConfig, - {}, + object, Partial >({ mutationFn: async (opt) => { @@ -72,7 +72,7 @@ export const useAdminDeleteUser = () => { export const useUpdateAdminSlackConfig = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async (dto) => { const { data } = await apiRequest.put( "/api/v1/admin/integrations/slack/config", diff --git a/frontend-v2/src/hooks/api/apiKeys/queries.tsx b/frontend-v2/src/hooks/api/apiKeys/queries.tsx index c1a2e4355..c913b797c 100644 --- a/frontend-v2/src/hooks/api/apiKeys/queries.tsx +++ b/frontend-v2/src/hooks/api/apiKeys/queries.tsx @@ -13,7 +13,7 @@ import { export const useCreateAPIKeyV2 = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ name }) => { const { data } = await apiRequest.post("/api/v3/api-key", { name @@ -29,7 +29,7 @@ export const useCreateAPIKeyV2 = () => { export const useUpdateAPIKeyV2 = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ apiKeyDataId, name }) => { const { data: { apiKeyData } @@ -46,7 +46,7 @@ export const useUpdateAPIKeyV2 = () => { export const useDeleteAPIKeyV2 = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ apiKeyDataId }) => { const { data: { apiKeyData } diff --git a/frontend-v2/src/hooks/api/auditLogStreams/mutations.tsx b/frontend-v2/src/hooks/api/auditLogStreams/mutations.tsx index 2d99f57c4..88094ad6b 100644 --- a/frontend-v2/src/hooks/api/auditLogStreams/mutations.tsx +++ b/frontend-v2/src/hooks/api/auditLogStreams/mutations.tsx @@ -13,7 +13,7 @@ import { export const useCreateAuditLogStream = () => { const queryClient = useQueryClient(); - return useMutation<{ auditLogStream: TAuditLogStream }, {}, TCreateAuditLogStreamDTO>({ + return useMutation<{ auditLogStream: TAuditLogStream }, object, TCreateAuditLogStreamDTO>({ mutationFn: async (dto) => { const { data } = await apiRequest.post<{ auditLogStream: TAuditLogStream }>( "/api/v1/audit-log-streams", @@ -30,7 +30,7 @@ export const useCreateAuditLogStream = () => { export const useUpdateAuditLogStream = () => { const queryClient = useQueryClient(); - return useMutation<{ auditLogStream: TAuditLogStream }, {}, TUpdateAuditLogStreamDTO>({ + return useMutation<{ auditLogStream: TAuditLogStream }, object, TUpdateAuditLogStreamDTO>({ mutationFn: async (dto) => { const { data } = await apiRequest.patch<{ auditLogStream: TAuditLogStream }>( `/api/v1/audit-log-streams/${dto.id}`, @@ -47,7 +47,7 @@ export const useUpdateAuditLogStream = () => { export const useDeleteAuditLogStream = () => { const queryClient = useQueryClient(); - return useMutation<{ auditLogStream: TAuditLogStream }, {}, TDeleteAuditLogStreamDTO>({ + return useMutation<{ auditLogStream: TAuditLogStream }, object, TDeleteAuditLogStreamDTO>({ mutationFn: async (dto) => { const { data } = await apiRequest.delete<{ auditLogStream: TAuditLogStream }>( `/api/v1/audit-log-streams/${dto.id}` diff --git a/frontend-v2/src/hooks/api/auditLogs/types.tsx b/frontend-v2/src/hooks/api/auditLogs/types.tsx index 5221b5033..62cf1b823 100644 --- a/frontend-v2/src/hooks/api/auditLogs/types.tsx +++ b/frontend-v2/src/hooks/api/auditLogs/types.tsx @@ -45,10 +45,9 @@ export interface IdentityActor { metadata: IdentityActorMetadata; } -export interface PlatformActorMetadata {} export interface PlatformActor { type: ActorType.PLATFORM; - metadata: PlatformActorMetadata; + metadata: object; } export type Actor = UserActor | ServiceActor | IdentityActor | PlatformActor; diff --git a/frontend-v2/src/hooks/api/auth/queries.tsx b/frontend-v2/src/hooks/api/auth/queries.tsx index c8bfbd79d..8d03ce614 100644 --- a/frontend-v2/src/hooks/api/auth/queries.tsx +++ b/frontend-v2/src/hooks/api/auth/queries.tsx @@ -148,7 +148,7 @@ export const useCompleteAccountSignup = () => { }; export const useSendMfaToken = () => { - return useMutation<{}, {}, SendMfaTokenDTO>({ + return useMutation({ mutationFn: async ({ email }) => { const { data } = await apiRequest.post("/api/v2/auth/mfa/send", { email }); return data; @@ -175,7 +175,7 @@ export const verifyMfaToken = async ({ }; export const useVerifyMfaToken = () => { - return useMutation({ + return useMutation({ mutationFn: async ({ email, mfaCode, mfaMethod }) => { return verifyMfaToken({ email, diff --git a/frontend-v2/src/hooks/api/bots/queries.tsx b/frontend-v2/src/hooks/api/bots/queries.tsx index 23049892c..3c9915791 100644 --- a/frontend-v2/src/hooks/api/bots/queries.tsx +++ b/frontend-v2/src/hooks/api/bots/queries.tsx @@ -23,7 +23,7 @@ export const useGetWorkspaceBot = (workspaceId: string) => export const useUpdateBotActiveStatus = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, TSetBotActiveStatusDto>({ + return useMutation({ mutationFn: ({ botId, isActive, botKey }) => { return apiRequest.patch(`/api/v1/bot/${botId}/active`, { isActive, diff --git a/frontend-v2/src/hooks/api/ca/mutations.tsx b/frontend-v2/src/hooks/api/ca/mutations.tsx index 0bbec617b..7fd09f346 100644 --- a/frontend-v2/src/hooks/api/ca/mutations.tsx +++ b/frontend-v2/src/hooks/api/ca/mutations.tsx @@ -21,7 +21,7 @@ import { export const useCreateCa = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async (body) => { const { data: { ca } @@ -36,7 +36,7 @@ export const useCreateCa = () => { export const useUpdateCa = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ caId, projectSlug, ...body }) => { const { data: { ca } @@ -52,7 +52,7 @@ export const useUpdateCa = () => { export const useDeleteCa = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ caId }) => { const { data: { ca } @@ -67,7 +67,7 @@ export const useDeleteCa = () => { export const useSignIntermediate = () => { // TODO: consider renaming - return useMutation({ + return useMutation({ mutationFn: async (body) => { const { data } = await apiRequest.post( `/api/v1/pki/ca/${body.caId}/sign-intermediate`, @@ -80,7 +80,7 @@ export const useSignIntermediate = () => { export const useImportCaCertificate = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ caId, ...body }) => { const { data } = await apiRequest.post( `/api/v1/pki/ca/${caId}/import-certificate`, @@ -99,7 +99,7 @@ export const useImportCaCertificate = () => { // consider rename to issue certificate export const useCreateCertificate = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async (body) => { const { data } = await apiRequest.post( "/api/v1/pki/certificates/issue-certificate", @@ -115,7 +115,7 @@ export const useCreateCertificate = () => { export const useRenewCa = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async (body) => { const { data } = await apiRequest.post( `/api/v1/pki/ca/${body.caId}/renew`, diff --git a/frontend-v2/src/hooks/api/certificateTemplates/mutations.tsx b/frontend-v2/src/hooks/api/certificateTemplates/mutations.tsx index 8545cf70c..f53543961 100644 --- a/frontend-v2/src/hooks/api/certificateTemplates/mutations.tsx +++ b/frontend-v2/src/hooks/api/certificateTemplates/mutations.tsx @@ -16,7 +16,7 @@ import { export const useCreateCertTemplate = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async (data) => { const { data: certificateTemplate } = await apiRequest.post( "/api/v1/pki/certificate-templates", @@ -33,7 +33,7 @@ export const useCreateCertTemplate = () => { export const useUpdateCertTemplate = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async (data) => { const { data: certificateTemplate } = await apiRequest.patch( `/api/v1/pki/certificate-templates/${data.id}`, @@ -52,7 +52,7 @@ export const useUpdateCertTemplate = () => { export const useDeleteCertTemplate = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async (data) => { const { data: certificateTemplate } = await apiRequest.delete( `/api/v1/pki/certificate-templates/${data.id}` @@ -69,7 +69,7 @@ export const useDeleteCertTemplate = () => { export const useCreateEstConfig = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, TCreateEstConfigDTO>({ + return useMutation({ mutationFn: async (body) => { const { data } = await apiRequest.post( `/api/v1/pki/certificate-templates/${body.certificateTemplateId}/est-config`, @@ -85,7 +85,7 @@ export const useCreateEstConfig = () => { export const useUpdateEstConfig = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, TUpdateEstConfigDTO>({ + return useMutation({ mutationFn: async (body) => { const { data } = await apiRequest.patch( `/api/v1/pki/certificate-templates/${body.certificateTemplateId}/est-config`, diff --git a/frontend-v2/src/hooks/api/certificates/mutations.tsx b/frontend-v2/src/hooks/api/certificates/mutations.tsx index d73a0cd15..00747f114 100644 --- a/frontend-v2/src/hooks/api/certificates/mutations.tsx +++ b/frontend-v2/src/hooks/api/certificates/mutations.tsx @@ -7,7 +7,7 @@ import { TCertificate, TDeleteCertDTO, TRevokeCertDTO } from "./types"; export const useDeleteCert = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ serialNumber }) => { const { data: { certificate } @@ -24,7 +24,7 @@ export const useDeleteCert = () => { export const useRevokeCert = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ serialNumber, revocationReason }) => { const { data: { certificate } diff --git a/frontend-v2/src/hooks/api/dynamicSecret/mutation.ts b/frontend-v2/src/hooks/api/dynamicSecret/mutation.ts index f8fbb4d05..b630132d2 100644 --- a/frontend-v2/src/hooks/api/dynamicSecret/mutation.ts +++ b/frontend-v2/src/hooks/api/dynamicSecret/mutation.ts @@ -14,7 +14,7 @@ import { export const useCreateDynamicSecret = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, TCreateDynamicSecretDTO>({ + return useMutation({ mutationFn: async (dto) => { const { data } = await apiRequest.post<{ dynamicSecret: TDynamicSecret }>( "/api/v1/dynamic-secrets", @@ -33,7 +33,7 @@ export const useCreateDynamicSecret = () => { export const useUpdateDynamicSecret = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, TUpdateDynamicSecretDTO>({ + return useMutation({ mutationFn: async (dto) => { const { data } = await apiRequest.patch<{ dynamicSecret: TDynamicSecret }>( `/api/v1/dynamic-secrets/${dto.name}`, @@ -52,7 +52,7 @@ export const useUpdateDynamicSecret = () => { export const useDeleteDynamicSecret = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, TDeleteDynamicSecretDTO>({ + return useMutation({ mutationFn: async (dto) => { const { data } = await apiRequest.delete<{ dynamicSecret: TDynamicSecret }>( `/api/v1/dynamic-secrets/${dto.name}`, diff --git a/frontend-v2/src/hooks/api/dynamicSecretLease/mutation.ts b/frontend-v2/src/hooks/api/dynamicSecretLease/mutation.ts index 3ed2b75d9..d1c6149f7 100644 --- a/frontend-v2/src/hooks/api/dynamicSecretLease/mutation.ts +++ b/frontend-v2/src/hooks/api/dynamicSecretLease/mutation.ts @@ -15,7 +15,7 @@ export const useCreateDynamicSecretLease = () => { return useMutation< { lease: TDynamicSecretLease; data: unknown }, - {}, + object, TCreateDynamicSecretLeaseDTO >({ mutationFn: async (dto) => { @@ -36,7 +36,7 @@ export const useCreateDynamicSecretLease = () => { export const useRenewDynamicSecretLease = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, TRenewDynamicSecretLeaseDTO>({ + return useMutation({ mutationFn: async (dto) => { const { data } = await apiRequest.post<{ lease: TDynamicSecretLease }>( `/api/v1/dynamic-secrets/leases/${dto.leaseId}/renew`, @@ -55,7 +55,7 @@ export const useRenewDynamicSecretLease = () => { export const useRevokeDynamicSecretLease = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, TRevokeDynamicSecretLeaseDTO>({ + return useMutation({ mutationFn: async (dto) => { const { data } = await apiRequest.delete<{ lease: TDynamicSecretLease }>( `/api/v1/dynamic-secrets/leases/${dto.leaseId}`, diff --git a/frontend-v2/src/hooks/api/identities/mutations.tsx b/frontend-v2/src/hooks/api/identities/mutations.tsx index 8daaae236..5efc69cad 100644 --- a/frontend-v2/src/hooks/api/identities/mutations.tsx +++ b/frontend-v2/src/hooks/api/identities/mutations.tsx @@ -55,7 +55,7 @@ import { export const useCreateIdentity = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async (body) => { const { data: { identity } @@ -70,7 +70,7 @@ export const useCreateIdentity = () => { export const useUpdateIdentity = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ identityId, name, role, metadata }) => { const { data: { identity } @@ -91,7 +91,7 @@ export const useUpdateIdentity = () => { export const useDeleteIdentity = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ identityId }) => { const { data: { identity } @@ -108,7 +108,7 @@ export const useDeleteIdentity = () => { export const useAddIdentityUniversalAuth = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ identityId, clientSecretTrustedIps, @@ -138,7 +138,7 @@ export const useAddIdentityUniversalAuth = () => { export const useUpdateIdentityUniversalAuth = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ identityId, clientSecretTrustedIps, @@ -168,7 +168,7 @@ export const useUpdateIdentityUniversalAuth = () => { export const useDeleteIdentityUniversalAuth = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ identityId }) => { const { data: { identityUniversalAuth } @@ -187,7 +187,7 @@ export const useCreateIdentityUniversalAuthClientSecret = () => { const queryClient = useQueryClient(); return useMutation< CreateIdentityUniversalAuthClientSecretRes, - {}, + object, CreateIdentityUniversalAuthClientSecretDTO >({ mutationFn: async ({ identityId, description, ttl, numUsesLimit }) => { @@ -211,7 +211,7 @@ export const useCreateIdentityUniversalAuthClientSecret = () => { export const useRevokeIdentityUniversalAuthClientSecret = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ identityId, clientSecretId }) => { const { data: { clientSecretData } @@ -230,7 +230,7 @@ export const useRevokeIdentityUniversalAuthClientSecret = () => { export const useAddIdentityGcpAuth = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ identityId, type, @@ -270,7 +270,7 @@ export const useAddIdentityGcpAuth = () => { export const useUpdateIdentityGcpAuth = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ identityId, type, @@ -310,7 +310,7 @@ export const useUpdateIdentityGcpAuth = () => { export const useDeleteIdentityGcpAuth = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ identityId }) => { const { data: { identityGcpAuth } @@ -327,7 +327,7 @@ export const useDeleteIdentityGcpAuth = () => { export const useAddIdentityAwsAuth = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ identityId, stsEndpoint, @@ -365,7 +365,7 @@ export const useAddIdentityAwsAuth = () => { export const useUpdateIdentityAwsAuth = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ identityId, stsEndpoint, @@ -403,7 +403,7 @@ export const useUpdateIdentityAwsAuth = () => { export const useDeleteIdentityAwsAuth = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ identityId }) => { const { data: { identityAwsAuth } @@ -420,7 +420,7 @@ export const useDeleteIdentityAwsAuth = () => { export const useUpdateIdentityOidcAuth = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ identityId, accessTokenTTL, @@ -464,7 +464,7 @@ export const useUpdateIdentityOidcAuth = () => { export const useAddIdentityOidcAuth = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ identityId, oidcDiscoveryUrl, @@ -508,7 +508,7 @@ export const useAddIdentityOidcAuth = () => { export const useDeleteIdentityOidcAuth = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ identityId }) => { const { data: { identityOidcAuth } @@ -524,7 +524,7 @@ export const useDeleteIdentityOidcAuth = () => { }; export const useUpdateIdentityJwtAuth = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ identityId, configurationType, @@ -572,7 +572,7 @@ export const useUpdateIdentityJwtAuth = () => { export const useAddIdentityJwtAuth = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ identityId, configurationType, @@ -620,7 +620,7 @@ export const useAddIdentityJwtAuth = () => { export const useDeleteIdentityJwtAuth = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ identityId }) => { const { data: { identityJwtAuth } @@ -637,7 +637,7 @@ export const useDeleteIdentityJwtAuth = () => { export const useAddIdentityAzureAuth = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ identityId, tenantId, @@ -675,7 +675,7 @@ export const useAddIdentityAzureAuth = () => { export const useAddIdentityKubernetesAuth = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ identityId, kubernetesHost, @@ -719,7 +719,7 @@ export const useAddIdentityKubernetesAuth = () => { export const useUpdateIdentityAzureAuth = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ identityId, tenantId, @@ -757,7 +757,7 @@ export const useUpdateIdentityAzureAuth = () => { export const useDeleteIdentityAzureAuth = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ identityId }) => { const { data: { identityAzureAuth } @@ -774,7 +774,7 @@ export const useDeleteIdentityAzureAuth = () => { export const useUpdateIdentityKubernetesAuth = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ identityId, kubernetesHost, @@ -818,7 +818,7 @@ export const useUpdateIdentityKubernetesAuth = () => { export const useDeleteIdentityKubernetesAuth = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ identityId }) => { const { data: { identityKubernetesAuth } @@ -835,7 +835,7 @@ export const useDeleteIdentityKubernetesAuth = () => { export const useAddIdentityTokenAuth = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ identityId, accessTokenTTL, @@ -867,7 +867,7 @@ export const useAddIdentityTokenAuth = () => { export const useUpdateIdentityTokenAuth = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ identityId, accessTokenTTL, @@ -899,7 +899,7 @@ export const useUpdateIdentityTokenAuth = () => { export const useDeleteIdentityTokenAuth = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ identityId }) => { const { data: { identityTokenAuth } @@ -916,7 +916,7 @@ export const useDeleteIdentityTokenAuth = () => { export const useCreateTokenIdentityTokenAuth = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ identityId, name }) => { const { data } = await apiRequest.post( `/api/v1/auth/token-auth/identities/${identityId}/tokens`, @@ -935,7 +935,7 @@ export const useCreateTokenIdentityTokenAuth = () => { export const useUpdateIdentityTokenAuthToken = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ tokenId, name }) => { const { data: { token } @@ -956,7 +956,7 @@ export const useUpdateIdentityTokenAuthToken = () => { export const useRevokeIdentityTokenAuthToken = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ tokenId }) => { const { data } = await apiRequest.post( `/api/v1/auth/token-auth/tokens/${tokenId}/revoke` diff --git a/frontend-v2/src/hooks/api/identityProjectAdditionalPrivilege/mutation.tsx b/frontend-v2/src/hooks/api/identityProjectAdditionalPrivilege/mutation.tsx index ab8a2e5d1..167eea73e 100644 --- a/frontend-v2/src/hooks/api/identityProjectAdditionalPrivilege/mutation.tsx +++ b/frontend-v2/src/hooks/api/identityProjectAdditionalPrivilege/mutation.tsx @@ -13,7 +13,7 @@ import { export const useCreateIdentityProjectAdditionalPrivilege = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async (dto) => { const { data } = await apiRequest.post("/api/v2/identity-project-additional-privilege", dto); return data.privilege; @@ -27,7 +27,7 @@ export const useCreateIdentityProjectAdditionalPrivilege = () => { export const useUpdateIdentityProjectAdditionalPrivilege = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ projectId, privilegeId, identityId, permissions, slug, type }) => { const { data: res } = await apiRequest.patch( `/api/v2/identity-project-additional-privilege/${privilegeId}`, @@ -51,7 +51,7 @@ export const useUpdateIdentityProjectAdditionalPrivilege = () => { export const useDeleteIdentityProjectAdditionalPrivilege = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ identityId, projectId, privilegeId }) => { const { data } = await apiRequest.delete( `/api/v2/identity-project-additional-privilege/${privilegeId}`, diff --git a/frontend-v2/src/hooks/api/incidentContacts/queries.tsx b/frontend-v2/src/hooks/api/incidentContacts/queries.tsx index 98f95d785..04611879c 100644 --- a/frontend-v2/src/hooks/api/incidentContacts/queries.tsx +++ b/frontend-v2/src/hooks/api/incidentContacts/queries.tsx @@ -25,7 +25,7 @@ export const useGetOrgIncidentContact = (orgId: string) => export const useAddIncidentContact = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, AddIncidentContactDTO>({ + return useMutation({ mutationFn: async ({ orgId, email }) => { const { data } = await apiRequest.post(`/api/v1/organization/${orgId}/incidentContactOrg`, { email @@ -41,7 +41,7 @@ export const useAddIncidentContact = () => { export const useDeleteIncidentContact = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, DeleteIncidentContactDTO>({ + return useMutation({ mutationFn: async ({ orgId, incidentContactId }) => { const { data } = await apiRequest.delete( `/api/v1/organization/${orgId}/incidentContactOrg/${incidentContactId}` diff --git a/frontend-v2/src/hooks/api/integrationAuth/mutations.tsx b/frontend-v2/src/hooks/api/integrationAuth/mutations.tsx index b7a3f18bd..b66eea530 100644 --- a/frontend-v2/src/hooks/api/integrationAuth/mutations.tsx +++ b/frontend-v2/src/hooks/api/integrationAuth/mutations.tsx @@ -6,7 +6,7 @@ import { IntegrationAuth, TDuplicateIntegrationAuthDTO } from "./types"; // For now, this should only be used in the Github app integration flow. export const useDuplicateIntegrationAuth = () => { - return useMutation({ + return useMutation({ mutationFn: async (body) => { const { data } = await apiRequest.post<{ integrationAuth: IntegrationAuth }>( `/api/v1/integration-auth/${body.integrationAuthId}/duplicate`, diff --git a/frontend-v2/src/hooks/api/integrationAuth/queries.tsx b/frontend-v2/src/hooks/api/integrationAuth/queries.tsx index e5f928158..e43f4cc68 100644 --- a/frontend-v2/src/hooks/api/integrationAuth/queries.tsx +++ b/frontend-v2/src/hooks/api/integrationAuth/queries.tsx @@ -966,7 +966,7 @@ export const useSaveIntegrationAccessToken = () => { export const useDeleteIntegrationAuths = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, { integration: string; workspaceId: string }>({ + return useMutation({ mutationFn: ({ integration, workspaceId }) => apiRequest.delete( `/api/v1/integration-auth?${new URLSearchParams({ @@ -985,7 +985,7 @@ export const useDeleteIntegrationAuth = () => { // not used const queryClient = useQueryClient(); - return useMutation<{}, {}, { id: string; workspaceId: string }>({ + return useMutation({ mutationFn: ({ id }) => apiRequest.delete(`/api/v1/integration-auth/${id}`), onSuccess: (_, { workspaceId }) => { queryClient.invalidateQueries(workspaceKeys.getWorkspaceAuthorization(workspaceId)); diff --git a/frontend-v2/src/hooks/api/integrations/queries.tsx b/frontend-v2/src/hooks/api/integrations/queries.tsx index 11d42631a..414cf691c 100644 --- a/frontend-v2/src/hooks/api/integrations/queries.tsx +++ b/frontend-v2/src/hooks/api/integrations/queries.tsx @@ -123,8 +123,8 @@ export const useDeleteIntegration = () => { const queryClient = useQueryClient(); return useMutation< - {}, - {}, + object, + object, { id: string; workspaceId: string; shouldDeleteIntegrationSecrets: boolean } >({ mutationFn: ({ id, shouldDeleteIntegrationSecrets }) => @@ -159,7 +159,7 @@ export const useGetIntegration = ( }; export const useSyncIntegration = () => { - return useMutation<{}, {}, { id: string; workspaceId: string; lastUsed: string }>({ + return useMutation({ mutationFn: ({ id }) => apiRequest.post(`/api/v1/integration/${id}/sync`), onSuccess: () => { createNotification({ diff --git a/frontend-v2/src/hooks/api/keys/queries.tsx b/frontend-v2/src/hooks/api/keys/queries.tsx index 7e59c0840..f902f85d3 100644 --- a/frontend-v2/src/hooks/api/keys/queries.tsx +++ b/frontend-v2/src/hooks/api/keys/queries.tsx @@ -31,7 +31,7 @@ export const uploadWsKey = async ({ workspaceId, userId, encryptedKey, nonce }: }; export const useUploadWsKey = () => - useMutation<{}, {}, UploadWsKeyDTO>({ + useMutation({ mutationFn: async ({ encryptedKey, nonce, userId, workspaceId }) => { return uploadWsKey({ workspaceId, diff --git a/frontend-v2/src/hooks/api/ldapConfig/queries.tsx b/frontend-v2/src/hooks/api/ldapConfig/queries.tsx index e92a7a1c7..d3358014b 100644 --- a/frontend-v2/src/hooks/api/ldapConfig/queries.tsx +++ b/frontend-v2/src/hooks/api/ldapConfig/queries.tsx @@ -19,7 +19,7 @@ export const useGetLDAPConfig = (organizationId: string) => { ); return data; - } catch (err) { + } catch { return null; } }, diff --git a/frontend-v2/src/hooks/api/oidcConfig/queries.tsx b/frontend-v2/src/hooks/api/oidcConfig/queries.tsx index 49db7c5d4..e22d2ee2f 100644 --- a/frontend-v2/src/hooks/api/oidcConfig/queries.tsx +++ b/frontend-v2/src/hooks/api/oidcConfig/queries.tsx @@ -18,7 +18,7 @@ export const useGetOIDCConfig = (orgSlug: string) => { ); return data; - } catch (err) { + } catch { return null; } }, diff --git a/frontend-v2/src/hooks/api/organization/queries.tsx b/frontend-v2/src/hooks/api/organization/queries.tsx index 90844d7fe..a99be251f 100644 --- a/frontend-v2/src/hooks/api/organization/queries.tsx +++ b/frontend-v2/src/hooks/api/organization/queries.tsx @@ -100,7 +100,7 @@ export const useCreateOrg = (options: { invalidate: boolean } = { invalidate: tr export const useUpdateOrg = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, UpdateOrgDTO>({ + return useMutation({ mutationFn: ({ name, authEnforced, diff --git a/frontend-v2/src/hooks/api/pkiAlerts/mutations.tsx b/frontend-v2/src/hooks/api/pkiAlerts/mutations.tsx index 54aa8eeff..1a5159df7 100644 --- a/frontend-v2/src/hooks/api/pkiAlerts/mutations.tsx +++ b/frontend-v2/src/hooks/api/pkiAlerts/mutations.tsx @@ -8,7 +8,7 @@ import { TCreatePkiAlertDTO, TDeletePkiAlertDTO, TPkiAlert, TUpdatePkiAlertDTO } export const useCreatePkiAlert = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async (body) => { const { data: alert } = await apiRequest.post("/api/v1/pki/alerts", body); return alert; @@ -21,7 +21,7 @@ export const useCreatePkiAlert = () => { export const useUpdatePkiAlert = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ alertId, ...body }) => { const { data: alert } = await apiRequest.patch( `/api/v1/pki/alerts/${alertId}`, @@ -38,7 +38,7 @@ export const useUpdatePkiAlert = () => { export const useDeletePkiAlert = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ alertId }) => { const { data: alert } = await apiRequest.delete(`/api/v1/pki/alerts/${alertId}`); return alert; diff --git a/frontend-v2/src/hooks/api/pkiCollections/mutations.tsx b/frontend-v2/src/hooks/api/pkiCollections/mutations.tsx index 496a17051..8451befcf 100644 --- a/frontend-v2/src/hooks/api/pkiCollections/mutations.tsx +++ b/frontend-v2/src/hooks/api/pkiCollections/mutations.tsx @@ -16,7 +16,7 @@ import { export const useCreatePkiCollection = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async (body) => { const { data: pkiCollection } = await apiRequest.post( "/api/v1/pki/collections", @@ -32,7 +32,7 @@ export const useCreatePkiCollection = () => { export const useUpdatePkiCollection = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ collectionId, ...body }) => { const { data: pkiCollection } = await apiRequest.patch( `/api/v1/pki/collections/${collectionId}`, @@ -49,7 +49,7 @@ export const useUpdatePkiCollection = () => { export const useDeletePkiCollection = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ collectionId }) => { const { data: pkiCollection } = await apiRequest.delete( `/api/v1/pki/collections/${collectionId}` @@ -65,7 +65,7 @@ export const useDeletePkiCollection = () => { export const useAddItemToPkiCollection = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ collectionId, type, itemId }) => { const { data: pkiCollectionItem } = await apiRequest.post( `/api/v1/pki/collections/${collectionId}/items`, @@ -84,7 +84,7 @@ export const useAddItemToPkiCollection = () => { export const useRemoveItemFromPkiCollection = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ collectionId, itemId }) => { const { data: pkiCollectionItem } = await apiRequest.delete( `/api/v1/pki/collections/${collectionId}/items/${itemId}` diff --git a/frontend-v2/src/hooks/api/projectUserAdditionalPrivilege/mutation.tsx b/frontend-v2/src/hooks/api/projectUserAdditionalPrivilege/mutation.tsx index de0a1a51e..32ecc36d4 100644 --- a/frontend-v2/src/hooks/api/projectUserAdditionalPrivilege/mutation.tsx +++ b/frontend-v2/src/hooks/api/projectUserAdditionalPrivilege/mutation.tsx @@ -13,7 +13,7 @@ import { export const useCreateProjectUserAdditionalPrivilege = () => { const queryClient = useQueryClient(); - return useMutation<{ privilege: TProjectUserPrivilege }, {}, TCreateProjectUserPrivilegeDTO>({ + return useMutation<{ privilege: TProjectUserPrivilege }, object, TCreateProjectUserPrivilegeDTO>({ mutationFn: async (dto) => { const { data } = await apiRequest.post("/api/v1/user-project-additional-privilege", dto); return data.privilege; @@ -27,7 +27,7 @@ export const useCreateProjectUserAdditionalPrivilege = () => { export const useUpdateProjectUserAdditionalPrivilege = () => { const queryClient = useQueryClient(); - return useMutation<{ privilege: TProjectUserPrivilege }, {}, TUpdateProjectUserPrivlegeDTO>({ + return useMutation<{ privilege: TProjectUserPrivilege }, object, TUpdateProjectUserPrivlegeDTO>({ mutationFn: async (dto) => { const { data } = await apiRequest.patch( `/api/v1/user-project-additional-privilege/${dto.privilegeId}`, @@ -44,7 +44,7 @@ export const useUpdateProjectUserAdditionalPrivilege = () => { export const useDeleteProjectUserAdditionalPrivilege = () => { const queryClient = useQueryClient(); - return useMutation<{ privilege: TProjectUserPrivilege }, {}, TDeleteProjectUserPrivilegeDTO>({ + return useMutation<{ privilege: TProjectUserPrivilege }, object, TDeleteProjectUserPrivilegeDTO>({ mutationFn: async (dto) => { const { data } = await apiRequest.delete( `/api/v1/user-project-additional-privilege/${dto.privilegeId}` diff --git a/frontend-v2/src/hooks/api/rateLimit/mutation.ts b/frontend-v2/src/hooks/api/rateLimit/mutation.ts index 22a7f9898..2bc79b81d 100644 --- a/frontend-v2/src/hooks/api/rateLimit/mutation.ts +++ b/frontend-v2/src/hooks/api/rateLimit/mutation.ts @@ -8,7 +8,7 @@ import { TRateLimit } from "./types"; export const useUpdateRateLimit = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async (opt) => { const { data } = await apiRequest.put<{ rateLimit: TRateLimit }>("/api/v1/rate-limit", opt); return data.rateLimit; diff --git a/frontend-v2/src/hooks/api/roles/mutation.tsx b/frontend-v2/src/hooks/api/roles/mutation.tsx index 1562fbf1a..80921063d 100644 --- a/frontend-v2/src/hooks/api/roles/mutation.tsx +++ b/frontend-v2/src/hooks/api/roles/mutation.tsx @@ -18,7 +18,7 @@ import { export const useCreateProjectRole = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ projectId, ...dto }: TCreateProjectRoleDTO) => { const { data: { role } @@ -34,7 +34,7 @@ export const useCreateProjectRole = () => { export const useUpdateProjectRole = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ id, projectId, ...dto }: TUpdateProjectRoleDTO) => { const { data: { role } @@ -52,7 +52,7 @@ export const useUpdateProjectRole = () => { export const useDeleteProjectRole = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ projectId, id }: TDeleteProjectRoleDTO) => { const { data: { role } @@ -68,7 +68,7 @@ export const useDeleteProjectRole = () => { export const useCreateOrgRole = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ orgId, permissions, ...dto }: TCreateOrgRoleDTO) => { const { data: { role } @@ -88,7 +88,7 @@ export const useCreateOrgRole = () => { export const useUpdateOrgRole = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ id, orgId, permissions, ...dto }: TUpdateOrgRoleDTO) => { const { data: { role } @@ -109,7 +109,7 @@ export const useUpdateOrgRole = () => { export const useDeleteOrgRole = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ orgId, id }: TDeleteOrgRoleDTO) => { const { data: { role } diff --git a/frontend-v2/src/hooks/api/scim/mutations.tsx b/frontend-v2/src/hooks/api/scim/mutations.tsx index f779b8860..259b140c1 100644 --- a/frontend-v2/src/hooks/api/scim/mutations.tsx +++ b/frontend-v2/src/hooks/api/scim/mutations.tsx @@ -7,7 +7,7 @@ import { CreateScimTokenDTO, CreateScimTokenRes, DeleteScimTokenDTO } from "./ty export const useCreateScimToken = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ organizationId, description, ttlDays }) => { const { data } = await apiRequest.post("/api/v1/scim/scim-tokens", { organizationId, @@ -25,7 +25,7 @@ export const useCreateScimToken = () => { export const useDeleteScimToken = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ scimTokenId }) => { const { data } = await apiRequest.delete(`/api/v1/scim/scim-tokens/${scimTokenId}`); return data; diff --git a/frontend-v2/src/hooks/api/secretApproval/mutation.tsx b/frontend-v2/src/hooks/api/secretApproval/mutation.tsx index ceebd3493..75fdfff87 100644 --- a/frontend-v2/src/hooks/api/secretApproval/mutation.tsx +++ b/frontend-v2/src/hooks/api/secretApproval/mutation.tsx @@ -8,7 +8,7 @@ import { TCreateSecretPolicyDTO, TDeleteSecretPolicyDTO, TUpdateSecretPolicyDTO export const useCreateSecretApprovalPolicy = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, TCreateSecretPolicyDTO>({ + return useMutation({ mutationFn: async ({ environment, workspaceId, @@ -38,7 +38,7 @@ export const useCreateSecretApprovalPolicy = () => { export const useUpdateSecretApprovalPolicy = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, TUpdateSecretPolicyDTO>({ + return useMutation({ mutationFn: async ({ id, approvers, approvals, secretPath, name, enforcementLevel }) => { const { data } = await apiRequest.patch(`/api/v1/secret-approvals/${id}`, { approvals, @@ -58,7 +58,7 @@ export const useUpdateSecretApprovalPolicy = () => { export const useDeleteSecretApprovalPolicy = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, TDeleteSecretPolicyDTO>({ + return useMutation({ mutationFn: async ({ id }) => { const { data } = await apiRequest.delete(`/api/v1/secret-approvals/${id}`); return data; diff --git a/frontend-v2/src/hooks/api/secretApprovalRequest/mutation.tsx b/frontend-v2/src/hooks/api/secretApprovalRequest/mutation.tsx index f3b389644..0366bf7cb 100644 --- a/frontend-v2/src/hooks/api/secretApprovalRequest/mutation.tsx +++ b/frontend-v2/src/hooks/api/secretApprovalRequest/mutation.tsx @@ -12,7 +12,7 @@ import { export const useUpdateSecretApprovalReviewStatus = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, TUpdateSecretApprovalReviewStatusDTO>({ + return useMutation({ mutationFn: async ({ id, status }) => { const { data } = await apiRequest.post(`/api/v1/secret-approval-requests/${id}/review`, { status @@ -28,7 +28,7 @@ export const useUpdateSecretApprovalReviewStatus = () => { export const useUpdateSecretApprovalRequestStatus = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, TUpdateSecretApprovalRequestStatusDTO>({ + return useMutation({ mutationFn: async ({ id, status }) => { const { data } = await apiRequest.post(`/api/v1/secret-approval-requests/${id}/status`, { status @@ -45,7 +45,7 @@ export const useUpdateSecretApprovalRequestStatus = () => { export const usePerformSecretApprovalRequestMerge = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, TPerformSecretApprovalRequestMerge>({ + return useMutation({ mutationFn: async ({ id, bypassReason }) => { const { data } = await apiRequest.post(`/api/v1/secret-approval-requests/${id}/merge`, { bypassReason diff --git a/frontend-v2/src/hooks/api/secretApprovalRequest/queries.tsx b/frontend-v2/src/hooks/api/secretApprovalRequest/queries.tsx index a15316018..d5bca0ccd 100644 --- a/frontend-v2/src/hooks/api/secretApprovalRequest/queries.tsx +++ b/frontend-v2/src/hooks/api/secretApprovalRequest/queries.tsx @@ -143,7 +143,7 @@ const fetchSecretApprovalRequestList = async ({ export const useGetSecretApprovalRequests = ({ workspaceId, environment, - options = {}, + options = object, status, limit = 20, committer diff --git a/frontend-v2/src/hooks/api/secretFolders/queries.tsx b/frontend-v2/src/hooks/api/secretFolders/queries.tsx index d85bc558a..f3b1cb649 100644 --- a/frontend-v2/src/hooks/api/secretFolders/queries.tsx +++ b/frontend-v2/src/hooks/api/secretFolders/queries.tsx @@ -116,7 +116,7 @@ export const useGetFoldersByEnv = ({ export const useCreateFolder = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, TCreateFolderDTO>({ + return useMutation({ mutationFn: async (dto) => { const { data } = await apiRequest.post("/api/v1/folders", { ...dto, @@ -147,7 +147,7 @@ export const useCreateFolder = () => { export const useUpdateFolder = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, TUpdateFolderDTO>({ + return useMutation({ mutationFn: async ({ path = "/", folderId, name, environment, projectId }) => { const { data } = await apiRequest.patch(`/api/v1/folders/${folderId}`, { name, @@ -180,7 +180,7 @@ export const useUpdateFolder = () => { export const useDeleteFolder = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, TDeleteFolderDTO>({ + return useMutation({ mutationFn: async ({ path = "/", folderId, environment, projectId }) => { const { data } = await apiRequest.delete(`/api/v1/folders/${folderId}`, { data: { @@ -214,7 +214,7 @@ export const useDeleteFolder = () => { export const useUpdateFolderBatch = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, TUpdateFolderBatchDTO>({ + return useMutation({ mutationFn: async ({ projectSlug, folders }) => { const { data } = await apiRequest.patch("/api/v1/folders/batch", { projectSlug, diff --git a/frontend-v2/src/hooks/api/secretImports/mutation.tsx b/frontend-v2/src/hooks/api/secretImports/mutation.tsx index 4bee1a4ed..0f55333fd 100644 --- a/frontend-v2/src/hooks/api/secretImports/mutation.tsx +++ b/frontend-v2/src/hooks/api/secretImports/mutation.tsx @@ -14,7 +14,7 @@ import { export const useCreateSecretImport = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, TCreateSecretImportDTO>({ + return useMutation({ mutationFn: async ({ import: secretImport, environment, isReplication, projectId, path }) => { const { data } = await apiRequest.post("/api/v1/secret-imports", { import: secretImport, @@ -42,7 +42,7 @@ export const useCreateSecretImport = () => { export const useUpdateSecretImport = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, TUpdateSecretImportDTO>({ + return useMutation({ mutationFn: async ({ environment, import: secretImports, projectId, path, id }) => { const { data } = await apiRequest.patch(`/api/v1/secret-imports/${id}`, { import: secretImports, @@ -67,7 +67,7 @@ export const useUpdateSecretImport = () => { }; export const useResyncSecretReplication = () => { - return useMutation<{}, {}, TResyncSecretReplicationDTO>({ + return useMutation({ mutationFn: async ({ environment, projectId, path, id }) => { const { data } = await apiRequest.post(`/api/v1/secret-imports/${id}/replication-resync`, { environment, @@ -82,7 +82,7 @@ export const useResyncSecretReplication = () => { export const useDeleteSecretImport = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, TDeleteSecretImportDTO>({ + return useMutation({ mutationFn: async ({ id, projectId, path, environment }) => { const { data } = await apiRequest.delete(`/api/v1/secret-imports/${id}`, { data: { diff --git a/frontend-v2/src/hooks/api/secretRotation/mutation.tsx b/frontend-v2/src/hooks/api/secretRotation/mutation.tsx index cda4f8074..c62ea1ead 100644 --- a/frontend-v2/src/hooks/api/secretRotation/mutation.tsx +++ b/frontend-v2/src/hooks/api/secretRotation/mutation.tsx @@ -12,7 +12,7 @@ import { export const useCreateSecretRotation = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, TCreateSecretRotationDTO>({ + return useMutation({ mutationFn: async (dto) => { const { data } = await apiRequest.post("/api/v1/secret-rotations", dto); return data; @@ -26,7 +26,7 @@ export const useCreateSecretRotation = () => { export const useDeleteSecretRotation = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, TDeleteSecretRotationDTO>({ + return useMutation({ mutationFn: async (dto) => { const { data } = await apiRequest.delete(`/api/v1/secret-rotations/${dto.id}`); return data; @@ -40,7 +40,7 @@ export const useDeleteSecretRotation = () => { export const useRestartSecretRotation = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, TRestartSecretRotationDTO>({ + return useMutation({ mutationFn: async (dto) => { const { data } = await apiRequest.post("/api/v1/secret-rotations/restart", { id: dto.id }); return data; diff --git a/frontend-v2/src/hooks/api/secretSnapshots/queries.tsx b/frontend-v2/src/hooks/api/secretSnapshots/queries.tsx index f45d6db5e..5003d5abe 100644 --- a/frontend-v2/src/hooks/api/secretSnapshots/queries.tsx +++ b/frontend-v2/src/hooks/api/secretSnapshots/queries.tsx @@ -142,7 +142,7 @@ export const useGetWsSnapshotCount = ({ export const usePerformSecretRollback = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, TSecretRollbackDTO>({ + return useMutation({ mutationFn: async ({ snapshotId }) => { const { data } = await apiRequest.post(`/api/v1/secret-snapshot/${snapshotId}/rollback`); return data; diff --git a/frontend-v2/src/hooks/api/secrets/mutations.tsx b/frontend-v2/src/hooks/api/secrets/mutations.tsx index 7bc3849be..4dc52de58 100644 --- a/frontend-v2/src/hooks/api/secrets/mutations.tsx +++ b/frontend-v2/src/hooks/api/secrets/mutations.tsx @@ -19,10 +19,10 @@ import { export const useCreateSecretV3 = ({ options }: { - options?: Omit, "mutationFn">; + options?: Omit, "mutationFn">; } = {}) => { const queryClient = useQueryClient(); - return useMutation<{}, {}, TCreateSecretsV3DTO>({ + return useMutation({ mutationFn: async ({ secretPath = "/", type, @@ -68,10 +68,10 @@ export const useCreateSecretV3 = ({ export const useUpdateSecretV3 = ({ options }: { - options?: Omit, "mutationFn">; + options?: Omit, "mutationFn">; } = {}) => { const queryClient = useQueryClient(); - return useMutation<{}, {}, TUpdateSecretsV3DTO>({ + return useMutation({ mutationFn: async ({ secretPath = "/", type, @@ -123,11 +123,11 @@ export const useUpdateSecretV3 = ({ export const useDeleteSecretV3 = ({ options }: { - options?: Omit, "mutationFn">; + options?: Omit, "mutationFn">; } = {}) => { const queryClient = useQueryClient(); - return useMutation<{}, {}, TDeleteSecretsV3DTO>({ + return useMutation({ mutationFn: async ({ secretPath = "/", type, @@ -169,11 +169,11 @@ export const useDeleteSecretV3 = ({ export const useCreateSecretBatch = ({ options }: { - options?: Omit, "mutationFn">; + options?: Omit, "mutationFn">; } = {}) => { const queryClient = useQueryClient(); - return useMutation<{}, {}, TCreateSecretBatchDTO>({ + return useMutation({ mutationFn: async ({ secretPath = "/", workspaceId, environment, secrets }) => { const { data } = await apiRequest.post("/api/v3/secrets/batch/raw", { workspaceId, @@ -205,11 +205,11 @@ export const useCreateSecretBatch = ({ export const useUpdateSecretBatch = ({ options }: { - options?: Omit, "mutationFn">; + options?: Omit, "mutationFn">; } = {}) => { const queryClient = useQueryClient(); - return useMutation<{}, {}, TUpdateSecretBatchDTO>({ + return useMutation({ mutationFn: async ({ secretPath = "/", workspaceId, environment, secrets }) => { const { data } = await apiRequest.patch("/api/v3/secrets/batch/raw", { workspaceId, @@ -241,11 +241,11 @@ export const useUpdateSecretBatch = ({ export const useDeleteSecretBatch = ({ options }: { - options?: Omit, "mutationFn">; + options?: Omit, "mutationFn">; } = {}) => { const queryClient = useQueryClient(); - return useMutation<{}, {}, TDeleteSecretBatchDTO>({ + return useMutation({ mutationFn: async ({ secretPath = "/", workspaceId, environment, secrets }) => { const { data } = await apiRequest.delete("/api/v3/secrets/batch/raw", { data: { @@ -279,7 +279,7 @@ export const useDeleteSecretBatch = ({ export const useMoveSecrets = ({ options }: { - options?: Omit, "mutationFn">; + options?: Omit, "mutationFn">; } = {}) => { const queryClient = useQueryClient(); @@ -288,7 +288,7 @@ export const useMoveSecrets = ({ isSourceUpdated: boolean; isDestinationUpdated: boolean; }, - {}, + object, TMoveSecretsDTO >({ mutationFn: async ({ @@ -355,7 +355,7 @@ export const createSecret = async (dto: TCreateSecretsV3DTO) => { }; export const useBackfillSecretReference = () => - useMutation<{ message: string }, {}, { projectId: string }>({ + useMutation<{ message: string }, object, { projectId: string }>({ mutationFn: async ({ projectId }) => { const { data } = await apiRequest.post("/api/v3/secrets/backfill-secret-references", { projectId diff --git a/frontend-v2/src/hooks/api/serviceTokens/queries.tsx b/frontend-v2/src/hooks/api/serviceTokens/queries.tsx index d3f129cc7..7911f95b8 100644 --- a/frontend-v2/src/hooks/api/serviceTokens/queries.tsx +++ b/frontend-v2/src/hooks/api/serviceTokens/queries.tsx @@ -36,7 +36,7 @@ export const useCreateServiceToken = () => { // TODO: deprecate const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async (body) => { const { data } = await apiRequest.post("/api/v2/service-token/", body); data.serviceToken += `.${body.randomBytes}`; @@ -51,7 +51,7 @@ export const useCreateServiceToken = () => { export const useDeleteServiceToken = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async (serviceTokenId) => { const { data } = await apiRequest.delete(`/api/v2/service-token/${serviceTokenId}`); return data; diff --git a/frontend-v2/src/hooks/api/ssoConfig/queries.tsx b/frontend-v2/src/hooks/api/ssoConfig/queries.tsx index cbb8e0abe..69abd4f84 100644 --- a/frontend-v2/src/hooks/api/ssoConfig/queries.tsx +++ b/frontend-v2/src/hooks/api/ssoConfig/queries.tsx @@ -17,7 +17,7 @@ export const useGetSSOConfig = (organizationId: string) => { ); return data; - } catch (err) { + } catch { return null; } }, diff --git a/frontend-v2/src/hooks/api/tags/queries.tsx b/frontend-v2/src/hooks/api/tags/queries.tsx index d1c4b533d..fa5975145 100644 --- a/frontend-v2/src/hooks/api/tags/queries.tsx +++ b/frontend-v2/src/hooks/api/tags/queries.tsx @@ -27,7 +27,7 @@ export const useGetWsTags = (workspaceID: string) => { export const useCreateWsTag = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ workspaceID, tagColor, tagSlug }) => { const { data } = await apiRequest.post<{ workspaceTag: WsTag }>( `/api/v1/workspace/${workspaceID}/tags`, @@ -47,7 +47,7 @@ export const useCreateWsTag = () => { export const useDeleteWsTag = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ tagID, projectId }) => { const { data } = await apiRequest.delete<{ workspaceTag: WsTag }>( `/api/v1/workspace/${projectId}/tags/${tagID}` diff --git a/frontend-v2/src/hooks/api/userEngagement/mutations.tsx b/frontend-v2/src/hooks/api/userEngagement/mutations.tsx index d876e65c8..30ae73dc9 100644 --- a/frontend-v2/src/hooks/api/userEngagement/mutations.tsx +++ b/frontend-v2/src/hooks/api/userEngagement/mutations.tsx @@ -5,7 +5,7 @@ import { apiRequest } from "@app/config/request"; import { TCreateUserWishDto } from "./types"; export const useCreateUserWish = () => { - return useMutation<{}, {}, TCreateUserWishDto>({ + return useMutation({ mutationFn: async (dto) => { const { data } = await apiRequest.post("/api/v1/user-engagement/me/wish", dto); return data; diff --git a/frontend-v2/src/hooks/api/users/mutation.tsx b/frontend-v2/src/hooks/api/users/mutation.tsx index e8cf41acb..5cc50e845 100644 --- a/frontend-v2/src/hooks/api/users/mutation.tsx +++ b/frontend-v2/src/hooks/api/users/mutation.tsx @@ -13,7 +13,7 @@ import { AddUserToWsDTOE2EE, AddUserToWsDTONonE2EE } from "./types"; export const useAddUserToWsE2EE = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, AddUserToWsDTOE2EE>({ + return useMutation({ mutationFn: async ({ workspaceId, members, decryptKey, userPrivateKey }) => { // assymmetrically decrypt symmetric key with local private key const key = decryptAssymmetric({ @@ -50,7 +50,7 @@ export const useAddUserToWsE2EE = () => { export const useAddUserToWsNonE2EE = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, AddUserToWsDTONonE2EE>({ + return useMutation({ mutationFn: async ({ projectId, usernames, roleSlugs }) => { const { data } = await apiRequest.post(`/api/v2/workspace/${projectId}/memberships`, { usernames, diff --git a/frontend-v2/src/hooks/api/users/queries.tsx b/frontend-v2/src/hooks/api/users/queries.tsx index 602c06b35..730dba8c3 100644 --- a/frontend-v2/src/hooks/api/users/queries.tsx +++ b/frontend-v2/src/hooks/api/users/queries.tsx @@ -80,7 +80,7 @@ export const fetchUserProjectFavorites = async (orgId: string) => { export const useRenameUser = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, RenameUserDTO>({ + return useMutation({ mutationFn: ({ newName }) => apiRequest.patch("/api/v2/users/me/name", { firstName: newName?.split(" ")[0], @@ -152,7 +152,7 @@ export const useAddUsersToOrg = () => { }; }; - return useMutation({ + return useMutation({ mutationFn: (dto) => { return apiRequest.post("/api/v1/invite-org/signup", dto); }, @@ -207,7 +207,7 @@ export const useGetOrgMembershipProjectMemberships = ( export const useDeleteOrgMembership = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, DeletOrgMembershipDTO>({ + return useMutation({ mutationFn: ({ membershipId, orgId }) => { return apiRequest.delete(`/api/v2/organizations/${orgId}/memberships/${membershipId}`); }, @@ -220,7 +220,7 @@ export const useDeleteOrgMembership = () => { export const useDeactivateOrgMembership = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, DeletOrgMembershipDTO>({ + return useMutation({ mutationFn: ({ membershipId, orgId }) => { return apiRequest.post( `/api/v2/organizations/${orgId}/memberships/${membershipId}/deactivate` @@ -236,7 +236,7 @@ export const useDeactivateOrgMembership = () => { export const useUpdateOrgMembership = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, UpdateOrgMembershipDTO>({ + return useMutation({ mutationFn: ({ organizationId, membershipId, role, isActive, metadata }) => { return apiRequest.patch( `/api/v2/organizations/${organizationId}/memberships/${membershipId}`, @@ -261,7 +261,7 @@ export const useUpdateOrgMembership = () => { export const useRegisterUserAction = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, string>({ + return useMutation({ mutationFn: (action) => apiRequest.post("/api/v1/user-action", { action }), onSuccess: () => { queryClient.invalidateQueries(userKeys.userAction); diff --git a/frontend-v2/src/hooks/api/webhooks/mutation.tsx b/frontend-v2/src/hooks/api/webhooks/mutation.tsx index 786fbb459..46f20a6fa 100644 --- a/frontend-v2/src/hooks/api/webhooks/mutation.tsx +++ b/frontend-v2/src/hooks/api/webhooks/mutation.tsx @@ -8,7 +8,7 @@ import { TCreateWebhookDto, TDeleteWebhookDto, TTestWebhookDTO, TUpdateWebhookDt export const useCreateWebhook = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, TCreateWebhookDto>({ + return useMutation({ mutationFn: async (dto) => { const { data } = await apiRequest.post("/api/v1/webhooks", dto); return data; @@ -22,7 +22,7 @@ export const useCreateWebhook = () => { export const useTestWebhook = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, TTestWebhookDTO>({ + return useMutation({ mutationFn: async ({ webhookId }) => { const { data } = await apiRequest.post(`/api/v1/webhooks/${webhookId}/test`); return data; @@ -39,7 +39,7 @@ export const useTestWebhook = () => { export const useUpdateWebhook = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, TUpdateWebhookDto>({ + return useMutation({ mutationFn: async (dto) => { const { data } = await apiRequest.patch(`/api/v1/webhooks/${dto.webhookId}`, { isDisabled: dto.isDisabled @@ -55,7 +55,7 @@ export const useUpdateWebhook = () => { export const useDeleteWebhook = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, TDeleteWebhookDto>({ + return useMutation({ mutationFn: async (dto) => { const { data } = await apiRequest.delete(`/api/v1/webhooks/${dto.webhookId}`); return data; diff --git a/frontend-v2/src/hooks/api/workflowIntegrations/mutation.tsx b/frontend-v2/src/hooks/api/workflowIntegrations/mutation.tsx index bf43325ff..eea7bc92d 100644 --- a/frontend-v2/src/hooks/api/workflowIntegrations/mutation.tsx +++ b/frontend-v2/src/hooks/api/workflowIntegrations/mutation.tsx @@ -13,7 +13,7 @@ import { export const useUpdateSlackIntegration = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, TUpdateSlackIntegrationDTO>({ + return useMutation({ mutationFn: async (dto) => { const { data } = await apiRequest.patch(`/api/v1/workflow-integrations/slack/${dto.id}`, dto); @@ -29,7 +29,7 @@ export const useUpdateSlackIntegration = () => { export const useDeleteSlackIntegration = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, TDeleteSlackIntegrationDTO>({ + return useMutation({ mutationFn: async (dto) => { const { data } = await apiRequest.delete(`/api/v1/workflow-integrations/slack/${dto.id}`); diff --git a/frontend-v2/src/hooks/api/workspace/mutations.tsx b/frontend-v2/src/hooks/api/workspace/mutations.tsx index c4b8211bb..4de00d2de 100644 --- a/frontend-v2/src/hooks/api/workspace/mutations.tsx +++ b/frontend-v2/src/hooks/api/workspace/mutations.tsx @@ -78,7 +78,7 @@ export const useDeleteGroupFromWorkspace = () => { export const useLeaveProject = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, { workspaceId: string }>({ + return useMutation({ mutationFn: ({ workspaceId }) => { return apiRequest.delete(`/api/v1/workspace/${workspaceId}/leave`); }, @@ -90,7 +90,7 @@ export const useLeaveProject = () => { export const useMigrateProjectToV3 = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, { workspaceId: string }>({ + return useMutation({ mutationFn: ({ workspaceId }) => { return apiRequest.post(`/api/v1/workspace/${workspaceId}/migrate-v3`); }, diff --git a/frontend-v2/src/hooks/api/workspace/queries.tsx b/frontend-v2/src/hooks/api/workspace/queries.tsx index 9fdce5b67..74fdfda98 100644 --- a/frontend-v2/src/hooks/api/workspace/queries.tsx +++ b/frontend-v2/src/hooks/api/workspace/queries.tsx @@ -76,7 +76,7 @@ export const fetchWorkspaceSecrets = async (workspaceId: string) => { export const useUpgradeProject = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, { projectId: string; privateKey: string }>({ + return useMutation({ mutationFn: ({ projectId, privateKey }) => { return apiRequest.post(`/api/v2/workspace/${projectId}/upgrade`, { userPrivateKey: privateKey @@ -171,7 +171,7 @@ export const useGetUserWorkspaceMemberships = (orgId: string) => export const useNameWorkspaceSecrets = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, NameWorkspaceSecretsDTO>({ + return useMutation({ mutationFn: async ({ workspaceId, secretsToUpdate }) => apiRequest.post(`/api/v3/workspaces/${workspaceId}/secrets/names`, { secretsToUpdate @@ -225,7 +225,7 @@ export const createWorkspace = ( export const useCreateWorkspace = () => { const queryClient = useQueryClient(); - return useMutation<{ data: { project: Workspace } }, {}, CreateWorkspaceDTO>({ + return useMutation<{ data: { project: Workspace } }, object, CreateWorkspaceDTO>({ mutationFn: async ({ projectName, projectDescription, kmsKeyId, template, type }) => createWorkspace({ projectName, @@ -243,7 +243,7 @@ export const useCreateWorkspace = () => { export const useUpdateProject = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ projectID, newProjectName, newProjectDescription }) => { const { data } = await apiRequest.patch<{ workspace: Workspace }>( `/api/v1/workspace/${projectID}`, @@ -263,7 +263,7 @@ export const useUpdateProject = () => { export const useToggleAutoCapitalization = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ workspaceID, state }) => { const { data } = await apiRequest.post<{ workspace: Workspace }>( `/api/v1/workspace/${workspaceID}/auto-capitalization`, @@ -282,7 +282,7 @@ export const useToggleAutoCapitalization = () => { export const useUpdateWorkspaceVersionLimit = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ projectSlug, pitVersionLimit }) => { const { data } = await apiRequest.put(`/api/v1/workspace/${projectSlug}/version-limit`, { pitVersionLimit @@ -298,7 +298,7 @@ export const useUpdateWorkspaceVersionLimit = () => { export const useUpdateWorkspaceAuditLogsRetention = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ projectSlug, auditLogsRetentionDays }) => { const { data } = await apiRequest.put( `/api/v1/workspace/${projectSlug}/audit-logs-retention`, @@ -317,7 +317,7 @@ export const useUpdateWorkspaceAuditLogsRetention = () => { export const useDeleteWorkspace = () => { const queryClient = useQueryClient(); - return useMutation({ + return useMutation({ mutationFn: async ({ workspaceID }) => { const { data } = await apiRequest.delete(`/api/v1/workspace/${workspaceID}`); return data.workspace; @@ -332,7 +332,7 @@ export const useDeleteWorkspace = () => { export const useCreateWsEnvironment = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, CreateEnvironmentDTO>({ + return useMutation({ mutationFn: ({ workspaceId, name, slug }) => { return apiRequest.post(`/api/v1/workspace/${workspaceId}/environments`, { name, @@ -348,7 +348,7 @@ export const useCreateWsEnvironment = () => { export const useUpdateWsEnvironment = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, UpdateEnvironmentDTO>({ + return useMutation({ mutationFn: ({ workspaceId, id, name, slug, position }) => { return apiRequest.patch(`/api/v1/workspace/${workspaceId}/environments/${id}`, { name, @@ -365,7 +365,7 @@ export const useUpdateWsEnvironment = () => { export const useDeleteWsEnvironment = () => { const queryClient = useQueryClient(); - return useMutation<{}, {}, DeleteEnvironmentDTO>({ + return useMutation({ mutationFn: ({ id, workspaceId }) => { return apiRequest.delete(`/api/v1/workspace/${workspaceId}/environments/${id}`); }, diff --git a/frontend-v2/src/hooks/usePersistentState.ts b/frontend-v2/src/hooks/usePersistentState.ts index 496db1bda..5d47bc761 100644 --- a/frontend-v2/src/hooks/usePersistentState.ts +++ b/frontend-v2/src/hooks/usePersistentState.ts @@ -1,8 +1,8 @@ import { useEffect, useState } from "react"; -type TPersisntentStateReturn = [T, (val: T) => void]; +type TPersisntentStateReturn = [T, (val: T) => void]; -export const usePersistentState = ( +export const usePersistentState = ( initialValue: T, persistenceKey: string ): TPersisntentStateReturn => { diff --git a/frontend-v2/src/hooks/useTimedReset.tsx b/frontend-v2/src/hooks/useTimedReset.tsx index 60e286978..8dd810ad5 100644 --- a/frontend-v2/src/hooks/useTimedReset.tsx +++ b/frontend-v2/src/hooks/useTimedReset.tsx @@ -1,6 +1,6 @@ import { Dispatch, SetStateAction, useEffect, useState } from "react"; -type Props = { +type Props = { initialState: T; delay?: number; }; diff --git a/frontend-v2/src/layouts/OrganizationLayout/OrganizationLayout.tsx b/frontend-v2/src/layouts/OrganizationLayout/OrganizationLayout.tsx index 1c4455e16..63604d224 100644 --- a/frontend-v2/src/layouts/OrganizationLayout/OrganizationLayout.tsx +++ b/frontend-v2/src/layouts/OrganizationLayout/OrganizationLayout.tsx @@ -1,107 +1,37 @@ import { useState } from "react"; import { useTranslation } from "react-i18next"; -import { faGithub, faSlack } from "@fortawesome/free-brands-svg-icons"; -import { - faAngleDown, - faArrowUpRightFromSquare, - faBook, - faCheck, - faEnvelope, - faInfinity, - faInfo, - faMobile, - faPlus, - faQuestion -} from "@fortawesome/free-solid-svg-icons"; +import { faMobile } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { DropdownMenuTrigger } from "@radix-ui/react-dropdown-menu"; +import { Link, Outlet } from "@tanstack/react-router"; -import SecurityClient from "@app/components/utilities/SecurityClient"; -import { - Button, - DropdownMenu, - DropdownMenuContent, - DropdownMenuItem, - Menu, - MenuItem -} from "@app/components/v2"; -import { useOrganization, useSubscription, useUser } from "@app/context"; -import { usePopUp, useToggle } from "@app/hooks"; -import { - useGetOrganizations, - useGetOrgTrialUrl, - useLogoutUser, - useSelectOrganization -} from "@app/hooks/api"; -import { MfaMethod } from "@app/hooks/api/auth/types"; -import { AuthMethod } from "@app/hooks/api/users/types"; -import { ProjectType } from "@app/hooks/api/workspace/types"; -import { InsecureConnectionBanner } from "./components/InsecureConnectionBanner"; -// import { navigateUserToOrg } from "@app/views/Login/Login.utils"; -// import { CreateOrgModal } from "@app/views/Org/components"; - -import { WishForm } from "@app/components/features/WishForm"; import { Mfa } from "@app/components/auth/Mfa"; -import { Link, Outlet, useNavigate } from "@tanstack/react-router"; +import SecurityClient from "@app/components/utilities/SecurityClient"; +import { Menu, MenuItem } from "@app/components/v2"; +import { useOrganization, useUser } from "@app/context"; +import { usePopUp, useToggle } from "@app/hooks"; +import { useSelectOrganization } from "@app/hooks/api"; +import { MfaMethod } from "@app/hooks/api/auth/types"; +import { ProjectType } from "@app/hooks/api/workspace/types"; -const supportOptions = [ - [ - , - "Support Forum", - "https://infisical.com/slack" - ], - [ - , - "Read Docs", - "https://infisical.com/docs/documentation/getting-started/introduction" - ], - [ - , - "GitHub Issues", - "https://github.com/Infisical/infisical/issues" - ], - [ - , - "Email Support", - "mailto:support@infisical.com" - ] -]; +import { InsecureConnectionBanner } from "./components/InsecureConnectionBanner"; +import { SidebarFooter } from "./components/SidebarFooter"; +import { SidebarHeader } from "./components/SidebarHeader"; export const OrganizationLayout = () => { - const navigate = useNavigate(); - - const { mutateAsync } = useGetOrgTrialUrl(); - const { currentOrg } = useOrganization(); - const { data: orgs } = useGetOrganizations(); const [shouldShowMfa, toggleShowMfa] = useToggle(false); const [requiredMfaMethod, setRequiredMfaMethod] = useState(MfaMethod.EMAIL); const [mfaSuccessCallback, setMfaSuccessCallback] = useState<() => void>(() => {}); const { user } = useUser(); - const { subscription } = useSubscription(); - - const infisicalPlatformVersion = process.env.NEXT_PUBLIC_INFISICAL_PLATFORM_VERSION; const { popUp, handlePopUpToggle } = usePopUp(["createOrg"] as const); + const { mutateAsync: selectOrganization } = useSelectOrganization(); const { t } = useTranslation(); - const { mutateAsync: selectOrganization } = useSelectOrganization(); - - const logout = useLogoutUser(); - const logOutUser = async () => { - try { - console.log("Logging out..."); - await logout.mutateAsync(); - navigate({ to: "/login" }); - } catch (error) { - console.error(error); - } - }; - - const changeOrg = async (orgId: string) => { + const handleOrgChange = async (orgId: string) => { const { token, isMfaEnabled, mfaMethod } = await selectOrganization({ organizationId: orgId }); @@ -112,8 +42,7 @@ export const OrganizationLayout = () => { setRequiredMfaMethod(mfaMethod); } toggleShowMfa.on(); - setMfaSuccessCallback(() => () => changeOrg(orgId)); - return; + setMfaSuccessCallback(() => () => handleOrgChange(orgId)); } // await navigateUserToOrg(router, orgId); @@ -140,144 +69,7 @@ export const OrganizationLayout = () => { { diff --git a/frontend-v2/src/layouts/OrganizationLayout/components/InsecureConnectionBanner/InsecureConnectionBanner.tsx b/frontend-v2/src/layouts/OrganizationLayout/components/InsecureConnectionBanner/InsecureConnectionBanner.tsx index fbef45185..e213276b3 100644 --- a/frontend-v2/src/layouts/OrganizationLayout/components/InsecureConnectionBanner/InsecureConnectionBanner.tsx +++ b/frontend-v2/src/layouts/OrganizationLayout/components/InsecureConnectionBanner/InsecureConnectionBanner.tsx @@ -17,7 +17,7 @@ export const InsecureConnectionBanner = () => { if (isAcknowledged) return null; return ( -
+
Your connection to this Infisical instance is not secured via HTTPS. Some features may not diff --git a/frontend-v2/src/layouts/OrganizationLayout/components/SidebarFooter/SidebarFooter.tsx b/frontend-v2/src/layouts/OrganizationLayout/components/SidebarFooter/SidebarFooter.tsx new file mode 100644 index 000000000..d71a70263 --- /dev/null +++ b/frontend-v2/src/layouts/OrganizationLayout/components/SidebarFooter/SidebarFooter.tsx @@ -0,0 +1,134 @@ +import { faGithub, faSlack } from "@fortawesome/free-brands-svg-icons"; +import { + faBook, + faEnvelope, + faInfinity, + faInfo, + faPlus, + faQuestion +} from "@fortawesome/free-solid-svg-icons"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { Link } from "@tanstack/react-router"; + +import { WishForm } from "@app/components/features/WishForm"; +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuTrigger +} from "@app/components/v2"; +import { useOrganization, useSubscription } from "@app/context"; +import { useGetOrgTrialUrl } from "@app/hooks/api"; + +const supportOptions = [ + [ + , + "Support Forum", + "https://infisical.com/slack" + ], + [ + , + "Read Docs", + "https://infisical.com/docs/documentation/getting-started/introduction" + ], + [ + , + "GitHub Issues", + "https://github.com/Infisical/infisical/issues" + ], + [ + , + "Email Support", + "mailto:support@infisical.com" + ] +]; + +export const SidebarFooter = () => { + const { subscription } = useSubscription(); + const { currentOrg } = useOrganization(); + + const { mutateAsync } = useGetOrgTrialUrl(); + + const infisicalPlatformVersion = import.meta.env.VITE_INFISICAL_PLATFORM_VERSION; + + return ( +
+ {(window.location.origin.includes("https://app.infisical.com") || + window.location.origin.includes("https://gamma.infisical.com")) && } + +
+ + Invite people +
+ + + +
+ + Help & Support +
+
+ + {supportOptions.map(([icon, text, url]) => ( + + +
+ {icon} +
{text}
+
+
+
+ ))} + {infisicalPlatformVersion && ( +
+ + Version: {infisicalPlatformVersion} +
+ )} +
+
+ {subscription && subscription.slug === "starter" && !subscription.has_used_trial && ( + + )} +
+ ); +}; diff --git a/frontend-v2/src/layouts/OrganizationLayout/components/SidebarFooter/index.tsx b/frontend-v2/src/layouts/OrganizationLayout/components/SidebarFooter/index.tsx new file mode 100644 index 000000000..bb9714b13 --- /dev/null +++ b/frontend-v2/src/layouts/OrganizationLayout/components/SidebarFooter/index.tsx @@ -0,0 +1 @@ +export { SidebarFooter } from "./SidebarFooter"; diff --git a/frontend-v2/src/layouts/OrganizationLayout/components/SidebarHeader/SidebarHeader.tsx b/frontend-v2/src/layouts/OrganizationLayout/components/SidebarHeader/SidebarHeader.tsx new file mode 100644 index 000000000..1f71d793c --- /dev/null +++ b/frontend-v2/src/layouts/OrganizationLayout/components/SidebarHeader/SidebarHeader.tsx @@ -0,0 +1,169 @@ +import { faAngleDown, faArrowUpRightFromSquare, faCheck } from "@fortawesome/free-solid-svg-icons"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { Link, useNavigate } from "@tanstack/react-router"; + +import { + Button, + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuTrigger +} from "@app/components/v2"; +import { useOrganization, useUser } from "@app/context"; +import { useGetOrganizations, useLogoutUser } from "@app/hooks/api"; +import { AuthMethod } from "@app/hooks/api/users/types"; + +type Prop = { + onChangeOrg: (orgId: string) => void; +}; + +export const SidebarHeader = ({ onChangeOrg }: Prop) => { + const { currentOrg } = useOrganization(); + const { user } = useUser(); + const navigate = useNavigate(); + const { data: orgs } = useGetOrganizations(); + + const logout = useLogoutUser(); + const logOutUser = async () => { + try { + console.log("Logging out..."); + await logout.mutateAsync(); + navigate({ to: "/login" }); + } catch (error) { + console.error(error); + } + }; + + return ( +
+ + +
+
+ {currentOrg?.name.charAt(0)} +
+
+ {currentOrg?.name} +
+ +
+
+ +
{user?.username}
+ {orgs?.map((org) => { + return ( + + + + ); + })} + +
+ + + + + +
+ {user?.firstName?.charAt(0)} + {user?.lastName && user?.lastName?.charAt(0)} +
+
+ +
{user?.username}
+ + Personal Settings + + + + Documentation + + + + + + Join Slack Community + + + + {user?.superAdmin && ( + + + Server Admin Console + + + )} + + + Organization Admin Console + + +
+ + + +
+ ); +}; diff --git a/frontend-v2/src/layouts/OrganizationLayout/components/SidebarHeader/index.tsx b/frontend-v2/src/layouts/OrganizationLayout/components/SidebarHeader/index.tsx new file mode 100644 index 000000000..bdc4db6ef --- /dev/null +++ b/frontend-v2/src/layouts/OrganizationLayout/components/SidebarHeader/index.tsx @@ -0,0 +1 @@ +export { SidebarHeader } from "./SidebarHeader"; diff --git a/frontend-v2/src/routes/_authenticate.tsx b/frontend-v2/src/routes/_authenticate.tsx index a9fe612af..3e4df0e27 100644 --- a/frontend-v2/src/routes/_authenticate.tsx +++ b/frontend-v2/src/routes/_authenticate.tsx @@ -1,10 +1,10 @@ import { createFileRoute, redirect } from "@tanstack/react-router"; import { createNotification } from "@app/components/notifications"; -import { authKeys, fetchAuthToken } from "@app/hooks/api/auth/queries"; import { userKeys } from "@app/hooks/api"; -import { fetchUserDetails } from "@app/hooks/api/users/queries"; +import { authKeys, fetchAuthToken } from "@app/hooks/api/auth/queries"; import { setAuthToken } from "@app/hooks/api/reactQuery"; +import { fetchUserDetails } from "@app/hooks/api/users/queries"; export const Route = createFileRoute("/_authenticate")({ beforeLoad: async ({ context, location }) => { diff --git a/frontend-v2/src/routes/_authenticate/_org_details.tsx b/frontend-v2/src/routes/_authenticate/_org_details.tsx index 47d3acaf4..14ca962d7 100644 --- a/frontend-v2/src/routes/_authenticate/_org_details.tsx +++ b/frontend-v2/src/routes/_authenticate/_org_details.tsx @@ -1,6 +1,7 @@ +import { createFileRoute } from "@tanstack/react-router"; + import { fetchOrganizationById, organizationKeys } from "@app/hooks/api/organization/queries"; import { fetchOrgSubscription, subscriptionQueryKeys } from "@app/hooks/api/subscriptions/queries"; -import { createFileRoute } from "@tanstack/react-router"; export const Route = createFileRoute("/_authenticate/_org_details")({ beforeLoad: async ({ context }) => { diff --git a/frontend-v2/src/routes/_authenticate/_org_details/_organization_layout.tsx b/frontend-v2/src/routes/_authenticate/_org_details/_organization_layout.tsx index e7604f19b..1df97722c 100644 --- a/frontend-v2/src/routes/_authenticate/_org_details/_organization_layout.tsx +++ b/frontend-v2/src/routes/_authenticate/_org_details/_organization_layout.tsx @@ -1,6 +1,7 @@ -import { OrganizationLayout } from "@app/layouts/OrganizationLayout"; import { createFileRoute } from "@tanstack/react-router"; +import { OrganizationLayout } from "@app/layouts/OrganizationLayout"; + export const Route = createFileRoute("/_authenticate/_org_details/_organization_layout")({ component: OrganizationLayout }); diff --git a/frontend-v2/src/routes/_authenticate/_org_details/_organization_layout/organization/$organizationId/index.tsx b/frontend-v2/src/routes/_authenticate/_org_details/_organization_layout/organization/$organizationId/index.tsx index d316b7e6e..3a4eafb4c 100644 --- a/frontend-v2/src/routes/_authenticate/_org_details/_organization_layout/organization/$organizationId/index.tsx +++ b/frontend-v2/src/routes/_authenticate/_org_details/_organization_layout/organization/$organizationId/index.tsx @@ -1,15 +1,11 @@ -import { - createFileRoute, - useRouteContext, - useRouter, -} from '@tanstack/react-router' +import { createFileRoute, useRouteContext, useRouter } from "@tanstack/react-router"; function RouteComponent() { const user = useRouteContext({ - from: '/_authenticate', - select: (el) => el.user, - }) - const router = useRouter() + from: "/_authenticate", + select: (el) => el.user + }); + const router = useRouter(); return (
@@ -19,20 +15,20 @@ function RouteComponent() { onClick={() => { router.invalidate({ filter: (d) => { - console.log(d) - return true - }, - }) + console.log(d); + return true; + } + }); }} > Click
- ) + ); } export const Route = createFileRoute( - '/_authenticate/_org_details/_organization_layout/organization/$organizationId/', + "/_authenticate/_org_details/_organization_layout/organization/$organizationId/" )({ - component: RouteComponent, -}) + component: RouteComponent +}); diff --git a/frontend-v2/src/routes/_authenticate/_org_details/_organization_layout/organization/$organizationId/secret-manager.tsx b/frontend-v2/src/routes/_authenticate/_org_details/_organization_layout/organization/$organizationId/secret-manager.tsx index 93c4d40b9..3bb0da130 100644 --- a/frontend-v2/src/routes/_authenticate/_org_details/_organization_layout/organization/$organizationId/secret-manager.tsx +++ b/frontend-v2/src/routes/_authenticate/_org_details/_organization_layout/organization/$organizationId/secret-manager.tsx @@ -1,11 +1,11 @@ -import { createFileRoute } from '@tanstack/react-router' +import { createFileRoute } from "@tanstack/react-router"; function SecretManagerOverviewPage() { - return
Hello "/organization/secret-manager"!
+ return
Hello "/organization/secret-manager"!
; } export const Route = createFileRoute( - '/_authenticate/_org_details/_organization_layout/organization/$organizationId/secret-manager', + "/_authenticate/_org_details/_organization_layout/organization/$organizationId/secret-manager" )({ - component: SecretManagerOverviewPage, -}) + component: SecretManagerOverviewPage +}); diff --git a/frontend-v2/src/routes/_authenticate/_restrict_login_signup/login/-components/PasswordStep/PasswordStep.tsx b/frontend-v2/src/routes/_authenticate/_restrict_login_signup/login/-components/PasswordStep/PasswordStep.tsx index 78f2d44d7..1bf401399 100644 --- a/frontend-v2/src/routes/_authenticate/_restrict_login_signup/login/-components/PasswordStep/PasswordStep.tsx +++ b/frontend-v2/src/routes/_authenticate/_restrict_login_signup/login/-components/PasswordStep/PasswordStep.tsx @@ -6,6 +6,7 @@ import axios from "axios"; import { addSeconds, formatISO } from "date-fns"; import { jwtDecode } from "jwt-decode"; +import { Mfa } from "@app/components/auth/Mfa"; import { createNotification } from "@app/components/notifications"; import attemptCliLogin from "@app/components/utilities/attemptCliLogin"; import attemptLogin from "@app/components/utilities/attemptLogin"; @@ -20,7 +21,6 @@ import { fetchOrganizations } from "@app/hooks/api/organization/queries"; import { fetchMyPrivateKey } from "@app/hooks/api/users/queries"; import { navigateUserToOrg, useNavigateToSelectOrganization } from "../Login.utils"; -import { Mfa } from "@app/components/auth/Mfa"; type Props = { providerAuthToken: string; diff --git a/frontend-v2/src/routes/_authenticate/_restrict_login_signup/login/select-organization/index.tsx b/frontend-v2/src/routes/_authenticate/_restrict_login_signup/login/select-organization/index.tsx index 49d315caa..35cd23bf7 100644 --- a/frontend-v2/src/routes/_authenticate/_restrict_login_signup/login/select-organization/index.tsx +++ b/frontend-v2/src/routes/_authenticate/_restrict_login_signup/login/select-organization/index.tsx @@ -8,6 +8,7 @@ import axios from "axios"; import { addSeconds, formatISO } from "date-fns"; import { jwtDecode } from "jwt-decode"; +import { Mfa } from "@app/components/auth/Mfa"; import { createNotification } from "@app/components/notifications"; import { IsCliLoginSuccessful } from "@app/components/utilities/attemptCliLogin"; import SecurityClient from "@app/components/utilities/SecurityClient"; @@ -26,7 +27,6 @@ import { Organization } from "@app/hooks/api/types"; import { AuthMethod } from "@app/hooks/api/users/types"; import { navigateUserToOrg } from "../-components/Login.utils"; -import { Mfa } from "../-components/Mfa"; const LoadingScreen = () => { return (