feat: removed last bit of workspace in frontend. Fatality!

This commit is contained in:
=
2025-09-14 20:57:06 +05:30
parent 37a80fa1ac
commit ac80242749
356 changed files with 1788 additions and 1890 deletions

View File

@@ -4,7 +4,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { Link, useParams } from "@tanstack/react-router";
import { twMerge } from "tailwind-merge";
import { useOrganization, useWorkspace } from "@app/context";
import { useOrganization, useProject } from "@app/context";
import { useToggle } from "@app/hooks";
import { createNotification } from "../notifications";
@@ -51,7 +51,7 @@ export default function NavHeader({
isProtectedBranch = false,
protectionPolicyName
}: Props): JSX.Element {
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const { currentOrg } = useOrganization();
const [isCopied, { timedToggle: toggleIsCopied }] = useToggle(false);
@@ -79,7 +79,7 @@ export default function NavHeader({
<>
<FontAwesomeIcon icon={faAngleRight} className="ml-3 mr-3 text-xs text-gray-400" />
<div className="truncate text-sm font-semibold text-bunker-300">
{currentWorkspace?.name}
{currentProject?.name}
</div>
</>
)}
@@ -93,7 +93,7 @@ export default function NavHeader({
{pageName === "Secrets" ? (
<Link
to="/projects/secret-management/$projectId/overview"
params={{ projectId: currentWorkspace.id }}
params={{ projectId: currentProject.id }}
className="text-sm font-semibold text-primary/80 hover:text-primary"
>
{pageName}
@@ -129,7 +129,7 @@ export default function NavHeader({
<FontAwesomeIcon icon={faAngleRight} className="ml-3 mr-1.5 text-xs text-gray-400" />
<Link
to="/projects/secret-management/$projectId/secrets/$envSlug"
params={{ projectId: currentWorkspace.id, envSlug: routerEnvSlug }}
params={{ projectId: currentProject.id, envSlug: routerEnvSlug }}
className="text-sm font-semibold text-primary/80 hover:text-primary"
>
{userAvailableEnvs?.find(({ slug }) => slug === currentEnv)?.name}
@@ -192,7 +192,7 @@ export default function NavHeader({
<Link
to="/projects/secret-management/$projectId/secrets/$envSlug"
params={{
projectId: currentWorkspace.id,
projectId: currentProject.id,
envSlug: routerEnvSlug || ""
}}
search={(query) => ({ ...query, secretPath: newSecretPath })}

View File

@@ -3,7 +3,7 @@ import { useFormContext, useWatch } from "react-hook-form";
import { MongoAbility, MongoQuery } from "@casl/ability";
import { Edge, Node, useEdgesState, useNodesState } from "@xyflow/react";
import { ProjectPermissionSub, useWorkspace } from "@app/context";
import { ProjectPermissionSub, useProject } from "@app/context";
import { ProjectPermissionSet } from "@app/context/ProjectPermissionContext";
import { useListProjectEnvironmentsFolders } from "@app/hooks/api/secretFolders/queries";
import { TSecretFolderWithPath } from "@app/hooks/api/secretFolders/types";
@@ -36,15 +36,15 @@ export const useAccessTree = (
searchPath: string,
subject: ProjectPermissionSub
) => {
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const { secretName, setSecretName, setViewMode, viewMode } = useAccessTreeContext();
const { control } = useFormContext<AccessTreeForm>();
const metadata = useWatch({ control, name: "metadata" });
const [nodes, setNodes] = useNodesState<Node>([]);
const [edges, setEdges] = useEdgesState<Edge>([]);
const [environment, setEnvironment] = useState(currentWorkspace.environments[0]?.slug ?? "");
const [environment, setEnvironment] = useState(currentProject.environments[0]?.slug ?? "");
const { data: environmentsFolders, isPending } = useListProjectEnvironmentsFolders(
currentWorkspace.id
currentProject.id
);
const [levelFolderMap, setLevelFolderMap] = useState<LevelFolderMap>({});
@@ -279,7 +279,7 @@ export const useAccessTree = (
environment,
setEnvironment,
isLoading: isPending,
environments: currentWorkspace.environments,
environments: currentProject.environments,
secretName,
setSecretName,
viewMode,

View File

@@ -6,7 +6,7 @@ import { z } from "zod";
import { createNotification } from "@app/components/notifications";
import { ProjectPermissionCan } from "@app/components/permissions";
import { Button, FormControl, Input, TextArea } from "@app/components/v2";
import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context";
import { ProjectPermissionActions, ProjectPermissionSub, useProject } from "@app/context";
import { useUpdateProject } from "@app/hooks/api";
const baseFormSchema = z.object({
@@ -37,35 +37,35 @@ type Props = {
};
export const ProjectOverviewChangeSection = ({ showSlugField = false }: Props) => {
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const { mutateAsync, isPending } = useUpdateProject();
const { handleSubmit, control, reset, watch } = useForm<BaseFormData | FormDataWithSlug>({
resolver: zodResolver(showSlugField ? formSchemaWithSlug : baseFormSchema)
});
const currentSlug = showSlugField ? watch("slug") : currentWorkspace?.slug;
const currentSlug = showSlugField ? watch("slug") : currentProject?.slug;
useEffect(() => {
if (currentWorkspace) {
if (currentProject) {
reset({
name: currentWorkspace.name,
description: currentWorkspace.description ?? "",
...(showSlugField && { slug: currentWorkspace.slug })
name: currentProject.name,
description: currentProject.description ?? "",
...(showSlugField && { slug: currentProject.slug })
});
}
}, [currentWorkspace, showSlugField]);
}, [currentProject, showSlugField]);
const onFormSubmit = async (data: BaseFormData | FormDataWithSlug) => {
try {
if (!currentWorkspace?.id) return;
if (!currentProject?.id) return;
await mutateAsync({
projectID: currentWorkspace.id,
projectId: currentProject.id,
newProjectName: data.name,
newProjectDescription: data.description,
...(showSlugField &&
"slug" in data && {
newSlug: data.slug !== currentWorkspace.slug ? data.slug : undefined
newSlug: data.slug !== currentProject.slug ? data.slug : undefined
})
});
@@ -105,7 +105,7 @@ export const ProjectOverviewChangeSection = ({ showSlugField = false }: Props) =
variant="outline_bg"
size="sm"
onClick={() => {
navigator.clipboard.writeText(currentWorkspace?.id || "");
navigator.clipboard.writeText(currentProject?.id || "");
createNotification({
text: "Copied project ID to clipboard",
type: "success"

View File

@@ -34,10 +34,10 @@ import {
useUser
} from "@app/context";
import { getProjectHomePage, getProjectLottieIcon } from "@app/helpers/project";
import { useCreateWorkspace, useGetExternalKmsList, useGetUserWorkspaces } from "@app/hooks/api";
import { useCreateWorkspace, useGetExternalKmsList, useGetUserProjects } from "@app/hooks/api";
import { INTERNAL_KMS_KEY_ID } from "@app/hooks/api/kms/types";
import { InfisicalProjectTemplate, useListProjectTemplates } from "@app/hooks/api/projectTemplates";
import { ProjectType } from "@app/hooks/api/workspace/types";
import { ProjectType } from "@app/hooks/api/projects/types";
const formSchema = z.object({
name: z.string().trim().min(1, "Required").max(64, "Too long, maximum length is 64 characters"),
@@ -89,7 +89,7 @@ const NewProjectForm = ({ onOpenChange }: NewProjectFormProps) => {
const { permission } = useOrgPermission();
const { user } = useUser();
const createWs = useCreateWorkspace();
const { refetch: refetchWorkspaces } = useGetUserWorkspaces();
const { refetch: refetchWorkspaces } = useGetUserProjects();
const { subscription } = useSubscription();
const canReadProjectTemplates = permission.can(

View File

@@ -7,12 +7,12 @@ import { SecretRotationV2ModalHeader } from "@app/components/secret-rotations-v2
import { SecretRotationV2Select } from "@app/components/secret-rotations-v2/SecretRotationV2Select";
import { Modal, ModalContent } from "@app/components/v2";
import { SecretRotation, TSecretRotationV2 } from "@app/hooks/api/secretRotationsV2";
import { WorkspaceEnv } from "@app/hooks/api/workspace/types";
import { ProjectEnv } from "@app/hooks/api/projects/types";
type SharedProps = {
secretPath: string;
environment?: string;
environments?: WorkspaceEnv[];
environments?: ProjectEnv[];
};
type Props = {

View File

@@ -9,14 +9,14 @@ import {
IS_ROTATION_DUAL_CREDENTIALS,
SECRET_ROTATION_MAP
} from "@app/helpers/secretRotationsV2";
import { WorkspaceEnv } from "@app/hooks/api/workspace/types";
import { ProjectEnv } from "@app/hooks/api/projects/types";
import { TSecretRotationV2Form } from "./schemas";
import { SecretRotationV2ConnectionField } from "./SecretRotationV2ConnectionField";
type Props = {
isUpdate: boolean;
environments?: WorkspaceEnv[];
environments?: ProjectEnv[];
};
export const SecretRotationV2ConfigurationFields = ({ isUpdate, environments }: Props) => {

View File

@@ -11,7 +11,7 @@ import { SecretRotationV2ParametersFields } from "@app/components/secret-rotatio
import { SecretRotationV2ReviewFields } from "@app/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields";
import { SecretRotationV2SecretsMappingFields } from "@app/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields";
import { Button } from "@app/components/v2";
import { useWorkspace } from "@app/context";
import { useProject } from "@app/context";
import { IS_ROTATION_DUAL_CREDENTIALS, SECRET_ROTATION_MAP } from "@app/helpers/secretRotationsV2";
import {
SecretRotation,
@@ -22,7 +22,7 @@ import {
useCreateSecretRotationV2,
useUpdateSecretRotationV2
} from "@app/hooks/api/secretRotationsV2/mutations";
import { WorkspaceEnv } from "@app/hooks/api/workspace/types";
import { ProjectEnv } from "@app/hooks/api/projects/types";
import { SecretRotationV2FormSchema, TSecretRotationV2Form } from "./schemas";
@@ -32,7 +32,7 @@ type Props = {
onCancel: () => void;
secretPath: string;
environment?: string;
environments?: WorkspaceEnv[];
environments?: ProjectEnv[];
secretRotation?: TSecretRotationV2;
};
@@ -68,7 +68,7 @@ export const SecretRotationV2Form = ({
}: Props) => {
const createSecretRotation = useCreateSecretRotationV2();
const updateSecretRotation = useUpdateSecretRotationV2();
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const { name: rotationType } = SECRET_ROTATION_MAP[type];
const [selectedTabIndex, setSelectedTabIndex] = useState(0);
@@ -80,7 +80,7 @@ export const SecretRotationV2Form = ({
defaultValues: secretRotation
? {
...secretRotation,
environment: currentWorkspace?.environments.find((env) => env.slug === envSlug),
environment: currentProject?.environments.find((env) => env.slug === envSlug),
secretPath
}
: {
@@ -91,7 +91,7 @@ export const SecretRotationV2Form = ({
hours: 0,
minutes: 0
},
environment: currentWorkspace?.environments.find((env) => env.slug === envSlug),
environment: currentProject?.environments.find((env) => env.slug === envSlug),
secretPath,
...(rotationOption!.template as object) // can't infer type since we don't know which specific type it is
},
@@ -115,7 +115,7 @@ export const SecretRotationV2Form = ({
connectionId: connection.id,
environment: environment.slug,
projectId: currentWorkspace.id
projectId: currentProject.id
});
try {
const rotation = await mutation;

View File

@@ -6,7 +6,7 @@ import { twMerge } from "tailwind-merge";
import { createNotification } from "@app/components/notifications";
import { Button } from "@app/components/v2";
import { useWorkspace } from "@app/context";
import { useProject } from "@app/context";
import { SECRET_SCANNING_DATA_SOURCE_MAP } from "@app/helpers/secretScanningV2";
import {
SecretScanningDataSource,
@@ -39,7 +39,7 @@ const FORM_TABS: { name: string; key: string; fields: (keyof TSecretScanningData
export const SecretScanningDataSourceForm = ({ type, onComplete, onCancel, dataSource }: Props) => {
const createDataSource = useCreateSecretScanningDataSource();
const updateDataSource = useUpdateSecretScanningDataSource();
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const { name: sourceType } = SECRET_SCANNING_DATA_SOURCE_MAP[type];
const [selectedTabIndex, setSelectedTabIndex] = useState(0);
@@ -63,7 +63,7 @@ export const SecretScanningDataSourceForm = ({ type, onComplete, onCancel, dataS
: createDataSource.mutateAsync({
...formData,
connectionId: connection?.id,
projectId: currentWorkspace.id
projectId: currentProject.id
});
try {
const source = await mutation;

View File

@@ -8,7 +8,7 @@ import { twMerge } from "tailwind-merge";
import { createNotification } from "@app/components/notifications";
import { Button, FormControl, Switch } from "@app/components/v2";
import { useWorkspace } from "@app/context";
import { useProject } from "@app/context";
import { SECRET_SYNC_MAP } from "@app/helpers/secretSyncs";
import {
SecretSync,
@@ -41,7 +41,7 @@ const FORM_TABS: { name: string; key: string; fields: (keyof TSecretSyncForm)[]
export const CreateSecretSyncForm = ({ destination, onComplete, onCancel }: Props) => {
const createSecretSync = useCreateSecretSync();
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const { name: destinationName } = SECRET_SYNC_MAP[destination];
const [showConfirmation, setShowConfirmation] = useState(false);
@@ -70,7 +70,7 @@ export const CreateSecretSyncForm = ({ destination, onComplete, onCancel }: Prop
...formData,
connectionId: connection.id,
environment: environment.slug,
projectId: currentWorkspace.id
projectId: currentProject.id
});
createNotification({

View File

@@ -4,7 +4,7 @@ import { subject } from "@casl/ability";
import { FilterableSelect, FormControl } from "@app/components/v2";
import { SecretPathInput } from "@app/components/v2/SecretPathInput";
import { useProjectPermission, useWorkspace } from "@app/context";
import { useProjectPermission, useProject } from "@app/context";
import {
ProjectPermissionSecretSyncActions,
ProjectPermissionSub
@@ -16,7 +16,7 @@ export const SecretSyncSourceFields = () => {
const { control, watch, setError, clearErrors } = useFormContext<TSecretSyncForm>();
const { permission } = useProjectPermission();
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const selectedEnvironment = watch("environment");
const selectedSecretPath = watch("secretPath");
@@ -48,7 +48,7 @@ export const SecretSyncSourceFields = () => {
</p>
<Controller
defaultValue={currentWorkspace.environments[0]}
defaultValue={currentProject.environments[0]}
control={control}
name="environment"
render={({ field: { value, onChange }, fieldState: { error } }) => (
@@ -56,7 +56,7 @@ export const SecretSyncSourceFields = () => {
<FilterableSelect
value={value}
onChange={onChange}
options={currentWorkspace.environments}
options={currentProject.environments}
placeholder="Select environment..."
getOptionLabel={(option) => option?.name}
getOptionValue={(option) => option?.id}

View File

@@ -13,7 +13,7 @@ import { twMerge } from "tailwind-merge";
import { createNotification } from "@app/components/notifications";
import { FormControl, FormLabel, SecretInput, Spinner, Tooltip } from "@app/components/v2";
import { useWorkspace } from "@app/context";
import { useProject } from "@app/context";
import { useGetSecretReferenceTree } from "@app/hooks/api";
import { ApiErrorTypes, TApiErrors, TSecretReferenceTraceNode } from "@app/hooks/api/types";
@@ -89,8 +89,8 @@ export const SecretReferenceNode = ({
};
export const SecretReferenceTree = ({ secretPath, environment, secretKey }: Props) => {
const { currentWorkspace } = useWorkspace();
const projectId = currentWorkspace?.id || "";
const { currentProject } = useProject();
const projectId = currentProject?.id || "";
const { data, isPending, isError, error } = useGetSecretReferenceTree({
secretPath,

View File

@@ -15,7 +15,7 @@ import {
ModalContent,
Tooltip
} from "@app/components/v2";
import { useWorkspace } from "@app/context";
import { useProject } from "@app/context";
import { useCreateWsTag } from "@app/hooks/api";
import { slugSchema } from "@app/lib/schemas";
@@ -115,11 +115,10 @@ export const CreateTagModal = ({ isOpen, onToggle }: Props): JSX.Element => {
}
});
const { currentWorkspace } = useWorkspace();
const workspaceId = currentWorkspace?.id || "";
const { currentProject } = useProject();
const projectId = currentProject?.id || "";
const { mutateAsync: createWsTag } = useCreateWsTag();
const [showHexInput, setShowHexInput] = useState<boolean>(false);
const selectedTagColor = watch("color", secretTagsColors[0].hex);
@@ -130,7 +129,7 @@ export const CreateTagModal = ({ isOpen, onToggle }: Props): JSX.Element => {
const onFormSubmit = async ({ slug, color }: FormData) => {
try {
await createWsTag({
workspaceID: workspaceId,
projectId,
tagColor: color,
tagSlug: slug
});

View File

@@ -3,7 +3,7 @@ import { faFolder, faKey, faLayerGroup } from "@fortawesome/free-solid-svg-icons
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import * as Popover from "@radix-ui/react-popover";
import { useWorkspace } from "@app/context";
import { useProject } from "@app/context";
import { useDebounce, useToggle } from "@app/hooks";
import { useGetProjectFolders, useGetProjectSecrets } from "@app/hooks/api";
@@ -76,8 +76,8 @@ export const InfisicalSecretInput = forwardRef<HTMLTextAreaElement, Props>(
},
ref
) => {
const { currentWorkspace } = useWorkspace();
const workspaceId = currentWorkspace?.id || "";
const { currentProject } = useProject();
const projectId = currentProject?.id || "";
const [debouncedValue] = useDebounce(value, 100);
@@ -101,7 +101,7 @@ export const InfisicalSecretInput = forwardRef<HTMLTextAreaElement, Props>(
let predicate = suggestionSourceValue;
if (isDeep) {
const [envSlug, ...folderPaths] = suggestionSourceValue.split(".");
const isValidEnvSlug = currentWorkspace?.environments.find((e) => e.slug === envSlug);
const isValidEnvSlug = currentProject?.environments.find((e) => e.slug === envSlug);
suggestionSourceEnv = isValidEnvSlug ? envSlug : undefined;
suggestionSourceSecretPath = `/${folderPaths.slice(0, -1)?.join("/")}`;
predicate = folderPaths[folderPaths.length - 1];
@@ -125,7 +125,7 @@ export const InfisicalSecretInput = forwardRef<HTMLTextAreaElement, Props>(
viewSecretValue: false,
environment: suggestionSource.environment || "",
secretPath: suggestionSource.secretPath || "",
workspaceId,
projectId,
options: {
enabled: isPopupOpen
}
@@ -133,7 +133,7 @@ export const InfisicalSecretInput = forwardRef<HTMLTextAreaElement, Props>(
const { data: folders } = useGetProjectFolders({
environment: suggestionSource.environment || "",
path: suggestionSource.secretPath || "",
projectId: workspaceId,
projectId: projectId,
options: {
enabled: isPopupOpen
}
@@ -148,7 +148,7 @@ export const InfisicalSecretInput = forwardRef<HTMLTextAreaElement, Props>(
if (!suggestionSource.isDeep) {
// At first level only environments and secrets
(currentWorkspace?.environments || []).forEach(({ name, slug }) => {
(currentProject?.environments || []).forEach(({ name, slug }) => {
if (name.toLowerCase().startsWith(predicate))
suggestionsArr.push({
label: name,
@@ -176,7 +176,7 @@ export const InfisicalSecretInput = forwardRef<HTMLTextAreaElement, Props>(
});
});
return suggestionsArr;
}, [secrets, folders, currentWorkspace?.environments, isPopupOpen, suggestionSource.value]);
}, [secrets, folders, currentProject?.environments, isPopupOpen, suggestionSource.value]);
const handleSuggestionSelect = (selectIndex?: number) => {
const selectedSuggestion =

View File

@@ -4,7 +4,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import * as Popover from "@radix-ui/react-popover";
import { twMerge } from "tailwind-merge";
import { useWorkspace } from "@app/context";
import { useProject } from "@app/context";
import { useDebounce } from "@app/hooks";
import { useGetFoldersByEnv } from "@app/hooks/api";
@@ -35,11 +35,11 @@ export const SecretPathInput = ({
const [highlightedIndex, setHighlightedIndex] = useState(-1);
const [debouncedInputValue] = useDebounce(inputValue, 200);
const { currentWorkspace } = useWorkspace();
const workspaceId = currentWorkspace?.id || "";
const { currentProject } = useProject();
const workspaceId = currentProject?.id || "";
const { folderNames: folders } = useGetFoldersByEnv({
path: secretPath,
environments: [environment || currentWorkspace?.environments?.[0].slug || ""],
environments: [environment || currentProject?.environments?.[0].slug || ""],
projectId: workspaceId
});

View File

@@ -22,8 +22,8 @@ export const useProjectPermission = () => {
const {
data: { permission, membership, assumedPrivilegeDetails }
} = useSuspenseQuery({
queryKey: roleQueryKeys.getUserProjectPermissions({ workspaceId: projectId }),
queryFn: () => fetchUserProjectPermissions({ workspaceId: projectId }),
queryKey: roleQueryKeys.getUserProjectPermissions({ projectId }),
queryFn: () => fetchUserProjectPermissions({ projectId }),
staleTime: Infinity,
select: (data) => {
const rule = unpackRules<RawRuleOf<MongoAbility<ProjectPermissionSet>>>(data.permissions);

View File

@@ -2,9 +2,9 @@ import { useSuspenseQuery } from "@tanstack/react-query";
import { useParams } from "@tanstack/react-router";
import { projectKeys } from "@app/hooks/api";
import { fetchWorkspaceById } from "@app/hooks/api/workspace/queries";
import { fetchProjectById } from "@app/hooks/api/projects/queries";
export const useWorkspace = () => {
export const useProject = () => {
const params = useParams({
strict: false
});
@@ -12,11 +12,11 @@ export const useWorkspace = () => {
throw new Error("Missing project id");
}
const { data: currentWorkspace } = useSuspenseQuery({
queryKey: projectKeys.getWorkspaceById(params.projectId),
queryFn: () => fetchWorkspaceById(params.projectId as string),
const { data: currentProject } = useSuspenseQuery({
queryKey: projectKeys.getProjectById(params.projectId),
queryFn: () => fetchProjectById(params.projectId as string),
staleTime: Infinity
});
return { currentWorkspace };
return { currentProject, projectId: currentProject.id };
};

View File

@@ -1 +1 @@
export { useWorkspace } from "./WorkspaceContext";
export { useProject } from "./WorkspaceContext";

View File

@@ -29,4 +29,4 @@ export {
export { useServerConfig } from "./ServerConfigContext";
export { useSubscription } from "./SubscriptionContext";
export { useUser } from "./UserContext";
export { useWorkspace } from "./WorkspaceContext";
export { useProject } from "./WorkspaceContext";

View File

@@ -1,6 +1,6 @@
import { apiRequest } from "@app/config/request";
import { createWorkspace } from "@app/hooks/api/workspace/queries";
import { ProjectType, WorkspaceEnv } from "@app/hooks/api/workspace/types";
import { createWorkspace } from "@app/hooks/api/projects/queries";
import { ProjectType, ProjectEnv } from "@app/hooks/api/projects/types";
const secretsToBeAdded = [
{
@@ -74,7 +74,7 @@ export const getProjectBaseURL = (type: ProjectType) => {
// @ts-expect-error akhilmhdh: will remove this later
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export const getProjectHomePage = (type: ProjectType, environments: WorkspaceEnv[]) => {
export const getProjectHomePage = (type: ProjectType, environments: ProjectEnv[]) => {
switch (type) {
case ProjectType.SecretManager:
return "/projects/secret-management/$projectId/overview" as const;

View File

@@ -1,7 +1,7 @@
import { EnforcementLevel, PolicyType } from "../policies/enums";
import { TProjectPermission } from "../roles/types";
import { ApprovalStatus } from "../secretApprovalRequest/types";
import { WorkspaceEnv } from "../workspace/types";
import { ProjectEnv } from "../projects/types";
export type TAccessApprovalPolicy = {
id: string;
@@ -9,7 +9,7 @@ export type TAccessApprovalPolicy = {
approvals: number;
secretPath: string;
workspace: string;
environments: WorkspaceEnv[];
environments: ProjectEnv[];
projectId: string;
policyType: PolicyType;
approversRequired: boolean;

View File

@@ -20,7 +20,7 @@ export const eventToNameMap: { [K in EventType]: string } = {
[EventType.CREATE_SECRET]: "Create secret",
[EventType.UPDATE_SECRET]: "Update secret",
[EventType.DELETE_SECRET]: "Delete secret",
[EventType.GET_WORKSPACE_KEY]: "Read project key",
[EventType.GET_PROJECT_KEY]: "Read project key",
[EventType.AUTHORIZE_INTEGRATION]: "Authorize integration",
[EventType.UPDATE_INTEGRATION_AUTH]: "Update integration auth",
[EventType.UNAUTHORIZE_INTEGRATION]: "Unauthorize integration",
@@ -45,8 +45,8 @@ export const eventToNameMap: { [K in EventType]: string } = {
[EventType.CREATE_ENVIRONMENT]: "Create environment",
[EventType.UPDATE_ENVIRONMENT]: "Update environment",
[EventType.DELETE_ENVIRONMENT]: "Delete environment",
[EventType.ADD_WORKSPACE_MEMBER]: "Add member",
[EventType.REMOVE_WORKSPACE_MEMBER]: "Remove member",
[EventType.ADD_PROJECT_MEMBER]: "Add member",
[EventType.REMOVE_PROJECT_MEMBER]: "Remove member",
[EventType.CREATE_FOLDER]: "Create folder",
[EventType.UPDATE_FOLDER]: "Update folder",
[EventType.DELETE_FOLDER]: "Delete folder",
@@ -58,8 +58,8 @@ export const eventToNameMap: { [K in EventType]: string } = {
[EventType.CREATE_SECRET_IMPORT]: "Create secret import",
[EventType.UPDATE_SECRET_IMPORT]: "Update secret import",
[EventType.DELETE_SECRET_IMPORT]: "Delete secret import",
[EventType.UPDATE_USER_WORKSPACE_DENIED_PERMISSIONS]: "Update denied permissions",
[EventType.UPDATE_USER_WORKSPACE_ROLE]: "Update user role",
[EventType.UPDATE_USER_PROJECT_DENIED_PERMISSIONS]: "Update denied permissions",
[EventType.UPDATE_USER_PROJECT_ROLE]: "Update user role",
[EventType.CREATE_CA]: "Create CA",
[EventType.GET_CA]: "Get CA",
[EventType.UPDATE_CA]: "Update CA",

View File

@@ -26,7 +26,7 @@ export enum EventType {
CREATE_SECRET = "create-secret",
UPDATE_SECRET = "update-secret",
DELETE_SECRET = "delete-secret",
GET_WORKSPACE_KEY = "get-workspace-key",
GET_PROJECT_KEY = "get-project-key",
AUTHORIZE_INTEGRATION = "authorize-integration",
UPDATE_INTEGRATION_AUTH = "update-integration-auth",
UNAUTHORIZE_INTEGRATION = "unauthorize-integration",
@@ -58,8 +58,8 @@ export enum EventType {
CREATE_ENVIRONMENT = "create-environment",
UPDATE_ENVIRONMENT = "update-environment",
DELETE_ENVIRONMENT = "delete-environment",
ADD_WORKSPACE_MEMBER = "add-workspace-member",
REMOVE_WORKSPACE_MEMBER = "remove-workspace-member",
ADD_PROJECT_MEMBER = "add-project-member",
REMOVE_PROJECT_MEMBER = "remove-project-member",
CREATE_FOLDER = "create-folder",
UPDATE_FOLDER = "update-folder",
DELETE_FOLDER = "delete-folder",
@@ -71,8 +71,8 @@ export enum EventType {
CREATE_SECRET_IMPORT = "create-secret-import",
UPDATE_SECRET_IMPORT = "update-secret-import",
DELETE_SECRET_IMPORT = "delete-secret-import",
UPDATE_USER_WORKSPACE_ROLE = "update-user-workspace-role",
UPDATE_USER_WORKSPACE_DENIED_PERMISSIONS = "update-user-workspace-denied-permissions",
UPDATE_USER_PROJECT_ROLE = "update-user-project-role",
UPDATE_USER_PROJECT_DENIED_PERMISSIONS = "update-user-project-denied-permissions",
CREATE_CA = "create-certificate-authority",
GET_CA = "get-certificate-authority",
UPDATE_CA = "update-certificate-authority",

View File

@@ -129,7 +129,7 @@ interface DeleteSecretEvent {
}
interface GetWorkspaceKeyEvent {
type: EventType.GET_WORKSPACE_KEY;
type: EventType.GET_PROJECT_KEY;
metadata: {
keyId: string;
};
@@ -361,7 +361,7 @@ interface DeleteEnvironmentEvent {
}
interface AddWorkspaceMemberEvent {
type: EventType.ADD_WORKSPACE_MEMBER;
type: EventType.ADD_PROJECT_MEMBER;
metadata: {
userId: string;
email: string;
@@ -369,7 +369,7 @@ interface AddWorkspaceMemberEvent {
}
interface RemoveWorkspaceMemberEvent {
type: EventType.REMOVE_WORKSPACE_MEMBER;
type: EventType.REMOVE_PROJECT_MEMBER;
metadata: {
userId: string;
email: string;
@@ -500,7 +500,7 @@ interface DeleteSecretImportEvent {
}
interface UpdateUserRole {
type: EventType.UPDATE_USER_WORKSPACE_ROLE;
type: EventType.UPDATE_USER_PROJECT_ROLE;
metadata: {
userId: string;
email: string;
@@ -510,7 +510,7 @@ interface UpdateUserRole {
}
interface UpdateUserDeniedPermissions {
type: EventType.UPDATE_USER_WORKSPACE_DENIED_PERMISSIONS;
type: EventType.UPDATE_USER_PROJECT_DENIED_PERMISSIONS;
metadata: {
userId: string;
email: string;

View File

@@ -6,7 +6,7 @@ import { SessionStorageKeys } from "@app/const";
import { organizationKeys } from "../organization/queries";
import { setAuthToken } from "../reactQuery";
import { workspaceKeys } from "../workspace";
import { projectKeys } from "../projects";
import {
CompleteAccountDTO,
CompleteAccountSignupDTO,
@@ -101,7 +101,7 @@ export const useSelectOrganization = () => {
},
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: [organizationKeys.getUserOrganizations, workspaceKeys.getAllUserWorkspace]
queryKey: [organizationKeys.getUserOrganizations, projectKeys.getAllUserProjects]
});
}
});

View File

@@ -2,7 +2,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { workspaceKeys } from "../workspace";
import { projectKeys } from "../projects";
import { CaType } from "./enums";
import { caKeys } from "./queries";
import {
@@ -118,8 +118,8 @@ export const useImportCaCertificate = (projectId: string) => {
);
return data;
},
onSuccess: (_, { caId, projectSlug }) => {
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspaceCas({ projectSlug }) });
onSuccess: (_, { caId }) => {
queryClient.invalidateQueries({ queryKey: projectKeys.getProjectCas({ projectId }) });
queryClient.invalidateQueries({ queryKey: caKeys.getCaCerts(caId) });
queryClient.invalidateQueries({ queryKey: caKeys.getCaCert(caId) });
queryClient.invalidateQueries({
@@ -142,7 +142,7 @@ export const useCreateCertificate = () => {
},
onSuccess: (_, { projectSlug }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.forWorkspaceCertificates(projectSlug)
queryKey: projectKeys.forProjectCertificates(projectSlug)
});
}
});
@@ -158,8 +158,8 @@ export const useRenewCa = () => {
);
return data;
},
onSuccess: (_, { caId, projectSlug }) => {
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspaceCas({ projectSlug }) });
onSuccess: ({ projectId }, { caId }) => {
queryClient.invalidateQueries({ queryKey: projectKeys.getProjectCas({ projectId }) });
queryClient.invalidateQueries({ queryKey: caKeys.getCaById(caId) });
queryClient.invalidateQueries({ queryKey: caKeys.getCaCert(caId) });
queryClient.invalidateQueries({ queryKey: caKeys.getCaCerts(caId) });

View File

@@ -182,4 +182,5 @@ export type TRenewCaResponse = {
certificate: string;
certificateChain: string;
serialNumber: string;
projectId: string;
};

View File

@@ -3,7 +3,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { caKeys } from "../ca/queries";
import { workspaceKeys } from "../workspace";
import { projectKeys } from "../projects";
import { certTemplateKeys } from "./queries";
import {
TCertificateTemplate,
@@ -29,7 +29,7 @@ export const useCreateCertTemplate = () => {
},
onSuccess: ({ caId }, { projectId }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceCertificateTemplates(projectId)
queryKey: projectKeys.getProjectCertificateTemplates(projectId)
});
queryClient.invalidateQueries({ queryKey: caKeys.getCaCertTemplates(caId) });
}
@@ -49,7 +49,7 @@ export const useUpdateCertTemplate = () => {
},
onSuccess: ({ caId }, { projectId, id }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceCertificateTemplates(projectId)
queryKey: projectKeys.getProjectCertificateTemplates(projectId)
});
queryClient.invalidateQueries({ queryKey: certTemplateKeys.getCertTemplateById(id) });
queryClient.invalidateQueries({ queryKey: caKeys.getCaCertTemplates(caId) });
@@ -68,7 +68,7 @@ export const useDeleteCertTemplate = () => {
},
onSuccess: ({ caId }, { projectId, id }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceCertificateTemplates(projectId)
queryKey: projectKeys.getProjectCertificateTemplates(projectId)
});
queryClient.invalidateQueries({ queryKey: certTemplateKeys.getCertTemplateById(id) });
queryClient.invalidateQueries({ queryKey: caKeys.getCaCertTemplates(caId) });

View File

@@ -3,7 +3,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { pkiSubscriberKeys } from "../pkiSubscriber/queries";
import { workspaceKeys } from "../workspace";
import { projectKeys } from "../projects";
import {
TCertificate,
TDeleteCertDTO,
@@ -25,7 +25,7 @@ export const useDeleteCert = () => {
},
onSuccess: (_, { projectSlug }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.forWorkspaceCertificates(projectSlug)
queryKey: projectKeys.forProjectCertificates(projectSlug)
});
}
});
@@ -47,7 +47,7 @@ export const useRevokeCert = () => {
},
onSuccess: (_, { projectSlug }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.forWorkspaceCertificates(projectSlug)
queryKey: projectKeys.forProjectCertificates(projectSlug)
});
queryClient.invalidateQueries({
queryKey: pkiSubscriberKeys.allPkiSubscriberCertificates()
@@ -68,7 +68,7 @@ export const useImportCertificate = () => {
},
onSuccess: (_, { projectSlug }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.forWorkspaceCertificates(projectSlug)
queryKey: projectKeys.forProjectCertificates(projectSlug)
});
}
});

View File

@@ -1,7 +1,7 @@
import { OrderByDirection } from "../generic/types";
import { OrgIdentityOrderBy } from "../organization/types";
import { TOrgRole } from "../roles/types";
import { ProjectUserMembershipTemporaryMode, Project } from "../workspace/types";
import { ProjectUserMembershipTemporaryMode, Project } from "../projects/types";
import { IdentityAuthMethod, IdentityJwtConfigurationType } from "./enums";
export type IdentityTrustedIp = {

View File

@@ -1,5 +1,5 @@
export * from "./accessApproval";
export * from "./admin";
export * from "./accessApproval";
export * from "./apiKeys";
export * from "./assumePrivileges";
export * from "./auditLogs";
@@ -20,7 +20,6 @@ export * from "./identityProjectAdditionalPrivilege";
export * from "./incidentContacts";
export * from "./integrationAuth";
export * from "./integrations";
export * from "./keys";
export * from "./kms";
export * from "./ldapConfig";
export * from "./oidcConfig";
@@ -54,4 +53,4 @@ export * from "./trustedIps";
export * from "./users";
export * from "./webhooks";
export * from "./workflowIntegrations";
export * from "./workspace";
export * from "./projects";

View File

@@ -3,7 +3,7 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { TReactQueryOptions } from "@app/types/reactQuery";
import { workspaceKeys } from "../workspace";
import { projectKeys } from "../projects";
import {
App,
BitbucketEnvironment,
@@ -970,7 +970,7 @@ export const useAuthorizeIntegration = () => {
},
onSuccess: (res) => {
queryClient.invalidateQueries({
queryKey: { queryKey: workspaceKeys.getWorkspaceAuthorization(res.workspace) }
queryKey: { queryKey: projectKeys.getProjectAuthorization(res.workspace) }
});
}
});
@@ -1016,7 +1016,7 @@ export const useSaveIntegrationAccessToken = () => {
},
onSuccess: (res) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceAuthorization(res.workspace)
queryKey: projectKeys.getProjectAuthorization(res.workspace)
});
}
});
@@ -1035,10 +1035,10 @@ export const useDeleteIntegrationAuths = () => {
),
onSuccess: (_, { workspaceId }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceAuthorization(workspaceId)
queryKey: projectKeys.getProjectAuthorization(workspaceId)
});
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceIntegrations(workspaceId)
queryKey: projectKeys.getProjectIntegrations(workspaceId)
});
}
});
@@ -1052,10 +1052,10 @@ export const useDeleteIntegrationAuth = () => {
mutationFn: ({ id }) => apiRequest.delete(`/api/v1/integration-auth/${id}`),
onSuccess: (_, { workspaceId }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceAuthorization(workspaceId)
queryKey: projectKeys.getProjectAuthorization(workspaceId)
});
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceIntegrations(workspaceId)
queryKey: projectKeys.getProjectIntegrations(workspaceId)
});
}
});

View File

@@ -3,7 +3,7 @@ import { useMutation, useQuery, useQueryClient, UseQueryOptions } from "@tanstac
import { createNotification } from "@app/components/notifications";
import { apiRequest } from "@app/config/request";
import { workspaceKeys } from "../workspace";
import { projectKeys } from "../projects";
import {
IntegrationMetadataSyncMode,
TCloudIntegration,
@@ -121,7 +121,7 @@ export const useCreateIntegration = () => {
},
onSuccess: (res) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceIntegrations(res.workspace)
queryKey: projectKeys.getProjectIntegrations(res.workspace)
});
}
});
@@ -141,10 +141,10 @@ export const useDeleteIntegration = () => {
),
onSuccess: (_, { workspaceId }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceIntegrations(workspaceId)
queryKey: projectKeys.getProjectIntegrations(workspaceId)
});
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceAuthorization(workspaceId)
queryKey: projectKeys.getProjectAuthorization(workspaceId)
});
}
});

View File

@@ -2,7 +2,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { workspaceKeys } from "../workspace";
import { projectKeys } from "../projects";
export const useImportEnvKey = () => {
const queryClient = useQueryClient();
@@ -34,7 +34,7 @@ export const useImportEnvKey = () => {
},
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getAllUserWorkspace()
queryKey: projectKeys.getAllUserProjects()
});
}
});

View File

@@ -2,7 +2,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { workspaceKeys } from "../workspace";
import { projectKeys } from "../projects";
import { pkiAlertKeys } from "./queries";
import { TCreatePkiAlertDTO, TDeletePkiAlertDTO, TPkiAlert, TUpdatePkiAlertDTO } from "./types";
@@ -14,7 +14,7 @@ export const useCreatePkiAlert = () => {
return alert;
},
onSuccess: (_, { projectId }) => {
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspacePkiAlerts(projectId) });
queryClient.invalidateQueries({ queryKey: projectKeys.getProjectPkiAlerts(projectId) });
}
});
};
@@ -30,7 +30,7 @@ export const useUpdatePkiAlert = () => {
return alert;
},
onSuccess: (_, { projectId, alertId }) => {
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspacePkiAlerts(projectId) });
queryClient.invalidateQueries({ queryKey: projectKeys.getProjectPkiAlerts(projectId) });
queryClient.invalidateQueries({ queryKey: pkiAlertKeys.getPkiAlertById(alertId) });
}
});
@@ -44,7 +44,7 @@ export const useDeletePkiAlert = () => {
return alert;
},
onSuccess: (_, { projectId, alertId }) => {
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspacePkiAlerts(projectId) });
queryClient.invalidateQueries({ queryKey: projectKeys.getProjectPkiAlerts(projectId) });
queryClient.invalidateQueries({ queryKey: pkiAlertKeys.getPkiAlertById(alertId) });
}
});

View File

@@ -2,7 +2,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { workspaceKeys } from "../workspace";
import { projectKeys } from "../projects";
import { pkiCollectionKeys } from "./queries";
import {
TAddItemToPkiCollectionDTO,
@@ -26,7 +26,7 @@ export const useCreatePkiCollection = () => {
},
onSuccess: (_, { projectId }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspacePkiCollections(projectId)
queryKey: projectKeys.getProjectPkiCollections(projectId)
});
}
});
@@ -44,7 +44,7 @@ export const useUpdatePkiCollection = () => {
},
onSuccess: (_, { projectId, collectionId }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspacePkiCollections(projectId)
queryKey: projectKeys.getProjectPkiCollections(projectId)
});
queryClient.invalidateQueries({
queryKey: pkiCollectionKeys.getPkiCollectionById(collectionId)
@@ -64,7 +64,7 @@ export const useDeletePkiCollection = () => {
},
onSuccess: (_, { projectId, collectionId }) => {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspacePkiCollections(projectId)
queryKey: projectKeys.getProjectPkiCollections(projectId)
});
queryClient.invalidateQueries({
queryKey: pkiCollectionKeys.getPkiCollectionById(collectionId)

View File

@@ -3,7 +3,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { TCreateCertificateResponse } from "../ca/types";
import { projectKeys } from "../workspace/query-keys";
import { projectKeys } from "../projects/query-keys";
import { pkiSubscriberKeys } from "./queries";
import {
TCreatePkiSubscriberDTO,
@@ -22,7 +22,7 @@ export const useCreatePkiSubscriber = () => {
},
onSuccess: ({ projectId, name }) => {
queryClient.invalidateQueries({
queryKey: projectKeys.getWorkspacePkiSubscribers(projectId)
queryKey: projectKeys.getProjectPkiSubscribers(projectId)
});
queryClient.invalidateQueries({
queryKey: pkiSubscriberKeys.getPkiSubscriber({
@@ -46,7 +46,7 @@ export const useUpdatePkiSubscriber = () => {
},
onSuccess: ({ projectId, name }) => {
queryClient.invalidateQueries({
queryKey: projectKeys.getWorkspacePkiSubscribers(projectId)
queryKey: projectKeys.getProjectPkiSubscribers(projectId)
});
queryClient.invalidateQueries({
queryKey: pkiSubscriberKeys.getPkiSubscriber({
@@ -74,7 +74,7 @@ export const useDeletePkiSubscriber = () => {
},
onSuccess: ({ name, projectId }) => {
queryClient.invalidateQueries({
queryKey: projectKeys.getWorkspacePkiSubscribers(projectId)
queryKey: projectKeys.getProjectPkiSubscribers(projectId)
});
queryClient.invalidateQueries({
queryKey: pkiSubscriberKeys.getPkiSubscriber({

View File

@@ -1,6 +1,6 @@
import { TProjectRole } from "@app/hooks/api/roles/types";
import { ProjectType } from "../workspace/types";
import { ProjectType } from "../projects/types";
export type TProjectTemplate = {
id: string;

View File

@@ -18,7 +18,7 @@ export {
useGetProjectSshConfig,
useGetUpgradeProjectStatus,
useGetUserWorkspaceMemberships,
useGetUserWorkspaces,
useGetUserProjects,
useGetWorkspaceAuthorizations,
useGetWorkspaceById,
useGetWorkspaceIdentityMembershipDetails,
@@ -41,7 +41,6 @@ export {
useListWorkspaceSshHostGroups,
useListWorkspaceSshHosts,
useSearchProjects,
useToggleAutoCapitalization,
useUpdateIdentityWorkspaceRole,
useUpdateProject,
useUpdateUserWorkspaceRole,

View File

@@ -32,7 +32,7 @@ export const useAddGroupToWorkspace = () => {
},
onSuccess: (_, { projectId }) => {
queryClient.invalidateQueries({
queryKey: projectKeys.getWorkspaceGroupMemberships(projectId)
queryKey: projectKeys.getProjectGroupMemberships(projectId)
});
}
});
@@ -52,10 +52,10 @@ export const useUpdateGroupWorkspaceRole = () => {
},
onSuccess: (_, { projectId, groupId }) => {
queryClient.invalidateQueries({
queryKey: projectKeys.getWorkspaceGroupMemberships(projectId)
queryKey: projectKeys.getProjectGroupMemberships(projectId)
});
queryClient.invalidateQueries({
queryKey: projectKeys.getWorkspaceGroupMembershipDetails(projectId, groupId)
queryKey: projectKeys.getProjectGroupMembershipDetails(projectId, groupId)
});
}
});
@@ -79,7 +79,7 @@ export const useDeleteGroupFromWorkspace = () => {
},
onSuccess: (_, { projectId, username }) => {
queryClient.invalidateQueries({
queryKey: projectKeys.getWorkspaceGroupMemberships(projectId)
queryKey: projectKeys.getProjectGroupMemberships(projectId)
});
if (username) {
@@ -96,7 +96,7 @@ export const useLeaveProject = () => {
return apiRequest.delete(`/api/v1/projects/${projectId}/leave`);
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: projectKeys.getAllUserWorkspace() });
queryClient.invalidateQueries({ queryKey: projectKeys.getAllUserProjects() });
}
});
};
@@ -109,7 +109,7 @@ export const useMigrateProjectToV3 = () => {
},
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: projectKeys.getAllUserWorkspace()
queryKey: projectKeys.getAllUserProjects()
});
}
});

View File

@@ -35,21 +35,18 @@ import {
ProjectType,
TGetUpgradeProjectStatusDTO,
TListProjectIdentitiesDTO,
ToggleAutoCapitalizationDTO,
ToggleDeleteProjectProtectionDTO,
TProjectSshConfig,
TSearchProjectsDTO,
TUpdateWorkspaceIdentityRoleDTO,
TUpdateWorkspaceUserRoleDTO,
UpdateAuditLogsRetentionDTO,
UpdateEnvironmentDTO,
UpdatePitVersionLimitDTO,
UpdateProjectDTO,
Project,
WorkspaceEnv
ProjectEnv
} from "./types";
export const fetchWorkspaceById = async (projectId: string) => {
export const fetchProjectById = async (projectId: string) => {
const { data } = await apiRequest.get<{ project: Project }>(`/api/v1/projects/${projectId}`);
return data.project;
@@ -82,7 +79,7 @@ export const useUpgradeProject = () => {
},
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: projectKeys.getAllUserWorkspace()
queryKey: projectKeys.getAllUserProjects()
});
}
});
@@ -113,7 +110,7 @@ const fetchUserWorkspaces = async (includeRoles?: boolean, type?: ProjectType |
export const useGetWorkspaceIndexStatus = (projectId: string) => {
return useQuery({
queryKey: projectKeys.getWorkspaceIndexStatus(projectId),
queryKey: projectKeys.getProjectIndexStatus(projectId),
queryFn: () => fetchWorkspaceIndexStatus(projectId),
enabled: true
});
@@ -124,14 +121,14 @@ export const useGetWorkspaceById = (
dto?: { refetchInterval?: number | false }
) => {
return useQuery({
queryKey: projectKeys.getWorkspaceById(projectId),
queryFn: () => fetchWorkspaceById(projectId),
queryKey: projectKeys.getProjectById(projectId),
queryFn: () => fetchProjectById(projectId),
enabled: Boolean(projectId),
refetchInterval: dto?.refetchInterval
});
};
export const useGetUserWorkspaces = ({
export const useGetUserProjects = ({
includeRoles,
options = {}
}: {
@@ -139,14 +136,14 @@ export const useGetUserWorkspaces = ({
options?: { enabled?: boolean };
} = {}) =>
useQuery({
queryKey: projectKeys.getAllUserWorkspace(),
queryKey: projectKeys.getAllUserProjects(),
queryFn: () => fetchUserWorkspaces(includeRoles),
...options
});
export const useSearchProjects = ({ options, ...dto }: TSearchProjectsDTO) =>
useQuery({
queryKey: projectKeys.searchWorkspace(dto),
queryKey: projectKeys.searchProject(dto),
queryFn: async () => {
const { data } = await apiRequest.post<{
projects: (Project & { isMember: boolean })[];
@@ -169,7 +166,7 @@ const fetchUserWorkspaceMemberships = async (orgId: string) => {
// to get all userids in an org with the project they are part of
export const useGetUserWorkspaceMemberships = (orgId: string) =>
useQuery({
queryKey: projectKeys.getWorkspaceMemberships(orgId),
queryKey: projectKeys.getProjectMemberships(orgId),
queryFn: () => fetchUserWorkspaceMemberships(orgId),
enabled: Boolean(orgId)
});
@@ -187,7 +184,7 @@ export const useGetWorkspaceAuthorizations = <TData = IntegrationAuth[],>(
select?: (data: IntegrationAuth[]) => TData
) =>
useQuery({
queryKey: projectKeys.getWorkspaceAuthorization(projectId),
queryKey: projectKeys.getProjectAuthorization(projectId),
queryFn: () => fetchWorkspaceAuthorization(projectId),
enabled: Boolean(projectId),
select
@@ -202,7 +199,7 @@ export const fetchWorkspaceIntegrations = async (projectId: string) => {
export const useGetWorkspaceIntegrations = (projectId: string) =>
useQuery({
queryKey: projectKeys.getWorkspaceIntegrations(projectId),
queryKey: projectKeys.getProjectIntegrations(projectId),
queryFn: () => fetchWorkspaceIntegrations(projectId),
enabled: Boolean(projectId),
refetchInterval: 4000
@@ -228,7 +225,7 @@ export const useCreateWorkspace = () => {
}),
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: projectKeys.getAllUserWorkspace()
queryKey: projectKeys.getAllUserProjects()
});
}
});
@@ -239,8 +236,9 @@ export const useUpdateProject = () => {
return useMutation<Project, object, UpdateProjectDTO>({
mutationFn: async ({
projectID,
projectId: projectID,
newProjectName,
hasDeleteProtection,
newProjectDescription,
newSlug,
secretSharing,
@@ -259,67 +257,14 @@ export const useUpdateProject = () => {
showSnapshotsLegacy,
secretDetectionIgnoreValues,
autoCapitalization,
pitVersionLimit
pitVersionLimit,
hasDeleteProtection
}
);
return data.project;
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: projectKeys.getAllUserWorkspace() });
}
});
};
export const useToggleAutoCapitalization = () => {
const queryClient = useQueryClient();
return useMutation<Project, object, ToggleAutoCapitalizationDTO>({
mutationFn: async ({ projectID, state }) => {
const { data } = await apiRequest.post<{ project: Project }>(
`/api/v1/projects/${projectID}/auto-capitalization`,
{
autoCapitalization: state
}
);
return data.project;
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: projectKeys.getAllUserWorkspace() });
}
});
};
export const useToggleDeleteProjectProtection = () => {
const queryClient = useQueryClient();
return useMutation<Project, object, ToggleDeleteProjectProtectionDTO>({
mutationFn: async ({ projectID, state }) => {
const { data } = await apiRequest.post<{ project: Project }>(
`/api/v1/projects/${projectID}/delete-protection`,
{
hasDeleteProtection: state
}
);
return data.project;
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: projectKeys.getAllUserWorkspace() });
}
});
};
export const useUpdateWorkspaceVersionLimit = () => {
const queryClient = useQueryClient();
return useMutation<Project, object, UpdatePitVersionLimitDTO>({
mutationFn: async ({ projectSlug, pitVersionLimit }) => {
const { data } = await apiRequest.put(`/api/v1/projects/${projectSlug}/version-limit`, {
pitVersionLimit
});
return data.project;
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: projectKeys.getAllUserWorkspace() });
queryClient.invalidateQueries({ queryKey: projectKeys.getAllUserProjects() });
}
});
};
@@ -338,7 +283,7 @@ export const useUpdateWorkspaceAuditLogsRetention = () => {
return data.project;
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: projectKeys.getAllUserWorkspace() });
queryClient.invalidateQueries({ queryKey: projectKeys.getAllUserProjects() });
}
});
};
@@ -352,7 +297,7 @@ export const useDeleteWorkspace = () => {
return data.project;
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: projectKeys.getAllUserWorkspace() });
queryClient.invalidateQueries({ queryKey: projectKeys.getAllUserProjects() });
queryClient.invalidateQueries({
queryKey: ["org-admin-projects"]
});
@@ -363,9 +308,9 @@ export const useDeleteWorkspace = () => {
export const useCreateWsEnvironment = () => {
const queryClient = useQueryClient();
return useMutation<WorkspaceEnv, WorkspaceEnv, CreateEnvironmentDTO>({
return useMutation<ProjectEnv, ProjectEnv, CreateEnvironmentDTO>({
mutationFn: async ({ projectId, name, slug }) => {
const { data } = await apiRequest.post<{ environment: WorkspaceEnv }>(
const { data } = await apiRequest.post<{ environment: ProjectEnv }>(
`/api/v1/projects/${projectId}/environments`,
{
name,
@@ -376,7 +321,7 @@ export const useCreateWsEnvironment = () => {
},
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: projectKeys.getAllUserWorkspace()
queryKey: projectKeys.getAllUserProjects()
});
}
});
@@ -395,7 +340,7 @@ export const useUpdateWsEnvironment = () => {
},
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: projectKeys.getAllUserWorkspace()
queryKey: projectKeys.getAllUserProjects()
});
}
});
@@ -410,7 +355,7 @@ export const useDeleteWsEnvironment = () => {
},
onSuccess: () => {
queryClient.invalidateQueries({
queryKey: projectKeys.getAllUserWorkspace()
queryKey: projectKeys.getAllUserProjects()
});
}
});
@@ -422,7 +367,7 @@ export const useGetWorkspaceUsers = (
roles?: string[]
) => {
return useQuery({
queryKey: projectKeys.getWorkspaceUsers(projectId, includeGroupMembers, roles),
queryKey: projectKeys.getProjectUsers(projectId, includeGroupMembers, roles),
queryFn: async () => {
const {
data: { users }
@@ -443,7 +388,7 @@ export const useGetWorkspaceUsers = (
export const useGetWorkspaceUserDetails = (projectId: string, membershipId: string) => {
return useQuery({
queryKey: projectKeys.getWorkspaceUserDetails(projectId, membershipId),
queryKey: projectKeys.getProjectUserDetails(projectId, membershipId),
queryFn: async () => {
const {
data: { membership }
@@ -476,7 +421,7 @@ export const useDeleteUserFromWorkspace = () => {
return deletedMembership;
},
onSuccess: (_, { orgId, projectId }) => {
queryClient.invalidateQueries({ queryKey: projectKeys.getWorkspaceUsers(projectId) });
queryClient.invalidateQueries({ queryKey: projectKeys.getProjectUsers(projectId) });
queryClient.invalidateQueries({
queryKey: userKeys.allOrgMembershipProjectMemberships(orgId)
});
@@ -499,9 +444,9 @@ export const useUpdateUserWorkspaceRole = () => {
return membership;
},
onSuccess: (_, { projectId, membershipId }) => {
queryClient.invalidateQueries({ queryKey: projectKeys.getWorkspaceUsers(projectId) });
queryClient.invalidateQueries({ queryKey: projectKeys.getProjectUsers(projectId) });
queryClient.invalidateQueries({
queryKey: projectKeys.getWorkspaceUserDetails(projectId, membershipId)
queryKey: projectKeys.getProjectUserDetails(projectId, membershipId)
});
}
});
@@ -532,7 +477,7 @@ export const useAddIdentityToWorkspace = () => {
},
onSuccess: (_, { identityId, projectId }) => {
queryClient.invalidateQueries({
queryKey: projectKeys.getWorkspaceIdentityMemberships(projectId)
queryKey: projectKeys.getProjectIdentityMemberships(projectId)
});
queryClient.invalidateQueries({
queryKey: identitiesKeys.getIdentityProjectMemberships(identityId)
@@ -558,13 +503,13 @@ export const useUpdateIdentityWorkspaceRole = () => {
},
onSuccess: (_, { identityId, projectId }) => {
queryClient.invalidateQueries({
queryKey: projectKeys.getWorkspaceIdentityMemberships(projectId)
queryKey: projectKeys.getProjectIdentityMemberships(projectId)
});
queryClient.invalidateQueries({
queryKey: identitiesKeys.getIdentityProjectMemberships(identityId)
});
queryClient.invalidateQueries({
queryKey: projectKeys.getWorkspaceIdentityMembershipDetails(projectId, identityId)
queryKey: projectKeys.getProjectIdentityMembershipDetails(projectId, identityId)
});
}
});
@@ -583,7 +528,7 @@ export const useDeleteIdentityFromWorkspace = () => {
},
onSuccess: (_, { identityId, projectId }) => {
queryClient.invalidateQueries({
queryKey: projectKeys.getWorkspaceIdentityMemberships(projectId)
queryKey: projectKeys.getProjectIdentityMemberships(projectId)
});
queryClient.invalidateQueries({
queryKey: identitiesKeys.getIdentityProjectMemberships(identityId)
@@ -606,13 +551,13 @@ export const useGetWorkspaceIdentityMemberships = (
TProjectIdentitiesList,
unknown,
TProjectIdentitiesList,
ReturnType<typeof projectKeys.getWorkspaceIdentityMembershipsWithParams>
ReturnType<typeof projectKeys.getProjectIdentityMembershipsWithParams>
>,
"queryKey" | "queryFn"
>
) => {
return useQuery({
queryKey: projectKeys.getWorkspaceIdentityMembershipsWithParams({
queryKey: projectKeys.getProjectIdentityMembershipsWithParams({
projectId,
offset,
limit,
@@ -643,7 +588,7 @@ export const useGetWorkspaceIdentityMemberships = (
export const useGetWorkspaceIdentityMembershipDetails = (projectId: string, identityId: string) => {
return useQuery({
enabled: Boolean(projectId && identityId),
queryKey: projectKeys.getWorkspaceIdentityMembershipDetails(projectId, identityId),
queryKey: projectKeys.getProjectIdentityMembershipDetails(projectId, identityId),
queryFn: async () => {
const {
data: { identityMembership }
@@ -658,7 +603,7 @@ export const useGetWorkspaceIdentityMembershipDetails = (projectId: string, iden
export const useGetWorkspaceGroupMembershipDetails = (projectId: string, groupId: string) => {
return useQuery({
enabled: Boolean(projectId && groupId),
queryKey: projectKeys.getWorkspaceGroupMembershipDetails(projectId, groupId),
queryKey: projectKeys.getProjectGroupMembershipDetails(projectId, groupId),
queryFn: async () => {
const {
data: { groupMembership }
@@ -672,7 +617,7 @@ export const useGetWorkspaceGroupMembershipDetails = (projectId: string, groupId
export const useListWorkspaceGroups = (projectId: string) => {
return useQuery({
queryKey: projectKeys.getWorkspaceGroupMemberships(projectId),
queryKey: projectKeys.getProjectGroupMemberships(projectId),
queryFn: async () => {
const {
data: { groupMemberships }
@@ -693,7 +638,7 @@ export const useListWorkspaceCas = ({
status?: CaStatus;
}) => {
return useQuery({
queryKey: projectKeys.specificWorkspaceCas({
queryKey: projectKeys.specificProjectCas({
projectId,
status
}),
@@ -726,7 +671,7 @@ export const useListWorkspaceCertificates = ({
limit: number;
}) => {
return useQuery({
queryKey: projectKeys.specificWorkspaceCertificates({
queryKey: projectKeys.specificProjectCertificates({
projectId,
offset,
limit
@@ -754,7 +699,7 @@ export const useListWorkspaceCertificates = ({
export const useListWorkspacePkiAlerts = ({ projectId }: { projectId: string }) => {
return useQuery({
queryKey: projectKeys.getWorkspacePkiAlerts(projectId),
queryKey: projectKeys.getProjectPkiAlerts(projectId),
queryFn: async () => {
const {
data: { alerts }
@@ -768,7 +713,7 @@ export const useListWorkspacePkiAlerts = ({ projectId }: { projectId: string })
export const useListWorkspacePkiCollections = ({ projectId }: { projectId: string }) => {
return useQuery({
queryKey: projectKeys.getWorkspacePkiCollections(projectId),
queryKey: projectKeys.getProjectPkiCollections(projectId),
queryFn: async () => {
const {
data: { collections }
@@ -784,7 +729,7 @@ export const useListWorkspacePkiCollections = ({ projectId }: { projectId: strin
export const useListWorkspaceCertificateTemplates = ({ projectId }: { projectId: string }) => {
return useQuery({
queryKey: projectKeys.getWorkspaceCertificateTemplates(projectId),
queryKey: projectKeys.getProjectCertificateTemplates(projectId),
queryFn: async () => {
const {
data: { certificateTemplates }
@@ -808,7 +753,7 @@ export const useListWorkspaceSshCertificates = ({
projectId: string;
}) => {
return useQuery({
queryKey: projectKeys.specificWorkspaceSshCertificates({
queryKey: projectKeys.specificProjectSshCertificates({
offset,
limit,
projectId
@@ -833,7 +778,7 @@ export const useListWorkspaceSshCertificates = ({
export const useListWorkspaceSshCas = (projectId: string) => {
return useQuery({
queryKey: projectKeys.getWorkspaceSshCas(projectId),
queryKey: projectKeys.getProjectSshCas(projectId),
queryFn: async () => {
const {
data: { cas }
@@ -848,7 +793,7 @@ export const useListWorkspaceSshCas = (projectId: string) => {
export const useListWorkspaceSshHosts = (projectId: string) => {
return useQuery({
queryKey: projectKeys.getWorkspaceSshHosts(projectId),
queryKey: projectKeys.getProjectSshHosts(projectId),
queryFn: async () => {
const {
data: { hosts }
@@ -861,7 +806,7 @@ export const useListWorkspaceSshHosts = (projectId: string) => {
export const useListWorkspacePkiSubscribers = (projectId: string) => {
return useQuery({
queryKey: projectKeys.getWorkspacePkiSubscribers(projectId),
queryKey: projectKeys.getProjectPkiSubscribers(projectId),
queryFn: async () => {
const {
data: { subscribers }
@@ -876,7 +821,7 @@ export const useListWorkspacePkiSubscribers = (projectId: string) => {
export const useListWorkspaceSshHostGroups = (projectId: string) => {
return useQuery({
queryKey: projectKeys.getWorkspaceSshHostGroups(projectId),
queryKey: projectKeys.getProjectSshHostGroups(projectId),
queryFn: async () => {
const {
data: { groups }
@@ -891,7 +836,7 @@ export const useListWorkspaceSshHostGroups = (projectId: string) => {
export const useListWorkspaceSshCertificateTemplates = (projectId: string) => {
return useQuery({
queryKey: projectKeys.getWorkspaceSshCertificateTemplates(projectId),
queryKey: projectKeys.getProjectSshCertificateTemplates(projectId),
queryFn: async () => {
const { data } = await apiRequest.get<{ certificateTemplates: TSshCertificateTemplate[] }>(
`/api/v1/projects/${projectId}/ssh-certificate-templates`
@@ -910,7 +855,7 @@ export const useGetWorkspaceWorkflowIntegrationConfig = ({
integration: WorkflowIntegrationPlatform;
}) => {
return useQuery({
queryKey: projectKeys.getWorkspaceWorkflowIntegrationConfig(projectId, integration),
queryKey: projectKeys.getProjectWorkflowIntegrationConfig(projectId, integration),
queryFn: async () => {
const { data } = await apiRequest
.get<ProjectWorkflowIntegrationConfig>(

View File

@@ -0,0 +1,78 @@
import { TListProjectIdentitiesDTO, TSearchProjectsDTO } from "./types";
import type { CaStatus } from "../ca";
import { WorkflowIntegrationPlatform } from "../workflowIntegrations/types";
export const projectKeys = {
getProjectById: (projectId: string) => ["projects", { projectId }] as const,
getProjectSecrets: (projectId: string) => [{ projectId }, "project-secrets"] as const,
getProjectIndexStatus: (projectId: string) => [{ projectId }, "project-index-status"] as const,
getProjectUpgradeStatus: (projectId: string) => [{ projectId }, "project-upgrade-status"],
getProjectMemberships: (orgId: string) => [{ orgId }, "project-memberships"],
getProjectAuthorization: (projectId: string) => [{ projectId }, "project-authorizations"],
getProjectIntegrations: (projectId: string) => [{ projectId }, "project-integrations"],
getAllUserProjects: () => ["projects"] as const,
getProjectAuditLogs: (projectId: string) => [{ projectId }, "project-audit-logs"] as const,
getProjectUsers: (
projectId: string,
includeGroupMembers: boolean = false,
roles: string[] = []
) => [{ projectId, includeGroupMembers, roles }, "project-users"] as const,
getProjectUserDetails: (projectId: string, membershipId: string) =>
[{ projectId, membershipId }, "project-user-details"] as const,
getProjectIdentityMemberships: (projectId: string) =>
[{ projectId }, "project-identity-memberships"] as const,
getProjectIdentityMembershipDetails: (projectId: string, identityId: string) =>
[{ projectId, identityId }, "project-identity-membership-details"] as const,
// allows invalidation using above key without knowing params
getProjectIdentityMembershipsWithParams: ({ projectId, ...params }: TListProjectIdentitiesDTO) =>
[...projectKeys.getProjectIdentityMemberships(projectId), params] as const,
searchProject: (dto: TSearchProjectsDTO) => ["search-projects", dto] as const,
getProjectGroupMemberships: (projectId: string) => [{ projectId }, "project-groups"] as const,
getProjectGroupMembershipDetails: (projectId: string, groupId: string) =>
[{ projectId, groupId }, "project-group-membership-details"] as const,
getProjectCas: ({ projectId }: { projectId: string }) => [{ projectId }, "project-cas"] as const,
specificProjectCas: ({ projectId, status }: { projectId: string; status?: CaStatus }) =>
[...projectKeys.getProjectCas({ projectId }), { status }] as const,
allProjectCertificates: () => ["project-certificates"] as const,
forProjectCertificates: (projectId: string) =>
[...projectKeys.allProjectCertificates(), projectId] as const,
specificProjectCertificates: ({
projectId,
offset,
limit
}: {
projectId: string;
offset: number;
limit: number;
}) => [...projectKeys.forProjectCertificates(projectId), { offset, limit }] as const,
getProjectPkiAlerts: (projectId: string) => [{ projectId }, "project-pki-alerts"] as const,
getProjectPkiSubscribers: (projectId: string) =>
[{ projectId }, "project-pki-subscribers"] as const,
getProjectPkiCollections: (projectId: string) =>
[{ projectId }, "project-pki-collections"] as const,
getProjectCertificateTemplates: (projectId: string) =>
[{ projectId }, "project-certificate-templates"] as const,
getProjectWorkflowIntegrationConfig: (
projectId: string,
integration: WorkflowIntegrationPlatform
) => [{ projectId, integration }, "project-workflow-integration-config"] as const,
getProjectSshCas: (projectId: string) => [{ projectId }, "project-ssh-cas"] as const,
allProjectSshCertificates: (projectId: string) =>
[{ projectId }, "project-ssh-certificates"] as const,
getProjectSshHosts: (projectId: string) => [{ projectId }, "project-ssh-hosts"] as const,
getProjectSshHostGroups: (projectId: string) =>
[{ projectId }, "project-ssh-host-groups"] as const,
specificProjectSshCertificates: ({
offset,
limit,
projectId
}: {
offset: number;
limit: number;
projectId: string;
}) => [...projectKeys.allProjectSshCertificates(projectId), { offset, limit }] as const,
getProjectSshCertificateTemplates: (projectId: string) =>
[{ projectId }, "project-ssh-certificate-templates"] as const,
getProjectSshConfig: (projectId: string) => [{ projectId }, "project-ssh-config"] as const
};

View File

@@ -31,7 +31,7 @@ export type Project = {
upgradeStatus: string | null;
updatedAt: string;
autoCapitalization: boolean;
environments: WorkspaceEnv[];
environments: ProjectEnv[];
pitVersionLimit: number;
auditLogsRetentionDays: number;
slug: string;
@@ -43,13 +43,13 @@ export type Project = {
secretDetectionIgnoreValues: string[];
};
export type WorkspaceEnv = {
export type ProjectEnv = {
id: string;
name: string;
slug: string;
};
export type WorkspaceTag = { id: string; name: string; slug: string };
export type ProjectTag = { id: string; name: string; slug: string };
export type NameWorkspaceSecretsDTO = {
projectId: string;
@@ -76,7 +76,7 @@ export type CreateWorkspaceDTO = {
};
export type UpdateProjectDTO = {
projectID: string;
projectId: string;
newProjectName?: string;
newProjectDescription?: string;
newSlug?: string;
@@ -85,6 +85,7 @@ export type UpdateProjectDTO = {
secretDetectionIgnoreValues?: string[];
pitVersionLimit?: number;
autoCapitalization?: boolean;
hasDeleteProtection?: boolean;
};
export type UpdatePitVersionLimitDTO = { projectSlug: string; pitVersionLimit: number };

View File

@@ -1,11 +1,11 @@
import { EnforcementLevel } from "../policies/enums";
import { WorkspaceEnv } from "../workspace/types";
import { ProjectEnv } from "../projects/types";
export type TSecretApprovalPolicy = {
id: string;
project: string;
name: string;
environments: WorkspaceEnv[];
environments: ProjectEnv[];
secretPath?: string;
approvals: number;
approvers: Approver[];

View File

@@ -1,4 +1,4 @@
import { WorkspaceEnv } from "@app/hooks/api/workspace/types";
import { ProjectEnv } from "@app/hooks/api/projects/types";
export enum ReservedFolders {
SecretReplication = "__reserve_replication_"
@@ -22,7 +22,7 @@ export type TSecretFolder = {
export type TSecretFolderWithPath = TSecretFolder & { path: string };
export type TProjectEnvironmentsFolders = {
[key: string]: WorkspaceEnv & { folders: TSecretFolderWithPath[] };
[key: string]: ProjectEnv & { folders: TSecretFolderWithPath[] };
};
export type TGetProjectFoldersDTO = {

View File

@@ -1,11 +1,11 @@
import { SecretV3Raw } from "../secrets/types";
import { WorkspaceEnv } from "../workspace/types";
import { ProjectEnv } from "../projects/types";
export type TSecretImport = {
id: string;
folderId: string;
importPath: string;
importEnv: WorkspaceEnv;
importEnv: ProjectEnv;
position: string;
createdAt: string;
updatedAt: string;
@@ -25,7 +25,7 @@ export type TGetImportedFoldersByEnvDTO = {
export type TImportedSecrets = {
environment: string;
environmentInfo: WorkspaceEnv;
environmentInfo: ProjectEnv;
secretPath: string;
folderId: string;
secrets: SecretV3Raw[];

View File

@@ -1,4 +1,4 @@
import { WorkspaceEnv } from "../workspace/types";
import { ProjectEnv } from "../projects/types";
export enum TProviderFunctionTypes {
HTTP = "http",
@@ -80,7 +80,7 @@ export type TSecretRotation = {
customProvider: string;
workspace: string;
envId: string;
environment: WorkspaceEnv;
environment: ProjectEnv;
secretPath: string;
outputs: Array<{
key: string;

View File

@@ -1,5 +1,5 @@
import { SecretVersions } from "../secrets/types";
import { WorkspaceEnv } from "../types";
import { ProjectEnv } from "../types";
export type TSecretSnapshot = {
id: string;
@@ -13,7 +13,7 @@ export type TSnapshotData = Omit<TSecretSnapshot, "secretVersions"> & {
id: string;
secretVersions: (SecretVersions & { isRotatedSecret?: boolean })[];
folderVersion: Array<{ name: string; id: string }>;
environment: WorkspaceEnv;
environment: ProjectEnv;
};
export type TSnapshotDataProps = {

View File

@@ -333,11 +333,11 @@ export const useMoveSecrets = ({
mutationFn: async ({
sourceEnvironment,
sourceSecretPath,
projectSlug,
destinationEnvironment,
destinationSecretPath,
secretIds,
shouldOverwrite
shouldOverwrite,
projectId
}) => {
const { data } = await apiRequest.post<{
isSourceUpdated: boolean;
@@ -345,11 +345,11 @@ export const useMoveSecrets = ({
}>("/api/v4/secrets/move", {
sourceEnvironment,
sourceSecretPath,
projectSlug,
destinationEnvironment,
destinationSecretPath,
secretIds,
shouldOverwrite
shouldOverwrite,
projectId
});
return data;

View File

@@ -227,7 +227,6 @@ export type TDeleteSecretBatchDTO = {
};
export type TMoveSecretsDTO = {
projectSlug: string;
projectId: string;
sourceEnvironment: string;
sourceSecretPath: string;

View File

@@ -2,7 +2,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { projectKeys } from "../workspace/query-keys";
import { projectKeys } from "../projects/query-keys";
import {
TCreateSshCaDTO,
TDeleteSshCaDTO,
@@ -28,7 +28,7 @@ export const useCreateSshCa = () => {
return ca;
},
onSuccess: ({ projectId }) => {
queryClient.invalidateQueries({ queryKey: projectKeys.getWorkspaceSshCas(projectId) });
queryClient.invalidateQueries({ queryKey: projectKeys.getProjectSshCas(projectId) });
}
});
};
@@ -43,7 +43,7 @@ export const useUpdateSshCa = () => {
return ca;
},
onSuccess: ({ projectId }, { caId }) => {
queryClient.invalidateQueries({ queryKey: projectKeys.getWorkspaceSshCas(projectId) });
queryClient.invalidateQueries({ queryKey: projectKeys.getProjectSshCas(projectId) });
queryClient.invalidateQueries({ queryKey: sshCaKeys.getSshCaById(caId) });
}
});
@@ -59,7 +59,7 @@ export const useDeleteSshCa = () => {
return ca;
},
onSuccess: ({ projectId }) => {
queryClient.invalidateQueries({ queryKey: projectKeys.getWorkspaceSshCas(projectId) });
queryClient.invalidateQueries({ queryKey: projectKeys.getProjectSshCas(projectId) });
}
});
};
@@ -76,7 +76,7 @@ export const useSignSshKey = () => {
},
onSuccess: (_, { projectId }) => {
queryClient.invalidateQueries({
queryKey: projectKeys.allWorkspaceSshCertificates(projectId)
queryKey: projectKeys.allProjectSshCertificates(projectId)
});
}
});
@@ -94,7 +94,7 @@ export const useIssueSshCreds = () => {
},
onSuccess: (_, { projectId }) => {
queryClient.invalidateQueries({
queryKey: projectKeys.allWorkspaceSshCertificates(projectId)
queryKey: projectKeys.allProjectSshCertificates(projectId)
});
}
});

View File

@@ -2,7 +2,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { projectKeys } from "../workspace/query-keys";
import { projectKeys } from "../projects/query-keys";
import { TCreateSshHostDTO, TDeleteSshHostDTO, TSshHost, TUpdateSshHostDTO } from "./types";
export const useCreateSshHost = () => {
@@ -13,7 +13,7 @@ export const useCreateSshHost = () => {
return host;
},
onSuccess: ({ projectId }) => {
queryClient.invalidateQueries({ queryKey: projectKeys.getWorkspaceSshHosts(projectId) });
queryClient.invalidateQueries({ queryKey: projectKeys.getProjectSshHosts(projectId) });
}
});
};
@@ -26,7 +26,7 @@ export const useUpdateSshHost = () => {
return host;
},
onSuccess: ({ projectId }) => {
queryClient.invalidateQueries({ queryKey: projectKeys.getWorkspaceSshHosts(projectId) });
queryClient.invalidateQueries({ queryKey: projectKeys.getProjectSshHosts(projectId) });
}
});
};
@@ -39,7 +39,7 @@ export const useDeleteSshHost = () => {
return host;
},
onSuccess: ({ projectId }) => {
queryClient.invalidateQueries({ queryKey: projectKeys.getWorkspaceSshHosts(projectId) });
queryClient.invalidateQueries({ queryKey: projectKeys.getProjectSshHosts(projectId) });
}
});
};

View File

@@ -2,7 +2,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { projectKeys } from "../workspace/query-keys";
import { projectKeys } from "../projects/query-keys";
import { sshHostGroupKeys } from "./queries";
import {
TCreateSshHostGroupDTO,
@@ -20,7 +20,7 @@ export const useCreateSshHostGroup = () => {
},
onSuccess: ({ projectId, id }) => {
queryClient.invalidateQueries({
queryKey: projectKeys.getWorkspaceSshHostGroups(projectId)
queryKey: projectKeys.getProjectSshHostGroups(projectId)
});
queryClient.invalidateQueries({
queryKey: sshHostGroupKeys.getSshHostGroupById(id)
@@ -41,10 +41,10 @@ export const useUpdateSshHostGroup = () => {
},
onSuccess: ({ projectId }, { sshHostGroupId }) => {
queryClient.invalidateQueries({
queryKey: projectKeys.getWorkspaceSshHostGroups(projectId)
queryKey: projectKeys.getProjectSshHostGroups(projectId)
});
queryClient.invalidateQueries({
queryKey: projectKeys.getWorkspaceSshHosts(projectId)
queryKey: projectKeys.getProjectSshHosts(projectId)
});
queryClient.invalidateQueries({
queryKey: sshHostGroupKeys.getSshHostGroupById(sshHostGroupId)
@@ -64,10 +64,10 @@ export const useDeleteSshHostGroup = () => {
},
onSuccess: ({ projectId }, { sshHostGroupId }) => {
queryClient.invalidateQueries({
queryKey: projectKeys.getWorkspaceSshHostGroups(projectId)
queryKey: projectKeys.getProjectSshHostGroups(projectId)
});
queryClient.invalidateQueries({
queryKey: projectKeys.getWorkspaceSshHosts(projectId)
queryKey: projectKeys.getProjectSshHosts(projectId)
});
queryClient.invalidateQueries({
queryKey: sshHostGroupKeys.getSshHostGroupById(sshHostGroupId)

View File

@@ -28,7 +28,7 @@ export const useCreateWsTag = () => {
const queryClient = useQueryClient();
return useMutation<WsTag, object, CreateTagDTO>({
mutationFn: async ({ projectID, tagColor, tagSlug }) => {
mutationFn: async ({ projectId: projectID, tagColor, tagSlug }) => {
const { data } = await apiRequest.post<{ projectTag: WsTag }>(
`/api/v1/projects/${projectID}/tags`,
{

View File

@@ -13,7 +13,7 @@ export type WsTag = {
export type WorkspaceTag = { id: string; name: string; slug: string };
export type CreateTagDTO = {
projectID: string;
projectId: string;
tagSlug: string;
tagColor: string;
};

View File

@@ -36,10 +36,10 @@ export type {
ToggleAutoCapitalizationDTO,
UpdateEnvironmentDTO,
UpdateProjectDTO,
Project as Workspace,
WorkspaceEnv,
WorkspaceTag
} from "./workspace/types";
Project,
ProjectEnv,
ProjectTag
} from "./projects/types";
export enum ApiErrorTypes {
ValidationError = "ValidationFailure",

View File

@@ -2,7 +2,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { projectKeys } from "../workspace";
import { projectKeys } from "../projects";
import { userKeys } from "./query-keys";
import { AddUserToWsDTONonE2EE } from "./types";
@@ -18,7 +18,7 @@ export const useAddUserToWsNonE2EE = () => {
return data;
},
onSuccess: (_, { orgId, projectId }) => {
queryClient.invalidateQueries({ queryKey: projectKeys.getWorkspaceUsers(projectId) });
queryClient.invalidateQueries({ queryKey: projectKeys.getProjectUsers(projectId) });
queryClient.invalidateQueries({
queryKey: userKeys.allOrgMembershipProjectMemberships(orgId)
});

View File

@@ -10,7 +10,7 @@ import { MfaMethod } from "../auth/types";
import { TGroupWithProjectMemberships } from "../groups/types";
import { setAuthToken } from "../reactQuery";
import { subscriptionQueryKeys } from "../subscriptions/queries";
import { workspaceKeys } from "../workspace";
import { projectKeys } from "../projects";
import { userKeys } from "./query-keys";
import {
AddUserToOrgDTO,
@@ -197,10 +197,10 @@ export const useAddUsersToOrg = () => {
projects?.forEach((project) => {
if (project.slug) {
queryClient.invalidateQueries({
queryKey: workspaceKeys.getWorkspaceGroupMemberships(project.slug)
queryKey: projectKeys.getProjectGroupMemberships(project.slug)
});
}
queryClient.invalidateQueries({ queryKey: workspaceKeys.getWorkspaceUsers(project.id) });
queryClient.invalidateQueries({ queryKey: projectKeys.getProjectUsers(project.id) });
});
}
});

View File

@@ -1,5 +1,5 @@
import { MfaMethod } from "../auth/types";
import { ProjectType, ProjectUserMembershipTemporaryMode } from "../workspace/types";
import { ProjectType, ProjectUserMembershipTemporaryMode } from "../projects/types";
export enum AuthMethod {
EMAIL = "email",

View File

@@ -2,7 +2,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { projectKeys } from "../workspace/query-keys";
import { projectKeys } from "../projects/query-keys";
import { workflowIntegrationKeys } from "./queries";
import {
TCheckMicrosoftTeamsIntegrationInstallationStatusDTO,
@@ -126,7 +126,7 @@ export const useUpdateProjectWorkflowIntegrationConfig = () => {
},
onSuccess: (_, { projectId: workspaceId, integration }) => {
queryClient.invalidateQueries({
queryKey: projectKeys.getWorkspaceWorkflowIntegrationConfig(workspaceId, integration)
queryKey: projectKeys.getProjectWorkflowIntegrationConfig(workspaceId, integration)
});
}
});
@@ -145,7 +145,7 @@ export const useDeleteProjectWorkflowIntegration = () => {
},
onSuccess: (_, { projectId, integration }) => {
queryClient.invalidateQueries({
queryKey: projectKeys.getWorkspaceWorkflowIntegrationConfig(projectId, integration)
queryKey: projectKeys.getProjectWorkflowIntegrationConfig(projectId, integration)
});
}
});

View File

@@ -1,82 +0,0 @@
import { TListProjectIdentitiesDTO, TSearchProjectsDTO } from "@app/hooks/api/workspace/types";
import type { CaStatus } from "../ca";
import { WorkflowIntegrationPlatform } from "../workflowIntegrations/types";
export const projectKeys = {
getWorkspaceById: (projectId: string) => ["projects", { projectId }] as const,
getWorkspaceSecrets: (projectId: string) => [{ projectId }, "project-secrets"] as const,
getWorkspaceIndexStatus: (projectId: string) => [{ projectId }, "project-index-status"] as const,
getProjectUpgradeStatus: (projectId: string) => [{ projectId }, "project-upgrade-status"],
getWorkspaceMemberships: (orgId: string) => [{ orgId }, "project-memberships"],
getWorkspaceAuthorization: (projectId: string) => [{ projectId }, "project-authorizations"],
getWorkspaceIntegrations: (projectId: string) => [{ projectId }, "project-integrations"],
getAllUserWorkspace: () => ["projects"] as const,
getWorkspaceAuditLogs: (projectId: string) => [{ projectId }, "project-audit-logs"] as const,
getWorkspaceUsers: (
projectId: string,
includeGroupMembers: boolean = false,
roles: string[] = []
) => [{ projectId, includeGroupMembers, roles }, "project-users"] as const,
getWorkspaceUserDetails: (projectId: string, membershipId: string) =>
[{ projectId, membershipId }, "project-user-details"] as const,
getWorkspaceIdentityMemberships: (projectId: string) =>
[{ projectId }, "project-identity-memberships"] as const,
getWorkspaceIdentityMembershipDetails: (projectId: string, identityId: string) =>
[{ projectId, identityId }, "project-identity-membership-details"] as const,
// allows invalidation using above key without knowing params
getWorkspaceIdentityMembershipsWithParams: ({
projectId,
...params
}: TListProjectIdentitiesDTO) =>
[...projectKeys.getWorkspaceIdentityMemberships(projectId), params] as const,
searchWorkspace: (dto: TSearchProjectsDTO) => ["search-projects", dto] as const,
getWorkspaceGroupMemberships: (projectId: string) => [{ projectId }, "project-groups"] as const,
getWorkspaceGroupMembershipDetails: (projectId: string, groupId: string) =>
[{ projectId, groupId }, "project-group-membership-details"] as const,
getWorkspaceCas: ({ projectId }: { projectId: string }) =>
[{ projectId }, "project-cas"] as const,
specificWorkspaceCas: ({ projectId, status }: { projectId: string; status?: CaStatus }) =>
[...projectKeys.getWorkspaceCas({ projectId }), { status }] as const,
allWorkspaceCertificates: () => ["project-certificates"] as const,
forWorkspaceCertificates: (projectId: string) =>
[...projectKeys.allWorkspaceCertificates(), projectId] as const,
specificWorkspaceCertificates: ({
projectId,
offset,
limit
}: {
projectId: string;
offset: number;
limit: number;
}) => [...projectKeys.forWorkspaceCertificates(projectId), { offset, limit }] as const,
getWorkspacePkiAlerts: (projectId: string) => [{ projectId }, "project-pki-alerts"] as const,
getWorkspacePkiSubscribers: (projectId: string) =>
[{ projectId }, "project-pki-subscribers"] as const,
getWorkspacePkiCollections: (projectId: string) =>
[{ projectId }, "project-pki-collections"] as const,
getWorkspaceCertificateTemplates: (projectId: string) =>
[{ projectId }, "project-certificate-templates"] as const,
getWorkspaceWorkflowIntegrationConfig: (
projectId: string,
integration: WorkflowIntegrationPlatform
) => [{ projectId, integration }, "project-workflow-integration-config"] as const,
getWorkspaceSshCas: (projectId: string) => [{ projectId }, "project-ssh-cas"] as const,
allWorkspaceSshCertificates: (projectId: string) =>
[{ projectId }, "project-ssh-certificates"] as const,
getWorkspaceSshHosts: (projectId: string) => [{ projectId }, "project-ssh-hosts"] as const,
getWorkspaceSshHostGroups: (projectId: string) =>
[{ projectId }, "project-ssh-host-groups"] as const,
specificWorkspaceSshCertificates: ({
offset,
limit,
projectId
}: {
offset: number;
limit: number;
projectId: string;
}) => [...projectKeys.allWorkspaceSshCertificates(projectId), { offset, limit }] as const,
getWorkspaceSshCertificateTemplates: (projectId: string) =>
[{ projectId }, "project-ssh-certificate-templates"] as const,
getProjectSshConfig: (projectId: string) => [{ projectId }, "project-ssh-config"] as const
};

View File

@@ -1,7 +1,7 @@
import { useMemo } from "react";
import { useRouterState } from "@tanstack/react-router";
import { ProjectType } from "@app/hooks/api/workspace/types";
import { ProjectType } from "@app/hooks/api/projects/types";
export const useGetProjectTypeFromRoute = () => {
const { location } = useRouterState();

View File

@@ -1,6 +1,6 @@
import { useMemo } from "react";
import { useSubscription, useWorkspace } from "@app/context";
import { useSubscription, useProject } from "@app/context";
import { useGetAccessApprovalPolicies } from "@app/hooks/api";
const matchesPath = (folderPath: string, pattern: string) => {
@@ -37,10 +37,10 @@ type Params = {
};
export const usePathAccessPolicies = ({ secretPath, environment }: Params) => {
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const { subscription } = useSubscription();
const { data: policies } = useGetAccessApprovalPolicies({
projectSlug: currentWorkspace.slug,
projectSlug: currentProject.slug,
options: {
enabled: subscription.secretApproval
}

View File

@@ -4,12 +4,12 @@ import { Link, Outlet } from "@tanstack/react-router";
import { motion } from "framer-motion";
import { Lottie, Menu, MenuGroup, MenuItem } from "@app/components/v2";
import { useProjectPermission, useWorkspace } from "@app/context";
import { useProjectPermission, useProject } from "@app/context";
import { AssumePrivilegeModeBanner } from "../ProjectLayout/components/AssumePrivilegeModeBanner";
export const KmsLayout = () => {
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const { assumedPrivilegeDetails } = useProjectPermission();
return (
@@ -34,7 +34,7 @@ export const KmsLayout = () => {
<Link
to="/projects/kms/$projectId/overview"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -51,7 +51,7 @@ export const KmsLayout = () => {
<Link
to="/projects/kms/$projectId/kmip"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -70,7 +70,7 @@ export const KmsLayout = () => {
<Link
to="/projects/kms/$projectId/access-management"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -87,7 +87,7 @@ export const KmsLayout = () => {
<Link
to="/projects/kms/$projectId/audit-logs"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -104,7 +104,7 @@ export const KmsLayout = () => {
<Link
to="/projects/kms/$projectId/settings"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (

View File

@@ -40,7 +40,7 @@ import { envConfig } from "@app/config/env";
import { useOrganization, useSubscription, useUser } from "@app/context";
import { isInfisicalCloud } from "@app/helpers/platform";
import { useToggle } from "@app/hooks";
import { useGetOrganizations, useLogoutUser, workspaceKeys } from "@app/hooks/api";
import { useGetOrganizations, useLogoutUser, projectKeys } from "@app/hooks/api";
import { authKeys, selectOrganization } from "@app/hooks/api/auth/queries";
import { MfaMethod } from "@app/hooks/api/auth/types";
import { getAuthToken } from "@app/hooks/api/reactQuery";
@@ -135,7 +135,7 @@ export const Navbar = () => {
const handleOrgChange = async (orgId: string) => {
queryClient.removeQueries({ queryKey: authKeys.getAuthToken });
queryClient.removeQueries({ queryKey: workspaceKeys.getAllUserWorkspace() });
queryClient.removeQueries({ queryKey: projectKeys.getAllUserProjects() });
const { token, isMfaEnabled, mfaMethod } = await selectOrganization({
organizationId: orgId

View File

@@ -16,12 +16,12 @@ import { Link, Outlet } from "@tanstack/react-router";
import { motion } from "framer-motion";
import { Lottie, Menu, MenuGroup, MenuItem } from "@app/components/v2";
import { useProjectPermission, useWorkspace } from "@app/context";
import { useProjectPermission, useProject } from "@app/context";
import { AssumePrivilegeModeBanner } from "../ProjectLayout/components/AssumePrivilegeModeBanner";
export const PkiManagerLayout = () => {
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const { assumedPrivilegeDetails } = useProjectPermission();
const { t } = useTranslation();
@@ -48,7 +48,7 @@ export const PkiManagerLayout = () => {
<Link
to="/projects/cert-management/$projectId/subscribers"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -65,7 +65,7 @@ export const PkiManagerLayout = () => {
<Link
to="/projects/cert-management/$projectId/certificate-templates"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -82,7 +82,7 @@ export const PkiManagerLayout = () => {
<Link
to="/projects/cert-management/$projectId/certificates"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -99,7 +99,7 @@ export const PkiManagerLayout = () => {
<Link
to="/projects/cert-management/$projectId/certificate-authorities"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -116,7 +116,7 @@ export const PkiManagerLayout = () => {
<Link
to="/projects/cert-management/$projectId/alerting"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -135,7 +135,7 @@ export const PkiManagerLayout = () => {
<Link
to="/projects/cert-management/$projectId/access-management"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -152,7 +152,7 @@ export const PkiManagerLayout = () => {
<Link
to="/projects/cert-management/$projectId/audit-logs"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -169,7 +169,7 @@ export const PkiManagerLayout = () => {
<Link
to="/projects/cert-management/$projectId/settings"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (

View File

@@ -2,13 +2,13 @@ import { faInfoCircle } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { Button } from "@app/components/v2";
import { useProjectPermission, useWorkspace } from "@app/context";
import { useProjectPermission, useProject } from "@app/context";
import { getProjectHomePage } from "@app/helpers/project";
import { useRemoveAssumeProjectPrivilege } from "@app/hooks/api";
import { ActorType } from "@app/hooks/api/auditLogs/enums";
export const AssumePrivilegeModeBanner = () => {
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const exitAssumePrivilegeMode = useRemoveAssumeProjectPrivilege();
const { assumedPrivilegeDetails } = useProjectPermission();
@@ -32,15 +32,12 @@ export const AssumePrivilegeModeBanner = () => {
onClick={() => {
exitAssumePrivilegeMode.mutate(
{
projectId: currentWorkspace.id
projectId: currentProject.id
},
{
onSuccess: () => {
const url = getProjectHomePage(
currentWorkspace.type,
currentWorkspace.environments
);
window.location.href = url.replace("$projectId", currentWorkspace.id);
const url = getProjectHomePage(currentProject.type, currentProject.environments);
window.location.href = url.replace("$projectId", currentProject.id);
}
}
);

View File

@@ -29,20 +29,20 @@ import {
OrgPermissionSubjects,
useOrganization,
useSubscription,
useWorkspace
useProject
} from "@app/context";
import { getProjectHomePage } from "@app/helpers/project";
import { usePopUp } from "@app/hooks";
import { useGetUserWorkspaces } from "@app/hooks/api";
import { useGetUserProjects } from "@app/hooks/api";
import { useUpdateUserProjectFavorites } from "@app/hooks/api/users/mutation";
import { useGetUserProjectFavorites } from "@app/hooks/api/users/queries";
import { Project } from "@app/hooks/api/workspace/types";
import { Project } from "@app/hooks/api/projects/types";
export const ProjectSelect = () => {
const [searchProject, setSearchProject] = useState("");
const { currentWorkspace } = useWorkspace();
const { currentProject: currentWorkspace } = useProject();
const { currentOrg } = useOrganization();
const { data: workspaces = [] } = useGetUserWorkspaces();
const { data: projects = [] } = useGetUserProjects();
const { data: projectFavorites } = useGetUserProjectFavorites(currentOrg.id);
const { subscription } = useSubscription();
@@ -86,8 +86,8 @@ export const ProjectSelect = () => {
"upgradePlan"
] as const);
const projects = useMemo(() => {
const projectOptions = workspaces
const projectsSortedByFav = useMemo(() => {
const projectOptions = projects
.map((w): Project & { isFavorite: boolean } => ({
...w,
isFavorite: Boolean(projectFavorites?.includes(w.id))
@@ -95,7 +95,7 @@ export const ProjectSelect = () => {
.sort((a, b) => Number(b.isFavorite) - Number(a.isFavorite));
return projectOptions;
}, [workspaces, projectFavorites, currentWorkspace]);
}, [projects, projectFavorites, currentWorkspace]);
return (
<div className="-mr-2 flex w-full items-center gap-1">
@@ -147,7 +147,7 @@ export const ProjectSelect = () => {
/>
</div>
<div className="thin-scrollbar max-h-80 overflow-auto">
{projects
{projectsSortedByFav
?.filter((el) => el.name?.toLowerCase().includes(searchProject.toLowerCase()))
?.map((workspace) => {
return (

View File

@@ -15,7 +15,7 @@ import { Link, Outlet, useLocation } from "@tanstack/react-router";
import { motion } from "framer-motion";
import { Badge, Lottie, Menu, MenuGroup, MenuItem } from "@app/components/v2";
import { useProjectPermission, useWorkspace } from "@app/context";
import { useProjectPermission, useProject } from "@app/context";
import {
useGetAccessRequestsCount,
useGetSecretApprovalRequestCount,
@@ -25,16 +25,15 @@ import {
import { AssumePrivilegeModeBanner } from "../ProjectLayout/components/AssumePrivilegeModeBanner";
export const SecretManagerLayout = () => {
const { currentWorkspace } = useWorkspace();
const { currentProject, projectId } = useProject();
const { assumedPrivilegeDetails } = useProjectPermission();
const { t } = useTranslation();
const workspaceId = currentWorkspace?.id || "";
const projectSlug = currentWorkspace?.slug || "";
const projectSlug = currentProject?.slug || "";
const location = useLocation();
const { data: secretApprovalReqCount } = useGetSecretApprovalRequestCount({
workspaceId
projectId
});
const { data: accessApprovalRequestCount } = useGetAccessRequestsCount({
projectSlug
@@ -42,7 +41,7 @@ export const SecretManagerLayout = () => {
// we only show the secret rotations v1 tab if they have existing rotations
const { data: secretRotations } = useGetSecretRotations({
workspaceId,
workspaceId: projectId,
options: {
refetchOnMount: false
}
@@ -74,9 +73,9 @@ export const SecretManagerLayout = () => {
<Link
to="/projects/secret-management/$projectId/overview"
params={{
projectId: currentWorkspace.id,
...(currentWorkspace.environments.length
? { envSlug: currentWorkspace.environments[0]?.slug }
projectId: currentProject.id,
...(currentProject.environments.length
? { envSlug: currentProject.environments[0]?.slug }
: {})
}}
>
@@ -85,7 +84,7 @@ export const SecretManagerLayout = () => {
isSelected={
isActive ||
location.pathname.startsWith(
`/projects/secret-management/${currentWorkspace.id}/overview`
`/projects/secret-management/${currentProject.id}/overview`
)
}
>
@@ -101,7 +100,7 @@ export const SecretManagerLayout = () => {
<Link
to="/projects/secret-management/$projectId/integrations"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -119,7 +118,7 @@ export const SecretManagerLayout = () => {
<Link
to="/projects/secret-management/$projectId/secret-rotation"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -137,7 +136,7 @@ export const SecretManagerLayout = () => {
<Link
to="/projects/secret-management/$projectId/approval"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -164,7 +163,7 @@ export const SecretManagerLayout = () => {
<Link
to="/projects/secret-management/$projectId/access-management"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -181,7 +180,7 @@ export const SecretManagerLayout = () => {
<Link
to="/projects/secret-management/$projectId/audit-logs"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -198,7 +197,7 @@ export const SecretManagerLayout = () => {
<Link
to="/projects/secret-management/$projectId/settings"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (

View File

@@ -15,7 +15,7 @@ import {
ProjectPermissionSub,
useProjectPermission,
useSubscription,
useWorkspace
useProject
} from "@app/context";
import { ProjectPermissionSecretScanningFindingActions } from "@app/context/ProjectPermissionContext/types";
import { useGetSecretScanningUnresolvedFindingCount } from "@app/hooks/api/secretScanningV2";
@@ -23,14 +23,14 @@ import { useGetSecretScanningUnresolvedFindingCount } from "@app/hooks/api/secre
import { AssumePrivilegeModeBanner } from "../ProjectLayout/components/AssumePrivilegeModeBanner";
export const SecretScanningLayout = () => {
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const { assumedPrivilegeDetails } = useProjectPermission();
const { permission } = useProjectPermission();
const { subscription } = useSubscription();
const { data: unresolvedFindings } = useGetSecretScanningUnresolvedFindingCount(
currentWorkspace.id,
currentProject.id,
{
enabled:
subscription.secretScanning &&
@@ -64,7 +64,7 @@ export const SecretScanningLayout = () => {
<Link
to="/projects/secret-scanning/$projectId/data-sources"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -81,7 +81,7 @@ export const SecretScanningLayout = () => {
<Link
to="/projects/secret-scanning/$projectId/findings"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -105,7 +105,7 @@ export const SecretScanningLayout = () => {
<Link
to="/projects/secret-scanning/$projectId/access-management"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -122,7 +122,7 @@ export const SecretScanningLayout = () => {
<Link
to="/projects/secret-scanning/$projectId/audit-logs"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -139,7 +139,7 @@ export const SecretScanningLayout = () => {
<Link
to="/projects/secret-scanning/$projectId/settings"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (

View File

@@ -16,13 +16,13 @@ import {
ProjectPermissionActions,
ProjectPermissionSub,
useProjectPermission,
useWorkspace
useProject
} from "@app/context";
import { AssumePrivilegeModeBanner } from "../ProjectLayout/components/AssumePrivilegeModeBanner";
export const SshLayout = () => {
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const { assumedPrivilegeDetails } = useProjectPermission();
return (
@@ -47,7 +47,7 @@ export const SshLayout = () => {
<Link
to="/projects/ssh/$projectId/overview"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -70,7 +70,7 @@ export const SshLayout = () => {
<Link
to="/projects/ssh/$projectId/cas"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -93,7 +93,7 @@ export const SshLayout = () => {
<Link
to="/projects/ssh/$projectId/access-management"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -110,7 +110,7 @@ export const SshLayout = () => {
<Link
to="/projects/ssh/$projectId/audit-logs"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (
@@ -127,7 +127,7 @@ export const SshLayout = () => {
<Link
to="/projects/ssh/$projectId/settings"
params={{
projectId: currentWorkspace.id
projectId: currentProject.id
}}
>
{({ isActive }) => (

View File

@@ -13,7 +13,7 @@ import {
Select,
SelectItem
} from "@app/components/v2";
import { useWorkspace } from "@app/context";
import { useProject } from "@app/context";
import {
useCreatePkiAlert,
useGetPkiAlertById,
@@ -60,15 +60,15 @@ type Props = {
};
export const PkiAlertModal = ({ popUp, handlePopUpToggle }: Props) => {
const { currentWorkspace } = useWorkspace();
const projectId = currentWorkspace?.id || "";
const { currentProject } = useProject();
const projectId = currentProject?.id || "";
const { data: alert } = useGetPkiAlertById(
(popUp?.pkiAlert?.data as { alertId: string })?.alertId || ""
);
const { data: pkiCollections } = useListWorkspacePkiCollections({
workspaceId: projectId
projectId
});
const { mutateAsync: createPkiAlert } = useCreatePkiAlert();

View File

@@ -4,7 +4,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { createNotification } from "@app/components/notifications";
import { ProjectPermissionCan } from "@app/components/permissions";
import { Button, DeleteActionModal } from "@app/components/v2";
import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context";
import { ProjectPermissionActions, ProjectPermissionSub, useProject } from "@app/context";
import { useDeletePkiAlert } from "@app/hooks/api";
import { usePopUp } from "@app/hooks/usePopUp";
@@ -12,8 +12,8 @@ import { PkiAlertModal } from "./PkiAlertModal";
import { PkiAlertsTable } from "./PkiAlertsTable";
export const PkiAlertsSection = () => {
const { currentWorkspace } = useWorkspace();
const projectId = currentWorkspace?.id || "";
const { currentProject } = useProject();
const projectId = currentProject?.id || "";
const { mutateAsync: deletePkiAlert } = useDeletePkiAlert();
const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([

View File

@@ -10,7 +10,7 @@ import {
THead,
Tr
} from "@app/components/v2";
import { useWorkspace } from "@app/context";
import { useProject } from "@app/context";
import { useListWorkspacePkiAlerts } from "@app/hooks/api";
import { UsePopUpState } from "@app/hooks/usePopUp";
@@ -24,11 +24,11 @@ type Props = {
};
export const PkiAlertsTable = ({ handlePopUpOpen }: Props) => {
const { currentWorkspace } = useWorkspace();
const projectId = currentWorkspace?.id || "";
const { currentProject } = useProject();
const projectId = currentProject?.id || "";
const { data, isPending } = useListWorkspacePkiAlerts({
workspaceId: projectId
projectId
});
return (

View File

@@ -6,7 +6,7 @@ import { z } from "zod";
import { createNotification } from "@app/components/notifications";
import { Button, FormControl, Input, Modal, ModalContent } from "@app/components/v2";
import { useWorkspace } from "@app/context";
import { useProject } from "@app/context";
import {
useCreatePkiCollection,
useGetPkiCollectionById,
@@ -28,8 +28,8 @@ type Props = {
export const PkiCollectionModal = ({ popUp, handlePopUpToggle }: Props) => {
const navigate = useNavigate();
const { currentWorkspace } = useWorkspace();
const projectId = currentWorkspace?.id || "";
const { currentProject } = useProject();
const projectId = currentProject?.id || "";
const { data: pkiCollection } = useGetPkiCollectionById(
(popUp?.pkiCollection?.data as { collectionId: string })?.collectionId || ""

View File

@@ -4,7 +4,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { createNotification } from "@app/components/notifications";
import { ProjectPermissionCan } from "@app/components/permissions";
import { Button, DeleteActionModal } from "@app/components/v2";
import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context";
import { ProjectPermissionActions, ProjectPermissionSub, useProject } from "@app/context";
import { useDeletePkiCollection } from "@app/hooks/api";
import { usePopUp } from "@app/hooks/usePopUp";
@@ -12,8 +12,8 @@ import { PkiCollectionModal } from "./PkiCollectionModal";
import { PkiCollectionTable } from "./PkiCollectionTable";
export const PkiCollectionSection = () => {
const { currentWorkspace } = useWorkspace();
const projectId = currentWorkspace?.id || "";
const { currentProject } = useProject();
const projectId = currentProject?.id || "";
const { mutateAsync: deletePkiCollection } = useDeletePkiCollection();
const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([

View File

@@ -19,7 +19,7 @@ import {
THead,
Tr
} from "@app/components/v2";
import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context";
import { ProjectPermissionActions, ProjectPermissionSub, useProject } from "@app/context";
import { useListWorkspacePkiCollections } from "@app/hooks/api";
import { UsePopUpState } from "@app/hooks/usePopUp";
@@ -32,11 +32,11 @@ type Props = {
export const PkiCollectionTable = ({ handlePopUpOpen }: Props) => {
const navigate = useNavigate();
const { currentWorkspace } = useWorkspace();
const projectId = currentWorkspace?.id || "";
const { currentProject } = useProject();
const projectId = currentProject?.id || "";
const { data, isPending } = useListWorkspacePkiCollections({
workspaceId: projectId
projectId
});
return (

View File

@@ -15,7 +15,7 @@ import {
Tooltip
} from "@app/components/v2";
import { ROUTE_PATHS } from "@app/const/routes";
import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context";
import { ProjectPermissionActions, ProjectPermissionSub, useProject } from "@app/context";
import { CaType, useDeleteCa, useGetCa } from "@app/hooks/api";
import { TInternalCertificateAuthority } from "@app/hooks/api/ca/types";
import { usePopUp } from "@app/hooks/usePopUp";
@@ -30,7 +30,7 @@ import {
} from "./components";
const Page = () => {
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const navigate = useNavigate();
const params = useParams({
from: ROUTE_PATHS.CertManager.CertAuthDetailsByIDPage.id
@@ -38,11 +38,11 @@ const Page = () => {
const { caName } = params as { caName: string };
const { data } = useGetCa({
caName,
projectId: currentWorkspace?.id || "",
projectId: currentProject?.id || "",
type: CaType.INTERNAL
}) as { data: TInternalCertificateAuthority };
const projectId = currentWorkspace?.id || "";
const projectId = currentProject?.id || "";
const { mutateAsync: deleteCa } = useDeleteCa();
@@ -55,11 +55,11 @@ const Page = () => {
const onRemoveCaSubmit = async () => {
try {
if (!currentWorkspace?.slug) return;
if (!currentProject?.slug) return;
await deleteCa({
caName,
projectId: currentWorkspace.id,
projectId: currentProject.id,
type: CaType.INTERNAL
});

View File

@@ -4,7 +4,7 @@ import { format } from "date-fns";
import { ProjectPermissionCan } from "@app/components/permissions";
import { Button, IconButton, Tooltip } from "@app/components/v2";
import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context";
import { ProjectPermissionActions, ProjectPermissionSub, useProject } from "@app/context";
import { useTimedReset } from "@app/hooks";
import { CaStatus, CaType, InternalCaType, useGetCa } from "@app/hooks/api";
import { caStatusToNameMap, caTypeToNameMap } from "@app/hooks/api/ca/constants";
@@ -21,7 +21,7 @@ type Props = {
};
export const CaDetailsSection = ({ caName, handlePopUpOpen }: Props) => {
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const [copyTextId, isCopyingId, setCopyTextId] = useTimedReset<string>({
initialState: "Copy ID to clipboard"
});
@@ -31,7 +31,7 @@ export const CaDetailsSection = ({ caName, handlePopUpOpen }: Props) => {
const { data } = useGetCa({
caName,
projectId: currentWorkspace.id,
projectId: currentProject.id,
type: CaType.INTERNAL
});

View File

@@ -13,7 +13,7 @@ import {
Select,
SelectItem
} from "@app/components/v2";
import { useWorkspace } from "@app/context";
import { useProject } from "@app/context";
import {
CaRenewalType,
useRenewCa
@@ -45,8 +45,8 @@ type Props = {
};
export const CaRenewalModal = ({ popUp, handlePopUpToggle }: Props) => {
const { currentWorkspace } = useWorkspace();
const projectSlug = currentWorkspace?.slug || "";
const { currentProject } = useProject();
const projectSlug = currentProject?.slug || "";
const popUpData = popUp?.renewCa?.data as {
caId: string;

View File

@@ -8,7 +8,7 @@ import { z } from "zod";
import { createNotification } from "@app/components/notifications";
import { Button, FormControl, IconButton, TextArea, Tooltip } from "@app/components/v2";
import { useWorkspace } from "@app/context";
import { useProject } from "@app/context";
import { useTimedReset } from "@app/hooks";
import { useGetCaCsr, useImportCaCertificate } from "@app/hooks/api";
import { UsePopUpState } from "@app/hooks/usePopUp";
@@ -26,7 +26,7 @@ type Props = {
};
export const ExternalCaInstallForm = ({ caId, handlePopUpToggle }: Props) => {
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const [copyTextCaCsr, isCopyingCaCsr, setCopyTextCaCsr] = useTimedReset<string>({
initialState: "Copy to clipboard"
});
@@ -41,7 +41,7 @@ export const ExternalCaInstallForm = ({ caId, handlePopUpToggle }: Props) => {
});
const { data: csr } = useGetCaCsr(caId);
const { mutateAsync: importCaCertificate } = useImportCaCertificate(currentWorkspace.id);
const { mutateAsync: importCaCertificate } = useImportCaCertificate(currentProject.id);
useEffect(() => {
reset();
@@ -49,11 +49,11 @@ export const ExternalCaInstallForm = ({ caId, handlePopUpToggle }: Props) => {
const onFormSubmit = async ({ certificate, certificateChain }: FormData) => {
try {
if (!csr || !caId || !currentWorkspace?.slug) return;
if (!csr || !caId || !currentProject?.slug) return;
await importCaCertificate({
caId,
projectSlug: currentWorkspace?.slug,
projectSlug: currentProject?.slug,
certificate,
certificateChain
});

View File

@@ -6,7 +6,7 @@ import { z } from "zod";
import { createNotification } from "@app/components/notifications";
import { Button, FormControl, Input, Select, SelectItem } from "@app/components/v2";
import { useWorkspace } from "@app/context";
import { useProject } from "@app/context";
import {
CaStatus,
useGetCaById,
@@ -46,16 +46,16 @@ type Props = {
};
export const InternalCaInstallForm = ({ caId, handlePopUpToggle }: Props) => {
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const { data: cas } = useListWorkspaceCas({
projectSlug: currentWorkspace?.slug ?? "",
projectId: currentProject.id,
status: CaStatus.ACTIVE
});
const { data: ca } = useGetCaById(caId);
const { data: csr } = useGetCaCsr(caId);
const { mutateAsync: signIntermediate } = useSignIntermediate();
const { mutateAsync: importCaCertificate } = useImportCaCertificate(currentWorkspace.id);
const { mutateAsync: importCaCertificate } = useImportCaCertificate(currentProject.id);
const {
control,
@@ -102,7 +102,7 @@ export const InternalCaInstallForm = ({ caId, handlePopUpToggle }: Props) => {
const onFormSubmit = async ({ notAfter, maxPathLength }: FormData) => {
try {
if (!csr || !caId || !currentWorkspace?.slug) return;
if (!csr || !caId || !currentProject?.slug) return;
const { certificate, certificateChain } = await signIntermediate({
caId: parentCaId,
@@ -114,7 +114,7 @@ export const InternalCaInstallForm = ({ caId, handlePopUpToggle }: Props) => {
await importCaCertificate({
caId,
projectSlug: currentWorkspace?.slug,
projectSlug: currentProject?.slug,
certificate,
certificateChain
});

View File

@@ -16,7 +16,7 @@ import {
Switch
// DatePicker
} from "@app/components/v2";
import { useWorkspace } from "@app/context";
import { useProject } from "@app/context";
import {
CaStatus,
CaType,
@@ -84,10 +84,10 @@ const caTypes = [
];
export const CaModal = ({ popUp, handlePopUpToggle }: Props) => {
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const { data: ca } = useGetCa({
caName: (popUp?.ca?.data as { name: string })?.name || "",
projectId: currentWorkspace?.id || "",
projectId: currentProject?.id || "",
type: CaType.INTERNAL
});
@@ -178,13 +178,13 @@ export const CaModal = ({ popUp, handlePopUpToggle }: Props) => {
configuration
}: FormData) => {
try {
if (!currentWorkspace?.slug) return;
if (!currentProject?.slug) return;
if (ca) {
// update
await updateMutateAsync({
caName: ca.name,
projectId: currentWorkspace.id,
projectId: currentProject.id,
name,
type: CaType.INTERNAL,
status,
@@ -193,7 +193,7 @@ export const CaModal = ({ popUp, handlePopUpToggle }: Props) => {
} else {
// create
await createMutateAsync({
projectId: currentWorkspace.id,
projectId: currentProject.id,
name,
type,
status,

View File

@@ -5,7 +5,7 @@ import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal";
import { createNotification } from "@app/components/notifications";
import { ProjectPermissionCan } from "@app/components/permissions";
import { Button, DeleteActionModal } from "@app/components/v2";
import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context";
import { ProjectPermissionActions, ProjectPermissionSub, useProject } from "@app/context";
import { CaStatus, CaType, useDeleteCa, useUpdateCa } from "@app/hooks/api";
import { usePopUp } from "@app/hooks/usePopUp";
@@ -15,7 +15,7 @@ import { CaModal } from "./CaModal";
import { CaTable } from "./CaTable";
export const CaSection = () => {
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const { mutateAsync: deleteCa } = useDeleteCa();
const { mutateAsync: updateCa } = useUpdateCa();
@@ -30,9 +30,9 @@ export const CaSection = () => {
const onRemoveCaSubmit = async (caName: string) => {
try {
if (!currentWorkspace?.slug) return;
if (!currentProject?.slug) return;
await deleteCa({ caName, projectId: currentWorkspace.id, type: CaType.INTERNAL });
await deleteCa({ caName, projectId: currentProject.id, type: CaType.INTERNAL });
createNotification({
text: "Successfully deleted CA",
@@ -50,9 +50,9 @@ export const CaSection = () => {
const onUpdateCaStatus = async ({ caName, status }: { caName: string; status: CaStatus }) => {
try {
if (!currentWorkspace?.slug) return;
if (!currentProject?.slug) return;
await updateCa({ caName, projectId: currentWorkspace.id, type: CaType.INTERNAL, status });
await updateCa({ caName, projectId: currentProject.id, type: CaType.INTERNAL, status });
createNotification({
text: `Successfully ${status === CaStatus.ACTIVE ? "enabled" : "disabled"} CA`,

View File

@@ -22,7 +22,7 @@ import {
Tooltip,
Tr
} from "@app/components/v2";
import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context";
import { ProjectPermissionActions, ProjectPermissionSub, useProject } from "@app/context";
import { CaStatus, CaType, useListCasByTypeAndProjectId } from "@app/hooks/api";
import {
caStatusToNameMap,
@@ -49,8 +49,8 @@ type Props = {
export const CaTable = ({ handlePopUpOpen }: Props) => {
const navigate = useNavigate();
const { currentWorkspace } = useWorkspace();
const { data, isPending } = useListCasByTypeAndProjectId(CaType.INTERNAL, currentWorkspace.id);
const { currentProject } = useProject();
const { data, isPending } = useListCasByTypeAndProjectId(CaType.INTERNAL, currentProject.id);
const cas = data as TInternalCertificateAuthority[];
return (
@@ -80,7 +80,7 @@ export const CaTable = ({ handlePopUpOpen }: Props) => {
navigate({
to: "/projects/cert-management/$projectId/ca/$caName",
params: {
projectId: currentWorkspace.id,
projectId: currentProject.id,
caName: ca.name
}
})

View File

@@ -16,7 +16,7 @@ import {
SelectItem,
Switch
} from "@app/components/v2";
import { useWorkspace } from "@app/context";
import { useProject } from "@app/context";
import { APP_CONNECTION_MAP } from "@app/helpers/appConnections";
import {
TAvailableAppConnection,
@@ -127,11 +127,11 @@ const caTypes = [
];
export const ExternalCaModal = ({ popUp, handlePopUpToggle }: Props) => {
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const { data: ca, isLoading: isCaLoading } = useGetCa({
caName: (popUp?.ca?.data as { name: string })?.name || "",
projectId: currentWorkspace?.id || "",
projectId: currentProject?.id || "",
type: (popUp?.ca?.data as { type: CaType })?.type || ""
});
@@ -297,7 +297,7 @@ export const ExternalCaModal = ({ popUp, handlePopUpToggle }: Props) => {
configuration: formConfiguration
}: FormData) => {
try {
if (!currentWorkspace?.slug) return;
if (!currentProject?.slug) return;
let configPayload: any;
@@ -321,7 +321,7 @@ export const ExternalCaModal = ({ popUp, handlePopUpToggle }: Props) => {
if (ca) {
await updateMutateAsync({
caName: ca.name,
projectId: currentWorkspace.id,
projectId: currentProject.id,
name,
type,
status,
@@ -330,7 +330,7 @@ export const ExternalCaModal = ({ popUp, handlePopUpToggle }: Props) => {
});
} else {
await createMutateAsync({
projectId: currentWorkspace.id,
projectId: currentProject.id,
name,
type,
status,

View File

@@ -5,7 +5,7 @@ import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal";
import { createNotification } from "@app/components/notifications";
import { ProjectPermissionCan } from "@app/components/permissions";
import { Button, DeleteActionModal } from "@app/components/v2";
import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context";
import { ProjectPermissionActions, ProjectPermissionSub, useProject } from "@app/context";
import { CaStatus, CaType, useDeleteCa, useUpdateCa } from "@app/hooks/api";
import { usePopUp } from "@app/hooks/usePopUp";
@@ -13,7 +13,7 @@ import { ExternalCaModal } from "./ExternalCaModal";
import { ExternalCaTable } from "./ExternalCaTable";
export const ExternalCaSection = () => {
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const { mutateAsync: deleteCa } = useDeleteCa();
const { mutateAsync: updateCa } = useUpdateCa();
@@ -26,9 +26,9 @@ export const ExternalCaSection = () => {
const onRemoveCaSubmit = async (caName: string, type: CaType) => {
try {
if (!currentWorkspace?.id) return;
if (!currentProject?.id) return;
await deleteCa({ caName, type, projectId: currentWorkspace.id });
await deleteCa({ caName, type, projectId: currentProject.id });
createNotification({
text: "Successfully deleted CA",
@@ -54,9 +54,9 @@ export const ExternalCaSection = () => {
status: CaStatus;
}) => {
try {
if (!currentWorkspace?.slug) return;
if (!currentProject?.slug) return;
await updateCa({ caName: name, type, status, projectId: currentWorkspace.id });
await updateCa({ caName: name, type, status, projectId: currentProject.id });
createNotification({
text: `Successfully ${status === CaStatus.ACTIVE ? "enabled" : "disabled"} CA`,

View File

@@ -26,7 +26,7 @@ import {
Tooltip,
Tr
} from "@app/components/v2";
import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context";
import { ProjectPermissionActions, ProjectPermissionSub, useProject } from "@app/context";
import { CaStatus, CaType, useListExternalCasByProjectId } from "@app/hooks/api";
import { caStatusToNameMap, getCaStatusBadgeVariant } from "@app/hooks/api/ca/constants";
import { UsePopUpState } from "@app/hooks/usePopUp";
@@ -44,8 +44,8 @@ type Props = {
};
export const ExternalCaTable = ({ handlePopUpOpen }: Props) => {
const { currentWorkspace } = useWorkspace();
const { data, isPending } = useListExternalCasByProjectId(currentWorkspace.id);
const { currentProject } = useProject();
const { data, isPending } = useListExternalCasByProjectId(currentProject.id);
return (
<div>

View File

@@ -14,7 +14,7 @@ import {
SelectItem,
TextArea
} from "@app/components/v2";
import { useWorkspace } from "@app/context";
import { useProject } from "@app/context";
import { useGetCert, useImportCertificate, useListWorkspacePkiCollections } from "@app/hooks/api";
import { UsePopUpState } from "@app/hooks/usePopUp";
@@ -48,13 +48,13 @@ type TCertificateDetails = {
export const CertificateImportModal = ({ popUp, handlePopUpToggle }: Props) => {
const [certificateDetails, setCertificateDetails] = useState<TCertificateDetails | null>(null);
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const { data: cert } = useGetCert(
(popUp?.certificateImport?.data as { serialNumber: string })?.serialNumber || ""
);
const { data } = useListWorkspacePkiCollections({
workspaceId: currentWorkspace?.id || ""
projectId: currentProject?.id || ""
});
const { mutateAsync: importCertificate } = useImportCertificate();
@@ -76,10 +76,10 @@ export const CertificateImportModal = ({ popUp, handlePopUpToggle }: Props) => {
collectionId
}: FormData) => {
try {
if (!currentWorkspace?.slug) return;
if (!currentProject?.slug) return;
const { serialNumber, certificate, certificateChain, privateKey } = await importCertificate({
projectSlug: currentWorkspace.slug,
projectSlug: currentProject.slug,
certificatePem,
privateKeyPem,

View File

@@ -22,7 +22,7 @@ import {
SelectItem,
Tooltip
} from "@app/components/v2";
import { useWorkspace } from "@app/context";
import { useProject } from "@app/context";
import {
CaStatus,
useCreateCertificate,
@@ -89,22 +89,22 @@ const CERT_TEMPLATE_NONE_VALUE = "none";
export const CertificateModal = ({ popUp, handlePopUpToggle }: Props) => {
const [certificateDetails, setCertificateDetails] = useState<TCertificateDetails | null>(null);
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const { data: cert } = useGetCert(
(popUp?.certificate?.data as { serialNumber: string })?.serialNumber || ""
);
const { data: cas } = useListWorkspaceCas({
projectSlug: currentWorkspace?.slug ?? "",
projectId: currentProject.id,
status: CaStatus.ACTIVE
});
const { data } = useListWorkspacePkiCollections({
workspaceId: currentWorkspace?.id || ""
projectId: currentProject?.id || ""
});
const { data: templatesData } = useListWorkspaceCertificateTemplates({
workspaceId: currentWorkspace?.id || ""
projectId: currentProject?.id || ""
});
const { mutateAsync: createCertificate } = useCreateCertificate();
@@ -191,12 +191,12 @@ export const CertificateModal = ({ popUp, handlePopUpToggle }: Props) => {
extendedKeyUsages
}: FormData) => {
try {
if (!currentWorkspace?.slug) return;
if (!currentProject?.slug) return;
const { serialNumber, certificate, certificateChain, privateKey } = await createCertificate({
caId: !selectedCertTemplate ? caId : undefined,
certificateTemplateId: selectedCertTemplate ? selectedCertTemplateId : undefined,
projectSlug: currentWorkspace.slug,
projectSlug: currentProject.slug,
pkiCollectionId: collectionId,
friendlyName,
commonName,

View File

@@ -4,7 +4,7 @@ import { z } from "zod";
import { createNotification } from "@app/components/notifications";
import { Button, FormControl, Modal, ModalContent, Select, SelectItem } from "@app/components/v2";
import { useWorkspace } from "@app/context";
import { useProject } from "@app/context";
import { useRevokeCert } from "@app/hooks/api";
import { crlReasons } from "@app/hooks/api/certificates/constants";
import { CrlReason } from "@app/hooks/api/certificates/enums";
@@ -35,7 +35,7 @@ type Props = {
};
export const CertificateRevocationModal = ({ popUp, handlePopUpToggle }: Props) => {
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const { mutateAsync: revokeCertificate } = useRevokeCert();
const {
@@ -49,12 +49,12 @@ export const CertificateRevocationModal = ({ popUp, handlePopUpToggle }: Props)
const onFormSubmit = async ({ revocationReason }: FormData) => {
try {
if (!currentWorkspace?.slug) return;
if (!currentProject?.slug) return;
const { serialNumber } = popUp.revokeCertificate.data as { serialNumber: string };
await revokeCertificate({
projectSlug: currentWorkspace.slug,
projectSlug: currentProject.slug,
serialNumber,
revocationReason
});

View File

@@ -22,7 +22,7 @@ import {
SelectItem,
Tooltip
} from "@app/components/v2";
import { useWorkspace } from "@app/context";
import { useProject } from "@app/context";
import {
CaStatus,
useCreateCertTemplate,
@@ -82,7 +82,7 @@ type Props = {
};
export const CertificateTemplateModal = ({ popUp, handlePopUpToggle, caId }: Props) => {
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const { data: ca } = useGetCaById(caId);
@@ -91,12 +91,12 @@ export const CertificateTemplateModal = ({ popUp, handlePopUpToggle, caId }: Pro
);
const { data: cas } = useListWorkspaceCas({
projectSlug: currentWorkspace?.slug ?? "",
projectId: currentProject?.id,
status: CaStatus.ACTIVE
});
const { data: collectionsData } = useListWorkspacePkiCollections({
workspaceId: currentWorkspace?.id || ""
projectId: currentProject?.id || ""
});
const { mutateAsync: createCertTemplate } = useCreateCertTemplate();
@@ -155,7 +155,7 @@ export const CertificateTemplateModal = ({ popUp, handlePopUpToggle, caId }: Pro
keyUsages,
extendedKeyUsages
}: FormData) => {
if (!currentWorkspace?.id) {
if (!currentProject?.id) {
return;
}
@@ -163,7 +163,7 @@ export const CertificateTemplateModal = ({ popUp, handlePopUpToggle, caId }: Pro
if (certTemplate) {
await updateCertTemplate({
id: certTemplate.id,
projectId: currentWorkspace.id,
projectId: currentProject.id,
pkiCollectionId: collectionId,
caId,
name,
@@ -184,7 +184,7 @@ export const CertificateTemplateModal = ({ popUp, handlePopUpToggle, caId }: Pro
});
} else {
await createCertTemplate({
projectId: currentWorkspace.id,
projectId: currentProject.id,
pkiCollectionId: collectionId,
caId,
name,

View File

@@ -12,7 +12,7 @@ import { DeleteActionModal, IconButton } from "@app/components/v2";
import {
ProjectPermissionPkiTemplateActions,
ProjectPermissionSub,
useWorkspace
useProject
} from "@app/context";
import { usePopUp } from "@app/hooks";
import { useDeleteCertTemplate } from "@app/hooks/api";
@@ -33,18 +33,18 @@ export const CertificateTemplatesSection = ({ caId }: Props) => {
"upgradePlan"
] as const);
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const { mutateAsync: deleteCertTemplate } = useDeleteCertTemplate();
const onRemoveCertificateTemplateSubmit = async (id: string) => {
if (!currentWorkspace?.id) {
if (!currentProject?.id) {
return;
}
try {
await deleteCertTemplate({
id,
projectId: currentWorkspace.id
projectId: currentProject.id
});
createNotification({

View File

@@ -7,7 +7,7 @@ import { Button, DeleteActionModal } from "@app/components/v2";
import {
ProjectPermissionCertificateActions,
ProjectPermissionSub,
useWorkspace
useProject
} from "@app/context";
import { useDeleteCert } from "@app/hooks/api";
import { usePopUp } from "@app/hooks/usePopUp";
@@ -19,7 +19,7 @@ import { CertificateRevocationModal } from "./CertificateRevocationModal";
import { CertificatesTable } from "./CertificatesTable";
export const CertificatesSection = () => {
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const { mutateAsync: deleteCert } = useDeleteCert();
const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([
@@ -32,9 +32,9 @@ export const CertificatesSection = () => {
const onRemoveCertificateSubmit = async (serialNumber: string) => {
try {
if (!currentWorkspace?.slug) return;
if (!currentProject?.slug) return;
await deleteCert({ serialNumber, projectSlug: currentWorkspace.slug });
await deleteCert({ serialNumber, projectSlug: currentProject.slug });
createNotification({
text: "Successfully deleted certificate",

View File

@@ -33,7 +33,7 @@ import {
import {
ProjectPermissionCertificateActions,
ProjectPermissionSub,
useWorkspace
useProject
} from "@app/context";
import { useListWorkspaceCertificates } from "@app/hooks/api";
import { caSupportsCapability } from "@app/hooks/api/ca/constants";
@@ -62,15 +62,15 @@ export const CertificatesTable = ({ handlePopUpOpen }: Props) => {
const [page, setPage] = useState(1);
const [perPage, setPerPage] = useState(PER_PAGE_INIT);
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const { data, isPending } = useListWorkspaceCertificates({
projectId: currentWorkspace?.slug ?? "",
projectId: currentProject?.slug ?? "",
offset: (page - 1) * perPage,
limit: perPage
});
// Fetch CA data to determine capabilities
const { data: caData } = useListCasByProjectId(currentWorkspace?.id ?? "");
const { data: caData } = useListCasByProjectId(currentProject?.id ?? "");
// Create mapping from caId to CA type for capability checking
const caCapabilityMap = useMemo(() => {

View File

@@ -16,7 +16,7 @@ import {
Tooltip
} from "@app/components/v2";
import { ROUTE_PATHS } from "@app/const/routes";
import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context";
import { ProjectPermissionActions, ProjectPermissionSub, useProject } from "@app/context";
import { useDeletePkiCollection, useGetPkiCollectionById } from "@app/hooks/api";
import { PkiItemType } from "@app/hooks/api/pkiCollections/constants";
import { usePopUp } from "@app/hooks/usePopUp";
@@ -30,8 +30,8 @@ export const PkiCollectionPage = () => {
from: ROUTE_PATHS.CertManager.PkiCollectionDetailsByIDPage.id
});
const collectionId = params.collectionId as string;
const { currentWorkspace } = useWorkspace();
const projectId = currentWorkspace?.id || "";
const { currentProject } = useProject();
const projectId = currentProject?.id || "";
const { data } = useGetPkiCollectionById(collectionId);
const { mutateAsync: deletePkiCollection } = useDeletePkiCollection();

View File

@@ -4,7 +4,7 @@ import { z } from "zod";
import { createNotification } from "@app/components/notifications";
import { Button, FormControl, Modal, ModalContent, Select, SelectItem } from "@app/components/v2";
import { useWorkspace } from "@app/context";
import { useProject } from "@app/context";
import {
CaStatus,
useAddItemToPkiCollection,
@@ -41,15 +41,15 @@ export const AddPkiCollectionItemModal = ({
popUp,
handlePopUpToggle
}: Props) => {
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const { data: cas } = useListWorkspaceCas({
projectSlug: currentWorkspace?.slug || "",
projectId: currentProject?.id || "",
status: CaStatus.ACTIVE
});
const { data } = useListWorkspaceCertificates({
projectId: currentWorkspace?.slug || "",
projectId: currentProject?.slug || "",
offset: 0,
limit: 25
});

View File

@@ -19,7 +19,7 @@ import { ROUTE_PATHS } from "@app/const/routes";
import {
ProjectPermissionPkiSubscriberActions,
ProjectPermissionSub,
useWorkspace
useProject
} from "@app/context";
import { useDeletePkiSubscriber, useGetPkiSubscriber } from "@app/hooks/api";
import { usePopUp } from "@app/hooks/usePopUp";
@@ -29,8 +29,8 @@ import { PkiSubscriberCertificatesSection, PkiSubscriberDetailsSection } from ".
const Page = () => {
const navigate = useNavigate();
const { currentWorkspace } = useWorkspace();
const projectId = currentWorkspace.id;
const { currentProject } = useProject();
const projectId = currentProject.id;
const subscriberName = useParams({
from: ROUTE_PATHS.CertManager.PkiSubscriberDetailsByIDPage.id,
select: (el) => el.subscriberName

View File

@@ -28,7 +28,7 @@ import {
ProjectPermissionPkiSubscriberActions,
ProjectPermissionSub,
useProjectPermission,
useWorkspace
useProject
} from "@app/context";
import { useGetPkiSubscriberCertificates } from "@app/hooks/api";
import { caSupportsCapability } from "@app/hooks/api/ca/constants";
@@ -45,8 +45,8 @@ type Props = {
const PER_PAGE_INIT = 25;
export const PkiSubscriberCertificatesTable = ({ subscriberName, handlePopUpOpen }: Props) => {
const { currentWorkspace } = useWorkspace();
const projectId = currentWorkspace.id;
const { currentProject } = useProject();
const projectId = currentProject.id;
const { permission } = useProjectPermission();
const [page, setPage] = useState(1);
const [perPage, setPerPage] = useState(PER_PAGE_INIT);
@@ -64,7 +64,7 @@ export const PkiSubscriberCertificatesTable = ({ subscriberName, handlePopUpOpen
);
// Fetch CA data to determine capabilities
const { data: caData } = useListCasByProjectId(currentWorkspace.id);
const { data: caData } = useListCasByProjectId(currentProject.id);
// Create mapping from caId to CA type for capability checking
const caCapabilityMap = useMemo(() => {

View File

@@ -17,7 +17,7 @@ import {
ProjectPermissionPkiSubscriberActions,
ProjectPermissionSub,
useProjectPermission,
useWorkspace
useProject
} from "@app/context";
import { useTimedReset } from "@app/hooks";
import {
@@ -44,8 +44,8 @@ type TCertificateDetails = {
};
export const PkiSubscriberDetailsSection = ({ subscriberName, handlePopUpOpen }: Props) => {
const { currentWorkspace } = useWorkspace();
const projectId = currentWorkspace.id;
const { currentProject } = useProject();
const projectId = currentProject.id;
const { permission } = useProjectPermission();
const [certificateDetails, setCertificateDetails] = useState<TCertificateDetails | null>(null);
const [isModalOpen, setIsModalOpen] = useState(false);

View File

@@ -22,7 +22,7 @@ import {
TabPanel,
Tabs
} from "@app/components/v2";
import { useWorkspace } from "@app/context";
import { useProject } from "@app/context";
import {
CaType,
useCreatePkiSubscriber,
@@ -158,8 +158,8 @@ const schema = z
export type FormData = z.infer<typeof schema>;
export const PkiSubscriberModal = ({ popUp, handlePopUpToggle }: Props) => {
const { currentWorkspace } = useWorkspace();
const projectId = currentWorkspace.id;
const { currentProject } = useProject();
const projectId = currentProject.id;
const { data: subscribers } = useListWorkspacePkiSubscribers(projectId);
const { data: cas } = useListCasByProjectId(projectId);
const [tabValue, setTabValue] = useState<FormTab>(FormTab.Configuration);

Some files were not shown because too many files have changed in this diff Show More