Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat: added new secret input component and updated toolbar key special prop to innerKey

akhilmhdhbca14dd5c4b0
diff --git a/frontend/src/components/navigation/NavHeader.tsx b/frontend/src/components/navigation/NavHeader.tsx
index fac8f4749d..d4a5c4352b 100644
--- a/frontend/src/components/navigation/NavHeader.tsx
+++ b/frontend/src/components/navigation/NavHeader.tsx
@@ -58,15 +58,13 @@ export default function NavHeader({
return (
<div className="flex flex-row items-center pt-6">
- <div className="mr-2 flex h-5 w-5 items-center justify-center rounded-md bg-primary text-black text-sm">
+ <div className="mr-2 flex h-5 w-5 items-center justify-center rounded-md bg-primary text-sm text-black">
{currentOrg?.name?.charAt(0)}
</div>
- <Link
- passHref
- legacyBehavior
- href={`/org/${currentOrg?._id}/overview`}
- >
- <a className="text-sm font-semibold text-primary/80 hover:text-primary pl-0.5">{currentOrg?.name}</a>
+ <Link passHref legacyBehavior href={`/org/${currentOrg?._id}/overview`}>
+ <a className="pl-0.5 text-sm font-semibold text-primary/80 hover:text-primary">
+ {currentOrg?.name}
+ </a>
</Link>
{isProjectRelated && (
<>
@@ -85,7 +83,7 @@ export default function NavHeader({
<Link
passHref
legacyBehavior
- href={{ pathname: "/project/[id]/secrets", query: { id: router.query.id } }}
+ href={{ pathname: "/project/[id]/secrets/overview", query: { id: router.query.id } }}
>
<a className="text-sm font-semibold text-primary/80 hover:text-primary">{pageName}</a>
</Link>
@@ -126,7 +124,11 @@ export default function NavHeader({
{index + 1 === folders?.length ? (
<span className="text-sm font-semibold text-bunker-300">{name}</span>
) : (
- <Link passHref legacyBehavior href={{ pathname: "/project/[id]/secrets", query }}>
+ <Link
+ passHref
+ legacyBehavior
+ href={{ pathname: "/project/[id]/secrets/[env]", query }}
+ >
<a className="text-sm font-semibold text-primary/80 hover:text-primary">
{name === "root" ? selectedEnv?.name : name}
</a>
diff --git a/frontend/src/components/v2/SecretInput/SecretInput.tsx b/frontend/src/components/v2/SecretInput/SecretInput.tsx
new file mode 100644
index 0000000000..73d40026ac
--- /dev/null
+++ b/frontend/src/components/v2/SecretInput/SecretInput.tsx
@@ -0,0 +1,92 @@
+/* eslint-disable react/no-danger */
+import { HTMLAttributes } from "react";
+import ContentEditable from "react-contenteditable";
+import sanitizeHtml from "sanitize-html";
+
+import { useToggle } from "@app/hooks";
+
+const REGEX = /\${([^}]+)}/g;
+const stripSpanTags = (str: string) => str.replace(/<\/?span[^>]*>/g, "");
+const replaceContentWithDot = (str: string) => {
+ let finalStr = "";
+ let isHtml = false;
+ for (let i = 0; i < str.length; i += 1) {
+ const char = str.at(i);
+
+ if (char === "<" || char === ">") {
+ isHtml = char === "<";
+ finalStr += char;
+ } else if (!isHtml && char !== "\n") {
+ finalStr += "&#8226;";
+ } else {
+ finalStr += char;
+ }
+ }
+ return finalStr;
+};
+
+const syntaxHighlight = (orgContent?: string | null, isVisible?: boolean) => {
+ if (!orgContent) return "";
+ if (!isVisible) return replaceContentWithDot(orgContent);
+ const content = stripSpanTags(orgContent);
+ const newContent = content.replace(
+ REGEX,
+ (_a, b) =>
+ `<span class="ph-no-capture text-yellow">&#36;&#123;<span class="ph-no-capture text-yello-200/80">${b}</span>&#125;</span>`
+ );
+
+ return newContent;
+};
+
+const sanitizeConf = {
+ allowedTags: ["div", "span", "br", "p"]
+};
+
+type Props = Omit<HTMLAttributes<HTMLDivElement>, "onChange" | "onBlur"> & {
+ value?: string | null;
+ isVisible?: boolean;
+ isDisabled?: boolean;
+ onChange?: (val: string, html: string) => void;
+ onBlur?: (sanitizedHtml: string) => void;
+};
+
+export const SecretInput = ({
+ value,
+ isVisible,
+ onChange,
+ onBlur,
+ isDisabled,
+ ...props
+}: Props) => {
+ const [isSecretFocused, setIsSecretFocused] = useToggle();
+
+ return (
+ <div
+ className="thin-scrollbar relative overflow-y-auto overflow-x-hidden"
+ style={{ maxHeight: `${21 * 7}px` }}
+ >
+ <div
+ dangerouslySetInnerHTML={{
+ __html: syntaxHighlight(value, isVisible || isSecretFocused)
+ }}
+ className="absolute top-0 left-0 z-0 h-full w-full text-ellipsis whitespace-pre-line break-all"
+ />
+ <ContentEditable
+ className="relative z-10 h-full w-full text-ellipsis whitespace-pre-line break-all text-transparent caret-white outline-none"
+ role="textbox"
+ onChange={(evt) => {
+ if (onChange) onChange(evt.currentTarget.innerText.trim(), evt.currentTarget.innerHTML);
+ }}
+ onFocus={() => setIsSecretFocused.on()}
+ disabled={isDisabled}
+ spellCheck={false}
+ onBlur={(evt) => {
+ if (onBlur) onBlur(sanitizeHtml(evt.currentTarget.innerHTML || "", sanitizeConf));
+ setIsSecretFocused.off();
+ }}
+ html={isVisible || isSecretFocused ? value || "" : syntaxHighlight(value, false)}
+ {...props}
+ />
+ </div>
+ );
+};
diff --git a/frontend/src/components/v2/SecretInput/index.tsx b/frontend/src/components/v2/SecretInput/index.tsx
new file mode 100644
index 0000000000..1c322fac4c
--- /dev/null
+++ b/frontend/src/components/v2/SecretInput/index.tsx
@@ -0,0 +1 @@
+export { SecretInput } from "./SecretInput";
diff --git a/frontend/src/components/v2/Table/Table.stories.tsx b/frontend/src/components/v2/Table/Table.stories.tsx
index a7b47e315b..95be1bb055 100644
--- a/frontend/src/components/v2/Table/Table.stories.tsx
+++ b/frontend/src/components/v2/Table/Table.stories.tsx
@@ -52,7 +52,7 @@ export const Loading: Story = {
</Tr>
</THead>
<TBody>
- <TableSkeleton columns={3} key="story-book-table" />
+ <TableSkeleton columns={3} innerKey="story-book-table" />
</TBody>
</Table>
</TableContainer>
diff --git a/frontend/src/components/v2/Table/Table.tsx b/frontend/src/components/v2/Table/Table.tsx
index d6cd74e455..7c698e2bb3 100644
--- a/frontend/src/components/v2/Table/Table.tsx
+++ b/frontend/src/components/v2/Table/Table.tsx
@@ -33,10 +33,7 @@ export type TableProps = {
export const Table = ({ children, className }: TableProps): JSX.Element => (
<table
- className={twMerge(
- "w-full bg-mineshaft-800 p-2 text-left text-sm text-gray-300",
- className
- )}
+ className={twMerge("w-full bg-mineshaft-800 p-2 text-left text-sm text-gray-300", className)}
>
{children}
</table>
@@ -58,11 +55,24 @@ export const THead = ({ children, className }: THeadProps): JSX.Element => (
export type TrProps = {
children: ReactNode;
className?: string;
+ isHoverable?: boolean;
+ isSelectable?: boolean;
} & HTMLAttributes<HTMLTableRowElement>;
-export const Tr = ({ children, className, ...props }: TrProps): JSX.Element => (
+export const Tr = ({
+ children,
+ className,
+ isHoverable,
+ isSelectable,
+ ...props
+}: TrProps): JSX.Element => (
<tr
- className={twMerge("border border-solid border-mineshaft-700 cursor-default", className)}
+ className={twMerge(
+ "cursor-default border border-solid border-mineshaft-700",
+ isHoverable && "hover:bg-mineshaft-600",
+ isSelectable && "cursor-pointer",
+ className
+ )}
{...props}
>
{children}
@@ -76,7 +86,14 @@ export type ThProps = {
};
export const Th = ({ children, className }: ThProps): JSX.Element => (
- <th className={twMerge("bg-mineshaft-800 px-5 pt-4 pb-3.5 font-semibold border-b-2 border-mineshaft-600", className)}>{children}</th>
+ <th
+ className={twMerge(
+ "border-b-2 border-mineshaft-600 bg-mineshaft-800 px-5 pt-4 pb-3.5 font-semibold",
+ className
+ )}
+ >
+ {children}
+ </th>
);
// table body
@@ -106,15 +123,15 @@ export type TBodyLoader = {
columns: number;
className?: string;
// unique key for mapping
- key: string;
+ innerKey: string;
};
-export const TableSkeleton = ({ rows = 3, columns, key, className }: TBodyLoader): JSX.Element => (
+export const TableSkeleton = ({ rows = 3, columns, innerKey, className }: TBodyLoader): JSX.Element => (
<>
{Array.apply(0, Array(rows)).map((_x, i) => (
- <Tr key={`${key}-skeleton-rows-${i + 1}`}>
+ <Tr key={`${innerKey}-skeleton-rows-${i + 1}`}>
{Array.apply(0, Array(columns)).map((_y, j) => (
- <Td key={`${key}-skeleton-rows-${i + 1}-column-${j + 1}`}>
+ <Td key={`${innerKey}-skeleton-rows-${i + 1}-column-${j + 1}`}>
<Skeleton className={className} />
</Td>
))}
diff --git a/frontend/src/components/v2/index.tsx b/frontend/src/components/v2/index.tsx
index 3ae3db0061..b4412b47bf 100644
--- a/frontend/src/components/v2/index.tsx
+++ b/frontend/src/components/v2/index.tsx
@@ -4,7 +4,7 @@ export * from "./Checkbox";
export * from "./DeleteActionModal";
export * from "./Drawer";
export * from "./Dropdown";
-export * from "./EmailServiceSetupModal"
+export * from "./EmailServiceSetupModal";
export * from "./EmptyState";
export * from "./FormControl";
export * from "./HoverCardv2";
@@ -13,6 +13,7 @@ export * from "./Input";
export * from "./Menu";
export * from "./Modal";
export * from "./Popoverv2";
+export * from "./SecretInput";
export * from "./Select";
export * from "./Skeleton";
export * from "./Spinner";
diff --git a/frontend/src/hooks/api/secretFolders/index.tsx b/frontend/src/hooks/api/secretFolders/index.tsx
index 4c25ec3a2c..3c0692eb66 100644
--- a/frontend/src/hooks/api/secretFolders/index.tsx
+++ b/frontend/src/hooks/api/secretFolders/index.tsx
@@ -1,6 +1,7 @@
export {
useCreateFolder,
useDeleteFolder,
+ useGetFoldersByEnv,
useGetProjectFolders,
useGetProjectFoldersBatch,
useUpdateFolder
diff --git a/frontend/src/hooks/api/secretFolders/queries.tsx b/frontend/src/hooks/api/secretFolders/queries.tsx
index 013a287938..36d013b72d 100644
--- a/frontend/src/hooks/api/secretFolders/queries.tsx
+++ b/frontend/src/hooks/api/secretFolders/queries.tsx
@@ -1,4 +1,4 @@
-import { useCallback } from "react";
+import { useCallback, useMemo } from "react";
import { useMutation, useQueries, useQuery, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
@@ -9,6 +9,7 @@ import {
DeleteFolderDTO,
GetProjectFoldersBatchDTO,
GetProjectFoldersDTO,
+ TGetFoldersByEnvDTO,
TSecretFolder,
UpdateFolderDTO
} from "./types";
@@ -62,6 +63,48 @@ export const useGetProjectFolders = ({
)
});
+export const useGetFoldersByEnv = ({
+ parentFolderPath,
+ workspaceId,
+ environments,
+ parentFolderId
+}: TGetFoldersByEnvDTO) => {
+ const folders = useQueries({
+ queries: environments.map((env) => ({
+ queryKey: queryKeys.getSecretFolders(workspaceId, env, parentFolderPath || parentFolderId),
+ queryFn: async () => fetchProjectFolders(workspaceId, env, parentFolderId, parentFolderPath),
+ enabled: Boolean(workspaceId) && Boolean(env)
+ }))
+ });
+
+ const folderNames = useMemo(() => {
+ const names = new Set<string>();
+ folders?.forEach(({ data }) => {
+ data?.folders.forEach(({ name }) => {
+ names.add(name);
+ });
+ });
+ return [...names];
+ }, [(folders || []).map((folder) => folder.data)]);
+
+ const isFolderPresentInEnv = useCallback(
+ (name: string, env: string) => {
+ const selectedEnvIndex = environments.indexOf(env);
+ if (selectedEnvIndex !== -1) {
+ return Boolean(
+ folders?.[selectedEnvIndex]?.data?.folders?.find(
+ ({ name: folderName }) => folderName === name
+ )
+ );
+ }
+ return false;
+ },
+ [(folders || []).map((folder) => folder.data)]
+ );
+
+ return { folders, folderNames, isFolderPresentInEnv };
+};
+
export const useGetProjectFoldersBatch = ({
folders = [],
isPaused,
diff --git a/frontend/src/hooks/api/secretFolders/types.ts b/frontend/src/hooks/api/secretFolders/types.ts
index d6240666a5..c9d7076209 100644
--- a/frontend/src/hooks/api/secretFolders/types.ts
+++ b/frontend/src/hooks/api/secretFolders/types.ts
@@ -17,6 +17,13 @@ export type GetProjectFoldersBatchDTO = {
parentFolderPath?: string;
};
+export type TGetFoldersByEnvDTO = {
+ environments: string[];
+ workspaceId: string;
+ parentFolderPath?: string;
+ parentFolderId?: string;
+};
+
export type CreateFolderDTO = {
workspaceId: string;
environment: string;
diff --git a/frontend/src/hooks/api/secrets/index.ts b/frontend/src/hooks/api/secrets/index.ts
index cad1e65d63..2e31e4f0b5 100644
--- a/frontend/src/hooks/api/secrets/index.ts
+++ b/frontend/src/hooks/api/secrets/index.ts
@@ -1,6 +1,7 @@
+export { useCreateSecretV3, useDeleteSecretV3, useUpdateSecretV3 } from "./mutations";
export {
useBatchSecretsOp,
useGetProjectSecrets,
- useGetProjectSecretsByKey,
+ useGetProjectSecretsAllEnv,
useGetSecretVersion
} from "./queries";
diff --git a/frontend/src/hooks/api/secrets/mutations.tsx b/frontend/src/hooks/api/secrets/mutations.tsx
new file mode 100644
index 0000000000..6df00174c4
--- /dev/null
+++ b/frontend/src/hooks/api/secrets/mutations.tsx
@@ -0,0 +1,172 @@
+import crypto from "crypto";
+
+import { useMutation, useQueryClient } from "@tanstack/react-query";
+
+import {
+ decryptAssymmetric,
+ encryptSymmetric
+} from "@app/components/utilities/cryptography/crypto";
+import { apiRequest } from "@app/config/request";
+
+import { secretKeys } from "./queries";
+import { TCreateSecretsV3DTO, TDeleteSecretsV3DTO, TUpdateSecretsV3DTO } from "./types";
+
+const encryptSecret = (randomBytes: string, key: string, value?: string, comment?: string) => {
+ // encrypt key
+ const {
+ ciphertext: secretKeyCiphertext,
+ iv: secretKeyIV,
+ tag: secretKeyTag
+ } = encryptSymmetric({
+ plaintext: key,
+ key: randomBytes
+ });
+
+ // encrypt value
+ const {
+ ciphertext: secretValueCiphertext,
+ iv: secretValueIV,
+ tag: secretValueTag
+ } = encryptSymmetric({
+ plaintext: value ?? "",
+ key: randomBytes
+ });
+
+ // encrypt comment
+ const {
+ ciphertext: secretCommentCiphertext,
+ iv: secretCommentIV,
+ tag: secretCommentTag
+ } = encryptSymmetric({
+ plaintext: comment ?? "",
+ key: randomBytes
+ });
+
+ return {
+ secretKeyCiphertext,
+ secretKeyIV,
+ secretKeyTag,
+ secretValueCiphertext,
+ secretValueIV,
+ secretValueTag,
+ secretCommentCiphertext,
+ secretCommentIV,
+ secretCommentTag
+ };
+};
+
+export const useCreateSecretV3 = () => {
+ const queryClient = useQueryClient();
+ return useMutation<{}, {}, TCreateSecretsV3DTO>({
+ mutationFn: async ({
+ secretPath = "/",
+ type,
+ environment,
+ workspaceId,
+ secretName,
+ secretValue,
+ latestFileKey,
+ secretComment
+ }) => {
+ const PRIVATE_KEY = localStorage.getItem("PRIVATE_KEY") as string;
+
+ const randomBytes = latestFileKey
+ ? decryptAssymmetric({
+ ciphertext: latestFileKey.encryptedKey,
+ nonce: latestFileKey.nonce,
+ publicKey: latestFileKey.sender.publicKey,
+ privateKey: PRIVATE_KEY
+ })
+ : crypto.randomBytes(16).toString("hex");
+
+ const reqBody = {
+ workspaceId,
+ environment,
+ type,
+ secretPath,
+ ...encryptSecret(randomBytes, secretName, secretValue, secretComment)
+ };
+ const { data } = await apiRequest.post(`/api/v3/secrets/${secretName}`, reqBody);
+ return data;
+ },
+ onSuccess: (_, { workspaceId, environment, secretPath }) => {
+ queryClient.invalidateQueries(
+ secretKeys.getProjectSecret(workspaceId, environment, secretPath)
+ );
+ }
+ });
+};
+
+export const useUpdateSecretV3 = () => {
+ const queryClient = useQueryClient();
+ return useMutation<{}, {}, TUpdateSecretsV3DTO>({
+ mutationFn: async ({
+ secretPath = "/",
+ type,
+ environment,
+ workspaceId,
+ secretName,
+ secretValue,
+ latestFileKey
+ }) => {
+ const PRIVATE_KEY = localStorage.getItem("PRIVATE_KEY") as string;
+
+ const randomBytes = latestFileKey
+ ? decryptAssymmetric({
+ ciphertext: latestFileKey.encryptedKey,
+ nonce: latestFileKey.nonce,
+ publicKey: latestFileKey.sender.publicKey,
+ privateKey: PRIVATE_KEY
+ })
+ : crypto.randomBytes(16).toString("hex");
+ const { secretValueIV, secretValueTag, secretValueCiphertext } = encryptSecret(
+ randomBytes,
+ secretName,
+ secretValue,
+ ""
+ );
+
+ const reqBody = {
+ workspaceId,
+ environment,
+ type,
+ secretPath,
+ secretValueIV,
+ secretValueTag,
+ secretValueCiphertext
+ };
+ const { data } = await apiRequest.patch(`/api/v3/secrets/${secretName}`, reqBody);
+ return data;
+ },
+ onSuccess: (_, { workspaceId, environment, secretPath }) => {
+ queryClient.invalidateQueries(
+ secretKeys.getProjectSecret(workspaceId, environment, secretPath)
+ );
+ }
+ });
+};
+
+export const useDeleteSecretV3 = () => {
+ const queryClient = useQueryClient();
+
+ return useMutation<{}, {}, TDeleteSecretsV3DTO>({
+ mutationFn: async ({ secretPath = "/", type, environment, workspaceId, secretName }) => {
+ const reqBody = {
+ workspaceId,
+ environment,
+ type,
+ secretPath
+ };
+
+ const { data } = await apiRequest.delete(`/api/v3/secrets/${secretName}`, {
+ data: reqBody
+ });
+ return data;
+ },
+ onSuccess: (_, { workspaceId, environment, secretPath }) => {
+ queryClient.invalidateQueries(
+ secretKeys.getProjectSecret(workspaceId, environment, secretPath)
+ );
+ }
+ });
+};
diff --git a/frontend/src/hooks/api/secrets/queries.tsx b/frontend/src/hooks/api/secrets/queries.tsx
index 3d0c816437..34ecd7ec49 100644
--- a/frontend/src/hooks/api/secrets/queries.tsx
+++ b/frontend/src/hooks/api/secrets/queries.tsx
@@ -1,5 +1,5 @@
/* eslint-disable no-param-reassign */
-import { useCallback } from "react";
+import { useCallback, useMemo } from "react";
import { useMutation, useQueries, useQuery, useQueryClient } from "@tanstack/react-query";
import {
@@ -38,40 +38,15 @@ const fetchProjectEncryptedSecrets = async (
folderId?: string,
secretPath?: string
) => {
- if (typeof env === "string") {
- const { data } = await apiRequest.get<{ secrets: EncryptedSecret[] }>("/api/v2/secrets", {
- params: {
- environment: env,
- workspaceId,
- folderId: folderId || undefined,
- secretPath
- }
- });
- return data.secrets;
- }
-
- if (typeof env === "object") {
- let allEnvData: any = [];
-
- // eslint-disable-next-line no-restricted-syntax
- for (const envPoint of env) {
- // eslint-disable-next-line no-await-in-loop
- const { data } = await apiRequest.get<{ secrets: EncryptedSecret[] }>("/api/v2/secrets", {
- params: {
- environment: envPoint,
- workspaceId,
- folderId,
- secretPath
- }
- });
- allEnvData = allEnvData.concat(data.secrets);
+ const { data } = await apiRequest.get<{ secrets: EncryptedSecret[] }>("/api/v2/secrets", {
+ params: {
+ environment: env,
+ workspaceId,
+ folderId: folderId || undefined,
+ secretPath
}
-
- return allEnvData;
- // eslint-disable-next-line no-else-return
- } else {
- return null;
- }
+ });
+ return data.secrets;
};
export const useGetProjectSecrets = ({
@@ -167,31 +142,13 @@ export const useGetProjectSecretsAllEnv = ({
decryptFileKey,
folderId,
secretPath
-}: TGetProjectSecretsAllEnvDTO) =>
- useQueries({
+}: TGetProjectSecretsAllEnvDTO) => {
+ const secrets = useQueries({
queries: envs.map((env) => ({
queryKey: secretKeys.getProjectSecret(workspaceId, env, secretPath || folderId),
enabled: Boolean(decryptFileKey && workspaceId && env),
- queryFn: () => fetchProjectEncryptedSecrets(workspaceId, env, folderId, secretPath)
- }))
- });
-
-export const useGetProjectSecretsByKey = ({
- workspaceId,
- env,
- decryptFileKey,
- isPaused,
- folderId,
- secretPath
-}: GetProjectSecretsDTO) =>
- useQuery({
- // wait for all values to be available
- enabled: Boolean(decryptFileKey && workspaceId && env) && !isPaused,
- // right now secretpath is passed as folderid as only this is used in overview
- queryKey: secretKeys.getProjectSecret(workspaceId, env, secretPath),
- queryFn: () => fetchProjectEncryptedSecrets(workspaceId, env, folderId, secretPath),
- select: useCallback(
- (data: EncryptedSecret[]) => {
+ queryFn: () => fetchProjectEncryptedSecrets(workspaceId, env, folderId, secretPath),
+ select: (data: EncryptedSecret[]) => {
const PRIVATE_KEY = localStorage.getItem("PRIVATE_KEY") as string;
const latestKey = decryptFileKey;
const key = decryptAssymmetric({
@@ -201,12 +158,11 @@ export const useGetProjectSecretsByKey = ({
privateKey: PRIVATE_KEY
});
- const sharedSecrets: Record<string, DecryptedSecret[]> = {};
+ const sharedSecrets: Record<string, DecryptedSecret> = {};
const personalSecrets: Record<string, { id: string; value: string }> = {};
// this used for add-only mode in dashboard
// type won't be there thus only one key is shown
const duplicateSecretKey: Record<string, boolean> = {};
- const uniqSecKeys: Record<string, boolean> = {};
data.forEach((encSecret: EncryptedSecret) => {
const secretKey = decryptSymmetric({
ciphertext: encSecret.secretKeyCiphertext,
@@ -214,7 +170,6 @@ export const useGetProjectSecretsByKey = ({
tag: encSecret.secretKeyTag,
key
});
- if (!uniqSecKeys?.[secretKey]) uniqSecKeys[secretKey] = true;
const secretValue = decryptSymmetric({
ciphertext: encSecret.secretValueCiphertext,
@@ -242,35 +197,65 @@ export const useGetProjectSecretsByKey = ({
};
if (encSecret.type === "personal") {
- personalSecrets[`${decryptedSecret.key}-${decryptedSecret.env}`] = {
+ personalSecrets[decryptedSecret.key] = {
id: encSecret._id,
value: secretValue
};
} else {
- if (!duplicateSecretKey?.[`${decryptedSecret.key}-${decryptedSecret.env}`]) {
- if (!sharedSecrets?.[secretKey]) sharedSecrets[secretKey] = [];
- sharedSecrets[secretKey].push(decryptedSecret);
+ if (!duplicateSecretKey?.[decryptedSecret.key]) {
+ sharedSecrets[decryptedSecret.key] = decryptedSecret;
}
- duplicateSecretKey[`${decryptedSecret.key}-${decryptedSecret.env}`] = true;
+ duplicateSecretKey[decryptedSecret.key] = true;
}
});
- Object.keys(sharedSecrets).forEach((secName) => {
- sharedSecrets[secName].forEach((val) => {
- const dupKey = `${val.key}-${val.env}`;
- if (personalSecrets?.[dupKey]) {
- val.idOverride = personalSecrets[dupKey].id;
- val.valueOverride = personalSecrets[dupKey].value;
- val.overrideAction = "modified";
- }
- });
- });
- return { secrets: sharedSecrets, uniqueSecCount: Object.keys(uniqSecKeys).length };
- },
- [decryptFileKey]
- )
+ Object.keys(sharedSecrets).forEach((val) => {
+ if (personalSecrets?.[val]) {
+ sharedSecrets[val].idOverride = personalSecrets[val].id;
+ sharedSecrets[val].valueOverride = personalSecrets[val].value;
+ sharedSecrets[val].overrideAction = "modified";
+ }
+ });
+ return sharedSecrets;
+ }
+ }))
});
+ const secKeys = useMemo(() => {
+ const keys = new Set<string>();
+ secrets?.forEach(({ data }) => {
+ // TODO(akhilmhdh): find out why this is unknown
+ Object.keys(data || {}).forEach((key) => keys.add(key));
+ });
+ return [...keys];
+ }, [(secrets || []).map((sec) => sec.data)]);
+
+ const getEnvSecretKeyCount = useCallback(
+ (env: string) => {
+ const selectedEnvIndex = envs.indexOf(env);
+ if (selectedEnvIndex !== -1) {
+ return Object.keys(secrets[selectedEnvIndex]?.data || {}).length;
+ }
+ return 0;
+ },
+ [(secrets || []).map((sec) => sec.data)]
+ );
+
+ const getSecretByKey = useCallback(
+ (env: string, key: string) => {
+ const selectedEnvIndex = envs.indexOf(env);
+ if (selectedEnvIndex !== -1) {
+ const sec = secrets[selectedEnvIndex]?.data?.[key];
+ return sec;
+ }
+ return undefined;
+ },
+ [(secrets || []).map((sec) => sec.data)]
+ );
+
+ return { data: secrets, secKeys, getSecretByKey, getEnvSecretKeyCount };
+};
+
const fetchEncryptedSecretVersion = async (secretId: string, offset: number, limit: number) => {
const { data } = await apiRequest.get<{ secretVersions: EncryptedSecretVersion[] }>(
`/api/v1/secret/${secretId}/secret-versions`,
diff --git a/frontend/src/hooks/api/secrets/types.ts b/frontend/src/hooks/api/secrets/types.ts
index fb995ce80a..9e30922570 100644
--- a/frontend/src/hooks/api/secrets/types.ts
+++ b/frontend/src/hooks/api/secrets/types.ts
@@ -118,3 +118,32 @@ export type GetSecretVersionsDTO = {
offset: number;
decryptFileKey: UserWsKeyPair;
};
+
+export type TCreateSecretsV3DTO = {
+ latestFileKey: UserWsKeyPair;
+ secretName: string;
+ secretValue: string;
+ secretComment: string;
+ secretPath: string;
+ workspaceId: string;
+ environment: string;
+ type: string;
+};
+
+export type TUpdateSecretsV3DTO = {
+ latestFileKey: UserWsKeyPair;
+ workspaceId: string;
+ environment: string;
+ type: string;
+ secretPath: string;
+ secretName: string;
+ secretValue: string;
+};
+
+export type TDeleteSecretsV3DTO = {
+ workspaceId: string;
+ environment: string;
+ type: string;
+ secretPath: string;
+ secretName: string;
+};
diff --git a/frontend/src/layouts/AppLayout/AppLayout.tsx b/frontend/src/layouts/AppLayout/AppLayout.tsx
index 877db215de..fea50dd8ac 100644
--- a/frontend/src/layouts/AppLayout/AppLayout.tsx
+++ b/frontend/src/layouts/AppLayout/AppLayout.tsx
@@ -13,7 +13,18 @@ import { useTranslation } from "react-i18next";
import Link from "next/link";
import { useRouter } from "next/router";
import { faGithub, faSlack } from "@fortawesome/free-brands-svg-icons";
-import { faAngleDown, faArrowLeft, faArrowUpRightFromSquare, faBook, faCheck, faEnvelope, faInfinity, faMobile, faPlus, faQuestion } from "@fortawesome/free-solid-svg-icons";
+import {
+ faAngleDown,
+ faArrowLeft,
+ faArrowUpRightFromSquare,
+ faBook,
+ faCheck,
+ faEnvelope,
+ faInfinity,
+ faMobile,
+ faPlus,
+ faQuestion
+} from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { yupResolver } from "@hookform/resolvers/yup";
import { DropdownMenuTrigger } from "@radix-ui/react-dropdown-menu";
@@ -41,7 +52,14 @@ import {
} from "@app/components/v2";
import { useOrganization, useSubscription, useUser, useWorkspace } from "@app/context";
import { usePopUp } from "@app/hooks";
-import { fetchOrgUsers, useAddUserToWs, useCreateWorkspace, useGetOrgTrialUrl, useLogoutUser, useUploadWsKey } from "@app/hooks/api";
+import {
+ fetchOrgUsers,
+ useAddUserToWs,
+ useCreateWorkspace,
+ useGetOrgTrialUrl,
+ useLogoutUser,
+ useUploadWsKey
+} from "@app/hooks/api";
interface LayoutProps {
children: React.ReactNode;
@@ -89,7 +107,9 @@ export const AppLayout = ({ children }: LayoutProps) => {
const { subscription } = useSubscription();
// const [ isLearningNoteOpen, setIsLearningNoteOpen ] = useState(true);
- const isAddingProjectsAllowed = subscription?.workspaceLimit ? (subscription.workspacesUsed < subscription.workspaceLimit) : true;
+ const isAddingProjectsAllowed = subscription?.workspaceLimit
+ ? subscription.workspacesUsed < subscription.workspaceLimit
+ : true;
const createWs = useCreateWorkspace();
const uploadWsKey = useUploadWsKey();
@@ -110,22 +130,22 @@ export const AppLayout = ({ children }: LayoutProps) => {
const { t } = useTranslation();
- useEffect(() => {
- const handleRouteChange = () => {
- (window).Intercom("update");
- };
-
- router.events.on("routeChangeComplete", handleRouteChange);
-
- return () => {
- router.events.off("routeChangeComplete", handleRouteChange);
- };
- }, []);
+ useEffect(() => {
+ const handleRouteChange = () => {
+ window.Intercom("update");
+ };
+
+ router.events.on("routeChangeComplete", handleRouteChange);
+
+ return () => {
+ router.events.off("routeChangeComplete", handleRouteChange);
+ };
+ }, []);
const logout = useLogoutUser();
const logOutUser = async () => {
try {
- console.log("Logging out...")
+ console.log("Logging out...");
await logout.mutateAsync();
localStorage.removeItem("protectedKey");
localStorage.removeItem("protectedKeyIV");
@@ -145,27 +165,30 @@ export const AppLayout = ({ children }: LayoutProps) => {
const changeOrg = async (orgId) => {
localStorage.setItem("orgData.id", orgId);
- router.push(`/org/${orgId}/overview`)
- }
+ router.push(`/org/${orgId}/overview`);
+ };
// TODO(akhilmhdh): This entire logic will be rechecked and will try to avoid
// Placing the localstorage as much as possible
// Wait till tony integrates the azure and its launched
useEffect(() => {
-
// Put a user in an org if they're not in one yet
const putUserInOrg = async () => {
if (tempLocalStorage("orgData.id") === "") {
localStorage.setItem("orgData.id", orgs[0]?._id);
}
- if (currentOrg && (
- (workspaces?.length === 0 && router.asPath.includes("project"))
- || router.asPath.includes("/project/undefined")
- || (!orgs?.map(org => org._id)?.includes(router.query.id) && !router.asPath.includes("project") && !router.asPath.includes("personal") && !router.asPath.includes("integration"))
- )) {
+ if (
+ currentOrg &&
+ ((workspaces?.length === 0 && router.asPath.includes("project")) ||
+ router.asPath.includes("/project/undefined") ||
+ (!orgs?.map((org) => org._id)?.includes(router.query.id) &&
+ !router.asPath.includes("project") &&
+ !router.asPath.includes("personal") &&
+ !router.asPath.includes("integration")))
+ ) {
router.push(`/org/${currentOrg?._id}/overview`);
- }
+ }
// else if (!router.asPath.includes("org") && !router.asPath.includes("project") && !router.asPath.includes("integrations") && !router.asPath.includes("personal-settings")) {
// const pathSegments = router.asPath.split("/").filter((segment) => segment.length > 0);
@@ -233,7 +256,7 @@ export const AppLayout = ({ children }: LayoutProps) => {
}
createNotification({ text: "Workspace created", type: "success" });
handlePopUpClose("addNewWs");
- router.push(`/project/${newWorkspaceId}/secrets`);
+ router.push(`/project/${newWorkspaceId}/secrets/overview`);
} catch (err) {
console.error(err);
createNotification({ text: "Failed to create workspace", type: "error" });
@@ -244,190 +267,235 @@ export const AppLayout = ({ children }: LayoutProps) => {
<>
<div className="dark hidden h-screen w-full flex-col overflow-x-hidden md:flex">
<div className="flex flex-grow flex-col overflow-y-hidden md:flex-row">
- <aside className="w-full border-r border-mineshaft-600 bg-gradient-to-tr from-mineshaft-700 via-mineshaft-800 to-mineshaft-900 md:w-60 dark">
+ <aside className="dark w-full border-r border-mineshaft-600 bg-gradient-to-tr from-mineshaft-700 via-mineshaft-800 to-mineshaft-900 md:w-60">
<nav className="items-between flex h-full flex-col justify-between overflow-y-auto dark:[color-scheme:dark]">
<div>
- {!router.asPath.includes("personal") && <div className="h-12 px-3 flex items-center pt-6 cursor-default">
- {(router.asPath.includes("project") || router.asPath.includes("integrations")) && <Link href={`/org/${currentOrg?._id}/overview`}><div className="pl-1 pr-2 text-mineshaft-400 hover:text-mineshaft-100 duration-200">
- <FontAwesomeIcon icon={faArrowLeft} />
- </div></Link>}
- <DropdownMenu>
- <DropdownMenuTrigger asChild className="data-[state=open]:bg-mineshaft-600">
- <div className="mr-auto flex items-center hover:bg-mineshaft-600 py-1.5 pl-1.5 pr-2 rounded-md">
- <div className="w-5 h-5 rounded-md bg-primary flex justify-center items-center text-sm">{currentOrg?.name.charAt(0)}</div>
- <div className="pl-3 text-mineshaft-100 text-sm">{currentOrg?.name} <FontAwesomeIcon icon={faAngleDown} className="text-xs pl-1 pt-1 text-mineshaft-300" /></div>
- </div>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="start" className="p-1">
- <div className="text-xs text-mineshaft-400 px-2 py-1">{user?.email}</div>
- {orgs?.map(org => <DropdownMenuItem key={org._id}>
+ {!router.asPath.includes("personal") && (
+ <div className="flex h-12 cursor-default items-center px-3 pt-6">
+ {(router.asPath.includes("project") ||
+ router.asPath.includes("integrations")) && (
+ <Link href={`/org/${currentOrg?._id}/overview`}>
+ <div className="pl-1 pr-2 text-mineshaft-400 duration-200 hover:text-mineshaft-100">
+ <FontAwesomeIcon icon={faArrowLeft} />
+ </div>
+ </Link>
+ )}
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild className="data-[state=open]:bg-mineshaft-600">
+ <div className="mr-auto flex items-center rounded-md py-1.5 pl-1.5 pr-2 hover:bg-mineshaft-600">
+ <div className="flex h-5 w-5 items-center justify-center rounded-md bg-primary text-sm">
+ {currentOrg?.name.charAt(0)}
+ </div>
+ <div className="pl-3 text-sm text-mineshaft-100">
+ {currentOrg?.name}{" "}
+ <FontAwesomeIcon
+ icon={faAngleDown}
+ className="pl-1 pt-1 text-xs text-mineshaft-300"
+ />
+ </div>
+ </div>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="start" className="p-1">
+ <div className="px-2 py-1 text-xs text-mineshaft-400">{user?.email}</div>
+ {orgs?.map((org) => (
+ <DropdownMenuItem key={org._id}>
+ <Button
+ onClick={() => changeOrg(org?._id)}
+ variant="plain"
+ colorSchema="secondary"
+ size="xs"
+ className="flex w-full items-center justify-start p-0 font-normal"
+ leftIcon={
+ currentOrg._id === org._id && (
+ <FontAwesomeIcon icon={faCheck} className="mr-3 text-primary" />
+ )
+ }
+ >
+ <div className="flex w-full items-center justify-between">
+ {org.name}
+ </div>
+ </Button>
+ </DropdownMenuItem>
+ ))}
+ <div className="mt-1 h-1 border-t border-mineshaft-600" />
+ <button type="button" onClick={logOutUser} className="w-full">
+ <DropdownMenuItem>Log Out</DropdownMenuItem>
+ </button>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ <DropdownMenu>
+ <DropdownMenuTrigger
+ asChild
+ className="p-1 hover:bg-primary-400 hover:text-black data-[state=open]:bg-primary-400 data-[state=open]:text-black"
+ >
+ <div className="child flex h-6 w-6 items-center justify-center rounded-full bg-mineshaft pr-1 text-xs text-mineshaft-300 hover:bg-mineshaft-500">
+ {user?.firstName?.charAt(0)}
+ {user?.lastName && user?.lastName?.charAt(0)}
+ </div>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="start" className="p-1">
+ <div className="px-2 py-1 text-xs text-mineshaft-400">{user?.email}</div>
+ <Link href="/personal-settings">
+ <DropdownMenuItem>Personal Settings</DropdownMenuItem>
+ </Link>
+ <a
+ href="https://infisical.com/docs/documentation/getting-started/introduction"
+ target="_blank"
+ rel="noopener noreferrer"
+ className="mt-3 w-full text-sm font-normal leading-[1.2rem] text-mineshaft-300 hover:text-mineshaft-100"
+ >
+ <DropdownMenuItem>
+ Documentation
+ <FontAwesomeIcon
+ icon={faArrowUpRightFromSquare}
+ className="mb-[0.06rem] pl-1.5 text-xxs"
+ />
+ </DropdownMenuItem>
+ </a>
+ <a
+ href="https://infisical.com/slack"
+ target="_blank"
+ rel="noopener noreferrer"
+ className="mt-3 w-full text-sm font-normal leading-[1.2rem] text-mineshaft-300 hover:text-mineshaft-100"
+ >
+ <DropdownMenuItem>
+ Join Slack Community
+ <FontAwesomeIcon
+ icon={faArrowUpRightFromSquare}
+ className="mb-[0.06rem] pl-1.5 text-xxs"
+ />
+ </DropdownMenuItem>
+ </a>
+ <div className="mt-1 h-1 border-t border-mineshaft-600" />
+ <button type="button" onClick={logOutUser} className="w-full">
+ <DropdownMenuItem>Log Out</DropdownMenuItem>
+ </button>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+ )}
+ {!router.asPath.includes("org") &&
+ (!router.asPath.includes("personal") && currentWorkspace ? (
+ <div className="mt-5 mb-4 w-full p-3">
+ <p className="ml-1.5 mb-1 text-xs font-semibold uppercase text-gray-400">
+ Project
+ </p>
+ <Select
+ defaultValue={currentWorkspace?._id}
+ value={currentWorkspace?._id}
+ className="w-full truncate bg-mineshaft-600 py-2.5 font-medium"
+ onValueChange={(value) => {
+ router.push(`/project/${value}/secrets/overview`);
+ localStorage.setItem("projectData.id", value);
+ }}
+ position="popper"
+ dropdownContainerClassName="text-bunker-200 bg-mineshaft-800 border border-mineshaft-600 z-50 max-h-96 border-gray-700"
+ >
+ <div className="no-scrollbar::-webkit-scrollbar h-full no-scrollbar">
+ {workspaces
+ .filter((ws) => ws.organization === currentOrg?._id)
+ .map(({ _id, name }) => (
+ <SelectItem
+ key={`ws-layout-list-${_id}`}
+ value={_id}
+ className={`${currentWorkspace?._id === _id && "bg-mineshaft-600"}`}
+ >
+ {name}
+ </SelectItem>
+ ))}
+ </div>
+ <hr className="mt-1 mb-1 h-px border-0 bg-gray-700" />
+ <div className="w-full">
<Button
- onClick={() => changeOrg(org?._id)}
- variant="plain"
- colorSchema="secondary"
- size="xs"
- className="w-full flex items-center justify-start p-0 font-normal"
- leftIcon={currentOrg._id === org._id && <FontAwesomeIcon icon={faCheck} className="mr-3 text-primary"/>}
+ className="w-full bg-mineshaft-700 py-2 text-bunker-200"
+ colorSchema="primary"
+ variant="outline_bg"
+ size="sm"
+ onClick={() => {
+ if (isAddingProjectsAllowed) {
+ handlePopUpOpen("addNewWs");
+ } else {
+ handlePopUpOpen("upgradePlan");
+ }
+ }}
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
>
- <div className="w-full flex justify-between items-center">{org.name}</div>
+ Add Project
</Button>
- </DropdownMenuItem>
- )}
- <div className="h-1 mt-1 border-t border-mineshaft-600"/>
- <button
- type="button"
- onClick={logOutUser}
- className="w-full"
- >
- <DropdownMenuItem>Log Out</DropdownMenuItem>
- </button>
- </DropdownMenuContent>
- </DropdownMenu>
- <DropdownMenu>
- <DropdownMenuTrigger asChild className="hover:bg-primary-400 hover:text-black data-[state=open]:text-black data-[state=open]:bg-primary-400 p-1">
- <div className="child w-6 h-6 rounded-full bg-mineshaft hover:bg-mineshaft-500 pr-1 text-xs text-mineshaft-300 flex justify-center items-center">
- {user?.firstName?.charAt(0)}{user?.lastName && user?.lastName?.charAt(0)}
+ </div>
+ </Select>
+ </div>
+ ) : (
+ <Link href={`/org/${currentOrg?._id}/overview`}>
+ <div className="my-6 flex cursor-default items-center justify-center pr-2 text-sm text-mineshaft-300 hover:text-mineshaft-100">
+ <FontAwesomeIcon icon={faArrowLeft} className="pr-3" />
+ Back to organization
</div>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="start" className="p-1">
- <div className="text-xs text-mineshaft-400 px-2 py-1">{user?.email}</div>
- <Link href="/personal-settings"><DropdownMenuItem>Personal Settings</DropdownMenuItem></Link>
- <a
- href="https://infisical.com/docs/documentation/getting-started/introduction"
- target="_blank"
- rel="noopener noreferrer"
- className="w-full mt-3 text-sm text-mineshaft-300 font-normal leading-[1.2rem] hover:text-mineshaft-100"
- >
- <DropdownMenuItem>Documentation<FontAwesomeIcon icon={faArrowUpRightFromSquare} className="pl-1.5 text-xxs mb-[0.06rem]" /></DropdownMenuItem>
- </a>
- <a
- href="https://infisical.com/slack"
- target="_blank"
- rel="noopener noreferrer"
- className="w-full mt-3 text-sm text-mineshaft-300 font-normal leading-[1.2rem] hover:text-mineshaft-100"
- >
- <DropdownMenuItem>Join Slack Community<FontAwesomeIcon icon={faArrowUpRightFromSquare} className="pl-1.5 text-xxs mb-[0.06rem]" /></DropdownMenuItem>
- </a>
- <div className="h-1 mt-1 border-t border-mineshaft-600"/>
- <button
- type="button"
- onClick={logOutUser}
- className="w-full"
- >
- <DropdownMenuItem>Log Out</DropdownMenuItem>
- </button>
- </DropdownMenuContent>
- </DropdownMenu>
- </div>}
- {!router.asPath.includes("org") && (!router.asPath.includes("personal") && currentWorkspace ? (
- <div className="mt-5 mb-4 w-full p-3">
- <p className="ml-1.5 mb-1 text-xs font-semibold uppercase text-gray-400">
- Project
- </p>
- <Select
- defaultValue={currentWorkspace?._id}
- value={currentWorkspace?._id}
- className="w-full truncate bg-mineshaft-600 py-2.5 font-medium"
- onValueChange={(value) => {
- router.push(`/project/${value}/secrets`);
- localStorage.setItem("projectData.id", value);
- }}
- position="popper"
- dropdownContainerClassName="text-bunker-200 bg-mineshaft-800 border border-mineshaft-600 z-50 max-h-96 border-gray-700"
- >
- <div className='h-full no-scrollbar no-scrollbar::-webkit-scrollbar'>
- {workspaces
- .filter((ws) => ws.organization === currentOrg?._id)
- .map(({ _id, name }) => (
- <SelectItem
- key={`ws-layout-list-${_id}`}
- value={_id}
- className={`${currentWorkspace?._id === _id && "bg-mineshaft-600"}`}
+ </Link>
+ ))}
+ <div className={`px-1 ${!router.asPath.includes("personal") ? "block" : "hidden"}`}>
+ {(router.asPath.includes("project") || router.asPath.includes("integrations")) &&
+ currentWorkspace ? (
+ <Menu>
+ <Link href={`/project/${currentWorkspace?._id}/secrets/overview`} passHref>
+ <a>
+ <MenuItem
+ isSelected={router.asPath.includes(
+ `/project/${currentWorkspace?._id}/secrets/overview`
+ )}
+ icon="system-outline-90-lock-closed"
>
- {name}
- </SelectItem>
- ))}
- </div>
- <hr className="mt-1 mb-1 h-px border-0 bg-gray-700" />
- <div className="w-full">
- <Button
- className="w-full bg-mineshaft-700 py-2 text-bunker-200"
- colorSchema="primary"
- variant="outline_bg"
- size="sm"
- onClick={() => {
- if (isAddingProjectsAllowed) {
- handlePopUpOpen("addNewWs")
- } else {
- handlePopUpOpen("upgradePlan");
+ {t("nav.menu.secrets")}
+ </MenuItem>
+ </a>
+ </Link>
+ <Link href={`/project/${currentWorkspace?._id}/members`} passHref>
+ <a>
+ <MenuItem
+ isSelected={
+ router.asPath === `/project/${currentWorkspace?._id}/members`
}
- }}
- leftIcon={<FontAwesomeIcon icon={faPlus} />}
- >
- Add Project
- </Button>
- </div>
- </Select>
- </div>
- ) : <Link href={`/org/${currentOrg?._id}/overview`}><div className="pr-2 my-6 flex justify-center items-center text-mineshaft-300 hover:text-mineshaft-100 cursor-default text-sm">
- <FontAwesomeIcon icon={faArrowLeft} className="pr-3"/>
- Back to organization
- </div></Link>)}
- <div className={`px-1 ${!router.asPath.includes("personal") ? "block" : "hidden"}`}>
- {((router.asPath.includes("project") || router.asPath.includes("integrations")) && currentWorkspace) ? <Menu>
- <Link href={`/project/${currentWorkspace?._id}/secrets`} passHref>
- <a>
- <MenuItem
- isSelected={router.asPath.includes(`/project/${currentWorkspace?._id}/secrets`)}
- icon="system-outline-90-lock-closed"
- >
- {t("nav.menu.secrets")}
- </MenuItem>
- </a>
- </Link>
- <Link href={`/project/${currentWorkspace?._id}/members`} passHref>
- <a>
- <MenuItem
- isSelected={router.asPath === `/project/${currentWorkspace?._id}/members`}
- icon="system-outline-96-groups"
- >
- {t("nav.menu.members")}
- </MenuItem>
- </a>
- </Link>
- <Link href={`/integrations/${currentWorkspace?._id}`} passHref>
- <a>
- <MenuItem
- isSelected={router.asPath === `/integrations/${currentWorkspace?._id}`}
- icon="system-outline-82-extension"
- >
- {t("nav.menu.integrations")}
- </MenuItem>
- </a>
- </Link>
- <Link href={`/project/${currentWorkspace?._id}/allowlist`} passHref>
- <a>
- <MenuItem
- isSelected={
- router.asPath === `/project/${currentWorkspace?._id}/allowlist`
- }
- icon="system-outline-126-verified"
- >
- IP Allowlist
- </MenuItem>
- </a>
- </Link>
- <Link href={`/project/${currentWorkspace?._id}/audit-logs`} passHref>
- <a>
- <MenuItem
- isSelected={router.asPath === `/project/${currentWorkspace?._id}/audit-logs`}
- icon="system-outline-168-view-headline"
- >
- Audit Logs
- </MenuItem>
- </a>
- </Link>
- {/* <Link href={`/project/${currentWorkspace?._id}/secret-scanning`} passHref>
+ icon="system-outline-96-groups"
+ >
+ {t("nav.menu.members")}
+ </MenuItem>
+ </a>
+ </Link>
+ <Link href={`/integrations/${currentWorkspace?._id}`} passHref>
+ <a>
+ <MenuItem
+ isSelected={router.asPath === `/integrations/${currentWorkspace?._id}`}
+ icon="system-outline-82-extension"
+ >
+ {t("nav.menu.integrations")}
+ </MenuItem>
+ </a>
+ </Link>
+ <Link href={`/project/${currentWorkspace?._id}/allowlist`} passHref>
+ <a>
+ <MenuItem
+ isSelected={
+ router.asPath === `/project/${currentWorkspace?._id}/allowlist`
+ }
+ icon="system-outline-126-verified"
+ >
+ IP Allowlist
+ </MenuItem>
+ </a>
+ </Link>
+ <Link href={`/project/${currentWorkspace?._id}/audit-logs`} passHref>
+ <a>
+ <MenuItem
+ isSelected={
+ router.asPath === `/project/${currentWorkspace?._id}/audit-logs`
+ }
+ icon="system-outline-168-view-headline"
+ >
+ Audit Logs
+ </MenuItem>
+ </a>
+ </Link>
+ {/* <Link href={`/project/${currentWorkspace?._id}/secret-scanning`} passHref>
<a>
<MenuItem
isSelected={router.asPath === `/project/${currentWorkspace?._id}/secret-scanning`}
@@ -438,20 +506,21 @@ export const AppLayout = ({ children }: LayoutProps) => {
</MenuItem>
</a>
</Link> */}
- <Link href={`/project/${currentWorkspace?._id}/settings`} passHref>
- <a>
- <MenuItem
- isSelected={
- router.asPath === `/project/${currentWorkspace?._id}/settings`
- }
- icon="system-outline-109-slider-toggle-settings"
- >
- {t("nav.menu.project-settings")}
- </MenuItem>
- </a>
- </Link>
- </Menu>
- : <Menu className="mt-4">
+ <Link href={`/project/${currentWorkspace?._id}/settings`} passHref>
+ <a>
+ <MenuItem
+ isSelected={
+ router.asPath === `/project/${currentWorkspace?._id}/settings`
+ }
+ icon="system-outline-109-slider-toggle-settings"
+ >
+ {t("nav.menu.project-settings")}
+ </MenuItem>
+ </a>
+ </Link>
+ </Menu>
+ ) : (
+ <Menu className="mt-4">
<Link href={`/org/${currentOrg?._id}/overview`} passHref>
<a>
<MenuItem
@@ -462,7 +531,7 @@ export const AppLayout = ({ children }: LayoutProps) => {
</MenuItem>
</a>
</Link>
- {/* {workspaces.map(project => <Link key={project._id} href={`/project/${project?._id}/secrets`} passHref>
+ {/* {workspaces.map(project => <Link key={project._id} href={`/project/${project?._id}/secrets/overview`} passHref>
<a>
<SubMenuItem
isSelected={false}
@@ -508,20 +577,25 @@ export const AppLayout = ({ children }: LayoutProps) => {
<Link href={`/org/${currentOrg?._id}/settings`} passHref>
<a>
<MenuItem
- isSelected={
- router.asPath === `/org/${currentOrg?._id}/settings`
- }
+ isSelected={router.asPath === `/org/${currentOrg?._id}/settings`}
icon="system-outline-109-slider-toggle-settings"
>
Organization Settings
</MenuItem>
</a>
</Link>
- </Menu>}
+ </Menu>
+ )}
</div>
</div>
- <div className={`relative mt-10 ${subscription && subscription.slug === "starter" && !subscription.has_used_trial ? "mb-2" : "mb-4"} w-full px-3 text-mineshaft-400 cursor-default text-sm flex flex-col items-center`}>
- {/* <div className={`${isLearningNoteOpen ? "block" : "hidden"} z-0 absolute h-60 w-[9.9rem] ${router.asPath.includes("org") ? "bottom-[8.4rem]" : "bottom-[5.4rem]"} bg-mineshaft-900 border border-mineshaft-600 mb-4 rounded-md opacity-30`}/>
+ <div
+ className={`relative mt-10 ${
+ subscription && subscription.slug === "starter" && !subscription.has_used_trial
+ ? "mb-2"
+ : "mb-4"
+ } flex w-full cursor-default flex-col items-center px-3 text-sm text-mineshaft-400`}
+ >
+ {/* <div className={`${isLearningNoteOpen ? "block" : "hidden"} z-0 absolute h-60 w-[9.9rem] ${router.asPath.includes("org") ? "bottom-[8.4rem]" : "bottom-[5.4rem]"} bg-mineshaft-900 border border-mineshaft-600 mb-4 rounded-md opacity-30`}/>
<div className={`${isLearningNoteOpen ? "block" : "hidden"} z-0 absolute h-60 w-[10.7rem] ${router.asPath.includes("org") ? "bottom-[8.15rem]" : "bottom-[5.15rem]"} bg-mineshaft-900 border border-mineshaft-600 mb-4 rounded-md opacity-50`}/>
<div className={`${isLearningNoteOpen ? "block" : "hidden"} z-0 absolute h-60 w-[11.5rem] ${router.asPath.includes("org") ? "bottom-[7.9rem]" : "bottom-[4.9rem]"} bg-mineshaft-900 border border-mineshaft-600 mb-4 rounded-md opacity-70`}/>
<div className={`${isLearningNoteOpen ? "block" : "hidden"} z-0 absolute h-60 w-[12.3rem] ${router.asPath.includes("org") ? "bottom-[7.65rem]" : "bottom-[4.65rem]"} bg-mineshaft-900 border border-mineshaft-600 mb-4 rounded-md opacity-90`}/>
@@ -549,22 +623,24 @@ export const AppLayout = ({ children }: LayoutProps) => {
</a>
</div>
</div> */}
- {router.asPath.includes("org") && <div
- onKeyDown={() => null}
- role="button"
- tabIndex={0}
- onClick={() => router.push(`/org/${router.query.id}/members?action=invite`)}
- className="w-full"
- >
- <div className="hover:text-mineshaft-200 duration-200 mb-3 pl-5 w-full">
- <FontAwesomeIcon icon={faPlus} className="mr-3"/>
- Invite people
+ {router.asPath.includes("org") && (
+ <div
+ onKeyDown={() => null}
+ role="button"
+ tabIndex={0}
+ onClick={() => router.push(`/org/${router.query.id}/members?action=invite`)}
+ className="w-full"
+ >
+ <div className="mb-3 w-full pl-5 duration-200 hover:text-mineshaft-200">
+ <FontAwesomeIcon icon={faPlus} className="mr-3" />
+ Invite people
+ </div>
</div>
- </div>}
+ )}
<DropdownMenu>
<DropdownMenuTrigger asChild>
- <div className="hover:text-mineshaft-200 duration-200 mb-2 pl-5 w-full">
- <FontAwesomeIcon icon={faQuestion} className="px-[0.1rem] mr-3"/>
+ <div className="mb-2 w-full pl-5 duration-200 hover:text-mineshaft-200">
+ <FontAwesomeIcon icon={faQuestion} className="mr-3 px-[0.1rem]" />
Help & Support
</div>
</DropdownMenuTrigger>
@@ -586,28 +662,33 @@ export const AppLayout = ({ children }: LayoutProps) => {
))}
</DropdownMenuContent>
</DropdownMenu>
- {subscription && subscription.slug === "starter" && !subscription.has_used_trial && (
- <button
- type="button"
- onClick={async () => {
- if (!subscription || !currentOrg) return;
-
- // direct user to start pro trial
- const url = await mutateAsync({
- orgId: currentOrg._id,
- success_url: window.location.href
- });
-
- window.location.href = url;
- }}
- className="w-full mt-1.5"
- >
- <div className="hover:text-primary-400 text-mineshaft-300 duration-200 flex justify-left items-center py-1 bg-mineshaft-600 rounded-md hover:bg-mineshaft-500 mb-1.5 mt-1.5 pl-4 w-full">
- <FontAwesomeIcon icon={faInfinity} className="mr-3 ml-0.5 py-2 text-primary"/>
- Start Free Pro Trial
- </div>
- </button>
- )}
+ {subscription &&
+ subscription.slug === "starter" &&
+ !subscription.has_used_trial && (
+ <button
+ type="button"
+ onClick={async () => {
+ if (!subscription || !currentOrg) return;
+
+ // direct user to start pro trial
+ const url = await mutateAsync({
+ orgId: currentOrg._id,
+ success_url: window.location.href
+ });
+
+ window.location.href = url;
+ }}
+ className="mt-1.5 w-full"
+ >
+ <div className="justify-left mb-1.5 mt-1.5 flex w-full items-center rounded-md bg-mineshaft-600 py-1 pl-4 text-mineshaft-300 duration-200 hover:bg-mineshaft-500 hover:text-primary-400">
+ <FontAwesomeIcon
+ icon={faInfinity}
+ className="mr-3 ml-0.5 py-2 text-primary"
+ />
+ Start Free Pro Trial
+ </div>
+ </button>
+ )}
</div>
</nav>
</aside>
diff --git a/frontend/src/pages/org/[id]/overview/index.tsx b/frontend/src/pages/org/[id]/overview/index.tsx
index 693af4d6fc..ca2f829d3a 100644
--- a/frontend/src/pages/org/[id]/overview/index.tsx
+++ b/frontend/src/pages/org/[id]/overview/index.tsx
@@ -1,4 +1,3 @@
-
import crypto from "crypto";
import { useEffect, useState } from "react";
@@ -9,14 +8,31 @@ import { useRouter } from "next/router";
import { IconProp } from "@fortawesome/fontawesome-svg-core";
import { faSlack } from "@fortawesome/free-brands-svg-icons";
import { faFolderOpen } from "@fortawesome/free-regular-svg-icons";
-import { faArrowRight, faCheckCircle, faHandPeace, faMagnifyingGlass, faNetworkWired, faPlug, faPlus, faUserPlus } from "@fortawesome/free-solid-svg-icons";
+import {
+ faArrowRight,
+ faCheckCircle,
+ faHandPeace,
+ faMagnifyingGlass,
+ faNetworkWired,
+ faPlug,
+ faPlus,
+ faUserPlus
+} from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { yupResolver } from "@hookform/resolvers/yup";
import * as yup from "yup";
import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider";
import onboardingCheck from "@app/components/utilities/checks/OnboardingCheck";
-import { Button, Checkbox, FormControl, Input, Modal, ModalContent, UpgradePlanModal } from "@app/components/v2";
+import {
+ Button,
+ Checkbox,
+ FormControl,
+ Input,
+ Modal,
+ ModalContent,
+ UpgradePlanModal
+} from "@app/components/v2";
import { TabsObject } from "@app/components/v2/Tabs";
import { useSubscription, useUser, useWorkspace } from "@app/context";
import { fetchOrgUsers, useAddUserToWs, useCreateWorkspace, useUploadWsKey } from "@app/hooks/api";
@@ -25,11 +41,14 @@ import { usePopUp } from "@app/hooks/usePopUp";
import { encryptAssymmetric } from "../../../../components/utilities/cryptography/crypto";
import registerUserAction from "../../../api/userActions/registerUserAction";
-const features = [{
- "_id": 0,
- "name": "Kubernetes Operator",
- "description": "Pull secrets into your Kubernetes containers and automatically redeploy upon secret changes."
-}]
+const features = [
+ {
+ _id: 0,
+ name: "Kubernetes Operator",
+ description:
+ "Pull secrets into your Kubernetes containers and automatically redeploy upon secret changes."
+ }
+];
type ItemProps = {
text: string;
@@ -58,7 +77,11 @@ const learningItem = ({
className={`w-full ${complete && "opacity-30 duration-200 hover:opacity-100"}`}
href={link}
>
- <div className={`${complete ? "bg-gradient-to-r from-primary-500/70 p-[0.07rem]" : ""} mb-3 rounded-md`}>
+ <div
+ className={`${
+ complete ? "bg-gradient-to-r from-primary-500/70 p-[0.07rem]" : ""
+ } mb-3 rounded-md`}
+ >
<div
onKeyDown={() => null}
role="button"
@@ -70,7 +93,11 @@ const learningItem = ({
});
}
}}
- className={`group relative flex h-[5.5rem] w-full items-center justify-between overflow-hidden rounded-md border ${complete? "bg-gradient-to-r from-[#0e1f01] to-mineshaft-700 border-mineshaft-900 cursor-default" : "bg-mineshaft-800 hover:bg-mineshaft-700 border-mineshaft-600 shadow-xl cursor-pointer"} duration-200 text-mineshaft-100`}
+ className={`group relative flex h-[5.5rem] w-full items-center justify-between overflow-hidden rounded-md border ${
+ complete
+ ? "cursor-default border-mineshaft-900 bg-gradient-to-r from-[#0e1f01] to-mineshaft-700"
+ : "cursor-pointer border-mineshaft-600 bg-mineshaft-800 shadow-xl hover:bg-mineshaft-700"
+ } text-mineshaft-100 duration-200`}
>
<div className="mr-4 flex flex-row items-center">
<FontAwesomeIcon icon={icon} className="mx-2 w-16 text-4xl" />
@@ -148,7 +175,11 @@ const learningItemSquare = ({
className={`w-full ${complete && "opacity-30 duration-200 hover:opacity-100"}`}
href={link}
>
- <div className={`${complete ? "bg-gradient-to-r from-primary-500/70 p-[0.07rem]" : ""} rounded-md w-full`}>
+ <div
+ className={`${
+ complete ? "bg-gradient-to-r from-primary-500/70 p-[0.07rem]" : ""
+ } w-full rounded-md`}
+ >
<div
onKeyDown={() => null}
role="button"
@@ -160,23 +191,32 @@ const learningItemSquare = ({
});
}
}}
- className={`group relative flex w-full items-center justify-between overflow-hidden rounded-md border ${complete? "bg-gradient-to-r from-[#0e1f01] to-mineshaft-700 border-mineshaft-900 cursor-default" : "bg-mineshaft-800 hover:bg-mineshaft-700 border-mineshaft-600 shadow-xl cursor-pointer"} duration-200 text-mineshaft-100`}
+ className={`group relative flex w-full items-center justify-between overflow-hidden rounded-md border ${
+ complete
+ ? "cursor-default border-mineshaft-900 bg-gradient-to-r from-[#0e1f01] to-mineshaft-700"
+ : "cursor-pointer border-mineshaft-600 bg-mineshaft-800 shadow-xl hover:bg-mineshaft-700"
+ } text-mineshaft-100 duration-200`}
>
- <div className="flex flex-col items-center w-full px-6 py-4">
- <div className="flex flex-row items-start justify-between w-full">
- <FontAwesomeIcon icon={icon} className="w-16 text-5xl text-mineshaft-200 group-hover:text-mineshaft-100 duration-100 pt-2" />
+ <div className="flex w-full flex-col items-center px-6 py-4">
+ <div className="flex w-full flex-row items-start justify-between">
+ <FontAwesomeIcon
+ icon={icon}
+ className="w-16 pt-2 text-5xl text-mineshaft-200 duration-100 group-hover:text-mineshaft-100"
+ />
{complete && (
<div className="absolute left-14 top-12 flex h-7 w-7 items-center justify-center rounded-full bg-bunker-500 p-2 group-hover:bg-mineshaft-700">
<FontAwesomeIcon icon={faCheckCircle} className="h-5 w-5 text-4xl text-primary" />
</div>
)}
<div
- className={`text-right text-sm font-normal text-mineshaft-300 ${complete ? "text-primary font-semibold" : ""}`}
+ className={`text-right text-sm font-normal text-mineshaft-300 ${
+ complete ? "font-semibold text-primary" : ""
+ }`}
>
{complete ? "Complete!" : `About ${time}`}
</div>
</div>
- <div className="flex flex-col items-start justify-start w-full pt-4">
+ <div className="flex w-full flex-col items-start justify-start pt-4">
<div className="mt-0.5 text-lg font-medium">{text}</div>
<div className="text-sm font-normal text-mineshaft-300">{subText}</div>
</div>
@@ -202,11 +242,14 @@ export default function Organization() {
const router = useRouter();
const { workspaces } = useWorkspace();
- const orgWorkspaces = workspaces?.filter(workspace => workspace.organization === localStorage.getItem("orgData.id")) || []
+ const orgWorkspaces =
+ workspaces?.filter(
+ (workspace) => workspace.organization === localStorage.getItem("orgData.id")
+ ) || [];
const currentOrg = String(router.query.id);
const { createNotification } = useNotificationContext();
const addWsUser = useAddUserToWs();
-
+
const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([
"addNewWs",
"upgradePlan"
@@ -269,7 +312,7 @@ export default function Organization() {
}
createNotification({ text: "Workspace created", type: "success" });
handlePopUpClose("addNewWs");
- router.push(`/project/${newWorkspaceId}/secrets`);
+ router.push(`/project/${newWorkspaceId}/secrets/overview`);
} catch (err) {
console.error(err);
createNotification({ text: "Failed to create workspace", type: "error" });
@@ -278,7 +321,9 @@ export default function Organization() {
const { subscription } = useSubscription();
- const isAddingProjectsAllowed = subscription?.workspaceLimit ? (subscription.workspacesUsed < subscription.workspaceLimit) : true;
+ const isAddingProjectsAllowed = subscription?.workspaceLimit
+ ? subscription.workspacesUsed < subscription.workspaceLimit
+ : true;
useEffect(() => {
onboardingCheck({
@@ -290,16 +335,16 @@ export default function Organization() {
}, []);
return (
- <div className="flex max-w-7xl mx-auto flex-col justify-start bg-bunker-800 md:h-screen">
+ <div className="mx-auto flex max-w-7xl flex-col justify-start bg-bunker-800 md:h-screen">
<Head>
<title>{t("common.head-title", { title: t("settings.members.title") })}</title>
<link rel="icon" href="/infisical.ico" />
</Head>
- <div className="flex flex-col items-start justify-start px-6 py-6 pb-0 text-3xl mb-4">
+ <div className="mb-4 flex flex-col items-start justify-start px-6 py-6 pb-0 text-3xl">
<p className="mr-4 font-semibold text-white">Projects</p>
- <div className="w-full flex flex-row mt-6">
+ <div className="mt-6 flex w-full flex-row">
<Input
- className="h-[2.3rem] text-sm bg-mineshaft-800 placeholder-mineshaft-50 duration-200 focus:bg-mineshaft-700/80"
+ className="h-[2.3rem] bg-mineshaft-800 text-sm placeholder-mineshaft-50 duration-200 focus:bg-mineshaft-700/80"
placeholder="Search by project name..."
value={searchFilter}
onChange={(e) => setSearchFilter(e.target.value)}
@@ -310,7 +355,7 @@ export default function Organization() {
leftIcon={<FontAwesomeIcon icon={faPlus} />}
onClick={() => {
if (isAddingProjectsAllowed) {
- handlePopUpOpen("addNewWs")
+ handlePopUpOpen("addNewWs");
} else {
handlePopUpOpen("upgradePlan");
}
@@ -320,120 +365,169 @@ export default function Organization() {
Add New Project
</Button>
</div>
- <div className="mt-4 w-full grid gap-4 grid-cols-1 lg:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4">
- {orgWorkspaces.filter(ws => ws?.name?.toLowerCase().includes(searchFilter.toLowerCase())).map(workspace => <div key={workspace._id} className="h-40 min-w-72 rounded-md bg-mineshaft-800 border border-mineshaft-600 p-4 flex flex-col justify-between">
- <div className="text-lg text-mineshaft-100 mt-0">{workspace.name}</div>
- <div className="text-sm text-mineshaft-300 mt-0 pb-6">{(workspace.environments?.length || 0)} environments</div>
- <button type="button" onClick={() => {
- router.push(`/project/${workspace._id}/secrets`);
- localStorage.setItem("projectData.id", workspace._id);
- }}>
- <div className="group cursor-default ml-auto hover:bg-primary-800/20 text-sm text-mineshaft-300 hover:text-mineshaft-200 bg-mineshaft-900 py-2 px-4 rounded-full w-max border border-mineshaft-600 hover:border-primary-500/80">Explore <FontAwesomeIcon icon={faArrowRight} className="pl-1.5 pr-0.5 group-hover:pl-2 group-hover:pr-0 duration-200" /></div>
- </button>
- </div>)}
+ <div className="mt-4 grid w-full grid-cols-1 gap-4 lg:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4">
+ {orgWorkspaces
+ .filter((ws) => ws?.name?.toLowerCase().includes(searchFilter.toLowerCase()))
+ .map((workspace) => (
+ <div
+ key={workspace._id}
+ className="min-w-72 flex h-40 flex-col justify-between rounded-md border border-mineshaft-600 bg-mineshaft-800 p-4"
+ >
+ <div className="mt-0 text-lg text-mineshaft-100">{workspace.name}</div>
+ <div className="mt-0 pb-6 text-sm text-mineshaft-300">
+ {workspace.environments?.length || 0} environments
+ </div>
+ <button
+ type="button"
+ onClick={() => {
+ router.push(`/project/${workspace._id}/secrets/overview`);
+ localStorage.setItem("projectData.id", workspace._id);
+ }}
+ >
+ <div className="group ml-auto w-max cursor-default rounded-full border border-mineshaft-600 bg-mineshaft-900 py-2 px-4 text-sm text-mineshaft-300 hover:border-primary-500/80 hover:bg-primary-800/20 hover:text-mineshaft-200">
+ Explore{" "}
+ <FontAwesomeIcon
+ icon={faArrowRight}
+ className="pl-1.5 pr-0.5 duration-200 group-hover:pl-2 group-hover:pr-0"
+ />
+ </div>
+ </button>
+ </div>
+ ))}
</div>
- {orgWorkspaces.length === 0 && (
- <div className="w-full rounded-md bg-mineshaft-800 border border-mineshaft-700 px-4 py-6 text-mineshaft-300 text-base">
- <FontAwesomeIcon icon={faFolderOpen} className="w-full text-center text-5xl mb-4 mt-2 text-mineshaft-400" />
+ {orgWorkspaces.length === 0 && (
+ <div className="w-full rounded-md border border-mineshaft-700 bg-mineshaft-800 px-4 py-6 text-base text-mineshaft-300">
+ <FontAwesomeIcon
+ icon={faFolderOpen}
+ className="mb-4 mt-2 w-full text-center text-5xl text-mineshaft-400"
+ />
<div className="text-center font-light">
- You are not part of any projects in this organization yet. When you are, they will appear
- here.
+ You are not part of any projects in this organization yet. When you are, they will
+ appear here.
</div>
<div className="mt-0.5 text-center font-light">
- Create a new project, or ask other organization members to give you necessary permissions.
+ Create a new project, or ask other organization members to give you necessary
+ permissions.
</div>
</div>
)}
</div>
- {((new Date()).getTime() - (new Date(user?.createdAt)).getTime()) < 30 * 24 * 60 * 60 * 1000 && <div className="flex flex-col items-start justify-start px-6 py-6 pb-0 text-3xl mb-4">
- <p className="mr-4 font-semibold text-white mb-4">Onboarding Guide</p>
- <div className="grid grid-cols-1 lg:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4 gap-3 w-full mb-3">
- {learningItemSquare({
- text: "Watch Infisical demo",
- subText: "Set up Infisical in 3 min.",
- complete: hasUserClickedIntro,
- icon: faHandPeace,
- time: "3 min",
- userAction: "intro_cta_clicked",
- link: "https://www.youtube.com/watch?v=PK23097-25I"
- })}
- {orgWorkspaces.length !== 0 && learningItemSquare({
- text: "Add your secrets",
- subText: "Drop a .env file or type your secrets.",
- complete: hasUserPushedSecrets,
- icon: faPlus,
- time: "1 min",
- userAction: "first_time_secrets_pushed",
- link: `/project/${orgWorkspaces[0]?._id}/secrets`
- })}
- {learningItemSquare({
- text: "Invite your teammates",
- subText: "Infisical is better used as a team.",
- complete: usersInOrg,
- icon: faUserPlus,
- time: "2 min",
- link: `/org/${router.query.id}/members?action=invite`
- })}
- <div className="block xl:hidden 2xl:block">{learningItemSquare({
- text: "Join Infisical Slack",
- subText: "Have any questions? Ask us!",
- complete: hasUserClickedSlack,
- icon: faSlack,
- time: "1 min",
- userAction: "slack_cta_clicked",
- link: "https://infisical.com/slack"
- })}</div>
- </div>
- {orgWorkspaces.length !== 0 && <div className="group text-mineshaft-100 relative mb-3 flex h-full w-full cursor-default flex-col items-center justify-between overflow-hidden rounded-md border border-mineshaft-600 bg-mineshaft-800 pl-2 pr-2 pt-4 pb-2 shadow-xl duration-200">
- <div className="mb-4 flex w-full flex-row items-center pr-4">
- <div className="mr-4 flex w-full flex-row items-center">
- <FontAwesomeIcon icon={faNetworkWired} className="mx-2 w-16 text-4xl" />
- {false && (
- <div className="absolute left-12 top-10 flex h-7 w-7 items-center justify-center rounded-full bg-bunker-500 p-2 group-hover:bg-mineshaft-700">
- <FontAwesomeIcon icon={faCheckCircle} className="h-5 w-5 text-4xl text-green" />
+ {new Date().getTime() - new Date(user?.createdAt).getTime() < 30 * 24 * 60 * 60 * 1000 && (
+ <div className="mb-4 flex flex-col items-start justify-start px-6 py-6 pb-0 text-3xl">
+ <p className="mr-4 mb-4 font-semibold text-white">Onboarding Guide</p>
+ <div className="mb-3 grid w-full grid-cols-1 gap-3 lg:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4">
+ {learningItemSquare({
+ text: "Watch Infisical demo",
+ subText: "Set up Infisical in 3 min.",
+ complete: hasUserClickedIntro,
+ icon: faHandPeace,
+ time: "3 min",
+ userAction: "intro_cta_clicked",
+ link: "https://www.youtube.com/watch?v=PK23097-25I"
+ })}
+ {orgWorkspaces.length !== 0 &&
+ learningItemSquare({
+ text: "Add your secrets",
+ subText: "Drop a .env file or type your secrets.",
+ complete: hasUserPushedSecrets,
+ icon: faPlus,
+ time: "1 min",
+ userAction: "first_time_secrets_pushed",
+ link: `/project/${orgWorkspaces[0]?._id}/secrets`
+ })}
+ {learningItemSquare({
+ text: "Invite your teammates",
+ subText: "Infisical is better used as a team.",
+ complete: usersInOrg,
+ icon: faUserPlus,
+ time: "2 min",
+ link: `/org/${router.query.id}/members?action=invite`
+ })}
+ <div className="block xl:hidden 2xl:block">
+ {learningItemSquare({
+ text: "Join Infisical Slack",
+ subText: "Have any questions? Ask us!",
+ complete: hasUserClickedSlack,
+ icon: faSlack,
+ time: "1 min",
+ userAction: "slack_cta_clicked",
+ link: "https://infisical.com/slack"
+ })}
+ </div>
+ </div>
+ {orgWorkspaces.length !== 0 && (
+ <div className="group relative mb-3 flex h-full w-full cursor-default flex-col items-center justify-between overflow-hidden rounded-md border border-mineshaft-600 bg-mineshaft-800 pl-2 pr-2 pt-4 pb-2 text-mineshaft-100 shadow-xl duration-200">
+ <div className="mb-4 flex w-full flex-row items-center pr-4">
+ <div className="mr-4 flex w-full flex-row items-center">
+ <FontAwesomeIcon icon={faNetworkWired} className="mx-2 w-16 text-4xl" />
+ {false && (
+ <div className="absolute left-12 top-10 flex h-7 w-7 items-center justify-center rounded-full bg-bunker-500 p-2 group-hover:bg-mineshaft-700">
+ <FontAwesomeIcon
+ icon={faCheckCircle}
+ className="h-5 w-5 text-4xl text-green"
+ />
+ </div>
+ )}
+ <div className="flex flex-col items-start pl-0.5">
+ <div className="mt-0.5 text-xl font-semibold">Inject secrets locally</div>
+ <div className="text-sm font-normal">
+ Replace .env files with a more secure and efficient alternative.
+ </div>
+ </div>
</div>
- )}
- <div className="flex flex-col items-start pl-0.5">
- <div className="mt-0.5 text-xl font-semibold">Inject secrets locally</div>
- <div className="text-sm font-normal">
- Replace .env files with a more secure and efficient alternative.
+ <div
+ className={`w-28 pr-4 text-right text-sm font-semibold ${false && "text-green"}`}
+ >
+ About 2 min
</div>
</div>
+ <TabsObject />
+ {false && <div className="absolute bottom-0 left-0 h-1 w-full bg-green" />}
</div>
- <div className={`w-28 pr-4 text-right text-sm font-semibold ${false && "text-green"}`}>
- About 2 min
- </div>
- </div>
- <TabsObject />
- {false && <div className="absolute bottom-0 left-0 h-1 w-full bg-green" />}
- </div>}
- {orgWorkspaces.length !== 0 && learningItem({
- text: "Integrate Infisical with your infrastructure",
- subText: "Connect Infisical to various 3rd party services and platforms.",
- complete: false,
- icon: faPlug,
- time: "15 min",
- link: "https://infisical.com/docs/integrations/overview"
- })}
- </div>}
- <div className="flex flex-col items-start justify-start px-6 py-6 pb-0 text-3xl mb-4 pb-6">
+ )}
+ {orgWorkspaces.length !== 0 &&
+ learningItem({
+ text: "Integrate Infisical with your infrastructure",
+ subText: "Connect Infisical to various 3rd party services and platforms.",
+ complete: false,
+ icon: faPlug,
+ time: "15 min",
+ link: "https://infisical.com/docs/integrations/overview"
+ })}
+ </div>
+ )}
+ <div className="mb-4 flex flex-col items-start justify-start px-6 py-6 pb-0 pb-6 text-3xl">
<p className="mr-4 font-semibold text-white">Explore More</p>
- <div className="mt-4 w-full grid grid-flow-dense gap-4" style={{ gridTemplateColumns: "repeat(auto-fill, minmax(256px, 4fr))" }}>
- {features.map(feature => <div key={feature._id} className="h-44 w-96 rounded-md bg-mineshaft-800 border border-mineshaft-600 p-4 flex flex-col justify-between">
- <div className="text-lg text-mineshaft-100 mt-0">{feature.name}</div>
- <div className="text-[15px] font-light text-mineshaft-300 mb-4 mt-2">{feature.description}</div>
- <div className="w-full flex items-center">
- <div className="text-mineshaft-300 text-[15px] font-light">Setup time: 20 min</div>
- <a
- target="_blank"
- rel="noopener noreferrer"
- className="group cursor-default ml-auto hover:bg-primary-800/20 text-sm text-mineshaft-300 hover:text-mineshaft-200 bg-mineshaft-900 py-2 px-4 rounded-full w-max border border-mineshaft-600 hover:border-primary-500/80"
- href="https://infisical.com/docs/documentation/getting-started/kubernetes"
- >
- Learn more <FontAwesomeIcon icon={faArrowRight} className="pl-1.5 pr-0.5 group-hover:pl-2 group-hover:pr-0 duration-200"/>
- </a>
+ <div
+ className="mt-4 grid w-full grid-flow-dense gap-4"
+ style={{ gridTemplateColumns: "repeat(auto-fill, minmax(256px, 4fr))" }}
+ >
+ {features.map((feature) => (
+ <div
+ key={feature._id}
+ className="flex h-44 w-96 flex-col justify-between rounded-md border border-mineshaft-600 bg-mineshaft-800 p-4"
+ >
+ <div className="mt-0 text-lg text-mineshaft-100">{feature.name}</div>
+ <div className="mb-4 mt-2 text-[15px] font-light text-mineshaft-300">
+ {feature.description}
+ </div>
+ <div className="flex w-full items-center">
+ <div className="text-[15px] font-light text-mineshaft-300">Setup time: 20 min</div>
+ <a
+ target="_blank"
+ rel="noopener noreferrer"
+ className="group ml-auto w-max cursor-default rounded-full border border-mineshaft-600 bg-mineshaft-900 py-2 px-4 text-sm text-mineshaft-300 hover:border-primary-500/80 hover:bg-primary-800/20 hover:text-mineshaft-200"
+ href="https://infisical.com/docs/documentation/getting-started/kubernetes"
+ >
+ Learn more{" "}
+ <FontAwesomeIcon
+ icon={faArrowRight}
+ className="pl-1.5 pr-0.5 duration-200 group-hover:pl-2 group-hover:pr-0"
+ />
+ </a>
+ </div>
</div>
- </div>)}
+ ))}
</div>
</div>
<Modal
diff --git a/frontend/src/pages/project/[id]/secrets/index.tsx b/frontend/src/pages/project/[id]/secrets/[env].tsx
similarity index 68%
rename from frontend/src/pages/project/[id]/secrets/index.tsx
rename to frontend/src/pages/project/[id]/secrets/[env].tsx
index 8ab831cb69..8838505922 100644
--- a/frontend/src/pages/project/[id]/secrets/index.tsx
+++ b/frontend/src/pages/project/[id]/secrets/[env].tsx
@@ -1,16 +1,10 @@
import { useTranslation } from "react-i18next";
import Head from "next/head";
-import { useRouter } from "next/router";
import { DashboardPage } from "@app/views/DashboardPage";
-import { DashboardEnvOverview } from "@app/views/DashboardPage/DashboardEnvOverview";
const Dashboard = () => {
const { t } = useTranslation();
- const router = useRouter();
-
- const queryEnv = router.query.env as string;
- const isOverviewMode = !queryEnv;
return (
<>
@@ -22,7 +16,7 @@ const Dashboard = () => {
<meta name="og:description" content={String(t("dashboard.og-description"))} />
</Head>
<div className="h-full">
- {isOverviewMode ? <DashboardEnvOverview /> : <DashboardPage envFromTop={queryEnv} />}
+ <DashboardPage />
</div>
</>
);
diff --git a/frontend/src/views/Org/MembersPage/components/OrgIncidentContactsTable/OrgIncidentContactsTable.tsx b/frontend/src/views/Org/MembersPage/components/OrgIncidentContactsTable/OrgIncidentContactsTable.tsx
index 858c2f2109..cfafae765c 100644
--- a/frontend/src/views/Org/MembersPage/components/OrgIncidentContactsTable/OrgIncidentContactsTable.tsx
+++ b/frontend/src/views/Org/MembersPage/components/OrgIncidentContactsTable/OrgIncidentContactsTable.tsx
@@ -53,7 +53,7 @@ export const OrgIncidentContactsTable = ({
isLoading
}: Props) => {
const [searchContact, setSearchContact] = useState("");
- const {data: serverDetails } = useFetchServerStatus()
+ const { data: serverDetails } = useFetchServerStatus();
const { handlePopUpToggle, popUp, handlePopUpOpen, handlePopUpClose } = usePopUp([
"addContact",
"removeContact",
@@ -98,7 +98,7 @@ export const OrgIncidentContactsTable = ({
<Button
leftIcon={<FontAwesomeIcon icon={faPlus} />}
onClick={() => {
- if (serverDetails?.emailConfigured){
+ if (serverDetails?.emailConfigured) {
handlePopUpOpen("addContact");
} else {
handlePopUpOpen("setUpEmail");
@@ -119,7 +119,7 @@ export const OrgIncidentContactsTable = ({
</Tr>
</THead>
<TBody>
- {isLoading && <TableSkeleton columns={2} key="incident-contact" />}
+ {isLoading && <TableSkeleton columns={2} innerKey="incident-contact" />}
{filteredContacts?.map(({ email }) => (
<Tr key={email}>
<Td className="w-full">{email}</Td>
diff --git a/frontend/src/views/Org/MembersPage/components/OrgMembersTable/OrgMembersTable.tsx b/frontend/src/views/Org/MembersPage/components/OrgMembersTable/OrgMembersTable.tsx
index 3a39560ca3..5a0a6fd834 100644
--- a/frontend/src/views/Org/MembersPage/components/OrgMembersTable/OrgMembersTable.tsx
+++ b/frontend/src/views/Org/MembersPage/components/OrgMembersTable/OrgMembersTable.tsx
@@ -1,7 +1,14 @@
import { Dispatch, SetStateAction, useEffect, useMemo, useState } from "react";
import { Controller, useForm } from "react-hook-form";
import { useRouter } from "next/router";
-import { faCheck, faCopy, faMagnifyingGlass, faPlus, faTrash, faUsers } from "@fortawesome/free-solid-svg-icons";
+import {
+ faCheck,
+ faCopy,
+ faMagnifyingGlass,
+ faPlus,
+ faTrash,
+ faUsers
+} from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { yupResolver } from "@hookform/resolvers/yup";
import * as yup from "yup";
@@ -10,7 +17,8 @@ import { useNotificationContext } from "@app/components/context/Notifications/No
import {
Button,
DeleteActionModal,
- EmailServiceSetupModal, EmptyState,
+ EmailServiceSetupModal,
+ EmptyState,
FormControl,
IconButton,
Input,
@@ -29,7 +37,7 @@ import {
Tr,
UpgradePlanModal
} from "@app/components/v2";
-import { useOrganization , useWorkspace } from "@app/context";
+import { useOrganization, useWorkspace } from "@app/context";
import { usePopUp, useToggle } from "@app/hooks";
import { useGetSSOConfig } from "@app/hooks/api";
import { useFetchServerStatus } from "@app/hooks/api/serverDetails";
@@ -47,8 +55,8 @@ type Props = {
onGrantAccess: (userId: string, publicKey: string) => Promise<void>;
// the current user id to block remove org button
userId: string;
- completeInviteLink: string | undefined,
- setCompleteInviteLink: Dispatch<SetStateAction<string | undefined>>
+ completeInviteLink: string | undefined;
+ setCompleteInviteLink: Dispatch<SetStateAction<string | undefined>>;
};
const addMemberFormSchema = yup.object({
@@ -76,7 +84,7 @@ export const OrgMembersTable = ({
const { currentOrg } = useOrganization();
const { data: ssoConfig, isLoading: isLoadingSSOConfig } = useGetSSOConfig(currentOrg?._id ?? "");
const [searchMemberFilter, setSearchMemberFilter] = useState("");
- const {data: serverDetails } = useFetchServerStatus()
+ const { data: serverDetails } = useFetchServerStatus();
const { workspaces } = useWorkspace();
const [isInviteLinkCopied, setInviteLinkCopied] = useToggle(false);
const { handlePopUpToggle, popUp, handlePopUpOpen, handlePopUpClose } = usePopUp([
@@ -85,7 +93,7 @@ export const OrgMembersTable = ({
"upgradePlan",
"setUpEmail"
] as const);
-
+
useEffect(() => {
if (router.query.action === "invite") {
handlePopUpOpen("addMember");
@@ -101,11 +109,11 @@ export const OrgMembersTable = ({
const onAddMember = async ({ email }: TAddMemberForm) => {
await onInviteMember(email);
- if (serverDetails?.emailConfigured){
- handlePopUpClose("addMember");
- }
-
- reset();
+ if (serverDetails?.emailConfigured) {
+ handlePopUpClose("addMember");
+ }
+
+ reset();
};
const onRemoveOrgMemberApproved = async () => {
@@ -118,7 +126,7 @@ export const OrgMembersTable = ({
() => members.find(({ user }) => userId === user?._id)?.role === "owner",
[userId, members]
);
-
+
const filterdUser = useMemo(
() =>
members.filter(
@@ -163,10 +171,10 @@ export const OrgMembersTable = ({
text: "You cannot invite users when SAML SSO is configured for your organization",
type: "error"
});
-
+
return;
}
-
+
if (isMoreUserNotAllowed) {
handlePopUpOpen("upgradePlan");
} else {
@@ -190,7 +198,7 @@ export const OrgMembersTable = ({
</Tr>
</THead>
<TBody>
- {isLoading && <TableSkeleton columns={5} key="org-members" />}
+ {isLoading && <TableSkeleton columns={5} innerKey="org-members" />}
{!isLoading &&
filterdUser.map(({ user, inviteEmail, role, _id: orgMembershipId, status }) => {
const name = user ? `${user.firstName} ${user.lastName}` : "-";
@@ -219,11 +227,17 @@ export const OrgMembersTable = ({
<SelectItem value="member">member</SelectItem>
</Select>
)}
- {((status === "invited" || status === "verified") && serverDetails?.emailConfigured) && (
- <Button className='w-40' colorSchema="primary" variant="outline_bg" onClick={() => onInviteMember(email)}>
- Resend Invite
- </Button>
- )}
+ {(status === "invited" || status === "verified") &&
+ serverDetails?.emailConfigured && (
+ <Button
+ className="w-40"
+ colorSchema="primary"
+ variant="outline_bg"
+ onClick={() => onInviteMember(email)}
+ >
+ Resend Invite
+ </Button>
+ )}
{status === "completed" && (
<Button
colorSchema="secondary"
@@ -241,18 +255,33 @@ export const OrgMembersTable = ({
</Tag>
))
) : (
- <div className='flex flex-row'>
- {((status === "invited" || status === "verified") && serverDetails?.emailConfigured)
- ? <Tag colorSchema="red">This user hasn&apos;t accepted the invite yet</Tag>
- : <Tag colorSchema="red">This user isn&apos;t part of any projects yet</Tag>}
- {router.query.id !== "undefined" && !((status === "invited" || status === "verified") && serverDetails?.emailConfigured) && <button
- type="button"
- onClick={() => router.push(`/project/${workspaces[0]?._id}/members`)}
- className='text-sm bg-mineshaft w-max px-1.5 py-0.5 hover:bg-primary duration-200 hover:text-black cursor-pointer rounded-sm'
- >
- <FontAwesomeIcon icon={faPlus} className="mr-1" />
- Add to projects
- </button>}
+ <div className="flex flex-row">
+ {(status === "invited" || status === "verified") &&
+ serverDetails?.emailConfigured ? (
+ <Tag colorSchema="red">
+ This user hasn&apos;t accepted the invite yet
+ </Tag>
+ ) : (
+ <Tag colorSchema="red">
+ This user isn&apos;t part of any projects yet
+ </Tag>
+ )}
+ {router.query.id !== "undefined" &&
+ !(
+ (status === "invited" || status === "verified") &&
+ serverDetails?.emailConfigured
+ ) && (
+ <button
+ type="button"
+ onClick={() =>
+ router.push(`/project/${workspaces[0]?._id}/members`)
+ }
+ className="w-max cursor-pointer rounded-sm bg-mineshaft px-1.5 py-0.5 text-sm duration-200 hover:bg-primary hover:text-black"
+ >
+ <FontAwesomeIcon icon={faPlus} className="mr-1" />
+ Add to projects
+ </button>
+ )}
</div>
)}
</Td>
@@ -282,67 +311,73 @@ export const OrgMembersTable = ({
isOpen={popUp?.addMember?.isOpen}
onOpenChange={(isOpen) => {
handlePopUpToggle("addMember", isOpen);
- setCompleteInviteLink(undefined)
+ setCompleteInviteLink(undefined);
}}
>
<ModalContent
title={`Invite others to ${orgName}`}
subTitle={
<div>
- {!completeInviteLink && <div>
- An invite is specific to an email address and expires after 1 day.
- <br />
- For security reasons, you will need to separately add members to projects.
- </div>}
- {completeInviteLink && "This Infisical instance does not have a email provider setup. Please share this invite link with the invitee manually"}
+ {!completeInviteLink && (
+ <div>
+ An invite is specific to an email address and expires after 1 day.
+ <br />
+ For security reasons, you will need to separately add members to projects.
+ </div>
+ )}
+ {completeInviteLink &&
+ "This Infisical instance does not have a email provider setup. Please share this invite link with the invitee manually"}
</div>
}
>
- {!completeInviteLink && <form onSubmit={handleSubmit(onAddMember)} >
- <Controller
- control={control}
- defaultValue=""
- name="email"
- render={({ field, fieldState: { error } }) => (
- <FormControl label="Email" isError={Boolean(error)} errorText={error?.message}>
- <Input {...field} />
- </FormControl>
- )}
- />
- <div className="mt-8 flex items-center">
- <Button
- className="mr-4"
- size="sm"
- type="submit"
- isLoading={isSubmitting}
- isDisabled={isSubmitting}
- >
- Add Member
- </Button>
- <Button
+ {!completeInviteLink && (
+ <form onSubmit={handleSubmit(onAddMember)}>
+ <Controller
+ control={control}
+ defaultValue=""
+ name="email"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl label="Email" isError={Boolean(error)} errorText={error?.message}>
+ <Input {...field} />
+ </FormControl>
+ )}
+ />
+ <div className="mt-8 flex items-center">
+ <Button
+ className="mr-4"
+ size="sm"
+ type="submit"
+ isLoading={isSubmitting}
+ isDisabled={isSubmitting}
+ >
+ Add Member
+ </Button>
+ <Button
+ colorSchema="secondary"
+ variant="plain"
+ onClick={() => handlePopUpClose("addMember")}
+ >
+ Cancel
+ </Button>
+ </div>
+ </form>
+ )}
+ {completeInviteLink && (
+ <div className="mt-2 mb-3 mr-2 flex items-center justify-end rounded-md bg-white/[0.07] p-2 text-base text-gray-400">
+ <p className="mr-4 break-all">{completeInviteLink}</p>
+ <IconButton
+ ariaLabel="copy icon"
colorSchema="secondary"
- variant="plain"
- onClick={() => handlePopUpClose("addMember")}
+ className="group relative"
+ onClick={copyTokenToClipboard}
>
- Cancel
- </Button>
+ <FontAwesomeIcon icon={isInviteLinkCopied ? faCheck : faCopy} />
+ <span className="absolute -left-8 -top-20 hidden w-28 translate-y-full rounded-md bg-bunker-800 py-2 pl-3 text-center text-sm text-gray-400 group-hover:flex group-hover:animate-fadeIn">
+ click to copy
+ </span>
+ </IconButton>
</div>
- </form>}
- {
- completeInviteLink &&
- <div className="mt-2 mb-3 mr-2 flex items-center justify-end rounded-md bg-white/[0.07] p-2 text-base text-gray-400">
- <p className="mr-4 break-all">{completeInviteLink}</p>
- <IconButton
- ariaLabel="copy icon"
- colorSchema="secondary"
- className="group relative"
- onClick={copyTokenToClipboard}
- >
- <FontAwesomeIcon icon={isInviteLinkCopied ? faCheck : faCopy} />
- <span className="absolute -left-8 -top-20 hidden w-28 translate-y-full rounded-md bg-bunker-800 py-2 pl-3 text-center text-sm text-gray-400 group-hover:flex group-hover:animate-fadeIn">click to copy</span>
- </IconButton>
- </div>
- }
+ )}
</ModalContent>
</Modal>
<DeleteActionModal
@@ -363,4 +398,4 @@ export const OrgMembersTable = ({
/>
</div>
);
-};
\ No newline at end of file
+};
diff --git a/frontend/src/views/Org/MembersPage/components/OrgServiceAccountsTable/OrgServiceAccountsTable.tsx b/frontend/src/views/Org/MembersPage/components/OrgServiceAccountsTable/OrgServiceAccountsTable.tsx
index 61b0db3617..bd9f601c2d 100644
--- a/frontend/src/views/Org/MembersPage/components/OrgServiceAccountsTable/OrgServiceAccountsTable.tsx
+++ b/frontend/src/views/Org/MembersPage/components/OrgServiceAccountsTable/OrgServiceAccountsTable.tsx
@@ -1,14 +1,15 @@
-import { useEffect, useMemo,useState } from "react";
-import { Controller,useForm } from "react-hook-form";
+import { useEffect, useMemo, useState } from "react";
+import { Controller, useForm } from "react-hook-form";
import { useRouter } from "next/router";
-import {
- faCheck,
- faCopy,
- faMagnifyingGlass,
- faPencil,
- faPlus,
- faServer,
- faTrash} from "@fortawesome/free-solid-svg-icons";
+import {
+ faCheck,
+ faCopy,
+ faMagnifyingGlass,
+ faPencil,
+ faPlus,
+ faServer,
+ faTrash
+} from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { yupResolver } from "@hookform/resolvers/yup";
import * as yup from "yup";
@@ -37,9 +38,10 @@ import {
import { useOrganization, useWorkspace } from "@app/context";
import { usePopUp, useToggle } from "@app/hooks";
import {
- useCreateServiceAccount,
- useDeleteServiceAccount,
- useGetServiceAccounts} from "@app/hooks/api";
+ useCreateServiceAccount,
+ useDeleteServiceAccount,
+ useGetServiceAccounts
+} from "@app/hooks/api";
const serviceAccountExpiration = [
{ label: "1 Day", value: 86400 },
@@ -51,317 +53,315 @@ const serviceAccountExpiration = [
];
const addServiceAccountFormSchema = yup.object({
- name: yup.string().required().label("Name").trim(),
- expiresIn: yup.string().required().label("Service Account Expiration")
+ name: yup.string().required().label("Name").trim(),
+ expiresIn: yup.string().required().label("Service Account Expiration")
});
type TAddServiceAccountForm = yup.InferType<typeof addServiceAccountFormSchema>;
export const OrgServiceAccountsTable = () => {
- const router = useRouter();
- const { currentOrg } = useOrganization();
- const { currentWorkspace } = useWorkspace();
-
- const orgId = currentOrg?._id || "";
- const [step, setStep] = useState(0);
- const [isAccessKeyCopied, setIsAccessKeyCopied] = useToggle(false);
- const [isPublicKeyCopied, setIsPublicKeyCopied] = useToggle(false);
- const [isPrivateKeyCopied, setIsPrivateKeyCopied] = useToggle(false);
- const [accessKey, setAccessKey] = useState("");
- const [publicKey, setPublicKey] = useState("");
- const [privateKey, setPrivateKey] = useState("");
- const [searchServiceAccountFilter, setSearchServiceAccountFilter] = useState("");
- const { handlePopUpToggle, popUp, handlePopUpOpen, handlePopUpClose } = usePopUp([
- "addServiceAccount",
- "removeServiceAccount",
- ] as const);
-
- const { data: serviceAccounts = [], isLoading: isServiceAccountsLoading } = useGetServiceAccounts(orgId);
-
- const createServiceAccount = useCreateServiceAccount();
- const removeServiceAccount = useDeleteServiceAccount();
-
- useEffect(() => {
- let timer: NodeJS.Timeout;
- if (isAccessKeyCopied) {
- timer = setTimeout(() => setIsAccessKeyCopied.off(), 2000);
- }
+ const router = useRouter();
+ const { currentOrg } = useOrganization();
+ const { currentWorkspace } = useWorkspace();
- if (isPublicKeyCopied) {
- timer = setTimeout(() => setIsPublicKeyCopied.off(), 2000);
- }
+ const orgId = currentOrg?._id || "";
+ const [step, setStep] = useState(0);
+ const [isAccessKeyCopied, setIsAccessKeyCopied] = useToggle(false);
+ const [isPublicKeyCopied, setIsPublicKeyCopied] = useToggle(false);
+ const [isPrivateKeyCopied, setIsPrivateKeyCopied] = useToggle(false);
+ const [accessKey, setAccessKey] = useState("");
+ const [publicKey, setPublicKey] = useState("");
+ const [privateKey, setPrivateKey] = useState("");
+ const [searchServiceAccountFilter, setSearchServiceAccountFilter] = useState("");
+ const { handlePopUpToggle, popUp, handlePopUpOpen, handlePopUpClose } = usePopUp([
+ "addServiceAccount",
+ "removeServiceAccount"
+ ] as const);
- if (isPrivateKeyCopied) {
- timer = setTimeout(() => setIsPrivateKeyCopied.off(), 2000);
- }
+ const { data: serviceAccounts = [], isLoading: isServiceAccountsLoading } =
+ useGetServiceAccounts(orgId);
- return () => clearTimeout(timer);
- }, [isAccessKeyCopied, isPublicKeyCopied, isPrivateKeyCopied]);
+ const createServiceAccount = useCreateServiceAccount();
+ const removeServiceAccount = useDeleteServiceAccount();
- const {
- control,
- handleSubmit,
- reset,
- formState: { isSubmitting }
- } = useForm<TAddServiceAccountForm>({ resolver: yupResolver(addServiceAccountFormSchema) });
-
- const onAddServiceAccount = async ({ name, expiresIn }: TAddServiceAccountForm) => {
- if (!currentOrg?._id) return;
-
- const keyPair = generateKeyPair();
- setPublicKey(keyPair.publicKey);
- setPrivateKey(keyPair.privateKey);
-
- const serviceAccountDetails = await createServiceAccount.mutateAsync({
- name,
- organizationId: currentOrg?._id,
- publicKey: keyPair.publicKey,
- expiresIn: Number(expiresIn)
- });
-
- setAccessKey(serviceAccountDetails.serviceAccountAccessKey);
+ useEffect(() => {
+ let timer: NodeJS.Timeout;
+ if (isAccessKeyCopied) {
+ timer = setTimeout(() => setIsAccessKeyCopied.off(), 2000);
+ }
- setStep(1);
- reset();
+ if (isPublicKeyCopied) {
+ timer = setTimeout(() => setIsPublicKeyCopied.off(), 2000);
}
-
- const onRemoveServiceAccount = async () => {
- const serviceAccountId = (popUp?.removeServiceAccount?.data as { _id: string })?._id;
- await removeServiceAccount.mutateAsync(serviceAccountId);
- handlePopUpClose("removeServiceAccount");
+
+ if (isPrivateKeyCopied) {
+ timer = setTimeout(() => setIsPrivateKeyCopied.off(), 2000);
}
-
- const filteredServiceAccounts = useMemo(
- () =>
- serviceAccounts.filter(
- ({ name }) =>
- name.toLowerCase().includes(searchServiceAccountFilter)
- ),
- [serviceAccounts, searchServiceAccountFilter]
- );
-
- const renderStep = (stepToRender: number) => {
- switch (stepToRender) {
- case 0:
- return (
- <form onSubmit={handleSubmit(onAddServiceAccount)}>
- <Controller
- control={control}
- defaultValue=""
- name="name"
- render={({ field, fieldState: { error } }) => (
- <FormControl label="Name" isError={Boolean(error)} errorText={error?.message}>
- <Input {...field} />
- </FormControl>
- )}
- />
- <Controller
- control={control}
- name="expiresIn"
- defaultValue={String(serviceAccountExpiration?.[0]?.value)}
- render={({ field: { onChange, ...field }, fieldState: { error } }) => {
- return (
- <FormControl
- label="Expiration"
- errorText={error?.message}
- isError={Boolean(error)}
- >
- <Select
- defaultValue={field.value}
- {...field}
- onValueChange={(e) => onChange(e)}
- className="w-full"
- >
- {serviceAccountExpiration.map(({ label, value }) => (
- <SelectItem value={String(value)} key={label}>
- {label}
- </SelectItem>
- ))}
- </Select>
- </FormControl>
- );
- }}
- />
- <div className="mt-8 flex items-center">
- <Button
- className="mr-4"
- size="sm"
- type="submit"
- isLoading={isSubmitting}
- isDisabled={isSubmitting}
- >
- Create Service Account
- </Button>
- <Button
- colorSchema="secondary"
- variant="plain"
- onClick={() => handlePopUpClose("addServiceAccount")}
- >
- Cancel
- </Button>
- </div>
- </form>
- );
- case 1:
+
+ return () => clearTimeout(timer);
+ }, [isAccessKeyCopied, isPublicKeyCopied, isPrivateKeyCopied]);
+
+ const {
+ control,
+ handleSubmit,
+ reset,
+ formState: { isSubmitting }
+ } = useForm<TAddServiceAccountForm>({ resolver: yupResolver(addServiceAccountFormSchema) });
+
+ const onAddServiceAccount = async ({ name, expiresIn }: TAddServiceAccountForm) => {
+ if (!currentOrg?._id) return;
+
+ const keyPair = generateKeyPair();
+ setPublicKey(keyPair.publicKey);
+ setPrivateKey(keyPair.privateKey);
+
+ const serviceAccountDetails = await createServiceAccount.mutateAsync({
+ name,
+ organizationId: currentOrg?._id,
+ publicKey: keyPair.publicKey,
+ expiresIn: Number(expiresIn)
+ });
+
+ setAccessKey(serviceAccountDetails.serviceAccountAccessKey);
+
+ setStep(1);
+ reset();
+ };
+
+ const onRemoveServiceAccount = async () => {
+ const serviceAccountId = (popUp?.removeServiceAccount?.data as { _id: string })?._id;
+ await removeServiceAccount.mutateAsync(serviceAccountId);
+ handlePopUpClose("removeServiceAccount");
+ };
+
+ const filteredServiceAccounts = useMemo(
+ () =>
+ serviceAccounts.filter(({ name }) => name.toLowerCase().includes(searchServiceAccountFilter)),
+ [serviceAccounts, searchServiceAccountFilter]
+ );
+
+ const renderStep = (stepToRender: number) => {
+ switch (stepToRender) {
+ case 0:
+ return (
+ <form onSubmit={handleSubmit(onAddServiceAccount)}>
+ <Controller
+ control={control}
+ defaultValue=""
+ name="name"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl label="Name" isError={Boolean(error)} errorText={error?.message}>
+ <Input {...field} />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="expiresIn"
+ defaultValue={String(serviceAccountExpiration?.[0]?.value)}
+ render={({ field: { onChange, ...field }, fieldState: { error } }) => {
return (
- <>
- <p>Access Key</p>
- <div className="flex items-center justify-end rounded-md p-2 text-base text-gray-400 bg-white/[0.07]">
- <p className="mr-4 break-all">{accessKey}</p>
- <IconButton
- ariaLabel="copy icon"
- colorSchema="secondary"
- className="group relative"
- onClick={() => {
- navigator.clipboard.writeText(accessKey);
- setIsAccessKeyCopied.on();
- }}
- >
- <FontAwesomeIcon icon={isAccessKeyCopied ? faCheck : faCopy} />
- <span className="absolute -left-8 -top-20 hidden w-28 translate-y-full rounded-md bg-bunker-800 py-2 pl-3 text-center text-sm text-gray-400 group-hover:flex group-hover:animate-fadeIn">
- Copy
- </span>
- </IconButton>
- </div>
- <p className="mt-4">Public Key</p>
- <div className="flex items-center justify-end rounded-md p-2 text-base text-gray-400 bg-white/[0.07]">
- <p className="mr-4 break-all">{publicKey}</p>
- <IconButton
- ariaLabel="copy icon"
- colorSchema="secondary"
- className="group relative"
- onClick={() => {
- navigator.clipboard.writeText(publicKey);
- setIsPublicKeyCopied.on();
- }}
- >
- <FontAwesomeIcon icon={isPublicKeyCopied ? faCheck : faCopy} />
- <span className="absolute -left-8 -top-20 hidden w-28 translate-y-full rounded-md bg-bunker-800 py-2 pl-3 text-center text-sm text-gray-400 group-hover:flex group-hover:animate-fadeIn">
- Copy
- </span>
- </IconButton>
- </div>
- <p className="mt-4">Private Key</p>
- <div className="flex items-center justify-end rounded-md p-2 text-base text-gray-400 bg-white/[0.07]">
- <p className="mr-4 break-all">{privateKey}</p>
- <IconButton
- ariaLabel="copy icon"
- colorSchema="secondary"
- className="group relative"
- onClick={() => {
- navigator.clipboard.writeText(privateKey);
- setIsPrivateKeyCopied.on();
- }}
- >
- <FontAwesomeIcon icon={isPrivateKeyCopied ? faCheck : faCopy} />
- <span className="absolute -left-8 -top-20 hidden w-28 translate-y-full rounded-md bg-bunker-800 py-2 pl-3 text-center text-sm text-gray-400 group-hover:flex group-hover:animate-fadeIn">
- Copy
- </span>
- </IconButton>
- </div>
-
- </>
+ <FormControl
+ label="Expiration"
+ errorText={error?.message}
+ isError={Boolean(error)}
+ >
+ <Select
+ defaultValue={field.value}
+ {...field}
+ onValueChange={(e) => onChange(e)}
+ className="w-full"
+ >
+ {serviceAccountExpiration.map(({ label, value }) => (
+ <SelectItem value={String(value)} key={label}>
+ {label}
+ </SelectItem>
+ ))}
+ </Select>
+ </FormControl>
);
- default:
- return <div />
- }
- }
-
- return (
- <div className="w-full">
- <div className="mb-4 flex">
- <div className="mr-4 flex-1">
- <Input
- value={searchServiceAccountFilter}
- onChange={(e) => setSearchServiceAccountFilter(e.target.value)}
- leftIcon={<FontAwesomeIcon icon={faMagnifyingGlass} />}
- placeholder="Search service accounts..."
- />
- </div>
- <Button
- leftIcon={<FontAwesomeIcon icon={faPlus} />}
- onClick={() => {
- setStep(0);
- reset();
- handlePopUpOpen("addServiceAccount");
- }}
- >
- Add Service Account
- </Button>
+ }}
+ />
+ <div className="mt-8 flex items-center">
+ <Button
+ className="mr-4"
+ size="sm"
+ type="submit"
+ isLoading={isSubmitting}
+ isDisabled={isSubmitting}
+ >
+ Create Service Account
+ </Button>
+ <Button
+ colorSchema="secondary"
+ variant="plain"
+ onClick={() => handlePopUpClose("addServiceAccount")}
+ >
+ Cancel
+ </Button>
</div>
- <TableContainer>
- <Table>
- <THead>
- <Th>Name</Th>
- <Th className="w-full">Valid Until</Th>
- <Th aria-label="actions" />
- </THead>
- <TBody>
- {isServiceAccountsLoading && <TableSkeleton columns={5} key="org-service-accounts" />}
- {!isServiceAccountsLoading && (
- filteredServiceAccounts.map(({
- name,
- expiresAt,
- _id: serviceAccountId
- }) => {
- return (
- <Tr key={`org-service-account-${serviceAccountId}`}>
- <Td>{name}</Td>
- <Td>{new Date(expiresAt).toUTCString()}</Td>
- <Td>
- <div className="flex">
- <IconButton
- ariaLabel="edit"
- colorSchema="secondary"
- onClick={() => {
- if (currentWorkspace?._id) {
- router.push(`/settings/org/${currentWorkspace._id}/service-accounts/${serviceAccountId}`);
- }
- }}
- className="mr-2"
- >
- <FontAwesomeIcon icon={faPencil} />
- </IconButton>
- <IconButton
- ariaLabel="delete"
- colorSchema="danger"
- onClick={() => handlePopUpOpen("removeServiceAccount", { _id: serviceAccountId })}
- >
- <FontAwesomeIcon icon={faTrash} />
- </IconButton>
- </div>
- </Td>
- </Tr>
- );
- })
- )}
- </TBody>
- </Table>
- {!isServiceAccountsLoading && filteredServiceAccounts?.length === 0 && (
- <EmptyState title="No service accounts found" icon={faServer} />
- )}
- </TableContainer>
- <Modal
- isOpen={popUp?.addServiceAccount?.isOpen}
- onOpenChange={(isOpen) => {
- handlePopUpToggle("addServiceAccount", isOpen);
- reset();
+ </form>
+ );
+ case 1:
+ return (
+ <>
+ <p>Access Key</p>
+ <div className="flex items-center justify-end rounded-md bg-white/[0.07] p-2 text-base text-gray-400">
+ <p className="mr-4 break-all">{accessKey}</p>
+ <IconButton
+ ariaLabel="copy icon"
+ colorSchema="secondary"
+ className="group relative"
+ onClick={() => {
+ navigator.clipboard.writeText(accessKey);
+ setIsAccessKeyCopied.on();
}}
- >
- <ModalContent
- title="Add Service Account"
- subTitle="A service account represents a machine identity such as a VM or application client."
- >
- {renderStep(step)}
- </ModalContent>
- </Modal>
- <DeleteActionModal
- isOpen={popUp.removeServiceAccount.isOpen}
- deleteKey="remove"
- title="Do you want to remove this service account from the org?"
- onChange={(isOpen) => handlePopUpToggle("removeServiceAccount", isOpen)}
- onDeleteApproved={onRemoveServiceAccount}
- />
+ >
+ <FontAwesomeIcon icon={isAccessKeyCopied ? faCheck : faCopy} />
+ <span className="absolute -left-8 -top-20 hidden w-28 translate-y-full rounded-md bg-bunker-800 py-2 pl-3 text-center text-sm text-gray-400 group-hover:flex group-hover:animate-fadeIn">
+ Copy
+ </span>
+ </IconButton>
+ </div>
+ <p className="mt-4">Public Key</p>
+ <div className="flex items-center justify-end rounded-md bg-white/[0.07] p-2 text-base text-gray-400">
+ <p className="mr-4 break-all">{publicKey}</p>
+ <IconButton
+ ariaLabel="copy icon"
+ colorSchema="secondary"
+ className="group relative"
+ onClick={() => {
+ navigator.clipboard.writeText(publicKey);
+ setIsPublicKeyCopied.on();
+ }}
+ >
+ <FontAwesomeIcon icon={isPublicKeyCopied ? faCheck : faCopy} />
+ <span className="absolute -left-8 -top-20 hidden w-28 translate-y-full rounded-md bg-bunker-800 py-2 pl-3 text-center text-sm text-gray-400 group-hover:flex group-hover:animate-fadeIn">
+ Copy
+ </span>
+ </IconButton>
+ </div>
+ <p className="mt-4">Private Key</p>
+ <div className="flex items-center justify-end rounded-md bg-white/[0.07] p-2 text-base text-gray-400">
+ <p className="mr-4 break-all">{privateKey}</p>
+ <IconButton
+ ariaLabel="copy icon"
+ colorSchema="secondary"
+ className="group relative"
+ onClick={() => {
+ navigator.clipboard.writeText(privateKey);
+ setIsPrivateKeyCopied.on();
+ }}
+ >
+ <FontAwesomeIcon icon={isPrivateKeyCopied ? faCheck : faCopy} />
+ <span className="absolute -left-8 -top-20 hidden w-28 translate-y-full rounded-md bg-bunker-800 py-2 pl-3 text-center text-sm text-gray-400 group-hover:flex group-hover:animate-fadeIn">
+ Copy
+ </span>
+ </IconButton>
+ </div>
+ </>
+ );
+ default:
+ return <div />;
+ }
+ };
+
+ return (
+ <div className="w-full">
+ <div className="mb-4 flex">
+ <div className="mr-4 flex-1">
+ <Input
+ value={searchServiceAccountFilter}
+ onChange={(e) => setSearchServiceAccountFilter(e.target.value)}
+ leftIcon={<FontAwesomeIcon icon={faMagnifyingGlass} />}
+ placeholder="Search service accounts..."
+ />
</div>
- );
-}
\ No newline at end of file
+ <Button
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ onClick={() => {
+ setStep(0);
+ reset();
+ handlePopUpOpen("addServiceAccount");
+ }}
+ >
+ Add Service Account
+ </Button>
+ </div>
+ <TableContainer>
+ <Table>
+ <THead>
+ <Th>Name</Th>
+ <Th className="w-full">Valid Until</Th>
+ <Th aria-label="actions" />
+ </THead>
+ <TBody>
+ {isServiceAccountsLoading && (
+ <TableSkeleton columns={5} innerKey="org-service-accounts" />
+ )}
+ {!isServiceAccountsLoading &&
+ filteredServiceAccounts.map(({ name, expiresAt, _id: serviceAccountId }) => {
+ return (
+ <Tr key={`org-service-account-${serviceAccountId}`}>
+ <Td>{name}</Td>
+ <Td>{new Date(expiresAt).toUTCString()}</Td>
+ <Td>
+ <div className="flex">
+ <IconButton
+ ariaLabel="edit"
+ colorSchema="secondary"
+ onClick={() => {
+ if (currentWorkspace?._id) {
+ router.push(
+ `/settings/org/${currentWorkspace._id}/service-accounts/${serviceAccountId}`
+ );
+ }
+ }}
+ className="mr-2"
+ >
+ <FontAwesomeIcon icon={faPencil} />
+ </IconButton>
+ <IconButton
+ ariaLabel="delete"
+ colorSchema="danger"
+ onClick={() =>
+ handlePopUpOpen("removeServiceAccount", { _id: serviceAccountId })
+ }
+ >
+ <FontAwesomeIcon icon={faTrash} />
+ </IconButton>
+ </div>
+ </Td>
+ </Tr>
+ );
+ })}
+ </TBody>
+ </Table>
+ {!isServiceAccountsLoading && filteredServiceAccounts?.length === 0 && (
+ <EmptyState title="No service accounts found" icon={faServer} />
+ )}
+ </TableContainer>
+ <Modal
+ isOpen={popUp?.addServiceAccount?.isOpen}
+ onOpenChange={(isOpen) => {
+ handlePopUpToggle("addServiceAccount", isOpen);
+ reset();
+ }}
+ >
+ <ModalContent
+ title="Add Service Account"
+ subTitle="A service account represents a machine identity such as a VM or application client."
+ >
+ {renderStep(step)}
+ </ModalContent>
+ </Modal>
+ <DeleteActionModal
+ isOpen={popUp.removeServiceAccount.isOpen}
+ deleteKey="remove"
+ title="Do you want to remove this service account from the org?"
+ onChange={(isOpen) => handlePopUpToggle("removeServiceAccount", isOpen)}
+ onDeleteApproved={onRemoveServiceAccount}
+ />
+ </div>
+ );
+};
diff --git a/frontend/src/views/SecretScanning/components/SecretScanningLogsTable.tsx b/frontend/src/views/SecretScanning/components/SecretScanningLogsTable.tsx
index b3b0cf03ff..28f0313b26 100644
--- a/frontend/src/views/SecretScanning/components/SecretScanningLogsTable.tsx
+++ b/frontend/src/views/SecretScanning/components/SecretScanningLogsTable.tsx
@@ -10,90 +10,94 @@ import {
Td,
Th,
THead,
- Tr} from "@app/components/v2";
+ Tr
+} from "@app/components/v2";
import timeSince from "@app/ee/utilities/timeSince";
-import getRisksByOrganization, { GitRisks } from "@app/pages/api/secret-scanning/getRisksByOrganization";
+import getRisksByOrganization, {
+ GitRisks
+} from "@app/pages/api/secret-scanning/getRisksByOrganization";
import { RiskStatusSelection } from "./RiskStatusSelection";
export const SecretScanningLogsTable = () => {
- const [isLoading, setIsLoading] = useState(false);
- const [gitRisks, setGitRisks] = useState<GitRisks[]>([]);
+ const [isLoading, setIsLoading] = useState(false);
+ const [gitRisks, setGitRisks] = useState<GitRisks[]>([]);
- useEffect(() => {
- const fetchRisks = async () => {
- setIsLoading(true);
- const risks = await getRisksByOrganization(String(localStorage.getItem("orgData.id")))
- setGitRisks(risks);
- setIsLoading(false);
- }
+ useEffect(() => {
+ const fetchRisks = async () => {
+ setIsLoading(true);
+ const risks = await getRisksByOrganization(String(localStorage.getItem("orgData.id")));
+ setGitRisks(risks);
+ setIsLoading(false);
+ };
- fetchRisks();
- },[])
+ fetchRisks();
+ }, []);
-
- return (
- <TableContainer className="mt-8">
- <Table>
- <THead>
- <Tr>
- <Th className="flex-1">Date</Th>
- <Th className="flex-1">Secret Type</Th>
- <Th className="flex-1">View Risk</Th>
- <Th className="flex-1">Info</Th>
- <Th className="flex-1">Status</Th>
- <Th className="flex-1">Action</Th>
- <Th className="w-5" />
+ return (
+ <TableContainer className="mt-8">
+ <Table>
+ <THead>
+ <Tr>
+ <Th className="flex-1">Date</Th>
+ <Th className="flex-1">Secret Type</Th>
+ <Th className="flex-1">View Risk</Th>
+ <Th className="flex-1">Info</Th>
+ <Th className="flex-1">Status</Th>
+ <Th className="flex-1">Action</Th>
+ <Th className="w-5" />
+ </Tr>
+ </THead>
+ <TBody>
+ {!isLoading &&
+ gitRisks &&
+ gitRisks?.map((risk) => {
+ return (
+ <Tr key={risk.ruleID} className="h-10">
+ <Td>{timeSince(new Date(risk.createdAt))}</Td>
+ <Td>{risk.ruleID}</Td>
+ <Td>
+ <a
+ href={`https://github.com/${risk.repositoryFullName}/blob/${risk.commit}/${risk.file}#L${risk.startLine}-L${risk.endLine}`}
+ target="_blank"
+ className="text-red-500"
+ rel="noreferrer"
+ >
+ View Exposed Secret
+ </a>
+ </Td>
+ <Td>
+ <div className="font-bold">
+ <a href={`https://github.com/${risk.repositoryFullName}`}>
+ {risk.repositoryFullName}
+ </a>
+ </div>
+ <div className="text-xs">
+ <span>{risk.file}</span>
+ <br />
+ <br />
+ <span className="font-bold">{risk.author}</span>
+ <br />
+ <span>{risk.email}</span>
+ </div>
+ </Td>
+ <Td>{risk.isResolved ? "Resolved" : "Needs Attention"}</Td>
+ <Td>
+ <RiskStatusSelection riskId={risk._id} currentSelection={risk.status} />
+ </Td>
</Tr>
- </THead>
- <TBody>
- {!isLoading && gitRisks && gitRisks?.map((risk) => {
- return (
- <Tr key={risk.ruleID} className="h-10">
- <Td>{timeSince(new Date(risk.createdAt))}</Td>
- <Td>{risk.ruleID}</Td>
- <Td>
- <a
- href={`https://github.com/${risk.repositoryFullName}/blob/${risk.commit}/${risk.file}#L${risk.startLine}-L${risk.endLine}`}
- target="_blank"
- className="text-red-500" rel="noreferrer"
- >
- View Exposed Secret
- </a>
- </Td>
- <Td>
- <div className="font-bold">
- <a href={`https://github.com/${risk.repositoryFullName}`}>
- {risk.repositoryFullName}
- </a>
- </div>
- <div className="text-xs">
- <span>{risk.file}</span><br/>
- <br/>
- <span className="font-bold">{risk.author}</span><br/>
- <span>{risk.email}</span>
- </div>
- </Td>
- <Td>{risk.isResolved ? "Resolved" : "Needs Attention"}</Td>
- <Td>
- <RiskStatusSelection riskId={risk._id} currentSelection={risk.status}/>
- </Td>
- </Tr>
- );
- })}
- {isLoading && <TableSkeleton columns={7} key="gitRisks" />}
- {!isLoading && gitRisks && gitRisks?.length === 0 && (
- <Tr>
- <Td colSpan={7}>
- <EmptyState
- title="No risks detected."
- icon={faCheck}
- />
- </Td>
- </Tr>
- )}
- </TBody>
- </Table>
- </TableContainer>
- );
-}
\ No newline at end of file
+ );
+ })}
+ {isLoading && <TableSkeleton columns={7} innerKey="gitRisks" />}
+ {!isLoading && gitRisks && gitRisks?.length === 0 && (
+ <Tr>
+ <Td colSpan={7}>
+ <EmptyState title="No risks detected." icon={faCheck} />
+ </Td>
+ </Tr>
+ )}
+ </TBody>
+ </Table>
+ </TableContainer>
+ );
+};
diff --git a/frontend/src/views/Settings/BillingSettingsPage/components/BillingCloudTab/CurrentPlanSection.tsx b/frontend/src/views/Settings/BillingSettingsPage/components/BillingCloudTab/CurrentPlanSection.tsx
index 3caad28c50..e90d6ca8bc 100644
--- a/frontend/src/views/Settings/BillingSettingsPage/components/BillingCloudTab/CurrentPlanSection.tsx
+++ b/frontend/src/views/Settings/BillingSettingsPage/components/BillingCloudTab/CurrentPlanSection.tsx
@@ -1,4 +1,4 @@
-import { faCircleCheck, faCircleXmark,faFileInvoice } from "@fortawesome/free-solid-svg-icons";
+import { faCircleCheck, faCircleXmark, faFileInvoice } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import {
@@ -10,78 +10,63 @@ import {
Td,
Th,
THead,
- Tr} from "@app/components/v2";
+ Tr
+} from "@app/components/v2";
import { useOrganization } from "@app/context";
-import {
- useGetOrgPlanTable
-} from "@app/hooks/api";
+import { useGetOrgPlanTable } from "@app/hooks/api";
export const CurrentPlanSection = () => {
- const { currentOrg } = useOrganization();
- const { data, isLoading } = useGetOrgPlanTable(currentOrg?._id ?? "");
-
- const displayCell = (value: null | number | string | boolean) => {
- if (value === null) return "-";
-
- if (typeof value === "boolean") {
- if (value) return (
- <FontAwesomeIcon
- icon={faCircleCheck}
- color='#2ecc71'
- />
- );
+ const { currentOrg } = useOrganization();
+ const { data, isLoading } = useGetOrgPlanTable(currentOrg?._id ?? "");
- return (
- <FontAwesomeIcon
- icon={faCircleXmark}
- color='#e74c3c'
- />
- );
- }
-
- return value;
+ const displayCell = (value: null | number | string | boolean) => {
+ if (value === null) return "-";
+
+ if (typeof value === "boolean") {
+ if (value) return <FontAwesomeIcon icon={faCircleCheck} color="#2ecc71" />;
+
+ return <FontAwesomeIcon icon={faCircleXmark} color="#e74c3c" />;
}
- return (
- <div className="p-4 bg-mineshaft-900 mb-6 rounded-lg border border-mineshaft-600">
- <h2 className="text-xl font-semibold flex-1 text-white mb-8">Current Usage</h2>
- <TableContainer className="mt-4">
- <Table>
- <THead>
- <Tr>
- <Th className="w-1/3">Feature</Th>
- <Th className="w-1/3">Allowed</Th>
- <Th className="w-1/3">Used</Th>
- </Tr>
- </THead>
- <TBody>
- {!isLoading && data && data?.rows?.length > 0 && data.rows.map(({
- name,
- allowed,
- used
- }) => {
- return (
- <Tr key={`current-plan-row-${name}`} className="h-12">
- <Td>{name}</Td>
- <Td>{displayCell(allowed)}</Td>
- <Td>{used}</Td>
- </Tr>
- );
- })}
- {isLoading && <TableSkeleton columns={5} key="invoices" />}
- {!isLoading && data && data?.rows?.length === 0 && (
- <Tr>
- <Td colSpan={3}>
- <EmptyState
- title="No plan details found"
- icon={faFileInvoice}
- />
- </Td>
- </Tr>
- )}
- </TBody>
- </Table>
- </TableContainer>
- </div>
- );
-}
\ No newline at end of file
+ return value;
+ };
+
+ return (
+ <div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
+ <h2 className="mb-8 flex-1 text-xl font-semibold text-white">Current Usage</h2>
+ <TableContainer className="mt-4">
+ <Table>
+ <THead>
+ <Tr>
+ <Th className="w-1/3">Feature</Th>
+ <Th className="w-1/3">Allowed</Th>
+ <Th className="w-1/3">Used</Th>
+ </Tr>
+ </THead>
+ <TBody>
+ {!isLoading &&
+ data &&
+ data?.rows?.length > 0 &&
+ data.rows.map(({ name, allowed, used }) => {
+ return (
+ <Tr key={`current-plan-row-${name}`} className="h-12">
+ <Td>{name}</Td>
+ <Td>{displayCell(allowed)}</Td>
+ <Td>{used}</Td>
+ </Tr>
+ );
+ })}
+ {isLoading && <TableSkeleton columns={5} innerKey="invoices" />}
+ {!isLoading && data && data?.rows?.length === 0 && (
+ <Tr>
+ <Td colSpan={3}>
+ <EmptyState title="No plan details found" icon={faFileInvoice} />
+ </Td>
+ </Tr>
+ )}
+ </TBody>
+ </Table>
+ </TableContainer>
+ </div>
+ );
+};
diff --git a/frontend/src/views/Settings/BillingSettingsPage/components/BillingCloudTab/ManagePlansTable.tsx b/frontend/src/views/Settings/BillingSettingsPage/components/BillingCloudTab/ManagePlansTable.tsx
index ffdcbc9946..f057f7ff0b 100644
--- a/frontend/src/views/Settings/BillingSettingsPage/components/BillingCloudTab/ManagePlansTable.tsx
+++ b/frontend/src/views/Settings/BillingSettingsPage/components/BillingCloudTab/ManagePlansTable.tsx
@@ -1,4 +1,4 @@
-import { faCircleCheck, faCircleXmark,faFileInvoice } from "@fortawesome/free-solid-svg-icons";
+import { faCircleCheck, faCircleXmark, faFileInvoice } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import {
@@ -11,166 +11,129 @@ import {
Td,
Th,
THead,
- Tr,
+ Tr
} from "@app/components/v2";
-import { useOrganization,useSubscription } from "@app/context";
-import {
- useCreateCustomerPortalSession,
- useGetOrgPlansTable} from "@app/hooks/api";
+import { useOrganization, useSubscription } from "@app/context";
+import { useCreateCustomerPortalSession, useGetOrgPlansTable } from "@app/hooks/api";
type Props = {
- billingCycle: "monthly" | "yearly"
-}
+ billingCycle: "monthly" | "yearly";
+};
-export const ManagePlansTable = ({
+export const ManagePlansTable = ({ billingCycle }: Props) => {
+ const { currentOrg } = useOrganization();
+ const { subscription } = useSubscription();
+ const { data: tableData, isLoading: isTableDataLoading } = useGetOrgPlansTable({
+ organizationId: currentOrg?._id ?? "",
billingCycle
-}: Props) => {
- const { currentOrg } = useOrganization();
- const { subscription } = useSubscription();
- const { data: tableData, isLoading: isTableDataLoading } = useGetOrgPlansTable({
- organizationId: currentOrg?._id ?? "",
- billingCycle
- });
- const createCustomerPortalSession = useCreateCustomerPortalSession();
+ });
+ const createCustomerPortalSession = useCreateCustomerPortalSession();
- const displayCell = (value: null | number | string | boolean) => {
- if (value === null) return "Unlimited";
-
- if (typeof value === "boolean") {
- if (value) return (
- <FontAwesomeIcon
- icon={faCircleCheck}
- color='#2ecc71'
- />
- );
+ const displayCell = (value: null | number | string | boolean) => {
+ if (value === null) return "Unlimited";
- return (
- <FontAwesomeIcon
- icon={faCircleXmark}
- color='#e74c3c'
- />
- );
- }
-
- return value;
+ if (typeof value === "boolean") {
+ if (value) return <FontAwesomeIcon icon={faCircleCheck} color="#2ecc71" />;
+
+ return <FontAwesomeIcon icon={faCircleXmark} color="#e74c3c" />;
}
- return (
- <TableContainer>
- <Table>
- <THead>
- {subscription && !isTableDataLoading && tableData && (
- <Tr>
- <Th className="">Feature / Limit</Th>
- {tableData.head.map(({
- name,
- priceLine
- }) => {
- return (
- <Th
- key={`plans-feature-head-${billingCycle}-${name}`}
- className="text-center flex-1"
- >
- <p>{name}</p>
- <p>{priceLine}</p>
- </Th>
- );
- })}
- </Tr>
- )}
- </THead>
- <TBody>
- {subscription && !isTableDataLoading && tableData && tableData.rows.map(({
- name,
- starter,
- team,
- pro,
- enterprise
- }) => {
- return (
- <Tr className="h-12" key={`plans-feature-row-${billingCycle}-${name}`}>
- <Td>{displayCell(name)}</Td>
- <Td className="text-center">
- {displayCell(starter)}
- </Td>
- <Td className="text-center">
- {displayCell(team)}
- </Td>
- <Td className="text-center">
- {displayCell(pro)}
- </Td>
- <Td className="text-center">
- {displayCell(enterprise)}
- </Td>
- </Tr>
- );
- })}
- {isTableDataLoading && <TableSkeleton columns={5} key="cloud-products" />}
- {!isTableDataLoading && tableData?.rows.length === 0 && (
- <Tr>
- <Td colSpan={5}>
- <EmptyState
- title="No cloud product details found"
- icon={faFileInvoice}
- />
- </Td>
- </Tr>
- )}
- {subscription && !isTableDataLoading && tableData && (
- <Tr className="h-12">
- <Td />
- {tableData.head.map(({
- slug,
- tier
- }) => {
-
- const isCurrentPlan = slug === subscription.slug;
- let subscriptionText = "Upgrade";
-
- if (subscription.tier > tier) {
- subscriptionText = "Downgrade"
- }
-
- if (tier === 3) {
- subscriptionText = "Contact sales"
- }
+ return value;
+ };
+
+ return (
+ <TableContainer>
+ <Table>
+ <THead>
+ {subscription && !isTableDataLoading && tableData && (
+ <Tr>
+ <Th className="">Feature / Limit</Th>
+ {tableData.head.map(({ name, priceLine }) => {
+ return (
+ <Th
+ key={`plans-feature-head-${billingCycle}-${name}`}
+ className="flex-1 text-center"
+ >
+ <p>{name}</p>
+ <p>{priceLine}</p>
+ </Th>
+ );
+ })}
+ </Tr>
+ )}
+ </THead>
+ <TBody>
+ {subscription &&
+ !isTableDataLoading &&
+ tableData &&
+ tableData.rows.map(({ name, starter, team, pro, enterprise }) => {
+ return (
+ <Tr className="h-12" key={`plans-feature-row-${billingCycle}-${name}`}>
+ <Td>{displayCell(name)}</Td>
+ <Td className="text-center">{displayCell(starter)}</Td>
+ <Td className="text-center">{displayCell(team)}</Td>
+ <Td className="text-center">{displayCell(pro)}</Td>
+ <Td className="text-center">{displayCell(enterprise)}</Td>
+ </Tr>
+ );
+ })}
+ {isTableDataLoading && <TableSkeleton columns={5} innerKey="cloud-products" />}
+ {!isTableDataLoading && tableData?.rows.length === 0 && (
+ <Tr>
+ <Td colSpan={5}>
+ <EmptyState title="No cloud product details found" icon={faFileInvoice} />
+ </Td>
+ </Tr>
+ )}
+ {subscription && !isTableDataLoading && tableData && (
+ <Tr className="h-12">
+ <Td />
+ {tableData.head.map(({ slug, tier }) => {
+ const isCurrentPlan = slug === subscription.slug;
+ let subscriptionText = "Upgrade";
+
+ if (subscription.tier > tier) {
+ subscriptionText = "Downgrade";
+ }
+
+ if (tier === 3) {
+ subscriptionText = "Contact sales";
+ }
+
+ return isCurrentPlan ? (
+ <Td>
+ <Button colorSchema="secondary" className="w-full" isDisabled>
+ Current
+ </Button>
+ </Td>
+ ) : (
+ <Td>
+ <Button
+ onClick={async () => {
+ if (!currentOrg?._id) return;
+
+ if (tier !== 3) {
+ const { url } = await createCustomerPortalSession.mutateAsync(
+ currentOrg._id
+ );
+ window.location.href = url;
+ return;
+ }
- return isCurrentPlan ? (
- <Td>
- <Button
- colorSchema="secondary"
- className="w-full"
- isDisabled
- >
- Current
- </Button>
- </Td>
- ) : (
- <Td>
- <Button
- onClick={async () => {
- if (!currentOrg?._id) return;
-
- if (tier !== 3) {
- const { url } = await createCustomerPortalSession.mutateAsync(currentOrg._id);
- window.location.href = url;
- return;
- }
-
- window.location.href = "https://infisical.com/scheduledemo";
- }}
- color="mineshaft"
- className="w-full"
- >
- {subscriptionText}
- </Button>
- </Td>
- );
- })}
- </Tr>
- )}
- </TBody>
- </Table>
- </TableContainer>
- );
-}
\ No newline at end of file
+ window.location.href = "https://infisical.com/scheduledemo";
+ }}
+ color="mineshaft"
+ className="w-full"
+ >
+ {subscriptionText}
+ </Button>
+ </Td>
+ );
+ })}
+ </Tr>
+ )}
+ </TBody>
+ </Table>
+ </TableContainer>
+ );
+};
diff --git a/frontend/src/views/Settings/BillingSettingsPage/components/BillingDetailsTab/PmtMethodsTable.tsx b/frontend/src/views/Settings/BillingSettingsPage/components/BillingDetailsTab/PmtMethodsTable.tsx
index 743106998f..17f4fd21c7 100644
--- a/frontend/src/views/Settings/BillingSettingsPage/components/BillingDetailsTab/PmtMethodsTable.tsx
+++ b/frontend/src/views/Settings/BillingSettingsPage/components/BillingDetailsTab/PmtMethodsTable.tsx
@@ -14,78 +14,68 @@ import {
Tr
} from "@app/components/v2";
import { useOrganization } from "@app/context";
-import {
- useDeleteOrgPmtMethod,
- useGetOrgPmtMethods
-} from "@app/hooks/api";
+import { useDeleteOrgPmtMethod, useGetOrgPmtMethods } from "@app/hooks/api";
export const PmtMethodsTable = () => {
- const { currentOrg } = useOrganization();
- const { data, isLoading } = useGetOrgPmtMethods(currentOrg?._id ?? "");
- const deleteOrgPmtMethod = useDeleteOrgPmtMethod();
+ const { currentOrg } = useOrganization();
+ const { data, isLoading } = useGetOrgPmtMethods(currentOrg?._id ?? "");
+ const deleteOrgPmtMethod = useDeleteOrgPmtMethod();
- const handleDeletePmtMethodBtnClick = async (pmtMethodId: string) => {
- if (!currentOrg?._id) return;
- await deleteOrgPmtMethod.mutateAsync({
- organizationId: currentOrg._id,
- pmtMethodId
- });
- }
+ const handleDeletePmtMethodBtnClick = async (pmtMethodId: string) => {
+ if (!currentOrg?._id) return;
+ await deleteOrgPmtMethod.mutateAsync({
+ organizationId: currentOrg._id,
+ pmtMethodId
+ });
+ };
- return (
- <TableContainer className="mt-4">
- <Table>
- <THead>
- <Tr>
- <Th className="flex-1">Brand</Th>
- <Th className="flex-1">Type</Th>
- <Th className="flex-1">Last 4 Digits</Th>
- <Th className="flex-1">Expiration</Th>
- <Th className="w-5" />
- </Tr>
- </THead>
- <TBody>
- {!isLoading && data && data?.length > 0 && data.map(({
- _id,
- brand,
- exp_month,
- exp_year,
- funding,
- last4
- }) => (
- <Tr key={`pmt-method-${_id}`} className="h-10">
- <Td>{brand.charAt(0).toUpperCase() + brand.slice(1)}</Td>
- <Td>{funding.charAt(0).toUpperCase() + funding.slice(1)}</Td>
- <Td>{last4}</Td>
- <Td>{`${exp_month}/${exp_year}`}</Td>
- <Td>
- <IconButton
- onClick={async () => {
- await handleDeletePmtMethodBtnClick(_id);
- }}
- size="lg"
- colorSchema="danger"
- variant="plain"
- ariaLabel="update"
- >
- <FontAwesomeIcon icon={faXmark} />
- </IconButton>
- </Td>
- </Tr>
- ))}
- {isLoading && <TableSkeleton columns={5} key="pmt-methods" />}
- {!isLoading && data && data?.length === 0 && (
- <Tr>
- <Td colSpan={5}>
- <EmptyState
- title="No payment methods on file"
- icon={faCreditCard}
- />
- </Td>
- </Tr>
- )}
- </TBody>
- </Table>
- </TableContainer>
- );
-}
\ No newline at end of file
+ return (
+ <TableContainer className="mt-4">
+ <Table>
+ <THead>
+ <Tr>
+ <Th className="flex-1">Brand</Th>
+ <Th className="flex-1">Type</Th>
+ <Th className="flex-1">Last 4 Digits</Th>
+ <Th className="flex-1">Expiration</Th>
+ <Th className="w-5" />
+ </Tr>
+ </THead>
+ <TBody>
+ {!isLoading &&
+ data &&
+ data?.length > 0 &&
+ data.map(({ _id, brand, exp_month, exp_year, funding, last4 }) => (
+ <Tr key={`pmt-method-${_id}`} className="h-10">
+ <Td>{brand.charAt(0).toUpperCase() + brand.slice(1)}</Td>
+ <Td>{funding.charAt(0).toUpperCase() + funding.slice(1)}</Td>
+ <Td>{last4}</Td>
+ <Td>{`${exp_month}/${exp_year}`}</Td>
+ <Td>
+ <IconButton
+ onClick={async () => {
+ await handleDeletePmtMethodBtnClick(_id);
+ }}
+ size="lg"
+ colorSchema="danger"
+ variant="plain"
+ ariaLabel="update"
+ >
+ <FontAwesomeIcon icon={faXmark} />
+ </IconButton>
+ </Td>
+ </Tr>
+ ))}
+ {isLoading && <TableSkeleton columns={5} innerKey="pmt-methods" />}
+ {!isLoading && data && data?.length === 0 && (
+ <Tr>
+ <Td colSpan={5}>
+ <EmptyState title="No payment methods on file" icon={faCreditCard} />
+ </Td>
+ </Tr>
+ )}
+ </TBody>
+ </Table>
+ </TableContainer>
+ );
+};
diff --git a/frontend/src/views/Settings/BillingSettingsPage/components/BillingDetailsTab/TaxIDTable.tsx b/frontend/src/views/Settings/BillingSettingsPage/components/BillingDetailsTab/TaxIDTable.tsx
index 873b41cf67..2779bb19d0 100644
--- a/frontend/src/views/Settings/BillingSettingsPage/components/BillingDetailsTab/TaxIDTable.tsx
+++ b/frontend/src/views/Settings/BillingSettingsPage/components/BillingDetailsTab/TaxIDTable.tsx
@@ -1,4 +1,4 @@
-import { faFileInvoice,faXmark } from "@fortawesome/free-solid-svg-icons";
+import { faFileInvoice, faXmark } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import {
@@ -11,127 +11,120 @@ import {
Td,
Th,
THead,
- Tr,
+ Tr
} from "@app/components/v2";
import { useOrganization } from "@app/context";
-import {
- useDeleteOrgTaxId,
- useGetOrgTaxIds
-} from "@app/hooks/api";
+import { useDeleteOrgTaxId, useGetOrgTaxIds } from "@app/hooks/api";
const taxIDTypeLabelMap: { [key: string]: string } = {
- "au_abn": "Australia ABN",
- "au_arn": "Australia ARN",
- "bg_uic": "Bulgaria UIC",
- "br_cnpj": "Brazil CNPJ",
- "br_cpf": "Brazil CPF",
- "ca_bn": "Canada BN",
- "ca_gst_hst": "Canada GST/HST",
- "ca_pst_bc": "Canada PST BC",
- "ca_pst_mb": "Canada PST MB",
- "ca_pst_sk": "Canada PST SK",
- "ca_qst": "Canada QST",
- "ch_vat": "Switzerland VAT",
- "cl_tin": "Chile TIN",
- "eg_tin": "Egypt TIN",
- "es_cif": "Spain CIF",
- "eu_oss_vat": "EU OSS VAT",
- "eu_vat": "EU VAT",
- "gb_vat": "GB VAT",
- "ge_vat": "Georgia VAT",
- "hk_br": "Hong Kong BR",
- "hu_tin": "Hungary TIN",
- "id_npwp": "Indonesia NPWP",
- "il_vat": "Israel VAT",
- "in_gst": "India GST",
- "is_vat": "Iceland VAT",
- "jp_cn": "Japan CN",
- "jp_rn": "Japan RN",
- "jp_trn": "Japan TRN",
- "ke_pin": "Kenya PIN",
- "kr_brn": "South Korea BRN",
- "li_uid": "Liechtenstein UID",
- "mx_rfc": "Mexico RFC",
- "my_frp": "Malaysia FRP",
- "my_itn": "Malaysia ITN",
- "my_sst": "Malaysia SST",
- "no_vat": "Norway VAT",
- "nz_gst": "New Zealand GST",
- "ph_tin": "Philippines TIN",
- "ru_inn": "Russia INN",
- "ru_kpp": "Russia KPP",
- "sa_vat": "Saudi Arabia VAT",
- "sg_gst": "Singapore GST",
- "sg_uen": "Singapore UEN",
- "si_tin": "Slovenia TIN",
- "th_vat": "Thailand VAT",
- "tr_tin": "Turkey TIN",
- "tw_vat": "Taiwan VAT",
- "ua_vat": "Ukraine VAT",
- "us_ein": "US EIN",
- "za_vat": "South Africa VAT"
+ au_abn: "Australia ABN",
+ au_arn: "Australia ARN",
+ bg_uic: "Bulgaria UIC",
+ br_cnpj: "Brazil CNPJ",
+ br_cpf: "Brazil CPF",
+ ca_bn: "Canada BN",
+ ca_gst_hst: "Canada GST/HST",
+ ca_pst_bc: "Canada PST BC",
+ ca_pst_mb: "Canada PST MB",
+ ca_pst_sk: "Canada PST SK",
+ ca_qst: "Canada QST",
+ ch_vat: "Switzerland VAT",
+ cl_tin: "Chile TIN",
+ eg_tin: "Egypt TIN",
+ es_cif: "Spain CIF",
+ eu_oss_vat: "EU OSS VAT",
+ eu_vat: "EU VAT",
+ gb_vat: "GB VAT",
+ ge_vat: "Georgia VAT",
+ hk_br: "Hong Kong BR",
+ hu_tin: "Hungary TIN",
+ id_npwp: "Indonesia NPWP",
+ il_vat: "Israel VAT",
+ in_gst: "India GST",
+ is_vat: "Iceland VAT",
+ jp_cn: "Japan CN",
+ jp_rn: "Japan RN",
+ jp_trn: "Japan TRN",
+ ke_pin: "Kenya PIN",
+ kr_brn: "South Korea BRN",
+ li_uid: "Liechtenstein UID",
+ mx_rfc: "Mexico RFC",
+ my_frp: "Malaysia FRP",
+ my_itn: "Malaysia ITN",
+ my_sst: "Malaysia SST",
+ no_vat: "Norway VAT",
+ nz_gst: "New Zealand GST",
+ ph_tin: "Philippines TIN",
+ ru_inn: "Russia INN",
+ ru_kpp: "Russia KPP",
+ sa_vat: "Saudi Arabia VAT",
+ sg_gst: "Singapore GST",
+ sg_uen: "Singapore UEN",
+ si_tin: "Slovenia TIN",
+ th_vat: "Thailand VAT",
+ tr_tin: "Turkey TIN",
+ tw_vat: "Taiwan VAT",
+ ua_vat: "Ukraine VAT",
+ us_ein: "US EIN",
+ za_vat: "South Africa VAT"
};
export const TaxIDTable = () => {
- const { currentOrg } = useOrganization();
- const { data, isLoading } = useGetOrgTaxIds(currentOrg?._id ?? "");
- const deleteOrgTaxId = useDeleteOrgTaxId();
+ const { currentOrg } = useOrganization();
+ const { data, isLoading } = useGetOrgTaxIds(currentOrg?._id ?? "");
+ const deleteOrgTaxId = useDeleteOrgTaxId();
- const handleDeleteTaxIdBtnClick = async (taxId: string) => {
- if (!currentOrg?._id) return;
- await deleteOrgTaxId.mutateAsync({
- organizationId: currentOrg._id,
- taxId
- });
- }
+ const handleDeleteTaxIdBtnClick = async (taxId: string) => {
+ if (!currentOrg?._id) return;
+ await deleteOrgTaxId.mutateAsync({
+ organizationId: currentOrg._id,
+ taxId
+ });
+ };
- return (
- <TableContainer className="mt-4">
- <Table>
- <THead>
- <Tr>
- <Th className="flex-1">Type</Th>
- <Th className="flex-1">Value</Th>
- <Th className="w-5" />
- </Tr>
- </THead>
- <TBody>
- {!isLoading && data && data?.length > 0 && data.map(({
- _id,
- type,
- value
- }) => (
- <Tr key={`tax-id-${_id}`} className="h-10">
- <Td>{taxIDTypeLabelMap[type]}</Td>
- <Td>{value}</Td>
- <Td>
- <IconButton
- onClick={async () => {
- await handleDeleteTaxIdBtnClick(_id);
- }}
- size="lg"
- colorSchema="danger"
- variant="plain"
- ariaLabel="update"
- >
- <FontAwesomeIcon icon={faXmark} />
- </IconButton>
- </Td>
- </Tr>
- ))}
- {isLoading && <TableSkeleton columns={3} key="tax-ids" />}
- {!isLoading && data && data?.length === 0 && (
- <Tr>
- <Td colSpan={5}>
- <EmptyState
- title="No Tax IDs on file"
- icon={faFileInvoice}
- />
- </Td>
- </Tr>
- )}
- </TBody>
- </Table>
- </TableContainer>
- );
-}
\ No newline at end of file
+ return (
+ <TableContainer className="mt-4">
+ <Table>
+ <THead>
+ <Tr>
+ <Th className="flex-1">Type</Th>
+ <Th className="flex-1">Value</Th>
+ <Th className="w-5" />
+ </Tr>
+ </THead>
+ <TBody>
+ {!isLoading &&
+ data &&
+ data?.length > 0 &&
+ data.map(({ _id, type, value }) => (
+ <Tr key={`tax-id-${_id}`} className="h-10">
+ <Td>{taxIDTypeLabelMap[type]}</Td>
+ <Td>{value}</Td>
+ <Td>
+ <IconButton
+ onClick={async () => {
+ await handleDeleteTaxIdBtnClick(_id);
+ }}
+ size="lg"
+ colorSchema="danger"
+ variant="plain"
+ ariaLabel="update"
+ >
+ <FontAwesomeIcon icon={faXmark} />
+ </IconButton>
+ </Td>
+ </Tr>
+ ))}
+ {isLoading && <TableSkeleton columns={3} innerKey="tax-ids" />}
+ {!isLoading && data && data?.length === 0 && (
+ <Tr>
+ <Td colSpan={5}>
+ <EmptyState title="No Tax IDs on file" icon={faFileInvoice} />
+ </Td>
+ </Tr>
+ )}
+ </TBody>
+ </Table>
+ </TableContainer>
+ );
+};
diff --git a/frontend/src/views/Settings/BillingSettingsPage/components/BillingReceiptsTab/InvoicesTable.tsx b/frontend/src/views/Settings/BillingSettingsPage/components/BillingReceiptsTab/InvoicesTable.tsx
index 612052a366..23a0852801 100644
--- a/frontend/src/views/Settings/BillingSettingsPage/components/BillingReceiptsTab/InvoicesTable.tsx
+++ b/frontend/src/views/Settings/BillingSettingsPage/components/BillingReceiptsTab/InvoicesTable.tsx
@@ -14,76 +14,67 @@ import {
Tr
} from "@app/components/v2";
import { useOrganization } from "@app/context";
-import {
- useGetOrgInvoices
-} from "@app/hooks/api";
+import { useGetOrgInvoices } from "@app/hooks/api";
export const InvoicesTable = () => {
- const { currentOrg } = useOrganization();
- const { data, isLoading } = useGetOrgInvoices(currentOrg?._id ?? "");
- return (
- <TableContainer className="mt-8">
- <Table>
- <THead>
- <Tr>
- <Th className="flex-1">Invoice #</Th>
- <Th className="flex-1">Date</Th>
- <Th className="flex-1">Status</Th>
- <Th className="flex-1">Amount</Th>
- <Th className="w-5" />
+ const { currentOrg } = useOrganization();
+ const { data, isLoading } = useGetOrgInvoices(currentOrg?._id ?? "");
+ return (
+ <TableContainer className="mt-8">
+ <Table>
+ <THead>
+ <Tr>
+ <Th className="flex-1">Invoice #</Th>
+ <Th className="flex-1">Date</Th>
+ <Th className="flex-1">Status</Th>
+ <Th className="flex-1">Amount</Th>
+ <Th className="w-5" />
+ </Tr>
+ </THead>
+ <TBody>
+ {!isLoading &&
+ data &&
+ data?.length > 0 &&
+ data.map(({ _id, created, paid, number, total, invoice_pdf }) => {
+ const formattedTotal = (Math.floor(total) / 100).toLocaleString("en-US", {
+ style: "currency",
+ currency: "USD"
+ });
+ const createdDate = new Date(created * 1000);
+ const day: number = createdDate.getDate();
+ const month: number = createdDate.getMonth() + 1;
+ const year: number = createdDate.getFullYear();
+ const formattedDate: string = `${day}/${month}/${year}`;
+
+ return (
+ <Tr key={`invoice-${_id}`} className="h-10">
+ <Td>{number}</Td>
+ <Td>{formattedDate}</Td>
+ <Td>{paid ? "Paid" : "Not Paid"}</Td>
+ <Td>{formattedTotal}</Td>
+ <Td>
+ <IconButton
+ onClick={async () => window.open(invoice_pdf)}
+ size="lg"
+ variant="plain"
+ ariaLabel="update"
+ >
+ <FontAwesomeIcon icon={faDownload} />
+ </IconButton>
+ </Td>
</Tr>
- </THead>
- <TBody>
- {!isLoading && data && data?.length > 0 && data.map(({
- _id,
- created,
- paid,
- number,
- total,
- invoice_pdf
- }) => {
- const formattedTotal = (Math.floor(total) / 100).toLocaleString("en-US", {
- style: "currency",
- currency: "USD",
- });
- const createdDate = new Date(created * 1000);
- const day: number = createdDate.getDate();
- const month: number = createdDate.getMonth() + 1;
- const year: number = createdDate.getFullYear();
- const formattedDate: string = `${day}/${month}/${year}`;
-
- return (
- <Tr key={`invoice-${_id}`} className="h-10">
- <Td>{number}</Td>
- <Td>{formattedDate}</Td>
- <Td>{paid ? "Paid" : "Not Paid"}</Td>
- <Td>{formattedTotal}</Td>
- <Td>
- <IconButton
- onClick={async () => window.open(invoice_pdf)}
- size="lg"
- variant="plain"
- ariaLabel="update"
- >
- <FontAwesomeIcon icon={faDownload} />
- </IconButton>
- </Td>
- </Tr>
- );
- })}
- {isLoading && <TableSkeleton columns={5} key="invoices" />}
- {!isLoading && data && data?.length === 0 && (
- <Tr>
- <Td colSpan={5}>
- <EmptyState
- title="No invoices on file"
- icon={faFileInvoice}
- />
- </Td>
- </Tr>
- )}
- </TBody>
- </Table>
- </TableContainer>
- );
-}
\ No newline at end of file
+ );
+ })}
+ {isLoading && <TableSkeleton columns={5} innerKey="invoices" />}
+ {!isLoading && data && data?.length === 0 && (
+ <Tr>
+ <Td colSpan={5}>
+ <EmptyState title="No invoices on file" icon={faFileInvoice} />
+ </Td>
+ </Tr>
+ )}
+ </TBody>
+ </Table>
+ </TableContainer>
+ );
+};
diff --git a/frontend/src/views/Settings/CreateServiceAccountPage/components/SAProjectLevelPermissionsTable/SAProjectLevelPermissionsTable.tsx b/frontend/src/views/Settings/CreateServiceAccountPage/components/SAProjectLevelPermissionsTable/SAProjectLevelPermissionsTable.tsx
index 7e4b785706..dc56cce65d 100644
--- a/frontend/src/views/Settings/CreateServiceAccountPage/components/SAProjectLevelPermissionsTable/SAProjectLevelPermissionsTable.tsx
+++ b/frontend/src/views/Settings/CreateServiceAccountPage/components/SAProjectLevelPermissionsTable/SAProjectLevelPermissionsTable.tsx
@@ -1,407 +1,412 @@
import { useState } from "react";
-import { Controller,useForm } from "react-hook-form";
-import {
- faKey,
- faMagnifyingGlass,
- faPlus,
- faTrash} from "@fortawesome/free-solid-svg-icons";
+import { Controller, useForm } from "react-hook-form";
+import { faKey, faMagnifyingGlass, faPlus, faTrash } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { yupResolver } from "@hookform/resolvers/yup";
import * as yup from "yup";
-import {
- decryptAssymmetric,
- encryptAssymmetric,
- verifyPrivateKey} from "@app/components/utilities/cryptography/crypto";
import {
- Button,
- Checkbox,
- DeleteActionModal,
- EmptyState,
- FormControl,
- IconButton,
- Input,
- Modal,
- ModalClose,
- ModalContent,
- Select,
- SelectItem,
- Table,
- TableContainer,
- TableSkeleton,
- TBody,
- Td,
- Th,
- THead,
- Tr} from "@app/components/v2";
+ decryptAssymmetric,
+ encryptAssymmetric,
+ verifyPrivateKey
+} from "@app/components/utilities/cryptography/crypto";
+import {
+ Button,
+ Checkbox,
+ DeleteActionModal,
+ EmptyState,
+ FormControl,
+ IconButton,
+ Input,
+ Modal,
+ ModalClose,
+ ModalContent,
+ Select,
+ SelectItem,
+ Table,
+ TableContainer,
+ TableSkeleton,
+ TBody,
+ Td,
+ Th,
+ THead,
+ Tr
+} from "@app/components/v2";
import { usePopUp } from "@app/hooks";
import {
- useCreateServiceAccountProjectLevelPermission,
- useDeleteServiceAccountProjectLevelPermission,
- useGetServiceAccountById,
- useGetServiceAccountProjectLevelPermissions,
- useGetUserWorkspaces
+ useCreateServiceAccountProjectLevelPermission,
+ useDeleteServiceAccountProjectLevelPermission,
+ useGetServiceAccountById,
+ useGetServiceAccountProjectLevelPermissions,
+ useGetUserWorkspaces
} from "@app/hooks/api";
import getLatestFileKey from "@app/pages/api/workspace/getLatestFileKey";
const createProjectLevelPermissionSchema = yup.object({
- privateKey: yup.string().required().label("Private Key"),
- workspace: yup.string().required().label("Workspace"),
- environment: yup.string().required().label("Environment"),
- permissions: yup.object().shape({
- read: yup.boolean().required(),
- write: yup.boolean().required()
- }).defined().required()
+ privateKey: yup.string().required().label("Private Key"),
+ workspace: yup.string().required().label("Workspace"),
+ environment: yup.string().required().label("Environment"),
+ permissions: yup
+ .object()
+ .shape({
+ read: yup.boolean().required(),
+ write: yup.boolean().required()
+ })
+ .defined()
+ .required()
});
type CreateProjectLevelPermissionForm = yup.InferType<typeof createProjectLevelPermissionSchema>;
type Props = {
- serviceAccountId: string;
-}
+ serviceAccountId: string;
+};
-export const SAProjectLevelPermissionsTable = ({
- serviceAccountId
-}: Props): JSX.Element => {
- const { data: serviceAccount } = useGetServiceAccountById(serviceAccountId);
- const { data: userWorkspaces, isLoading: isUserWorkspacesLoading } = useGetUserWorkspaces();
- const [searchPermissions, setSearchPermissions] = useState("");
+export const SAProjectLevelPermissionsTable = ({ serviceAccountId }: Props): JSX.Element => {
+ const { data: serviceAccount } = useGetServiceAccountById(serviceAccountId);
+ const { data: userWorkspaces, isLoading: isUserWorkspacesLoading } = useGetUserWorkspaces();
+ const [searchPermissions, setSearchPermissions] = useState("");
- const { data: serviceAccountWorkspacePermissions, isLoading: isPermissionsLoading } = useGetServiceAccountProjectLevelPermissions(serviceAccountId);
-
- const createServiceAccountProjectLevelPermission = useCreateServiceAccountProjectLevelPermission();
- const deleteServiceAccountProjectLevelPermission = useDeleteServiceAccountProjectLevelPermission();
+ const { data: serviceAccountWorkspacePermissions, isLoading: isPermissionsLoading } =
+ useGetServiceAccountProjectLevelPermissions(serviceAccountId);
- const { handlePopUpToggle, popUp, handlePopUpOpen, handlePopUpClose } = usePopUp([
- "addProjectLevelPermission",
- "removeProjectLevelPermission",
- ] as const);
-
- const [, setSelectedWorkspace] = useState<undefined | string>(undefined);
+ const createServiceAccountProjectLevelPermission =
+ useCreateServiceAccountProjectLevelPermission();
+ const deleteServiceAccountProjectLevelPermission =
+ useDeleteServiceAccountProjectLevelPermission();
- const {
- control,
- handleSubmit,
- reset,
- formState: { isSubmitting }
- } = useForm<CreateProjectLevelPermissionForm>({ resolver: yupResolver(createProjectLevelPermissionSchema) })
+ const { handlePopUpToggle, popUp, handlePopUpOpen, handlePopUpClose } = usePopUp([
+ "addProjectLevelPermission",
+ "removeProjectLevelPermission"
+ ] as const);
- const onAddProjectLevelPermission = async ({
- privateKey,
- workspace,
- environment,
- permissions: { read, write }
- }: CreateProjectLevelPermissionForm) => {
-
- // TODO: clean up / modularize this function
-
- if (!serviceAccount) return;
-
- const { latestKey } = await getLatestFileKey({
- workspaceId: workspace
- });
+ const [, setSelectedWorkspace] = useState<undefined | string>(undefined);
- verifyPrivateKey({
- privateKey,
- publicKey: serviceAccount.publicKey
- });
-
- const PRIVATE_KEY = localStorage.getItem("PRIVATE_KEY") as string;
+ const {
+ control,
+ handleSubmit,
+ reset,
+ formState: { isSubmitting }
+ } = useForm<CreateProjectLevelPermissionForm>({
+ resolver: yupResolver(createProjectLevelPermissionSchema)
+ });
- const key = decryptAssymmetric({
- ciphertext: latestKey.encryptedKey,
- nonce: latestKey.nonce,
- publicKey: latestKey.sender.publicKey,
- privateKey: PRIVATE_KEY
- });
-
- const { ciphertext, nonce } = encryptAssymmetric({
- plaintext: key,
- publicKey: serviceAccount.publicKey,
- privateKey
- });
-
- await createServiceAccountProjectLevelPermission.mutateAsync({
- serviceAccountId,
- workspaceId: workspace,
- environment,
- read,
- write,
- encryptedKey: ciphertext,
- nonce
- });
- handlePopUpClose("addProjectLevelPermission");
- }
-
- const onRemoveProjectLevelPermission = async () => {
- const serviceAccountWorkspacePermissionId = (popUp?.removeProjectLevelPermission?.data as { _id: string })?._id;
- await deleteServiceAccountProjectLevelPermission.mutateAsync({
- serviceAccountId,
- serviceAccountWorkspacePermissionId
- });
- handlePopUpClose("removeProjectLevelPermission");
- }
+ const onAddProjectLevelPermission = async ({
+ privateKey,
+ workspace,
+ environment,
+ permissions: { read, write }
+ }: CreateProjectLevelPermissionForm) => {
+ // TODO: clean up / modularize this function
- return (
- <div className="w-full bg-white/5 p-6">
- <p className="mb-4 text-xl font-semibold">Project-Level Permissions</p>
- <div className="mb-4 flex">
- <div className="mr-4 flex-1">
- <Input
- value={searchPermissions}
- onChange={(e) => setSearchPermissions(e.target.value)}
- leftIcon={<FontAwesomeIcon icon={faMagnifyingGlass} />}
- placeholder="Search service account project-level permissions..."
- />
- </div>
- <Button
- leftIcon={<FontAwesomeIcon icon={faPlus} />}
- onClick={() => {
- handlePopUpOpen("addProjectLevelPermission")
- reset();
- }}
- >
- Add Permission
- </Button>
- </div>
- <TableContainer>
- <Table>
- <THead>
- <Tr>
- <Th>Project</Th>
- <Th>Environment</Th>
- <Th>Read</Th>
- <Th>Write</Th>
- <Th aria-label="actions" />
- </Tr>
- </THead>
- <TBody>
- {isPermissionsLoading && <TableSkeleton columns={6} key="service-account-project-level-permissions" />}
- {!isPermissionsLoading && serviceAccountWorkspacePermissions && (
- serviceAccountWorkspacePermissions.map(({
- _id,
- workspace,
- environment,
- read,
- write
- }) => {
- const environmentName = (workspace.environments.find((env) => env.slug === environment))?.name;
- return (
- <Tr key={`service-account-project-level-permission-${_id}`} className="w-full">
- <Td>{workspace.name}</Td>
- <Td>{environmentName}</Td>
- <Td>
- <Checkbox
- id="isReadPermissionEnabled"
- isChecked={read}
- isDisabled
- >{/**/}</Checkbox>
- </Td>
- <Td>
- <Checkbox
- id="isWritePermissionEnabled"
- isChecked={write}
- isDisabled
- >{/**/}</Checkbox>
- </Td>
- <Td>
- <IconButton
- ariaLabel="delete"
- colorSchema="danger"
- onClick={() => handlePopUpOpen("removeProjectLevelPermission", { _id })}
- >
- <FontAwesomeIcon icon={faTrash} />
- </IconButton>
- </Td>
- </Tr>
- );
- })
- )}
- {!isPermissionsLoading && serviceAccountWorkspacePermissions?.length === 0 && (
- <Tr>
- <Td colSpan={7} className="py-6 text-center text-bunker-400">
- <EmptyState title="No permissions found" icon={faKey} />
- </Td>
- </Tr>
- )}
- </TBody>
- </Table>
- </TableContainer>
- <Modal
- isOpen={popUp?.addProjectLevelPermission?.isOpen}
- onOpenChange={(isOpen) => {
- handlePopUpToggle("addProjectLevelPermission", isOpen);
- }}
- >
- <ModalContent
- title="Add a Project-Level Permission"
- subTitle="The service account will be granted scoped access to the specified project and environment"
- >
- <form onSubmit={handleSubmit(onAddProjectLevelPermission)}>
- {!isUserWorkspacesLoading && userWorkspaces && (
- <>
- <Controller
- control={control}
- defaultValue=""
- name="privateKey"
- render={({ field, fieldState: { error } }) => (
- <FormControl
- label="Service Account Private Key"
- isError={Boolean(error)}
- errorText={error?.message}
- >
- <Input {...field} />
- </FormControl>
- )}
- />
- <Controller
- control={control}
- name="workspace"
- defaultValue={String(userWorkspaces?.[0]?._id)}
- render={({ field: { onChange, ...field }, fieldState: { error } }) => (
- <FormControl
- label="Project"
- errorText={error?.message}
- >
- <Select
- defaultValue={field.value}
- {...field}
- onValueChange={(e) => {
- onChange(e);
- setSelectedWorkspace(e);
- }}
- className="w-full border border-mine-shaft-500"
- >
- {userWorkspaces && userWorkspaces.length > 0 ? (
- userWorkspaces.map((userWorkspace) => {
- return (
- <SelectItem value={userWorkspace._id} key={`project-${userWorkspace._id}`}>
- {userWorkspace.name}
- </SelectItem>
- );
- })
- ) : (
- <SelectItem value="none" key="target-app-none">
- No projects found
- </SelectItem>
- )}
- </Select>
- </FormControl>
- )}
- />
- <Controller
- control={control}
- name="environment"
- defaultValue={String(userWorkspaces?.[0]?.environments?.[0]?.slug)}
- render={({ field: { onChange, ...field } }) => {
- /* eslint-disable-next-line no-underscore-dangle */
- const environments = userWorkspaces?.find((userWorkspace) => userWorkspace._id === control?._formValues?.workspace)?.environments ?? [];
- return (
- <FormControl
- label="Environment"
- className="mt-4"
- >
- <Select
- defaultValue={field.value}
- {...field}
- onValueChange={(e) => onChange(e)}
- className="w-full border border-mine-shaft-500"
- >
- {environments.length > 0 ? (
- environments.map((environment) => {
- return (
- <SelectItem value={environment.slug} key={`environment-${environment.slug}`}>
- {environment.name}
- </SelectItem>
- );
- })
- ) : (
- <SelectItem value="none" key="target-app-none">
- No environments found
- </SelectItem>
- )}
- </Select>
- </FormControl>
- );
- }}
- />
- </>
+ if (!serviceAccount) return;
+
+ const { latestKey } = await getLatestFileKey({
+ workspaceId: workspace
+ });
+
+ verifyPrivateKey({
+ privateKey,
+ publicKey: serviceAccount.publicKey
+ });
+
+ const PRIVATE_KEY = localStorage.getItem("PRIVATE_KEY") as string;
+
+ const key = decryptAssymmetric({
+ ciphertext: latestKey.encryptedKey,
+ nonce: latestKey.nonce,
+ publicKey: latestKey.sender.publicKey,
+ privateKey: PRIVATE_KEY
+ });
+
+ const { ciphertext, nonce } = encryptAssymmetric({
+ plaintext: key,
+ publicKey: serviceAccount.publicKey,
+ privateKey
+ });
+
+ await createServiceAccountProjectLevelPermission.mutateAsync({
+ serviceAccountId,
+ workspaceId: workspace,
+ environment,
+ read,
+ write,
+ encryptedKey: ciphertext,
+ nonce
+ });
+ handlePopUpClose("addProjectLevelPermission");
+ };
+
+ const onRemoveProjectLevelPermission = async () => {
+ const serviceAccountWorkspacePermissionId = (
+ popUp?.removeProjectLevelPermission?.data as { _id: string }
+ )?._id;
+ await deleteServiceAccountProjectLevelPermission.mutateAsync({
+ serviceAccountId,
+ serviceAccountWorkspacePermissionId
+ });
+ handlePopUpClose("removeProjectLevelPermission");
+ };
+
+ return (
+ <div className="w-full bg-white/5 p-6">
+ <p className="mb-4 text-xl font-semibold">Project-Level Permissions</p>
+ <div className="mb-4 flex">
+ <div className="mr-4 flex-1">
+ <Input
+ value={searchPermissions}
+ onChange={(e) => setSearchPermissions(e.target.value)}
+ leftIcon={<FontAwesomeIcon icon={faMagnifyingGlass} />}
+ placeholder="Search service account project-level permissions..."
+ />
+ </div>
+ <Button
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ onClick={() => {
+ handlePopUpOpen("addProjectLevelPermission");
+ reset();
+ }}
+ >
+ Add Permission
+ </Button>
+ </div>
+ <TableContainer>
+ <Table>
+ <THead>
+ <Tr>
+ <Th>Project</Th>
+ <Th>Environment</Th>
+ <Th>Read</Th>
+ <Th>Write</Th>
+ <Th aria-label="actions" />
+ </Tr>
+ </THead>
+ <TBody>
+ {isPermissionsLoading && (
+ <TableSkeleton columns={6} innerKey="service-account-project-level-permissions" />
+ )}
+ {!isPermissionsLoading &&
+ serviceAccountWorkspacePermissions &&
+ serviceAccountWorkspacePermissions.map(
+ ({ _id, workspace, environment, read, write }) => {
+ const environmentName = workspace.environments.find(
+ (env) => env.slug === environment
+ )?.name;
+ return (
+ <Tr key={`service-account-project-level-permission-${_id}`} className="w-full">
+ <Td>{workspace.name}</Td>
+ <Td>{environmentName}</Td>
+ <Td>
+ <Checkbox id="isReadPermissionEnabled" isChecked={read} isDisabled>
+ {/**/}
+ </Checkbox>
+ </Td>
+ <Td>
+ <Checkbox id="isWritePermissionEnabled" isChecked={write} isDisabled>
+ {/**/}
+ </Checkbox>
+ </Td>
+ <Td>
+ <IconButton
+ ariaLabel="delete"
+ colorSchema="danger"
+ onClick={() => handlePopUpOpen("removeProjectLevelPermission", { _id })}
+ >
+ <FontAwesomeIcon icon={faTrash} />
+ </IconButton>
+ </Td>
+ </Tr>
+ );
+ }
+ )}
+ {!isPermissionsLoading && serviceAccountWorkspacePermissions?.length === 0 && (
+ <Tr>
+ <Td colSpan={7} className="py-6 text-center text-bunker-400">
+ <EmptyState title="No permissions found" icon={faKey} />
+ </Td>
+ </Tr>
+ )}
+ </TBody>
+ </Table>
+ </TableContainer>
+ <Modal
+ isOpen={popUp?.addProjectLevelPermission?.isOpen}
+ onOpenChange={(isOpen) => {
+ handlePopUpToggle("addProjectLevelPermission", isOpen);
+ }}
+ >
+ <ModalContent
+ title="Add a Project-Level Permission"
+ subTitle="The service account will be granted scoped access to the specified project and environment"
+ >
+ <form onSubmit={handleSubmit(onAddProjectLevelPermission)}>
+ {!isUserWorkspacesLoading && userWorkspaces && (
+ <>
+ <Controller
+ control={control}
+ defaultValue=""
+ name="privateKey"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Service Account Private Key"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input {...field} />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="workspace"
+ defaultValue={String(userWorkspaces?.[0]?._id)}
+ render={({ field: { onChange, ...field }, fieldState: { error } }) => (
+ <FormControl label="Project" errorText={error?.message}>
+ <Select
+ defaultValue={field.value}
+ {...field}
+ onValueChange={(e) => {
+ onChange(e);
+ setSelectedWorkspace(e);
+ }}
+ className="border-mine-shaft-500 w-full border"
+ >
+ {userWorkspaces && userWorkspaces.length > 0 ? (
+ userWorkspaces.map((userWorkspace) => {
+ return (
+ <SelectItem
+ value={userWorkspace._id}
+ key={`project-${userWorkspace._id}`}
+ >
+ {userWorkspace.name}
+ </SelectItem>
+ );
+ })
+ ) : (
+ <SelectItem value="none" key="target-app-none">
+ No projects found
+ </SelectItem>
)}
- <Controller
- control={control}
- name="permissions"
- defaultValue={{
- read: true,
- write: false
- }}
- render={({ field: { onChange, value }, fieldState: { error }}) => {
- const options = [
- {
- label: "Read (default)",
- value: "read"
- },
- {
- label: "Write",
- value: "write"
- }
- ];
-
- return (
- <FormControl
- label="Permissions"
- errorText={error?.message}
- isError={Boolean(error)}
- >
- <>
- {options.map(({ label, value: optionValue }) => {
- return (
- <Checkbox
- id={value[optionValue]}
- key={optionValue}
- className="data-[state=checked]:bg-primary"
- isChecked={value[optionValue]}
- isDisabled={optionValue === "read"}
- onCheckedChange={(state) => {
- onChange({
- ...value,
- [optionValue]: state
- });
- }}
- >
- {label}
- </Checkbox>
- );
- })}
- </>
- </FormControl>
- );
+ </Select>
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="environment"
+ defaultValue={String(userWorkspaces?.[0]?.environments?.[0]?.slug)}
+ render={({ field: { onChange, ...field } }) => {
+ const environments =
+ userWorkspaces?.find(
+ /* eslint-disable-next-line no-underscore-dangle */
+ (userWorkspace) => userWorkspace._id === control?._formValues?.workspace
+ )?.environments ?? [];
+ return (
+ <FormControl label="Environment" className="mt-4">
+ <Select
+ defaultValue={field.value}
+ {...field}
+ onValueChange={(e) => onChange(e)}
+ className="border-mine-shaft-500 w-full border"
+ >
+ {environments.length > 0 ? (
+ environments.map((environment) => {
+ return (
+ <SelectItem
+ value={environment.slug}
+ key={`environment-${environment.slug}`}
+ >
+ {environment.name}
+ </SelectItem>
+ );
+ })
+ ) : (
+ <SelectItem value="none" key="target-app-none">
+ No environments found
+ </SelectItem>
+ )}
+ </Select>
+ </FormControl>
+ );
+ }}
+ />
+ </>
+ )}
+ <Controller
+ control={control}
+ name="permissions"
+ defaultValue={{
+ read: true,
+ write: false
+ }}
+ render={({ field: { onChange, value }, fieldState: { error } }) => {
+ const options = [
+ {
+ label: "Read (default)",
+ value: "read"
+ },
+ {
+ label: "Write",
+ value: "write"
+ }
+ ];
+
+ return (
+ <FormControl
+ label="Permissions"
+ errorText={error?.message}
+ isError={Boolean(error)}
+ >
+ <>
+ {options.map(({ label, value: optionValue }) => {
+ return (
+ <Checkbox
+ id={value[optionValue]}
+ key={optionValue}
+ className="data-[state=checked]:bg-primary"
+ isChecked={value[optionValue]}
+ isDisabled={optionValue === "read"}
+ onCheckedChange={(state) => {
+ onChange({
+ ...value,
+ [optionValue]: state
+ });
}}
- />
- <div className="mt-8 flex items-center">
- <Button
- className="mr-4"
- type="submit"
- isDisabled={isSubmitting}
- isLoading={isSubmitting}
- >
- Create
- </Button>
- <ModalClose asChild>
- <Button variant="plain" colorSchema="secondary">
- Cancel
- </Button>
- </ModalClose>
- </div>
- </form>
- </ModalContent>
- </Modal>
- <DeleteActionModal
- isOpen={popUp.removeProjectLevelPermission.isOpen}
- deleteKey="remove"
- title="Do you want to remove this permission from the service account?"
- onChange={(isOpen) => handlePopUpToggle("removeProjectLevelPermission", isOpen)}
- onDeleteApproved={onRemoveProjectLevelPermission}
+ >
+ {label}
+ </Checkbox>
+ );
+ })}
+ </>
+ </FormControl>
+ );
+ }}
/>
- </div>
- );
-}
\ No newline at end of file
+ <div className="mt-8 flex items-center">
+ <Button
+ className="mr-4"
+ type="submit"
+ isDisabled={isSubmitting}
+ isLoading={isSubmitting}
+ >
+ Create
+ </Button>
+ <ModalClose asChild>
+ <Button variant="plain" colorSchema="secondary">
+ Cancel
+ </Button>
+ </ModalClose>
+ </div>
+ </form>
+ </ModalContent>
+ </Modal>
+ <DeleteActionModal
+ isOpen={popUp.removeProjectLevelPermission.isOpen}
+ deleteKey="remove"
+ title="Do you want to remove this permission from the service account?"
+ onChange={(isOpen) => handlePopUpToggle("removeProjectLevelPermission", isOpen)}
+ onDeleteApproved={onRemoveProjectLevelPermission}
+ />
+ </div>
+ );
+};
diff --git a/frontend/src/views/Settings/OrgSettingsPage/components/OrgIncidentContactsSection/OrgIncidentContactsTable.tsx b/frontend/src/views/Settings/OrgSettingsPage/components/OrgIncidentContactsSection/OrgIncidentContactsTable.tsx
index f2c5d12085..0d30115726 100644
--- a/frontend/src/views/Settings/OrgSettingsPage/components/OrgIncidentContactsSection/OrgIncidentContactsTable.tsx
+++ b/frontend/src/views/Settings/OrgSettingsPage/components/OrgIncidentContactsSection/OrgIncidentContactsTable.tsx
@@ -1,9 +1,5 @@
import { useState } from "react";
-import {
- faContactBook,
- faMagnifyingGlass,
- faTrash
-} from "@fortawesome/free-solid-svg-icons";
+import { faContactBook, faMagnifyingGlass, faTrash } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider";
@@ -23,13 +19,11 @@ import {
} from "@app/components/v2";
import { useOrganization } from "@app/context";
import { usePopUp } from "@app/hooks";
-import {
- useDeleteIncidentContact,
- useGetOrgIncidentContact} from "@app/hooks/api";
+import { useDeleteIncidentContact, useGetOrgIncidentContact } from "@app/hooks/api";
export const OrgIncidentContactsTable = () => {
- const { createNotification } = useNotificationContext();
- const { currentOrg } = useOrganization();
+ const { createNotification } = useNotificationContext();
+ const { currentOrg } = useOrganization();
const { data: contacts, isLoading } = useGetOrgIncidentContact(currentOrg?._id ?? "");
const [searchContact, setSearchContact] = useState("");
const { handlePopUpToggle, popUp, handlePopUpOpen, handlePopUpClose } = usePopUp([
@@ -40,71 +34,71 @@ export const OrgIncidentContactsTable = () => {
const onRemoveIncidentContact = async () => {
try {
- const incidentContactEmail = (popUp?.removeContact?.data as { email: string })?.email;
-
- if (!currentOrg?._id) return;
- await mutateAsync({
- orgId: currentOrg._id,
- email: incidentContactEmail
- });
+ const incidentContactEmail = (popUp?.removeContact?.data as { email: string })?.email;
+
+ if (!currentOrg?._id) return;
+ await mutateAsync({
+ orgId: currentOrg._id,
+ email: incidentContactEmail
+ });
- createNotification({
- text: "Successfully removed incident contact",
- type: "success"
- });
-
- handlePopUpClose("removeContact");
+ createNotification({
+ text: "Successfully removed incident contact",
+ type: "success"
+ });
+
+ handlePopUpClose("removeContact");
} catch (err) {
- console.error(err);
- createNotification({
- text: "Failed to remove incident contact",
- type: "error"
- });
+ console.error(err);
+ createNotification({
+ text: "Failed to remove incident contact",
+ type: "error"
+ });
}
};
- const filteredContacts = contacts ? contacts.filter(({ email }) =>
- email.toLocaleLowerCase().includes(searchContact)
- ) : [];
+ const filteredContacts = contacts
+ ? contacts.filter(({ email }) => email.toLocaleLowerCase().includes(searchContact))
+ : [];
return (
<div>
- <Input
- value={searchContact}
- onChange={(e) => setSearchContact(e.target.value)}
- leftIcon={<FontAwesomeIcon icon={faMagnifyingGlass} />}
- placeholder="Search incident contact by email..."
- />
- <TableContainer className="mt-4">
- <Table>
- <THead>
- <Tr>
- <Th>Email</Th>
- <Th aria-label="actions" />
+ <Input
+ value={searchContact}
+ onChange={(e) => setSearchContact(e.target.value)}
+ leftIcon={<FontAwesomeIcon icon={faMagnifyingGlass} />}
+ placeholder="Search incident contact by email..."
+ />
+ <TableContainer className="mt-4">
+ <Table>
+ <THead>
+ <Tr>
+ <Th>Email</Th>
+ <Th aria-label="actions" />
+ </Tr>
+ </THead>
+ <TBody>
+ {isLoading && <TableSkeleton columns={2} innerKey="incident-contact" />}
+ {filteredContacts?.map(({ email }) => (
+ <Tr key={email}>
+ <Td className="w-full">{email}</Td>
+ <Td className="mr-4">
+ <IconButton
+ ariaLabel="delete"
+ colorSchema="danger"
+ onClick={() => handlePopUpOpen("removeContact", { email })}
+ >
+ <FontAwesomeIcon icon={faTrash} />
+ </IconButton>
+ </Td>
</Tr>
- </THead>
- <TBody>
- {isLoading && <TableSkeleton columns={2} key="incident-contact" />}
- {filteredContacts?.map(({ email }) => (
- <Tr key={email}>
- <Td className="w-full">{email}</Td>
- <Td className="mr-4">
- <IconButton
- ariaLabel="delete"
- colorSchema="danger"
- onClick={() => handlePopUpOpen("removeContact", { email })}
- >
- <FontAwesomeIcon icon={faTrash} />
- </IconButton>
- </Td>
- </Tr>
- ))}
- </TBody>
- </Table>
- {filteredContacts?.length === 0 && !isLoading && (
- <EmptyState title="No incident contacts found" icon={faContactBook} />
- )}
- </TableContainer>
+ ))}
+ </TBody>
+ </Table>
+ {filteredContacts?.length === 0 && !isLoading && (
+ <EmptyState title="No incident contacts found" icon={faContactBook} />
+ )}
+ </TableContainer>
<DeleteActionModal
isOpen={popUp.removeContact.isOpen}
deleteKey="remove"
diff --git a/frontend/src/views/Settings/OrgSettingsPage/components/OrgServiceAccountsTable/OrgServiceAccountsTable.tsx b/frontend/src/views/Settings/OrgSettingsPage/components/OrgServiceAccountsTable/OrgServiceAccountsTable.tsx
index 549d5727e5..6ead6cf878 100644
--- a/frontend/src/views/Settings/OrgSettingsPage/components/OrgServiceAccountsTable/OrgServiceAccountsTable.tsx
+++ b/frontend/src/views/Settings/OrgSettingsPage/components/OrgServiceAccountsTable/OrgServiceAccountsTable.tsx
@@ -1,17 +1,14 @@
-import { useEffect, useMemo,useState } from "react";
-import {
- // Controller,
- // useForm
-} from "react-hook-form";
+import { useEffect, useMemo, useState } from "react";
import { useRouter } from "next/router";
-import {
- faCheck,
- faCopy,
- faMagnifyingGlass,
- faPencil,
- faPlus,
- faServer,
- faTrash} from "@fortawesome/free-solid-svg-icons";
+import {
+ faCheck,
+ faCopy,
+ faMagnifyingGlass,
+ faPencil,
+ faPlus,
+ faServer,
+ faTrash
+} from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
// import { yupResolver } from "@hookform/resolvers/yup";
@@ -21,13 +18,13 @@ import {
Button,
DeleteActionModal,
EmptyState,
-// FormControl,
+ // FormControl,
IconButton,
Input,
Modal,
ModalContent,
-// Select,
-// SelectItem,
+ // Select,
+ // SelectItem,
Table,
TableContainer,
TableSkeleton,
@@ -40,11 +37,15 @@ import {
import { useOrganization, useWorkspace } from "@app/context";
import { usePopUp, useToggle } from "@app/hooks";
import {
- // useCreateServiceAccount,
- useDeleteServiceAccount,
- useGetServiceAccounts
+ // useCreateServiceAccount,
+ useDeleteServiceAccount,
+ useGetServiceAccounts
} from "@app/hooks/api";
+import // Controller,
+// useForm
+"react-hook-form";
+
// const serviceAccountExpiration = [
// { label: "1 Day", value: 86400 },
// { label: "7 Days", value: 604800 },
@@ -62,314 +63,312 @@ import {
// type TAddServiceAccountForm = yup.InferType<typeof addServiceAccountFormSchema>;
export const OrgServiceAccountsTable = () => {
- const router = useRouter();
- const { currentOrg } = useOrganization();
- const { currentWorkspace } = useWorkspace();
-
- const orgId = currentOrg?._id || "";
- const [step, setStep] = useState(0);
- const [isAccessKeyCopied, setIsAccessKeyCopied] = useToggle(false);
- const [isPublicKeyCopied, setIsPublicKeyCopied] = useToggle(false);
- const [isPrivateKeyCopied, setIsPrivateKeyCopied] = useToggle(false);
- const [accessKey] = useState("");
- const [publicKey] = useState("");
- const [privateKey] = useState("");
- const [searchServiceAccountFilter, setSearchServiceAccountFilter] = useState("");
- const { handlePopUpToggle, popUp, handlePopUpOpen, handlePopUpClose } = usePopUp([
- "addServiceAccount",
- "removeServiceAccount",
- ] as const);
+ const router = useRouter();
+ const { currentOrg } = useOrganization();
+ const { currentWorkspace } = useWorkspace();
+
+ const orgId = currentOrg?._id || "";
+ const [step, setStep] = useState(0);
+ const [isAccessKeyCopied, setIsAccessKeyCopied] = useToggle(false);
+ const [isPublicKeyCopied, setIsPublicKeyCopied] = useToggle(false);
+ const [isPrivateKeyCopied, setIsPrivateKeyCopied] = useToggle(false);
+ const [accessKey] = useState("");
+ const [publicKey] = useState("");
+ const [privateKey] = useState("");
+ const [searchServiceAccountFilter, setSearchServiceAccountFilter] = useState("");
+ const { handlePopUpToggle, popUp, handlePopUpOpen, handlePopUpClose } = usePopUp([
+ "addServiceAccount",
+ "removeServiceAccount"
+ ] as const);
+
+ const { data: serviceAccounts = [], isLoading: isServiceAccountsLoading } =
+ useGetServiceAccounts(orgId);
+
+ // const createServiceAccount = useCreateServiceAccount();
+ const removeServiceAccount = useDeleteServiceAccount();
+
+ useEffect(() => {
+ let timer: NodeJS.Timeout;
+ if (isAccessKeyCopied) {
+ timer = setTimeout(() => setIsAccessKeyCopied.off(), 2000);
+ }
+
+ if (isPublicKeyCopied) {
+ timer = setTimeout(() => setIsPublicKeyCopied.off(), 2000);
+ }
+
+ if (isPrivateKeyCopied) {
+ timer = setTimeout(() => setIsPrivateKeyCopied.off(), 2000);
+ }
+
+ return () => clearTimeout(timer);
+ }, [isAccessKeyCopied, isPublicKeyCopied, isPrivateKeyCopied]);
+
+ // const {
+ // control,
+ // handleSubmit,
+ // reset,
+ // formState: { isSubmitting }
+ // } = useForm<TAddServiceAccountForm>({ resolver: yupResolver(addServiceAccountFormSchema) });
- const { data: serviceAccounts = [], isLoading: isServiceAccountsLoading } = useGetServiceAccounts(orgId);
-
- // const createServiceAccount = useCreateServiceAccount();
- const removeServiceAccount = useDeleteServiceAccount();
-
- useEffect(() => {
- let timer: NodeJS.Timeout;
- if (isAccessKeyCopied) {
- timer = setTimeout(() => setIsAccessKeyCopied.off(), 2000);
- }
+ // const onAddServiceAccount = async ({ name, expiresIn }: TAddServiceAccountForm) => {
+ // if (!currentOrg?._id) return;
- if (isPublicKeyCopied) {
- timer = setTimeout(() => setIsPublicKeyCopied.off(), 2000);
- }
+ // const keyPair = generateKeyPair();
+ // setPublicKey(keyPair.publicKey);
+ // setPrivateKey(keyPair.privateKey);
- if (isPrivateKeyCopied) {
- timer = setTimeout(() => setIsPrivateKeyCopied.off(), 2000);
- }
+ // const serviceAccountDetails = await createServiceAccount.mutateAsync({
+ // name,
+ // organizationId: currentOrg?._id,
+ // publicKey: keyPair.publicKey,
+ // expiresIn: Number(expiresIn)
+ // });
- return () => clearTimeout(timer);
- }, [isAccessKeyCopied, isPublicKeyCopied, isPrivateKeyCopied]);
+ // setAccessKey(serviceAccountDetails.serviceAccountAccessKey);
- // const {
- // control,
- // handleSubmit,
- // reset,
- // formState: { isSubmitting }
- // } = useForm<TAddServiceAccountForm>({ resolver: yupResolver(addServiceAccountFormSchema) });
-
- // const onAddServiceAccount = async ({ name, expiresIn }: TAddServiceAccountForm) => {
- // if (!currentOrg?._id) return;
+ // setStep(1);
+ // reset();
+ // }
- // const keyPair = generateKeyPair();
- // setPublicKey(keyPair.publicKey);
- // setPrivateKey(keyPair.privateKey);
-
- // const serviceAccountDetails = await createServiceAccount.mutateAsync({
- // name,
- // organizationId: currentOrg?._id,
- // publicKey: keyPair.publicKey,
- // expiresIn: Number(expiresIn)
- // });
-
- // setAccessKey(serviceAccountDetails.serviceAccountAccessKey);
+ const onRemoveServiceAccount = async () => {
+ const serviceAccountId = (popUp?.removeServiceAccount?.data as { _id: string })?._id;
+ await removeServiceAccount.mutateAsync(serviceAccountId);
+ handlePopUpClose("removeServiceAccount");
+ };
- // setStep(1);
- // reset();
- // }
-
- const onRemoveServiceAccount = async () => {
- const serviceAccountId = (popUp?.removeServiceAccount?.data as { _id: string })?._id;
- await removeServiceAccount.mutateAsync(serviceAccountId);
- handlePopUpClose("removeServiceAccount");
+ const filteredServiceAccounts = useMemo(
+ () =>
+ serviceAccounts.filter(({ name }) => name.toLowerCase().includes(searchServiceAccountFilter)),
+ [serviceAccounts, searchServiceAccountFilter]
+ );
+
+ const renderStep = (stepToRender: number) => {
+ switch (stepToRender) {
+ case 0:
+ return (
+ <div>
+ We are currently revising the service account mechanism. In the meantime, please use
+ service tokens or API key to fetch secrets via API request.
+ </div>
+ // <form onSubmit={handleSubmit(onAddServiceAccount)}>
+ // <Controller
+ // control={control}
+ // defaultValue=""
+ // name="name"
+ // render={({ field, fieldState: { error } }) => (
+ // <FormControl label="Name" isError={Boolean(error)} errorText={error?.message}>
+ // <Input {...field} />
+ // </FormControl>
+ // )}
+ // />
+ // <Controller
+ // control={control}
+ // name="expiresIn"
+ // defaultValue={String(serviceAccountExpiration?.[0]?.value)}
+ // render={({ field: { onChange, ...field }, fieldState: { error } }) => {
+ // return (
+ // <FormControl
+ // label="Expiration"
+ // errorText={error?.message}
+ // isError={Boolean(error)}
+ // >
+ // <Select
+ // defaultValue={field.value}
+ // {...field}
+ // onValueChange={(e) => onChange(e)}
+ // className="w-full"
+ // >
+ // {serviceAccountExpiration.map(({ label, value }) => (
+ // <SelectItem value={String(value)} key={label}>
+ // {label}
+ // </SelectItem>
+ // ))}
+ // </Select>
+ // </FormControl>
+ // );
+ // }}
+ // />
+ // <div className="mt-8 flex items-center">
+ // <Button
+ // className="mr-4"
+ // size="sm"
+ // type="submit"
+ // isLoading={isSubmitting}
+ // isDisabled={isSubmitting}
+ // >
+ // Create Service Account
+ // </Button>
+ // <Button
+ // colorSchema="secondary"
+ // variant="plain"
+ // onClick={() => handlePopUpClose("addServiceAccount")}
+ // >
+ // Cancel
+ // </Button>
+ // </div>
+ // </form>
+ );
+ case 1:
+ return (
+ <>
+ <p>Access Key</p>
+ <div className="flex items-center justify-end rounded-md bg-white/[0.07] p-2 text-base text-gray-400">
+ <p className="mr-4 break-all">{accessKey}</p>
+ <IconButton
+ ariaLabel="copy icon"
+ colorSchema="secondary"
+ className="group relative"
+ onClick={() => {
+ navigator.clipboard.writeText(accessKey);
+ setIsAccessKeyCopied.on();
+ }}
+ >
+ <FontAwesomeIcon icon={isAccessKeyCopied ? faCheck : faCopy} />
+ <span className="absolute -left-8 -top-20 hidden w-28 translate-y-full rounded-md bg-bunker-800 py-2 pl-3 text-center text-sm text-gray-400 group-hover:flex group-hover:animate-fadeIn">
+ Copy
+ </span>
+ </IconButton>
+ </div>
+ <p className="mt-4">Public Key</p>
+ <div className="flex items-center justify-end rounded-md bg-white/[0.07] p-2 text-base text-gray-400">
+ <p className="mr-4 break-all">{publicKey}</p>
+ <IconButton
+ ariaLabel="copy icon"
+ colorSchema="secondary"
+ className="group relative"
+ onClick={() => {
+ navigator.clipboard.writeText(publicKey);
+ setIsPublicKeyCopied.on();
+ }}
+ >
+ <FontAwesomeIcon icon={isPublicKeyCopied ? faCheck : faCopy} />
+ <span className="absolute -left-8 -top-20 hidden w-28 translate-y-full rounded-md bg-bunker-800 py-2 pl-3 text-center text-sm text-gray-400 group-hover:flex group-hover:animate-fadeIn">
+ Copy
+ </span>
+ </IconButton>
+ </div>
+ <p className="mt-4">Private Key</p>
+ <div className="flex items-center justify-end rounded-md bg-white/[0.07] p-2 text-base text-gray-400">
+ <p className="mr-4 break-all">{privateKey}</p>
+ <IconButton
+ ariaLabel="copy icon"
+ colorSchema="secondary"
+ className="group relative"
+ onClick={() => {
+ navigator.clipboard.writeText(privateKey);
+ setIsPrivateKeyCopied.on();
+ }}
+ >
+ <FontAwesomeIcon icon={isPrivateKeyCopied ? faCheck : faCopy} />
+ <span className="absolute -left-8 -top-20 hidden w-28 translate-y-full rounded-md bg-bunker-800 py-2 pl-3 text-center text-sm text-gray-400 group-hover:flex group-hover:animate-fadeIn">
+ Copy
+ </span>
+ </IconButton>
+ </div>
+ </>
+ );
+ default:
+ return <div />;
}
-
- const filteredServiceAccounts = useMemo(
- () =>
- serviceAccounts.filter(
- ({ name }) =>
- name.toLowerCase().includes(searchServiceAccountFilter)
- ),
- [serviceAccounts, searchServiceAccountFilter]
- );
-
- const renderStep = (stepToRender: number) => {
- switch (stepToRender) {
- case 0:
- return (
- <div>
- We are currently revising the service account mechanism. In the meantime,
- please use service tokens or API key to fetch secrets via API request.
- </div>
- // <form onSubmit={handleSubmit(onAddServiceAccount)}>
- // <Controller
- // control={control}
- // defaultValue=""
- // name="name"
- // render={({ field, fieldState: { error } }) => (
- // <FormControl label="Name" isError={Boolean(error)} errorText={error?.message}>
- // <Input {...field} />
- // </FormControl>
- // )}
- // />
- // <Controller
- // control={control}
- // name="expiresIn"
- // defaultValue={String(serviceAccountExpiration?.[0]?.value)}
- // render={({ field: { onChange, ...field }, fieldState: { error } }) => {
- // return (
- // <FormControl
- // label="Expiration"
- // errorText={error?.message}
- // isError={Boolean(error)}
- // >
- // <Select
- // defaultValue={field.value}
- // {...field}
- // onValueChange={(e) => onChange(e)}
- // className="w-full"
- // >
- // {serviceAccountExpiration.map(({ label, value }) => (
- // <SelectItem value={String(value)} key={label}>
- // {label}
- // </SelectItem>
- // ))}
- // </Select>
- // </FormControl>
- // );
- // }}
- // />
- // <div className="mt-8 flex items-center">
- // <Button
- // className="mr-4"
- // size="sm"
- // type="submit"
- // isLoading={isSubmitting}
- // isDisabled={isSubmitting}
- // >
- // Create Service Account
- // </Button>
- // <Button
- // colorSchema="secondary"
- // variant="plain"
- // onClick={() => handlePopUpClose("addServiceAccount")}
- // >
- // Cancel
- // </Button>
- // </div>
- // </form>
- );
- case 1:
+ };
+
+ return (
+ <div className="w-full">
+ <div className="mb-4 flex justify-between">
+ <p className="text-xl font-semibold text-mineshaft-100">Service Accounts</p>
+ <Button
+ colorSchema="secondary"
+ leftIcon={<FontAwesomeIcon icon={faPlus} />}
+ onClick={() => {
+ setStep(0);
+ // reset();
+ handlePopUpOpen("addServiceAccount");
+ }}
+ >
+ Add Service Account
+ </Button>
+ </div>
+ <Input
+ value={searchServiceAccountFilter}
+ onChange={(e) => setSearchServiceAccountFilter(e.target.value)}
+ leftIcon={<FontAwesomeIcon icon={faMagnifyingGlass} />}
+ placeholder="Search service accounts..."
+ />
+ <TableContainer className="mt-4">
+ <Table>
+ <THead>
+ <Th>Name</Th>
+ <Th className="w-full">Valid Until</Th>
+ <Th aria-label="actions" />
+ </THead>
+ <TBody>
+ {isServiceAccountsLoading && (
+ <TableSkeleton columns={5} innerKey="org-service-accounts" />
+ )}
+ {!isServiceAccountsLoading &&
+ filteredServiceAccounts.map(({ name, expiresAt, _id: serviceAccountId }) => {
return (
- <>
- <p>Access Key</p>
- <div className="flex items-center justify-end rounded-md p-2 text-base text-gray-400 bg-white/[0.07]">
- <p className="mr-4 break-all">{accessKey}</p>
- <IconButton
- ariaLabel="copy icon"
- colorSchema="secondary"
- className="group relative"
- onClick={() => {
- navigator.clipboard.writeText(accessKey);
- setIsAccessKeyCopied.on();
- }}
- >
- <FontAwesomeIcon icon={isAccessKeyCopied ? faCheck : faCopy} />
- <span className="absolute -left-8 -top-20 hidden w-28 translate-y-full rounded-md bg-bunker-800 py-2 pl-3 text-center text-sm text-gray-400 group-hover:flex group-hover:animate-fadeIn">
- Copy
- </span>
- </IconButton>
- </div>
- <p className="mt-4">Public Key</p>
- <div className="flex items-center justify-end rounded-md p-2 text-base text-gray-400 bg-white/[0.07]">
- <p className="mr-4 break-all">{publicKey}</p>
- <IconButton
- ariaLabel="copy icon"
- colorSchema="secondary"
- className="group relative"
- onClick={() => {
- navigator.clipboard.writeText(publicKey);
- setIsPublicKeyCopied.on();
- }}
- >
- <FontAwesomeIcon icon={isPublicKeyCopied ? faCheck : faCopy} />
- <span className="absolute -left-8 -top-20 hidden w-28 translate-y-full rounded-md bg-bunker-800 py-2 pl-3 text-center text-sm text-gray-400 group-hover:flex group-hover:animate-fadeIn">
- Copy
- </span>
- </IconButton>
- </div>
- <p className="mt-4">Private Key</p>
- <div className="flex items-center justify-end rounded-md p-2 text-base text-gray-400 bg-white/[0.07]">
- <p className="mr-4 break-all">{privateKey}</p>
- <IconButton
- ariaLabel="copy icon"
- colorSchema="secondary"
- className="group relative"
- onClick={() => {
- navigator.clipboard.writeText(privateKey);
- setIsPrivateKeyCopied.on();
- }}
- >
- <FontAwesomeIcon icon={isPrivateKeyCopied ? faCheck : faCopy} />
- <span className="absolute -left-8 -top-20 hidden w-28 translate-y-full rounded-md bg-bunker-800 py-2 pl-3 text-center text-sm text-gray-400 group-hover:flex group-hover:animate-fadeIn">
- Copy
- </span>
- </IconButton>
- </div>
-
- </>
+ <Tr key={`org-service-account-${serviceAccountId}`}>
+ <Td>{name}</Td>
+ <Td>{new Date(expiresAt).toUTCString()}</Td>
+ <Td>
+ <div className="flex">
+ <IconButton
+ ariaLabel="edit"
+ colorSchema="secondary"
+ onClick={() => {
+ if (currentWorkspace?._id) {
+ router.push(
+ `/settings/org/${currentWorkspace._id}/service-accounts/${serviceAccountId}`
+ );
+ }
+ }}
+ className="mr-2"
+ >
+ <FontAwesomeIcon icon={faPencil} />
+ </IconButton>
+ <IconButton
+ ariaLabel="delete"
+ colorSchema="danger"
+ onClick={() =>
+ handlePopUpOpen("removeServiceAccount", { _id: serviceAccountId })
+ }
+ >
+ <FontAwesomeIcon icon={faTrash} />
+ </IconButton>
+ </div>
+ </Td>
+ </Tr>
);
- default:
- return <div />
- }
- }
-
- return (
- <div className="w-full">
- <div className="flex justify-between mb-4">
- <p className="text-xl font-semibold text-mineshaft-100">Service Accounts</p>
- <Button
- colorSchema="secondary"
- leftIcon={<FontAwesomeIcon icon={faPlus} />}
- onClick={() => {
- setStep(0);
- // reset();
- handlePopUpOpen("addServiceAccount");
- }}
- >
- Add Service Account
- </Button>
- </div>
- <Input
- value={searchServiceAccountFilter}
- onChange={(e) => setSearchServiceAccountFilter(e.target.value)}
- leftIcon={<FontAwesomeIcon icon={faMagnifyingGlass} />}
- placeholder="Search service accounts..."
- />
- <TableContainer className="mt-4">
- <Table>
- <THead>
- <Th>Name</Th>
- <Th className="w-full">Valid Until</Th>
- <Th aria-label="actions" />
- </THead>
- <TBody>
- {isServiceAccountsLoading && <TableSkeleton columns={5} key="org-service-accounts" />}
- {!isServiceAccountsLoading && (
- filteredServiceAccounts.map(({
- name,
- expiresAt,
- _id: serviceAccountId
- }) => {
- return (
- <Tr key={`org-service-account-${serviceAccountId}`}>
- <Td>{name}</Td>
- <Td>{new Date(expiresAt).toUTCString()}</Td>
- <Td>
- <div className="flex">
- <IconButton
- ariaLabel="edit"
- colorSchema="secondary"
- onClick={() => {
- if (currentWorkspace?._id) {
- router.push(`/settings/org/${currentWorkspace._id}/service-accounts/${serviceAccountId}`);
- }
- }}
- className="mr-2"
- >
- <FontAwesomeIcon icon={faPencil} />
- </IconButton>
- <IconButton
- ariaLabel="delete"
- colorSchema="danger"
- onClick={() => handlePopUpOpen("removeServiceAccount", { _id: serviceAccountId })}
- >
- <FontAwesomeIcon icon={faTrash} />
- </IconButton>
- </div>
- </Td>
- </Tr>
- );
- })
- )}
- </TBody>
- </Table>
- {!isServiceAccountsLoading && filteredServiceAccounts?.length === 0 && (
- <EmptyState title="No service accounts found" icon={faServer} />
- )}
- </TableContainer>
- <Modal
- isOpen={popUp?.addServiceAccount?.isOpen}
- onOpenChange={(isOpen) => {
- handlePopUpToggle("addServiceAccount", isOpen);
- // reset();
- }}
- >
- <ModalContent
- title="Add Service Account"
- subTitle="A service account represents a machine identity such as a VM or application client."
- >
- {renderStep(step)}
- </ModalContent>
- </Modal>
- <DeleteActionModal
- isOpen={popUp.removeServiceAccount.isOpen}
- deleteKey="remove"
- title="Do you want to remove this service account from the org?"
- onChange={(isOpen) => handlePopUpToggle("removeServiceAccount", isOpen)}
- onDeleteApproved={onRemoveServiceAccount}
- />
- </div>
- );
-}
\ No newline at end of file
+ })}
+ </TBody>
+ </Table>
+ {!isServiceAccountsLoading && filteredServiceAccounts?.length === 0 && (
+ <EmptyState title="No service accounts found" icon={faServer} />
+ )}
+ </TableContainer>
+ <Modal
+ isOpen={popUp?.addServiceAccount?.isOpen}
+ onOpenChange={(isOpen) => {
+ handlePopUpToggle("addServiceAccount", isOpen);
+ // reset();
+ }}
+ >
+ <ModalContent
+ title="Add Service Account"
+ subTitle="A service account represents a machine identity such as a VM or application client."
+ >
+ {renderStep(step)}
+ </ModalContent>
+ </Modal>
+ <DeleteActionModal
+ isOpen={popUp.removeServiceAccount.isOpen}
+ deleteKey="remove"
+ title="Do you want to remove this service account from the org?"
+ onChange={(isOpen) => handlePopUpToggle("removeServiceAccount", isOpen)}
+ onDeleteApproved={onRemoveServiceAccount}
+ />
+ </div>
+ );
+};
diff --git a/frontend/src/views/Settings/PersonalSettingsPage/APIKeySection/APIKeyTable.tsx b/frontend/src/views/Settings/PersonalSettingsPage/APIKeySection/APIKeyTable.tsx
index 5efaf12813..40a309eb0b 100644
--- a/frontend/src/views/Settings/PersonalSettingsPage/APIKeySection/APIKeyTable.tsx
+++ b/frontend/src/views/Settings/PersonalSettingsPage/APIKeySection/APIKeyTable.tsx
@@ -1,4 +1,4 @@
-import { faKey,faXmark } from "@fortawesome/free-solid-svg-icons";
+import { faKey, faXmark } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider";
@@ -14,99 +14,91 @@ import {
THead,
Tr
} from "@app/components/v2";
-import {
- useDeleteAPIKey,
- useGetMyAPIKeys} from "@app/hooks/api";
+import { useDeleteAPIKey, useGetMyAPIKeys } from "@app/hooks/api";
export const APIKeyTable = () => {
- const { createNotification } = useNotificationContext();
- const { data, isLoading } = useGetMyAPIKeys();
- const { mutateAsync } = useDeleteAPIKey();
+ const { createNotification } = useNotificationContext();
+ const { data, isLoading } = useGetMyAPIKeys();
+ const { mutateAsync } = useDeleteAPIKey();
- const handleDeleteAPIKeyDataClick = async (apiKeyDataId: string) => {
- try {
- await mutateAsync(apiKeyDataId);
- createNotification({
- text: "Successfully deleted API key",
- type: "success"
- });
- } catch (err) {
- console.error(err);
- createNotification({
- text: "Failed to delete API key",
- type: "error"
- });
- }
- }
-
- const formatDate = (dateToFormat: string) => {
- const date = new Date(dateToFormat);
- const year = date.getFullYear();
- const month = date.getMonth() + 1;
- const day = date.getDate();
-
- const formattedDate = `${day}/${month}/${year}`;
-
- return formattedDate;
+ const handleDeleteAPIKeyDataClick = async (apiKeyDataId: string) => {
+ try {
+ await mutateAsync(apiKeyDataId);
+ createNotification({
+ text: "Successfully deleted API key",
+ type: "success"
+ });
+ } catch (err) {
+ console.error(err);
+ createNotification({
+ text: "Failed to delete API key",
+ type: "error"
+ });
}
-
- return (
- <div>
- <TableContainer className="">
- <Table>
- <THead>
- <Tr>
- <Th className="flex-1">Name</Th>
- <Th className="flex-1">Last active</Th>
- <Th className="flex-1">Created</Th>
- <Th className="flex-1">Expiration</Th>
- <Th className="w-5" />
- </Tr>
- </THead>
- <TBody>
- {isLoading && <TableSkeleton columns={4} key="api-keys" />}
- {!isLoading && data && data.length > 0 && data.map(({
- _id,
- name,
- createdAt,
- expiresAt,
- lastUsed
- }) => {
- return (
- <Tr className="h-10" key={`api-key-${_id}`}>
- <Td>{name}</Td>
- <Td>{formatDate(lastUsed)}</Td>
- <Td>{formatDate(createdAt)}</Td>
- <Td>{formatDate(expiresAt)}</Td>
- <Td>
- <IconButton
- onClick={async () => {
- await handleDeleteAPIKeyDataClick(_id);
- }}
- size="lg"
- colorSchema="danger"
- variant="plain"
- ariaLabel="update"
- >
- <FontAwesomeIcon icon={faXmark} />
- </IconButton>
- </Td>
- </Tr>
- );
- })}
- {!isLoading && data && data?.length === 0 && (
- <Tr>
- <Td colSpan={5}>
- <EmptyState
- title="No API Keys on file"
- icon={faKey}
- />
- </Td>
- </Tr>
- )}
- </TBody>
- </Table>
- </TableContainer>
- </div>
- );
-}
\ No newline at end of file
+ };
+
+ const formatDate = (dateToFormat: string) => {
+ const date = new Date(dateToFormat);
+ const year = date.getFullYear();
+ const month = date.getMonth() + 1;
+ const day = date.getDate();
+
+ const formattedDate = `${day}/${month}/${year}`;
+
+ return formattedDate;
+ };
+
+ return (
+ <div>
+ <TableContainer className="">
+ <Table>
+ <THead>
+ <Tr>
+ <Th className="flex-1">Name</Th>
+ <Th className="flex-1">Last active</Th>
+ <Th className="flex-1">Created</Th>
+ <Th className="flex-1">Expiration</Th>
+ <Th className="w-5" />
+ </Tr>
+ </THead>
+ <TBody>
+ {isLoading && <TableSkeleton columns={4} innerKey="api-keys" />}
+ {!isLoading &&
+ data &&
+ data.length > 0 &&
+ data.map(({ _id, name, createdAt, expiresAt, lastUsed }) => {
+ return (
+ <Tr className="h-10" key={`api-key-${_id}`}>
+ <Td>{name}</Td>
+ <Td>{formatDate(lastUsed)}</Td>
+ <Td>{formatDate(createdAt)}</Td>
+ <Td>{formatDate(expiresAt)}</Td>
+ <Td>
+ <IconButton
+ onClick={async () => {
+ await handleDeleteAPIKeyDataClick(_id);
+ }}
+ size="lg"
+ colorSchema="danger"
+ variant="plain"
+ ariaLabel="update"
+ >
+ <FontAwesomeIcon icon={faXmark} />
+ </IconButton>
+ </Td>
+ </Tr>
+ );
+ })}
+ {!isLoading && data && data?.length === 0 && (
+ <Tr>
+ <Td colSpan={5}>
+ <EmptyState title="No API Keys on file" icon={faKey} />
+ </Td>
+ </Tr>
+ )}
+ </TBody>
+ </Table>
+ </TableContainer>
+ </div>
+ );
+};
diff --git a/frontend/src/views/Settings/PersonalSettingsPage/SessionsSection/SessionsTable.tsx b/frontend/src/views/Settings/PersonalSettingsPage/SessionsSection/SessionsTable.tsx
index b497711658..8a964b8d64 100644
--- a/frontend/src/views/Settings/PersonalSettingsPage/SessionsSection/SessionsTable.tsx
+++ b/frontend/src/views/Settings/PersonalSettingsPage/SessionsSection/SessionsTable.tsx
@@ -14,61 +14,54 @@ import {
import { useGetMySessions } from "@app/hooks/api";
export const SessionsTable = () => {
- const { data, isLoading } = useGetMySessions();
+ const { data, isLoading } = useGetMySessions();
- const formatDate = (dateToFormat: string) => {
- const date = new Date(dateToFormat);
- const year = date.getFullYear();
- const month = date.getMonth() + 1;
- const day = date.getDate();
-
- const formattedDate = `${day}/${month}/${year}`;
-
- return formattedDate;
- }
-
- return (
- <TableContainer className="mt-4">
- <Table>
- <THead>
- <Tr>
- <Th>Created</Th>
- <Th>Last active</Th>
- <Th>IP address</Th>
- <Th>Device</Th>
- </Tr>
- </THead>
- <TBody>
- {isLoading && <TableSkeleton columns={4} key="sesssions" />}
- {!isLoading && data && data.length > 0 && data.map(({
- _id,
- createdAt,
- lastUsed,
- ip,
- userAgent
- }) => {
- return (
- <Tr className="h-10" key={`session-${_id}`}>
- <Td>{formatDate(createdAt)}</Td>
- <Td>{formatDate(lastUsed)}</Td>
- <Td>{ip}</Td>
- <Td>{userAgent}</Td>
- </Tr>
- );
- })}
- {!isLoading && data && data?.length === 0 && (
- <Tr>
- <Td colSpan={4}>
- <EmptyState
- title="No sessions on file"
- icon={faServer}
- />
- </Td>
- </Tr>
- )}
- </TBody>
- </Table>
-
- </TableContainer>
- );
-}
\ No newline at end of file
+ const formatDate = (dateToFormat: string) => {
+ const date = new Date(dateToFormat);
+ const year = date.getFullYear();
+ const month = date.getMonth() + 1;
+ const day = date.getDate();
+
+ const formattedDate = `${day}/${month}/${year}`;
+
+ return formattedDate;
+ };
+
+ return (
+ <TableContainer className="mt-4">
+ <Table>
+ <THead>
+ <Tr>
+ <Th>Created</Th>
+ <Th>Last active</Th>
+ <Th>IP address</Th>
+ <Th>Device</Th>
+ </Tr>
+ </THead>
+ <TBody>
+ {isLoading && <TableSkeleton columns={4} innerKey="sesssions" />}
+ {!isLoading &&
+ data &&
+ data.length > 0 &&
+ data.map(({ _id, createdAt, lastUsed, ip, userAgent }) => {
+ return (
+ <Tr className="h-10" key={`session-${_id}`}>
+ <Td>{formatDate(createdAt)}</Td>
+ <Td>{formatDate(lastUsed)}</Td>
+ <Td>{ip}</Td>
+ <Td>{userAgent}</Td>
+ </Tr>
+ );
+ })}
+ {!isLoading && data && data?.length === 0 && (
+ <Tr>
+ <Td colSpan={4}>
+ <EmptyState title="No sessions on file" icon={faServer} />
+ </Td>
+ </Tr>
+ )}
+ </TBody>
+ </Table>
+ </TableContainer>
+ );
+};
diff --git a/frontend/src/views/Settings/ProjectSettingsPage/components/EnvironmentSection/EnvironmentTable.tsx b/frontend/src/views/Settings/ProjectSettingsPage/components/EnvironmentSection/EnvironmentTable.tsx
index 4e901989d8..e749e4e9a8 100644
--- a/frontend/src/views/Settings/ProjectSettingsPage/components/EnvironmentSection/EnvironmentTable.tsx
+++ b/frontend/src/views/Settings/ProjectSettingsPage/components/EnvironmentSection/EnvironmentTable.tsx
@@ -11,79 +11,79 @@ import {
Td,
Th,
THead,
- Tr,
+ Tr
} from "@app/components/v2";
import { useWorkspace } from "@app/context";
import { UsePopUpState } from "@app/hooks/usePopUp";
type Props = {
- handlePopUpOpen: (
- popUpName: keyof UsePopUpState<["updateEnv", "deleteEnv", "upgradePlan"]>,
- {
- name,
- slug
- }: {
- name: string;
- slug: string;
- }
- ) => void;
+ handlePopUpOpen: (
+ popUpName: keyof UsePopUpState<["updateEnv", "deleteEnv", "upgradePlan"]>,
+ {
+ name,
+ slug
+ }: {
+ name: string;
+ slug: string;
+ }
+ ) => void;
};
-export const EnvironmentTable = ({
- handlePopUpOpen
-}: Props) => {
- const { currentWorkspace, isLoading } = useWorkspace();
- return (
- <TableContainer>
- <Table>
- <THead>
- <Tr>
- <Th>Name</Th>
- <Th>Slug</Th>
- <Th aria-label="button" />
- </Tr>
- </THead>
- <TBody>
- {isLoading && <TableSkeleton columns={3} key="project-envs" />}
- {!isLoading && currentWorkspace && currentWorkspace.environments.map(({ name, slug }) => (
- <Tr key={name}>
- <Td>{name}</Td>
- <Td>{slug}</Td>
- <Td className="flex items-center justify-end">
- <IconButton
- className="mr-3 py-2"
- onClick={() => {
- handlePopUpOpen("updateEnv", { name, slug });
- }}
- colorSchema="primary"
- variant="plain"
- ariaLabel="update"
- >
- <FontAwesomeIcon icon={faPencil} />
- </IconButton>
- <IconButton
- onClick={() => {
- handlePopUpOpen("deleteEnv", { name, slug });
- }}
- size="lg"
- colorSchema="danger"
- variant="plain"
- ariaLabel="update"
- >
- <FontAwesomeIcon icon={faXmark} />
- </IconButton>
- </Td>
- </Tr>
- ))}
- {!isLoading && currentWorkspace && currentWorkspace.environments?.length === 0 && (
- <Tr>
- <Td colSpan={3}>
- <EmptyState title="No environments found" />
- </Td>
- </Tr>
- )}
- </TBody>
- </Table>
- </TableContainer>
- );
-}
\ No newline at end of file
+export const EnvironmentTable = ({ handlePopUpOpen }: Props) => {
+ const { currentWorkspace, isLoading } = useWorkspace();
+ return (
+ <TableContainer>
+ <Table>
+ <THead>
+ <Tr>
+ <Th>Name</Th>
+ <Th>Slug</Th>
+ <Th aria-label="button" />
+ </Tr>
+ </THead>
+ <TBody>
+ {isLoading && <TableSkeleton columns={3} innerKey="project-envs" />}
+ {!isLoading &&
+ currentWorkspace &&
+ currentWorkspace.environments.map(({ name, slug }) => (
+ <Tr key={name}>
+ <Td>{name}</Td>
+ <Td>{slug}</Td>
+ <Td className="flex items-center justify-end">
+ <IconButton
+ className="mr-3 py-2"
+ onClick={() => {
+ handlePopUpOpen("updateEnv", { name, slug });
+ }}
+ colorSchema="primary"
+ variant="plain"
+ ariaLabel="update"
+ >
+ <FontAwesomeIcon icon={faPencil} />
+ </IconButton>
+ <IconButton
+ onClick={() => {
+ handlePopUpOpen("deleteEnv", { name, slug });
+ }}
+ size="lg"
+ colorSchema="danger"
+ variant="plain"
+ ariaLabel="update"
+ >
+ <FontAwesomeIcon icon={faXmark} />
+ </IconButton>
+ </Td>
+ </Tr>
+ ))}
+ {!isLoading && currentWorkspace && currentWorkspace.environments?.length === 0 && (
+ <Tr>
+ <Td colSpan={3}>
+ <EmptyState title="No environments found" />
+ </Td>
+ </Tr>
+ )}
+ </TBody>
+ </Table>
+ </TableContainer>
+ );
+};
diff --git a/frontend/src/views/Settings/ProjectSettingsPage/components/SecretTagsSection/SecretTagsTable.tsx b/frontend/src/views/Settings/ProjectSettingsPage/components/SecretTagsSection/SecretTagsTable.tsx
index 0279cf62ba..cb8a0afd4b 100644
--- a/frontend/src/views/Settings/ProjectSettingsPage/components/SecretTagsSection/SecretTagsTable.tsx
+++ b/frontend/src/views/Settings/ProjectSettingsPage/components/SecretTagsSection/SecretTagsTable.tsx
@@ -18,65 +18,65 @@ import { useGetWsTags } from "@app/hooks/api";
import { UsePopUpState } from "@app/hooks/usePopUp";
type Props = {
- handlePopUpOpen: (
- popUpName: keyof UsePopUpState<["deleteTagConfirmation"]>,
- {
- name,
- id
- }: {
- name: string;
- id: string;
- }
- ) => void;
+ handlePopUpOpen: (
+ popUpName: keyof UsePopUpState<["deleteTagConfirmation"]>,
+ {
+ name,
+ id
+ }: {
+ name: string;
+ id: string;
+ }
+ ) => void;
};
-export const SecretTagsTable = ({
- handlePopUpOpen
-}: Props) => {
- const { currentWorkspace }= useWorkspace();
- const { data, isLoading } = useGetWsTags(currentWorkspace?._id ?? "");
+export const SecretTagsTable = ({ handlePopUpOpen }: Props) => {
+ const { currentWorkspace } = useWorkspace();
+ const { data, isLoading } = useGetWsTags(currentWorkspace?._id ?? "");
- return (
- <TableContainer className="mt-4">
- <Table>
- <THead>
- <Tr>
- <Th>Tag</Th>
- <Th>Slug</Th>
- <Th aria-label="button" />
- </Tr>
- </THead>
- <TBody>
- {isLoading && <TableSkeleton columns={3} key="secret-tags" />}
- {!isLoading && data && data.map(({ _id, name, slug }) => (
- <Tr key={name}>
- <Td>{name}</Td>
- <Td>{slug}</Td>
- <Td className="flex items-center justify-end">
- <IconButton
- onClick={() =>
- handlePopUpOpen("deleteTagConfirmation", {
- name,
- id: _id
- })
- }
- colorSchema="danger"
- ariaLabel="update"
- >
- <FontAwesomeIcon icon={faTrashCan} />
- </IconButton>
- </Td>
- </Tr>
- ))}
- {!isLoading && data && data?.length === 0 && (
- <Tr>
- <Td colSpan={3}>
- <EmptyState title="No secret tags found" icon={faTags} />
+ return (
+ <TableContainer className="mt-4">
+ <Table>
+ <THead>
+ <Tr>
+ <Th>Tag</Th>
+ <Th>Slug</Th>
+ <Th aria-label="button" />
+ </Tr>
+ </THead>
+ <TBody>
+ {isLoading && <TableSkeleton columns={3} innerKey="secret-tags" />}
+ {!isLoading &&
+ data &&
+ data.map(({ _id, name, slug }) => (
+ <Tr key={name}>
+ <Td>{name}</Td>
+ <Td>{slug}</Td>
+ <Td className="flex items-center justify-end">
+ <IconButton
+ onClick={() =>
+ handlePopUpOpen("deleteTagConfirmation", {
+ name,
+ id: _id
+ })
+ }
+ colorSchema="danger"
+ ariaLabel="update"
+ >
+ <FontAwesomeIcon icon={faTrashCan} />
+ </IconButton>
</Td>
</Tr>
- )}
- </TBody>
- </Table>
- </TableContainer>
- );
-}
\ No newline at end of file
+ ))}
+ {!isLoading && data && data?.length === 0 && (
+ <Tr>
+ <Td colSpan={3}>
+ <EmptyState title="No secret tags found" icon={faTags} />
+ </Td>
+ </Tr>
+ )}
+ </TBody>
+ </Table>
+ </TableContainer>
+ );
+};
diff --git a/frontend/src/views/Settings/ProjectSettingsPage/components/ServiceTokenSection/ServiceTokenTable.tsx b/frontend/src/views/Settings/ProjectSettingsPage/components/ServiceTokenSection/ServiceTokenTable.tsx
index ce39abde2a..8c40cef358 100644
--- a/frontend/src/views/Settings/ProjectSettingsPage/components/ServiceTokenSection/ServiceTokenTable.tsx
+++ b/frontend/src/views/Settings/ProjectSettingsPage/components/ServiceTokenSection/ServiceTokenTable.tsx
@@ -48,7 +48,7 @@ export const ServiceTokenTable = ({ handlePopUpOpen }: Props) => {
</Tr>
</THead>
<TBody>
- {isLoading && <TableSkeleton columns={4} key="project-service-tokens" />}
+ {isLoading && <TableSkeleton columns={4} innerKey="project-service-tokens" />}
{!isLoading &&
data &&
data.map((row) => (
diff --git a/frontend/src/views/Settings/ProjectSettingsPage/components/WebhooksTab/WebhooksTab.tsx b/frontend/src/views/Settings/ProjectSettingsPage/components/WebhooksTab/WebhooksTab.tsx
index 76b928ace3..598af03603 100644
--- a/frontend/src/views/Settings/ProjectSettingsPage/components/WebhooksTab/WebhooksTab.tsx
+++ b/frontend/src/views/Settings/ProjectSettingsPage/components/WebhooksTab/WebhooksTab.tsx
@@ -160,7 +160,7 @@ export const WebhooksTab = () => {
</Tr>
</THead>
<TBody>
- {isWebhooksLoading && <TableSkeleton columns={5} key="webhooks-loading" />}
+ {isWebhooksLoading && <TableSkeleton columns={5} innerKey="webhooks-loading" />}
{!isWebhooksLoading && webhooks && webhooks?.length === 0 && (
<Tr>
<Td colSpan={5}>