Skip to content

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

better types

Daniel Hougaardba01fdedcf7b
diff --git a/frontend/src/hooks/api/subscriptions/types.ts b/frontend/src/hooks/api/subscriptions/types.ts
index dcb64f6e9a..474352fc7f 100644
--- a/frontend/src/hooks/api/subscriptions/types.ts
+++ b/frontend/src/hooks/api/subscriptions/types.ts
@@ -1,3 +1,14 @@
+export enum SubscriptionPlanTypes {
+ Starter = "starter",
+ Pro = "pro",
+ ProAnnual = "pro-annual",
+ Team = "team",
+ TeamAnnual = "team-annual",
+ Enterprise = "enterprise",
+ OnPrem = "one-prem",
+ OnPremEnterprise = "one-prem-enterprise"
+}
+
export type SubscriptionPlan = {
id: string;
membersUsed: number;
@@ -17,7 +28,7 @@ export type SubscriptionPlan = {
ipAllowlisting: boolean;
rbac: boolean;
secretVersioning: boolean;
- slug: string;
+ slug: SubscriptionPlanTypes;
secretApproval: boolean;
secretRotation: boolean;
tier: number;
diff --git a/frontend/src/layouts/OrganizationLayout/components/NavBar/Navbar.tsx b/frontend/src/layouts/OrganizationLayout/components/NavBar/Navbar.tsx
index 0e17439f12..c7274415ff 100644
--- a/frontend/src/layouts/OrganizationLayout/components/NavBar/Navbar.tsx
+++ b/frontend/src/layouts/OrganizationLayout/components/NavBar/Navbar.tsx
@@ -82,6 +82,7 @@ import {
import { authKeys, selectOrganization } from "@app/hooks/api/auth/queries";
import { MfaMethod } from "@app/hooks/api/auth/types";
import { getAuthToken } from "@app/hooks/api/reactQuery";
+import { SubscriptionPlanTypes } from "@app/hooks/api/subscriptions/types";
import { Organization, SubscriptionPlan } from "@app/hooks/api/types";
import { AuthMethod } from "@app/hooks/api/users/types";
import { ProjectSelect } from "@app/layouts/ProjectLayout/components/ProjectSelect";
@@ -552,7 +553,9 @@ export const Navbar = () => {
)}
</div>
- {subscription && subscription.slug === "starter" && !subscription.has_used_trial ? (
+ {subscription &&
+ subscription.slug === SubscriptionPlanTypes.Starter &&
+ !subscription.has_used_trial ? (
<Tooltip>
<TooltipTrigger asChild>
<Button
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentitySection.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentitySection.tsx
index 9609fabb8b..2272567d58 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentitySection.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentitySection.tsx
@@ -32,6 +32,7 @@ import { OrgPermissionMachineIdentityAuthTemplateActions } from "@app/context/Or
import { withPermission } from "@app/hoc";
import { useDeleteOrgIdentity } from "@app/hooks/api";
import { useDeleteIdentityAuthTemplate } from "@app/hooks/api/identityAuthTemplates";
+import { SubscriptionPlanTypes } from "@app/hooks/api/subscriptions/types";
import { usePopUp } from "@app/hooks/usePopUp";
import { IdentityAuthTemplateModal } from "./IdentityAuthTemplateModal";
@@ -76,7 +77,7 @@ export const IdentitySection = withPermission(
? subscription.identitiesUsed < subscription.identityLimit
: true;
- const isEnterprise = subscription?.slug === "enterprise";
+ const isEnterprise = subscription?.slug === SubscriptionPlanTypes.Enterprise;
const onDeleteIdentitySubmit = async (identityId: string) => {
await deleteMutateAsync({
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersSection.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersSection.tsx
index 2e0d984e91..fbc9a92a5e 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersSection.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersSection.tsx
@@ -33,6 +33,7 @@ import {
useUser
} from "@app/context";
import { useDeleteOrgMembership, useGetOrgUsers, useUpdateOrgMembership } from "@app/hooks/api";
+import { SubscriptionPlanTypes } from "@app/hooks/api/subscriptions/types";
import { useDeleteOrgMembershipBatch } from "@app/hooks/api/users/queries";
import { OrgUser } from "@app/hooks/api/users/types";
import { usePopUp } from "@app/hooks/usePopUp";
@@ -89,7 +90,7 @@ export const OrgMembersSection = () => {
? subscription.identitiesUsed < subscription.identityLimit
: true;
- const isEnterprise = subscription?.slug === "enterprise";
+ const isEnterprise = subscription?.slug === SubscriptionPlanTypes.Enterprise;
const handleAddMemberModal = () => {
if (currentOrg?.authEnforced) {
diff --git a/frontend/src/pages/organization/BillingPage/components/BillingCloudTab/PreviewSection.tsx b/frontend/src/pages/organization/BillingPage/components/BillingCloudTab/PreviewSection.tsx
index 4cf94d9d99..e16d858c81 100644
--- a/frontend/src/pages/organization/BillingPage/components/BillingCloudTab/PreviewSection.tsx
+++ b/frontend/src/pages/organization/BillingPage/components/BillingCloudTab/PreviewSection.tsx
@@ -18,6 +18,7 @@ import {
useGetOrgTrialUrl
} from "@app/hooks/api";
import { subscriptionQueryKeys } from "@app/hooks/api/subscriptions/queries";
+import { SubscriptionPlanTypes } from "@app/hooks/api/subscriptions/types";
import { usePopUp } from "@app/hooks/usePopUp";
import { ManagePlansModal } from "./ManagePlansModal";
@@ -60,7 +61,7 @@ export const PreviewSection = () => {
return formattedDate;
};
- function formatPlanSlug(slug: string) {
+ function formatPlanSlug(slug: SubscriptionPlanTypes) {
if (!slug) {
return "-";
}
@@ -109,9 +110,9 @@ export const PreviewSection = () => {
return (
<div>
{subscription &&
- subscription?.slug !== "enterprise" &&
- subscription?.slug !== "pro" &&
- subscription?.slug !== "pro-annual" && (
+ subscription?.slug !== SubscriptionPlanTypes.Enterprise &&
+ subscription?.slug !== SubscriptionPlanTypes.Pro &&
+ subscription?.slug !== SubscriptionPlanTypes.ProAnnual && (
<div className="flex flex-row space-x-6">
<div className="mb-6 flex flex-1 items-center rounded-lg border border-primary/40 bg-primary/10 p-4">
<div className="flex-1">
@@ -193,7 +194,7 @@ export const PreviewSection = () => {
</OrgPermissionCan>
)}
</div>
- {subscription.slug !== "enterprise" ? (
+ {subscription.slug !== SubscriptionPlanTypes.Enterprise ? (
<div className="mr-4 flex-1 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
<p className="mb-2 text-gray-400">Price</p>
<p className="mb-8 text-2xl font-medium text-mineshaft-50">
@@ -202,7 +203,8 @@ export const PreviewSection = () => {
) : (
<>
{formatAmount(totalAmount)} / {data.interval}
- {(subscription.slug === "pro" || subscription.slug === "pro-annual") && (
+ {(subscription.slug === SubscriptionPlanTypes.Pro ||
+ subscription.slug === SubscriptionPlanTypes.ProAnnual) && (
<Tooltip
content={`Total price is based on the number of users and machine identities at ${formatAmount(data.amount)} each. You have ${data.users} ${data.users > 1 ? "users" : "user"} and ${data.identities} ${data.identities > 1 ? "machine identities" : "machine identity"}.`}
className="max-w-lg"