From aaba4a0895bc14a676834a5e94b0bd16be52b2d5 Mon Sep 17 00:00:00 2001 From: Akhil Mohan Date: Fri, 8 Dec 2023 11:21:40 +0530 Subject: [PATCH] feat(infisical-pg): changed frontend api types _id to normal id --- frontend/package.json | 2 +- frontend/public/data/frequentInterfaces.ts | 4 +- .../AddTagPopoverContent.tsx | 10 +- .../components/basic/dialog/UpgradePlan.tsx | 69 +- .../basic/table/ProjectUsersTable.tsx | 42 +- .../src/components/dashboard/AddTagsMenu.tsx | 66 +- frontend/src/components/dashboard/KeyPair.tsx | 240 +++-- .../src/components/navigation/NavHeader.tsx | 2 +- .../tags/CreateTagModal/CreateTagModal.tsx | 30 +- .../src/components/utilities/config/index.ts | 10 +- .../components/utilities/intercom/intercom.ts | 6 +- .../OrgPermissionContext.tsx | 4 +- .../OrganizationContext.tsx | 3 +- .../ProjectPermissionContext.tsx | 4 +- .../ServerConfigContext.tsx | 8 +- .../src/context/UserContext/UserContext.tsx | 4 +- .../WorkspaceContext/WorkspaceContext.tsx | 2 +- frontend/src/helpers/project.ts | 8 +- frontend/src/hooks/api/apiKeys/types.ts | 36 +- frontend/src/hooks/api/auditLogs/types.tsx | 12 +- .../src/hooks/api/integrationAuth/types.ts | 6 +- frontend/src/hooks/api/integrations/types.ts | 4 +- frontend/src/hooks/api/organization/types.ts | 26 +- frontend/src/hooks/api/serviceTokens/types.ts | 4 +- frontend/src/hooks/api/tags/types.ts | 23 +- frontend/src/hooks/api/trustedIps/types.ts | 16 +- frontend/src/hooks/api/types.ts | 2 +- frontend/src/hooks/api/users/queries.tsx | 5 +- frontend/src/hooks/api/users/types.ts | 18 +- frontend/src/hooks/api/workspace/types.ts | 5 +- .../src/layouts/AdminLayout/AdminLayout.tsx | 4 +- frontend/src/layouts/AppLayout/AppLayout.tsx | 94 +- .../AppLayout/components/NavBar/NavBar.tsx | 422 ++++---- .../secret-scanning/getRisksByOrganization.ts | 24 +- frontend/src/pages/dashboard.tsx | 6 +- .../aws-parameter-store/authorize.tsx | 27 +- .../aws-parameter-store/create.tsx | 95 +- .../aws-secret-manager/authorize.tsx | 15 +- .../aws-secret-manager/create.tsx | 88 +- .../integrations/azure-key-vault/create.tsx | 4 +- .../azure-key-vault/oauth2/callback.tsx | 8 +- .../pages/integrations/bitbucket/create.tsx | 10 +- .../bitbucket/oauth2/callback.tsx | 4 +- .../pages/integrations/checkly/authorize.tsx | 21 +- .../src/pages/integrations/checkly/create.tsx | 86 +- .../pages/integrations/circleci/authorize.tsx | 21 +- .../pages/integrations/circleci/create.tsx | 98 +- .../pages/integrations/cloud-66/authorize.tsx | 4 +- .../pages/integrations/cloud-66/create.tsx | 12 +- .../cloudflare-pages/authorize.tsx | 164 +-- .../integrations/cloudflare-pages/create.tsx | 286 ++--- .../cloudflare-workers/authorize.tsx | 149 ++- .../cloudflare-workers/create.tsx | 240 ++--- .../integrations/codefresh/authorize.tsx | 4 +- .../pages/integrations/codefresh/create.tsx | 8 +- .../digital-ocean-app-platform/authorize.tsx | 10 +- .../digital-ocean-app-platform/create.tsx | 8 +- .../pages/integrations/flyio/authorize.tsx | 52 +- .../src/pages/integrations/flyio/create.tsx | 96 +- .../gcp-secret-manager/authorize.tsx | 87 +- .../gcp-secret-manager/create.tsx | 288 +++-- .../gcp-secret-manager/oauth2/callback.tsx | 16 +- .../src/pages/integrations/github/create.tsx | 159 ++- .../integrations/github/oauth2/callback.tsx | 4 +- .../pages/integrations/gitlab/authorize.tsx | 61 +- .../src/pages/integrations/gitlab/create.tsx | 290 +++--- .../integrations/gitlab/oauth2/callback.tsx | 14 +- .../hashicorp-vault/authorize.tsx | 81 +- .../integrations/hashicorp-vault/create.tsx | 87 +- .../src/pages/integrations/heroku/create.tsx | 4 +- .../integrations/heroku/oauth2/callback.tsx | 4 +- .../integrations/laravel-forge/authorize.tsx | 18 +- .../integrations/laravel-forge/create.tsx | 9 +- .../src/pages/integrations/netlify/create.tsx | 8 +- .../integrations/netlify/oauth2/callback.tsx | 4 +- .../integrations/northflank/authorize.tsx | 4 +- .../pages/integrations/northflank/create.tsx | 17 +- .../pages/integrations/qovery/authorize.tsx | 21 +- .../src/pages/integrations/qovery/create.tsx | 303 +++--- .../pages/integrations/railway/authorize.tsx | 4 +- .../src/pages/integrations/railway/create.tsx | 4 +- .../pages/integrations/render/authorize.tsx | 19 +- .../src/pages/integrations/render/create.tsx | 98 +- .../pages/integrations/supabase/authorize.tsx | 4 +- .../pages/integrations/supabase/create.tsx | 8 +- .../pages/integrations/teamcity/authorize.tsx | 23 +- .../pages/integrations/teamcity/create.tsx | 91 +- .../terraform-cloud/authorize.tsx | 18 +- .../integrations/terraform-cloud/create.tsx | 39 +- .../pages/integrations/travisci/authorize.tsx | 4 +- .../pages/integrations/travisci/create.tsx | 8 +- .../src/pages/integrations/vercel/create.tsx | 93 +- .../integrations/vercel/oauth2/callback.tsx | 6 +- .../pages/integrations/windmill/authorize.tsx | 59 +- .../pages/integrations/windmill/create.tsx | 8 +- .../src/pages/org/[id]/overview/index.tsx | 16 +- .../pages/org/[id]/secret-scanning/index.tsx | 22 +- frontend/src/pages/signup/index.tsx | 2 +- .../IntegrationsSection.tsx | 3 +- frontend/src/views/Login/Login.utils.tsx | 34 +- .../src/views/Org/MembersPage/MembersPage.tsx | 14 +- .../OrgMembersTable/OrgMembersTable.tsx | 577 ++++++++++ .../OrgRoleModifySection.tsx | 12 +- .../OrgRoleTabSection/OrgRoleTable.tsx | 10 +- .../views/Org/components/CreateOrgModal.tsx | 6 +- .../AuditLogsPage/components/LogsFilter.tsx | 16 +- .../AuditLogsPage/components/LogsTable.tsx | 4 +- .../AuditLogsPage/components/LogsTableRow.tsx | 701 ++++++------- .../components/IPAllowlistModal.tsx | 316 +++--- .../components/IPAllowlistSection.tsx | 6 +- .../MemberListTab/MemberListTab.tsx | 81 +- .../ProjectRoleList/ProjectRoleList.tsx | 12 +- .../ProjectRoleModifySection.tsx | 10 +- .../AddServiceTokenV3Modal.tsx | 984 +++++++++--------- .../ServiceTokenV3Table.tsx | 192 ++-- .../SecretApprovalPage/SecretApprovalPage.tsx | 23 +- .../SecretApprovalPolicyList.tsx | 6 +- .../components/SecretApprovalPolicyRow.tsx | 14 +- .../components/SecretPolicyForm.tsx | 20 +- .../SecretApprovalRequest.tsx | 20 +- .../SecretApprovalRequestChangeItem.tsx | 22 +- .../SecretApprovalRequestChanges.tsx | 6 +- .../views/SecretMainPage/SecretMainPage.tsx | 10 +- .../components/ActionBar/ActionBar.tsx | 16 +- .../SecretDropzone/CopySecretsFromBoard.tsx | 4 +- .../SecretListView/SecretDetaiSidebar.tsx | 16 +- .../SecretListView/SecretListView.tsx | 16 +- .../components/SnapshotView/SecretItem.tsx | 18 +- .../components/SnapshotView/SnapshotView.tsx | 16 +- .../SecretRotationPage/SecretRotationPage.tsx | 56 +- .../steps/RotationOutputForm.tsx | 7 +- .../BillingCloudTab/PreviewSection.tsx | 45 +- .../BillingDetailsTab/CompanyNameSection.tsx | 10 +- .../BillingDetailsTab/InvoiceEmailSection.tsx | 10 +- .../BillingDetailsTab/PmtMethodsSection.tsx | 10 +- .../BillingDetailsTab/PmtMethodsTable.tsx | 12 +- .../BillingDetailsTab/TaxIDModal.tsx | 205 ++-- .../BillingDetailsTab/TaxIDTable.tsx | 12 +- .../BillingReceiptsTab/InvoicesTable.tsx | 6 +- .../BillingSelfHostedTab/LicensesSection.tsx | 99 +- .../components/OrgAuthTab/OrgSSOSection.tsx | 22 +- .../components/OrgAuthTab/SSOModal.tsx | 487 +++++---- .../OrgDeleteSection/OrgDeleteSection.tsx | 4 +- .../OrgNameChangeSection.tsx | 4 +- .../APIKeySection/APIKeyTable.tsx | 6 +- .../APIKeyV2Section/APIKeyV2Table.tsx | 185 ++-- .../SessionsSection/SessionsTable.tsx | 4 +- .../UserNameSection/UserNameSection.tsx | 55 +- .../AutoCapitalizationSection.tsx | 6 +- .../DeleteProjectSection.tsx | 77 +- .../components/E2EESection/E2EESection.tsx | 14 +- .../AddEnvironmentModal.tsx | 191 ++-- .../EnvironmentSection/EnvironmentSection.tsx | 10 +- .../EnvironmentSection/EnvironmentTable.tsx | 4 +- .../UpdateEnvironmentModal.tsx | 201 ++-- .../ProjectNameChangeSection.tsx | 8 +- .../SecretTagsSection/AddSecretTagModal.tsx | 186 ++-- .../SecretTagsSection/SecretTagsTable.tsx | 6 +- .../components/WebhooksTab/WebhooksTab.tsx | 4 +- .../admin/DashboardPage/DashboardPage.tsx | 2 +- frontend/tsconfig.tsbuildinfo | 1 + 161 files changed, 5359 insertions(+), 4511 deletions(-) create mode 100644 frontend/src/views/Org/MembersPage/components/OrgMembersTable/OrgMembersTable.tsx create mode 100644 frontend/tsconfig.tsbuildinfo diff --git a/frontend/package.json b/frontend/package.json index 0d6fded0f..6ea8e499d 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -8,7 +8,7 @@ "start:docker": "next build && next start", "lint": "eslint --ext js,ts,tsx ./src", "lint:fix": "eslint --fix --ext js,ts,tsx ./src", - "type-check": "tsc --project tsconfig.json", + "type:check": "tsc --project tsconfig.json --noEmit", "storybook": "storybook dev -p 6006 -s ./public", "build-storybook": "storybook build" }, diff --git a/frontend/public/data/frequentInterfaces.ts b/frontend/public/data/frequentInterfaces.ts index 953096e1d..eb40782da 100644 --- a/frontend/public/data/frequentInterfaces.ts +++ b/frontend/public/data/frequentInterfaces.ts @@ -1,5 +1,5 @@ export interface Tag { - _id: string; + id: string; name: string; slug: string; user: string; @@ -16,4 +16,4 @@ export interface SecretDataProps { idOverride?: string; comment: string; tags: Tag[]; -} \ No newline at end of file +} diff --git a/frontend/src/components/AddTagPopoverContent/AddTagPopoverContent.tsx b/frontend/src/components/AddTagPopoverContent/AddTagPopoverContent.tsx index d69cc76c8..56bee047f 100644 --- a/frontend/src/components/AddTagPopoverContent/AddTagPopoverContent.tsx +++ b/frontend/src/components/AddTagPopoverContent/AddTagPopoverContent.tsx @@ -31,18 +31,18 @@ const AddTagPopoverContent = ({ return (
Add tags to {secKey || "this secret"}
-
+
{wsTags?.map((wsTag: WsTag) => (
handleSelectTag(wsTag)} onMouseEnter={() => handleTagOnMouseEnter(wsTag)} onMouseLeave={() => handleTagOnMouseLeave()} @@ -54,7 +54,7 @@ const AddTagPopoverContent = ({
{" "} diff --git a/frontend/src/components/basic/dialog/UpgradePlan.tsx b/frontend/src/components/basic/dialog/UpgradePlan.tsx index 517d5a233..7c381df83 100644 --- a/frontend/src/components/basic/dialog/UpgradePlan.tsx +++ b/frontend/src/components/basic/dialog/UpgradePlan.tsx @@ -4,73 +4,64 @@ import { Dialog, Transition } from "@headlessui/react"; import { useOrganization } from "@app/context"; -// REFACTOR: Move all these modals into one reusable one +// REFACTOR: Move all these modals into one reusable one type Props = { isOpen?: boolean; - onClose: ()=>void; + onClose: () => void; text: string; -} +}; -const UpgradePlanModal = ({ - isOpen, - onClose, - text, -}:Props) => { +const UpgradePlanModal = ({ isOpen, onClose, text }: Props) => { const router = useRouter(); const { currentOrg } = useOrganization(); return (
- + -
+
-
-
+
+
- - + + Unleash Infisical's Full Power -
-

- {text} -

-

+

+

{text}

+

Upgrade and get access to this, as well as to other powerful enhancements.

-
+
diff --git a/frontend/src/components/dashboard/AddTagsMenu.tsx b/frontend/src/components/dashboard/AddTagsMenu.tsx index dfa902b87..3a54f77ab 100644 --- a/frontend/src/components/dashboard/AddTagsMenu.tsx +++ b/frontend/src/components/dashboard/AddTagsMenu.tsx @@ -13,17 +13,27 @@ import { Tag } from "public/data/frequentInterfaces"; * @param {function} obj.modifyTags - modify tags for a certain secret * @param {Tag[]} obj.position - currently selected tags for a certain secret */ -const AddTagsMenu = ({ allTags, currentTags, modifyTags, id }: { allTags: Tag[]; currentTags: Tag[]; modifyTags: (value: Tag[], id: string) => void; id: string; }) => { +const AddTagsMenu = ({ + allTags, + currentTags, + modifyTags, + id +}: { + allTags: Tag[]; + currentTags: Tag[]; + modifyTags: (value: Tag[], id: string) => void; + id: string; +}) => { const router = useRouter(); return ( - + -
- - {currentTags?.length > 2 && {currentTags.length - 2}} +
+ + {currentTags?.length > 2 && {currentTags.length - 2}}
- - {allTags?.map((tag) => { return ( - - - - )})} + + {allTags?.map((tag) => { + return ( + + + + ); + })} diff --git a/frontend/src/components/dashboard/KeyPair.tsx b/frontend/src/components/dashboard/KeyPair.tsx index b46c6c07c..d9d0360ae 100644 --- a/frontend/src/components/dashboard/KeyPair.tsx +++ b/frontend/src/components/dashboard/KeyPair.tsx @@ -38,8 +38,7 @@ const colors = [ "bg-[#6F1AB6]/40", "bg-[#C40B13]/40", "bg-[#332FD0]/40" -] - +]; const colorsText = [ "text-[#fcf0c3]/70", @@ -50,7 +49,7 @@ const colorsText = [ "text-[#FFE5F1]/70", "text-[#FFDEDE]/70", "text-[#DFF6FF]/70" -] +]; /** * This component represent a single row for an environemnt variable on the dashboard @@ -83,117 +82,160 @@ const KeyPair = ({ toggleSidebar, sidebarSecretId, isCapitalized, - isSnapshot, + isSnapshot, deleteRow, togglePITSidebar, tags }: KeyPairProps) => { - const tagData = (tags.map((tag, index) => {return { - ...tag, - color: colors[index%colors.length], - colorText: colorsText[index%colorsText.length] - }})); + const tagData = tags.map((tag, index) => { + return { + ...tag, + color: colors[index % colors.length], + colorText: colorsText[index % colorsText.length] + }; + }); return ( -
-
-
-
{keyPair.pos + 1}
-
- +
+
+
+ {keyPair.pos + 1} +
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+ {keyPair.tags?.map( + (tag, index) => + index < 2 && ( +
tagDp.id === tag.id)[0]?.color + } rounded-sm text-sm ${ + tagData.filter((tagDp) => tagDp.id === tag.id)[0]?.colorText + } flex items-center`} + > + {tag.name} + + modifyTags( + keyPair.tags.filter((ttag) => ttag.id !== tag.id), + keyPair.id + ) + } + /> +
+ ) + )} + +
-
-
-
- -
-
-
-
- -
-
-
-
- {keyPair.tags?.map((tag, index) => ( - index < 2 &&
tagDp.id === tag.id)[0]?.color} rounded-sm text-sm ${tagData.filter(tagDp => tagDp.id === tag.id)[0]?.colorText} flex items-center`}> - {tag.name} - modifyTags(keyPair.tags.filter(ttag => ttag.id !== tag.id), keyPair.id)}/> -
- ))} - - -
-
-
null} - role="button" - tabIndex={0} - onClick={() => { - if (togglePITSidebar) { - togglePITSidebar(false); - } - toggleSidebar(keyPair.id) - }} - className={`cursor-pointer w-[1.5rem] h-[2.35rem] ml-auto group-hover:bg-mineshaft-700 z-50 rounded-md invisible group-hover:visible flex flex-row justify-center items-center ${isSnapshot ?? "invisible"}`} - > - -
-
- {keyPair.key || keyPair.value - ? { if (deleteRow) { - deleteRow({ ids: [keyPair.id], secretName: keyPair?.key }) - }}} - isPlain - /> - :
null} role="button" tabIndex={0} - onClick={() => { if (deleteRow) { - deleteRow({ ids: [keyPair.id], secretName: keyPair?.key }) - }}} - className="invisible group-hover:visible" + onClick={() => { + if (togglePITSidebar) { + togglePITSidebar(false); + } + toggleSidebar(keyPair.id); + }} + className={`invisible z-50 ml-auto flex h-[2.35rem] w-[1.5rem] cursor-pointer flex-row items-center justify-center rounded-md group-hover:visible group-hover:bg-mineshaft-700 ${ + isSnapshot ?? "invisible" + }`} > - + +
+
+ {keyPair.key || keyPair.value ? ( + { + if (deleteRow) { + deleteRow({ ids: [keyPair.id], secretName: keyPair?.key }); + } + }} + isPlain + /> + ) : ( +
+
null} + role="button" + tabIndex={0} + onClick={() => { + if (deleteRow) { + deleteRow({ ids: [keyPair.id], secretName: keyPair?.key }); + } + }} + className="invisible group-hover:visible" + > + +
+
+ )}
-
}
-
-)}; + ); +}; export default KeyPair; diff --git a/frontend/src/components/navigation/NavHeader.tsx b/frontend/src/components/navigation/NavHeader.tsx index b8ebee59c..2bf596915 100644 --- a/frontend/src/components/navigation/NavHeader.tsx +++ b/frontend/src/components/navigation/NavHeader.tsx @@ -157,7 +157,7 @@ export default function NavHeader({ })} {isProtectedBranch && ( - + )}
diff --git a/frontend/src/components/tags/CreateTagModal/CreateTagModal.tsx b/frontend/src/components/tags/CreateTagModal/CreateTagModal.tsx index 8f9fd4ccc..cfe685ae2 100644 --- a/frontend/src/components/tags/CreateTagModal/CreateTagModal.tsx +++ b/frontend/src/components/tags/CreateTagModal/CreateTagModal.tsx @@ -119,9 +119,9 @@ export const CreateTagModal = ({ isOpen, onToggle }: Props): JSX.Element => { const [showHexInput, setShowHexInput] = useState(false); const selectedTagColor = watch("color", secretTagsColors[0].hex); - useEffect(()=>{ - if(!isOpen) reset(); - },[isOpen]) + useEffect(() => { + if (!isOpen) reset(); + }, [isOpen]); const onFormSubmit = async ({ name, color }: FormData) => { try { @@ -168,21 +168,21 @@ export const CreateTagModal = ({ isOpen, onToggle }: Props): JSX.Element => { Tag Color
-
+
-
+
{!showHexInput ? ( -
+
{secretTagsColors.map(($tagColor: TagColor) => { return (
setValue("color", $tagColor.hex)} @@ -200,18 +200,18 @@ export const CreateTagModal = ({ isOpen, onToggle }: Props): JSX.Element => { })}
) : ( -
-
+
+
{isValidHexColor(selectedTagColor) && (
)} {!isValidHexColor(selectedTagColor) && ( -
+
)}
@@ -225,10 +225,10 @@ export const CreateTagModal = ({ isOpen, onToggle }: Props): JSX.Element => {
)} -
-
+
+
setShowHexInput((prev) => !prev)} diff --git a/frontend/src/components/utilities/config/index.ts b/frontend/src/components/utilities/config/index.ts index 8804765a3..10d4856c0 100644 --- a/frontend/src/components/utilities/config/index.ts +++ b/frontend/src/components/utilities/config/index.ts @@ -1,12 +1,6 @@ const ENV = process.env.NEXT_PUBLIC_ENV! || "development"; // investigate const POSTHOG_API_KEY = process.env.NEXT_PUBLIC_POSTHOG_API_KEY!; -const POSTHOG_HOST = - process.env.NEXT_PUBLIC_POSTHOG_HOST! || "https://app.posthog.com"; +const POSTHOG_HOST = process.env.NEXT_PUBLIC_POSTHOG_HOST! || "https://app.posthog.com"; const INTERCOMid = process.env.NEXT_PUBLIC_INTERCOMid!; -export { - ENV, - INTERCOMid, - POSTHOG_API_KEY, - POSTHOG_HOST -}; \ No newline at end of file +export { ENV, INTERCOMid, POSTHOG_API_KEY, POSTHOG_HOST }; diff --git a/frontend/src/components/utilities/intercom/intercom.ts b/frontend/src/components/utilities/intercom/intercom.ts index fb531c4a4..56b374107 100644 --- a/frontend/src/components/utilities/intercom/intercom.ts +++ b/frontend/src/components/utilities/intercom/intercom.ts @@ -54,11 +54,9 @@ export const load = () => { // Initializes Intercom export const boot = (options = {}) => { - window && - window.Intercom && - window.Intercom("boot", { appid: APPid, ...options }); + window && window.Intercom && window.Intercom("boot", { appid: APPid, ...options }); }; export const update = () => { window && window.Intercom && window.Intercom("update"); -}; \ No newline at end of file +}; diff --git a/frontend/src/context/OrgPermissionContext/OrgPermissionContext.tsx b/frontend/src/context/OrgPermissionContext/OrgPermissionContext.tsx index 932e33e9b..1f3cd1de4 100644 --- a/frontend/src/context/OrgPermissionContext/OrgPermissionContext.tsx +++ b/frontend/src/context/OrgPermissionContext/OrgPermissionContext.tsx @@ -22,7 +22,7 @@ export const OrgPermissionProvider = ({ children }: Props): JSX.Element => { if (isLoading) { return ( -
+
{ if (!permission) { return ( -
+
Failed to load user permissions
); diff --git a/frontend/src/context/OrganizationContext/OrganizationContext.tsx b/frontend/src/context/OrganizationContext/OrganizationContext.tsx index 93c82b923..a4562ef82 100644 --- a/frontend/src/context/OrganizationContext/OrganizationContext.tsx +++ b/frontend/src/context/OrganizationContext/OrganizationContext.tsx @@ -3,7 +3,6 @@ import { createContext, ReactNode, useContext, useMemo } from "react"; import { useGetOrganizations } from "@app/hooks/api"; import { Organization } from "@app/hooks/api/types"; - type TOrgContext = { orgs?: Organization[]; currentOrg?: Organization; @@ -18,7 +17,7 @@ type Props = { export const OrgProvider = ({ children }: Props): JSX.Element => { const { data: userOrgs, isLoading } = useGetOrganizations(); - + // const currentWsOrgID = currentWorkspace?.organization; const currentWsOrgID = localStorage.getItem("orgData.id"); diff --git a/frontend/src/context/ProjectPermissionContext/ProjectPermissionContext.tsx b/frontend/src/context/ProjectPermissionContext/ProjectPermissionContext.tsx index 3b7a8af2f..b596cda5b 100644 --- a/frontend/src/context/ProjectPermissionContext/ProjectPermissionContext.tsx +++ b/frontend/src/context/ProjectPermissionContext/ProjectPermissionContext.tsx @@ -18,7 +18,7 @@ export const ProjectPermissionProvider = ({ children }: Props): JSX.Element => { if ((isLoading && currentWorkspace) || isWsLoading) { return ( -
+
{ if (!permission && currentWorkspace) { return ( -
+
Failed to load user permissions
); diff --git a/frontend/src/context/ServerConfigContext/ServerConfigContext.tsx b/frontend/src/context/ServerConfigContext/ServerConfigContext.tsx index aab7e4c56..291765e3b 100644 --- a/frontend/src/context/ServerConfigContext/ServerConfigContext.tsx +++ b/frontend/src/context/ServerConfigContext/ServerConfigContext.tsx @@ -72,9 +72,9 @@ export const ServerConfigProvider = ({ children }: Props): JSX.Element => { export const useServerConfig = () => { const ctx = useContext(ServerConfigContext); - // if (!ctx) { - // throw new Error("useServerConfig has to be used within "); - // } + if (!ctx) { + throw new Error("useServerConfig has to be used within "); + } - return ctx || { config: { allowSignUp: true } }; + return ctx; }; diff --git a/frontend/src/context/UserContext/UserContext.tsx b/frontend/src/context/UserContext/UserContext.tsx index 5dbe3e0e7..433fc3959 100644 --- a/frontend/src/context/UserContext/UserContext.tsx +++ b/frontend/src/context/UserContext/UserContext.tsx @@ -1,10 +1,10 @@ import { createContext, ReactNode, useContext, useMemo } from "react"; import { useGetUser } from "@app/hooks/api"; -import { User } from "@app/hooks/api/types"; +import { User, UserEnc } from "@app/hooks/api/types"; type TUserContext = { - user: User; + user: User & UserEnc; isLoading: boolean; }; diff --git a/frontend/src/context/WorkspaceContext/WorkspaceContext.tsx b/frontend/src/context/WorkspaceContext/WorkspaceContext.tsx index 1e0a01c7e..4cf8c585f 100644 --- a/frontend/src/context/WorkspaceContext/WorkspaceContext.tsx +++ b/frontend/src/context/WorkspaceContext/WorkspaceContext.tsx @@ -26,7 +26,7 @@ export const WorkspaceProvider = ({ children }: Props): JSX.Element => { const wsId = workspaceId || localStorage.getItem("projectData.id"); return { workspaces: ws || [], - currentWorkspace: (ws || []).find(({ id: id }) => id === wsId), + currentWorkspace: (ws || []).find(({ id }) => id === wsId), isLoading }; }, [ws, workspaceId, isLoading]); diff --git a/frontend/src/helpers/project.ts b/frontend/src/helpers/project.ts index 13352c586..21f73e4c6 100644 --- a/frontend/src/helpers/project.ts +++ b/frontend/src/helpers/project.ts @@ -112,8 +112,8 @@ const initProjectHelper = async ({ }); await uploadWsKey({ - workspaceId: workspace._id, - userId: user._id, + workspaceId: workspace.id, + userId: user.id, encryptedKey: ciphertext, nonce }); @@ -121,13 +121,13 @@ const initProjectHelper = async ({ // encrypt and upload secrets to new project const secrets = await encryptSecrets({ secretsToEncrypt: secretsToBeAdded, - workspaceId: workspace._id, + workspaceId: workspace.id, env: "dev" }); secrets?.forEach((secret) => { createSecret({ - workspaceId: workspace._id, + workspaceId: workspace.id, environment: secret.environment, type: secret.type, secretKey: secret.secretName, diff --git a/frontend/src/hooks/api/apiKeys/types.ts b/frontend/src/hooks/api/apiKeys/types.ts index bc5ff3a56..b05bd5981 100644 --- a/frontend/src/hooks/api/apiKeys/types.ts +++ b/frontend/src/hooks/api/apiKeys/types.ts @@ -1,27 +1,27 @@ export type APIKeyDataV2 = { - id: string; - name: string; - user: string; - lastUsed?: string; - usageCount: number; - createdAt: string; - updatedAt: string; - }; + id: string; + name: string; + user: string; + lastUsed?: string; + usageCount: number; + createdAt: string; + updatedAt: string; +}; export type CreateAPIKeyDataV2DTO = { - name: string; -} + name: string; +}; export type CreateServiceTokenDataV3Res = { - apiKeyData: APIKeyDataV2; - apiKey: string; -} + apiKeyData: APIKeyDataV2; + apiKey: string; +}; export type UpdateAPIKeyDataV2DTO = { - apiKeyDataId: string; - name: string; -} + apiKeyDataId: string; + name: string; +}; export type DeleteAPIKeyDataV2DTO = { - apiKeyDataId: string; -} \ No newline at end of file + apiKeyDataId: string; +}; diff --git a/frontend/src/hooks/api/auditLogs/types.tsx b/frontend/src/hooks/api/auditLogs/types.tsx index 54f4882b3..92611c814 100644 --- a/frontend/src/hooks/api/auditLogs/types.tsx +++ b/frontend/src/hooks/api/auditLogs/types.tsx @@ -194,7 +194,8 @@ interface DeleteServiceTokenEvent { }; } -interface CreateIdentityEvent { // note: currently not logging org-role +interface CreateIdentityEvent { + // note: currently not logging org-role type: EventType.CREATE_IDENTITY; metadata: { identityId: string; @@ -218,7 +219,7 @@ interface DeleteIdentityEvent { } interface LoginIdentityUniversalAuthEvent { - type: EventType.LOGIN_IDENTITY_UNIVERSAL_AUTH ; + type: EventType.LOGIN_IDENTITY_UNIVERSAL_AUTH; metadata: { identityId: string; identityUniversalAuthId: string; @@ -259,7 +260,7 @@ interface GetIdentityUniversalAuthEvent { } interface CreateIdentityUniversalAuthClientSecretEvent { - type: EventType.CREATE_IDENTITY_UNIVERSAL_AUTH_CLIENT_SECRET ; + type: EventType.CREATE_IDENTITY_UNIVERSAL_AUTH_CLIENT_SECRET; metadata: { identityId: string; clientSecretId: string; @@ -273,9 +274,8 @@ interface GetIdentityUniversalAuthClientSecretsEvent { }; } - interface RevokeIdentityUniversalAuthClientSecretEvent { - type: EventType.REVOKE_IDENTITY_UNIVERSAL_AUTH_CLIENT_SECRET ; + type: EventType.REVOKE_IDENTITY_UNIVERSAL_AUTH_CLIENT_SECRET; metadata: { identityId: string; clientSecretId: string; @@ -507,7 +507,7 @@ export type Event = | UpdateUserDeniedPermissions; export type AuditLog = { - _id: string; + id: string; actor: Actor; organization: string; workspace: string; diff --git a/frontend/src/hooks/api/integrationAuth/types.ts b/frontend/src/hooks/api/integrationAuth/types.ts index 7a6ff6d53..1711436a8 100644 --- a/frontend/src/hooks/api/integrationAuth/types.ts +++ b/frontend/src/hooks/api/integrationAuth/types.ts @@ -55,14 +55,14 @@ export type BitBucketWorkspace = { uuid: string; name: string; slug: string; -} +}; export type NorthflankSecretGroup = { name: string; groupId: string; -} +}; export type TeamCityBuildConfig = { name: string; buildConfigId: string; -} \ No newline at end of file +}; diff --git a/frontend/src/hooks/api/integrations/types.ts b/frontend/src/hooks/api/integrations/types.ts index 3c814e80b..716f4604c 100644 --- a/frontend/src/hooks/api/integrations/types.ts +++ b/frontend/src/hooks/api/integrations/types.ts @@ -32,9 +32,9 @@ export type TIntegration = { __v: number; metadata?: { secretSuffix?: string; - scope: string; + scope: string; org: string; project: string; environment: string; - } + }; }; diff --git a/frontend/src/hooks/api/organization/types.ts b/frontend/src/hooks/api/organization/types.ts index c2468d8c2..3bfbd7419 100644 --- a/frontend/src/hooks/api/organization/types.ts +++ b/frontend/src/hooks/api/organization/types.ts @@ -13,7 +13,7 @@ export type RenameOrgDTO = { export type BillingDetails = { name: string; email: string; -} +}; export type PlanBillingInfo = { amount: number; @@ -22,7 +22,7 @@ export type PlanBillingInfo = { interval: "month" | "year"; intervalCount: number; quantity: number; -} +}; export type Invoice = { id: string; @@ -31,23 +31,23 @@ export type Invoice = { number: string; paid: boolean; total: number; -} +}; export type PmtMethod = { id: string; brand: string; - exp_month: number; + exp_month: number; exp_year: number; funding: string; last4: string; -} +}; export type TaxID = { id: string; country: string; type: string; value: string; -} +}; export type License = { id: string; @@ -58,22 +58,22 @@ export type License = { expiresAt: string; createdAt: string; updatedAt: string; -} +}; export type OrgPlanTableHead = { name: string; -} +}; export type OrgPlanTableRow = { name: string; allowed: number | boolean | null; used: string; -} +}; export type OrgPlanTable = { head: OrgPlanTableHead[]; rows: OrgPlanTableRow[]; -} +}; export type ProductsTableHead = { name: string; @@ -82,7 +82,7 @@ export type ProductsTableHead = { productId: string; slug: string; tier: number; -} +}; export type ProductsTableRow = { name: string; @@ -90,9 +90,9 @@ export type ProductsTableRow = { team: number | boolean | null; pro: number | boolean | null; enterprise: number | boolean | null; -} +}; export type ProductsTable = { head: ProductsTableHead[]; rows: ProductsTableRow[]; -} \ No newline at end of file +}; diff --git a/frontend/src/hooks/api/serviceTokens/types.ts b/frontend/src/hooks/api/serviceTokens/types.ts index ea3223660..489661d8b 100644 --- a/frontend/src/hooks/api/serviceTokens/types.ts +++ b/frontend/src/hooks/api/serviceTokens/types.ts @@ -4,7 +4,7 @@ export type ServiceTokenScope = { }; export type ServiceToken = { - _id: string; + id: string; name: string; workspace: string; scopes: ServiceTokenScope[]; @@ -32,4 +32,4 @@ export type CreateServiceTokenRes = { serviceTokenData: ServiceToken; }; -export type DeleteServiceTokenRes = { serviceTokenData: ServiceToken }; \ No newline at end of file +export type DeleteServiceTokenRes = { serviceTokenData: ServiceToken }; diff --git a/frontend/src/hooks/api/tags/types.ts b/frontend/src/hooks/api/tags/types.ts index 6e428da70..161e0327b 100644 --- a/frontend/src/hooks/api/tags/types.ts +++ b/frontend/src/hooks/api/tags/types.ts @@ -9,7 +9,7 @@ export type WsTag = { createdAt: string; updatedAt: string; __v: number; -} +}; export type WorkspaceTag = { id: string; name: string; slug: string }; @@ -30,7 +30,7 @@ export type CreateTagRes = { id: string; }; -export type DeleteTagDTO = { tagID: string; }; +export type DeleteTagDTO = { tagID: string }; export type DeleteWsTagRes = { name: string; @@ -41,17 +41,16 @@ export type DeleteWsTagRes = { id: string; }; -export type SecretTags = { - id: string; +export type SecretTags = { id: string; - slug: string; + slug: string; tagColor: string; -} +}; -export type TagColor = { +export type TagColor = { id: number; - hex: string - rgba: string - name: string - selected: boolean -} \ No newline at end of file + hex: string; + rgba: string; + name: string; + selected: boolean; +}; diff --git a/frontend/src/hooks/api/trustedIps/types.ts b/frontend/src/hooks/api/trustedIps/types.ts index fb8177c45..bd14b1c6e 100644 --- a/frontend/src/hooks/api/trustedIps/types.ts +++ b/frontend/src/hooks/api/trustedIps/types.ts @@ -1,9 +1,9 @@ export type TrustedIp = { - id: string; - workspace: string; - ipAddress: string; - type: "ipv4" | "ipv6"; - isActive: boolean; - comment: string; - prefix?: number; -}; \ No newline at end of file + id: string; + workspace: string; + ipAddress: string; + type: "ipv4" | "ipv6"; + isActive: boolean; + comment: string; + prefix?: number; +}; diff --git a/frontend/src/hooks/api/types.ts b/frontend/src/hooks/api/types.ts index eae8fa0d7..06c382358 100644 --- a/frontend/src/hooks/api/types.ts +++ b/frontend/src/hooks/api/types.ts @@ -23,7 +23,7 @@ export * from "./secrets/types"; export type { CreateServiceTokenDTO, ServiceToken } from "./serviceTokens/types"; export type { SubscriptionPlan } from "./subscriptions/types"; export type { WsTag } from "./tags/types"; -export type { AddUserToWsDTO, OrgUser, TWorkspaceUser, User } from "./users/types"; +export type { AddUserToWsDTO, OrgUser, TWorkspaceUser, User, UserEnc } from "./users/types"; export type { TWebhook } from "./webhooks/types"; export type { CreateEnvironmentDTO, diff --git a/frontend/src/hooks/api/users/queries.tsx b/frontend/src/hooks/api/users/queries.tsx index b865f8758..5c0349be1 100644 --- a/frontend/src/hooks/api/users/queries.tsx +++ b/frontend/src/hooks/api/users/queries.tsx @@ -14,7 +14,8 @@ import { RenameUserDTO, TokenVersion, UpdateOrgUserRoleDTO, - User + User, + UserEnc } from "./types"; export const userKeys = { @@ -29,7 +30,7 @@ export const userKeys = { }; export const fetchUserDetails = async () => { - const { data } = await apiRequest.get<{ user: User }>("/api/v1/user"); + const { data } = await apiRequest.get<{ user: User & UserEnc }>("/api/v1/user"); return data.user; }; diff --git a/frontend/src/hooks/api/users/types.ts b/frontend/src/hooks/api/users/types.ts index 31169a3fc..5868d6f5b 100644 --- a/frontend/src/hooks/api/users/types.ts +++ b/frontend/src/hooks/api/users/types.ts @@ -19,6 +19,12 @@ export type User = { lastName?: string; authProvider?: AuthMethod; authMethods: AuthMethod[]; + isMfaEnabled: boolean; + seenIps: string[]; + id: string; +}; + +export type UserEnc = { encryptionVersion?: number; protectedKey?: string; protectedKeyIV?: string; @@ -27,19 +33,15 @@ export type User = { encryptedPrivateKey?: string; iv?: string; tag?: string; - isMfaEnabled: boolean; - seenIps: string[]; - _id: string; - __v: number; }; export type OrgUser = { - _id: string; + id: string; user: { email: string; firstName: string; lastName: string; - _id: string; + id: string; publicKey: string; }; inviteEmail: string; @@ -88,7 +90,7 @@ export type RenameUserDTO = { }; export type APIKeyData = { - _id: string; + id: string; name: string; user: string; lastUsed: string; @@ -97,7 +99,7 @@ export type APIKeyData = { }; export type TokenVersion = { - _id: string; + id: string; user: string; userAgent: string; ip: string; diff --git a/frontend/src/hooks/api/workspace/types.ts b/frontend/src/hooks/api/workspace/types.ts index 80d1aaaa8..a4acc2cf6 100644 --- a/frontend/src/hooks/api/workspace/types.ts +++ b/frontend/src/hooks/api/workspace/types.ts @@ -22,7 +22,7 @@ export type NameWorkspaceSecretsDTO = { secretName: string; id: string; }[]; -} +}; // mutation dto export type CreateWorkspaceDTO = { @@ -47,7 +47,6 @@ export type ReorderEnvironmentsDTO = { environmentName: string; otherEnvironmentSlug: string; otherEnvironmentName: string; - }; export type UpdateEnvironmentDTO = { @@ -57,4 +56,4 @@ export type UpdateEnvironmentDTO = { environmentName: string; }; -export type DeleteEnvironmentDTO = { workspaceID: string; environmentSlug: string }; \ No newline at end of file +export type DeleteEnvironmentDTO = { workspaceID: string; environmentSlug: string }; diff --git a/frontend/src/layouts/AdminLayout/AdminLayout.tsx b/frontend/src/layouts/AdminLayout/AdminLayout.tsx index 3cee01f11..0e38c9a13 100644 --- a/frontend/src/layouts/AdminLayout/AdminLayout.tsx +++ b/frontend/src/layouts/AdminLayout/AdminLayout.tsx @@ -100,7 +100,7 @@ export const AdminLayout = ({ children }: LayoutProps) => {