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

This commit is contained in:
=
2025-09-16 00:08:41 +05:30
parent 37a80fa1ac
commit ac80242749
356 changed files with 1788 additions and 1890 deletions
@@ -26,7 +26,7 @@ import {
ProjectPermissionDynamicSecretActions,
ProjectPermissionSub,
useProjectPermission,
useWorkspace
useProject
} from "@app/context";
import {
ProjectPermissionCommitsActions,
@@ -53,7 +53,7 @@ import { OrderByDirection } from "@app/hooks/api/generic/types";
import { PendingAction } from "@app/hooks/api/secretFolders/types";
import { useCreateCommit } from "@app/hooks/api/secrets/mutations";
import { SecretV3RawSanitized } from "@app/hooks/api/types";
import { ProjectVersion } from "@app/hooks/api/workspace/types";
import { ProjectVersion } from "@app/hooks/api/projects/types";
import { usePathAccessPolicies } from "@app/hooks/usePathAccessPolicies";
import { useResizableColWidth } from "@app/hooks/useResizableColWidth";
import { hasSecretReadValueOrDescribePermission } from "@app/lib/fn/permission";
@@ -94,7 +94,7 @@ const LOADER_TEXT = [
];
const Page = () => {
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const navigate = useNavigate({
from: ROUTE_PATHS.SecretManager.SecretDashboardPage.path
});
@@ -142,15 +142,15 @@ const Page = () => {
] as const);
// env slug
const workspaceId = currentWorkspace?.id || "";
const projectSlug = currentWorkspace?.slug || "";
const projectId = currentProject?.id || "";
const projectSlug = currentProject?.slug || "";
const secretPath = (routerQueryParams.secretPath as string) || "/";
useEffect(() => {
if (isBatchMode && workspaceId && environment && secretPath) {
loadPendingChanges({ workspaceId, environment, secretPath });
if (isBatchMode && projectId && environment && secretPath) {
loadPendingChanges({ projectId: projectId, environment, secretPath });
}
}, [isBatchMode, workspaceId, environment, secretPath, loadPendingChanges]);
}, [isBatchMode, projectId, environment, secretPath, loadPendingChanges]);
const canReadSecret = hasSecretReadValueOrDescribePermission(
permission,
@@ -240,7 +240,7 @@ const Page = () => {
const { togglePopUp } = usePopUpAction();
useEffect(() => {
if (!currentWorkspace?.environments.find((env) => env.slug === environment)) {
if (!currentProject?.environments.find((env) => env.slug === environment)) {
createNotification({
text: "No environment found with given slug",
type: "error"
@@ -248,11 +248,11 @@ const Page = () => {
navigate({
to: "/projects/secret-management/$projectId/overview",
params: {
projectId: workspaceId
projectId: projectId
}
});
}
}, [currentWorkspace, environment]);
}, [currentProject, environment]);
const isResourceTypeFiltered = Object.values(filter.include).some(Boolean);
const {
@@ -262,7 +262,7 @@ const Page = () => {
isFetched
} = useGetProjectSecretsDetails({
environment,
projectId: workspaceId,
projectId: projectId,
secretPath,
offset,
limit,
@@ -316,7 +316,7 @@ const Page = () => {
// fetch imported secrets to show user the overriden ones
const { data: importedSecrets } = useGetImportedSecretsSingleEnv({
projectId: workspaceId,
projectId: projectId,
environment,
path: secretPath,
options: {
@@ -326,13 +326,13 @@ const Page = () => {
// fetch tags
const { data: tags } = useGetWsTags(
permission.can(ProjectPermissionActions.Read, ProjectPermissionSub.Tags) ? workspaceId : ""
permission.can(ProjectPermissionActions.Read, ProjectPermissionSub.Tags) ? projectId : ""
);
const { pathPolicies, hasPathPolicies } = usePathAccessPolicies({ secretPath, environment });
const { data: boardPolicy } = useGetSecretApprovalPolicyOfABoard({
workspaceId,
projectId,
environment,
secretPath
});
@@ -341,7 +341,7 @@ const Page = () => {
const handleCreateCommit = async (changes: PendingChanges, message: string) => {
try {
await createCommit({
workspaceId,
projectId,
environment,
secretPath,
pendingChanges: changes,
@@ -368,7 +368,7 @@ const Page = () => {
fetchNextPage: fetchNextSnapshotList,
hasNextPage: hasNextSnapshotListPage
} = useGetWorkspaceSnapshotList({
workspaceId,
projectId,
directory: secretPath,
environment,
isPaused: !popUp.snapshots.isOpen || !canDoReadRollback,
@@ -381,7 +381,7 @@ const Page = () => {
isFetching: isFolderCommitsCountFetching
} = useGetFolderCommitsCount({
directory: secretPath,
workspaceId,
projectId,
environment,
isPaused: !canReadCommits
});
@@ -391,13 +391,13 @@ const Page = () => {
isPending: isSnapshotCountLoading,
isFetching: isSnapshotCountFetching
} = useGetWsSnapshotCount({
workspaceId,
projectId,
environment,
directory: secretPath,
isPaused: !canDoReadRollback
});
const isPITEnabled = !currentWorkspace?.showSnapshotsLegacy;
const isPITEnabled = !currentProject?.showSnapshotsLegacy;
const changesCount = useMemo(() => {
return isPITEnabled ? folderCommitsCount : snapshotCount;
@@ -416,7 +416,7 @@ const Page = () => {
navigate({
to: "/projects/secret-management/$projectId/commits/$environment/$folderId",
params: {
projectId: workspaceId,
projectId: projectId,
folderId,
environment
},
@@ -647,7 +647,7 @@ const Page = () => {
? change.tags?.map((tag) => ({
id: tag.id,
slug: tag.slug,
projectId: workspaceId,
projectId: projectId,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
__v: 0
@@ -734,7 +734,7 @@ const Page = () => {
const mergedSecrets = getMergedSecretsWithPending();
const mergedFolders = getMergedFoldersWithPending();
if (!(currentWorkspace?.version === ProjectVersion.V3))
if (!(currentProject?.version === ProjectVersion.V3))
return (
<div className="flex h-full w-full flex-col items-center justify-center px-6 text-mineshaft-50 dark:[color-scheme:dark]">
<SecretV2MigrationSection />
@@ -794,8 +794,6 @@ const Page = () => {
<>
<ActionBar
environment={environment}
workspaceId={workspaceId}
projectSlug={projectSlug}
secretPath={secretPath}
isVisible={isVisible}
isBatchMode={isBatchMode}
@@ -957,7 +955,7 @@ const Page = () => {
secretImports={imports}
isFetching={isDetailsFetching}
environment={environment}
workspaceId={workspaceId}
workspaceId={projectId}
secretPath={secretPath}
importedSecrets={importedSecrets}
/>
@@ -966,7 +964,7 @@ const Page = () => {
<FolderListView
folders={mergedFolders}
environment={environment}
workspaceId={workspaceId}
workspaceId={projectId}
secretPath={secretPath}
onNavigateToFolder={handleResetFilter}
canNavigate={isFetched}
@@ -990,7 +988,7 @@ const Page = () => {
tags={tags}
isVisible={isVisible}
environment={environment}
workspaceId={workspaceId}
projectId={projectId}
secretPath={secretPath}
isProtectedBranch={isProtectedBranch}
importedBy={importedBy}
@@ -1001,7 +999,7 @@ const Page = () => {
<CommitForm
onCommit={handleCreateCommit}
environment={environment}
workspaceId={workspaceId}
workspaceId={projectId}
secretPath={secretPath}
isCommitting={isCommitPending}
/>
@@ -1052,9 +1050,9 @@ const Page = () => {
>
<CreateSecretForm
environment={environment}
workspaceId={workspaceId}
projectId={projectId}
secretPath={secretPath}
autoCapitalize={currentWorkspace?.autoCapitalization}
autoCapitalize={currentProject?.autoCapitalization}
isProtectedBranch={isProtectedBranch}
isBatchMode={isBatchMode}
/>
@@ -1073,10 +1071,10 @@ const Page = () => {
)}
<SecretDropzone
environment={environment}
workspaceId={workspaceId}
projectId={projectId}
secretPath={secretPath}
isSmaller={isNotEmpty}
environments={currentWorkspace?.environments}
environments={currentProject?.environments}
isProtectedBranch={isProtectedBranch}
/>
<PitDrawer
@@ -1094,7 +1092,7 @@ const Page = () => {
<SnapshotView
snapshotId={snapshotId || ""}
environment={environment}
workspaceId={workspaceId}
projectId={projectId}
secretPath={secretPath}
secrets={secrets}
folders={folders}
@@ -97,7 +97,7 @@ export interface PendingChanges {
// Context interface for batch operations
export interface BatchContext {
workspaceId: string;
projectId: string;
environment: string;
secretPath: string;
}
@@ -257,8 +257,8 @@ type BatchModeState = {
};
};
const generateContextKey = (workspaceId: string, environment: string, secretPath: string) => {
return `${workspaceId}_${environment}_${secretPath}`;
const generateContextKey = (projectId: string, environment: string, secretPath: string) => {
return `${projectId}_${environment}_${secretPath}`;
};
const createBatchModeStore: StateCreator<CombinedState, [], [], BatchModeState> = (set, get) => ({
@@ -272,7 +272,7 @@ const createBatchModeStore: StateCreator<CombinedState, [], [], BatchModeState>
addPendingChange: (change: PendingChange, context: BatchContext) =>
set((state) => {
const contextKey = generateContextKey(
context.workspaceId,
context.projectId,
context.environment,
context.secretPath
);
@@ -551,7 +551,7 @@ const createBatchModeStore: StateCreator<CombinedState, [], [], BatchModeState>
const currentChanges =
contextKey ===
generateContextKey(
state.currentContext?.workspaceId || context.workspaceId,
state.currentContext?.projectId || context.projectId,
state.currentContext?.environment || context.environment,
state.currentContext?.secretPath || context.secretPath
)
@@ -568,7 +568,7 @@ const createBatchModeStore: StateCreator<CombinedState, [], [], BatchModeState>
removePendingChange: (changeId: string, resourceType: string, context: BatchContext) =>
set((state) => {
const contextKey = generateContextKey(
context.workspaceId,
context.projectId,
context.environment,
context.secretPath
);
@@ -593,7 +593,7 @@ const createBatchModeStore: StateCreator<CombinedState, [], [], BatchModeState>
state.currentContext &&
contextKey ===
generateContextKey(
state.currentContext.workspaceId,
state.currentContext.projectId,
state.currentContext.environment,
state.currentContext.secretPath
);
@@ -606,7 +606,7 @@ const createBatchModeStore: StateCreator<CombinedState, [], [], BatchModeState>
loadPendingChanges: (context) => {
const contextKey = generateContextKey(
context.workspaceId,
context.projectId,
context.environment,
context.secretPath
);
@@ -626,7 +626,7 @@ const createBatchModeStore: StateCreator<CombinedState, [], [], BatchModeState>
clearAllPendingChanges: (context) => {
const contextKey = generateContextKey(
context.workspaceId,
context.projectId,
context.environment,
context.secretPath
);
@@ -641,7 +641,7 @@ const createBatchModeStore: StateCreator<CombinedState, [], [], BatchModeState>
state.currentContext &&
contextKey ===
generateContextKey(
state.currentContext.workspaceId,
state.currentContext.projectId,
state.currentContext.environment,
state.currentContext.secretPath
);
@@ -57,7 +57,7 @@ import {
ProjectPermissionSub,
useProjectPermission,
useSubscription,
useWorkspace
useProject
} from "@app/context";
import {
ProjectPermissionCommitsActions,
@@ -109,9 +109,6 @@ type TSecOverwriteOpt = { update: TParsedEnv; create: TParsedEnv };
type Props = {
// switch the secrets type as it gets decrypted after api call
environment: string;
// @depreciated will be moving all these details to zustand
workspaceId: string;
projectSlug: string;
secretPath?: string;
filter: Filter;
tags?: WsTag[];
@@ -142,8 +139,6 @@ type Props = {
export const ActionBar = ({
environment,
workspaceId,
projectSlug,
secretPath = "/",
filter,
tags = [],
@@ -164,6 +159,7 @@ export const ActionBar = ({
hasPathPolicies,
onClearFilters
}: Props) => {
const { projectId, currentProject } = useProject();
const { handlePopUpOpen, handlePopUpToggle, handlePopUpClose, popUp } = usePopUp([
"addFolder",
"addDynamicSecret",
@@ -196,7 +192,6 @@ export const ActionBar = ({
const { reset: resetSelectedSecret } = useSelectedSecretActions();
const isMultiSelectActive = Boolean(Object.keys(selectedSecrets).length);
const { currentWorkspace } = useWorkspace();
const { permission } = useProjectPermission();
const handleFolderCreate = async (folderName: string, description: string | null) => {
@@ -214,7 +209,7 @@ export const ActionBar = ({
};
addPendingChange(pendingFolderCreate, {
workspaceId,
projectId,
environment,
secretPath
});
@@ -227,7 +222,7 @@ export const ActionBar = ({
name: folderName,
path: secretPath,
environment,
projectId: workspaceId,
projectId,
description
});
handlePopUpClose("addFolder");
@@ -247,7 +242,7 @@ export const ActionBar = ({
const handleSecretDownload = async () => {
try {
const { secrets: localSecrets, imports: localImportedSecrets } = await fetchProjectSecrets({
workspaceId,
projectId,
expandSecretReferences: true,
includeImports: true,
environment,
@@ -317,7 +312,7 @@ export const ActionBar = ({
try {
await deleteBatchSecretV3({
secretPath,
workspaceId,
projectId,
environment,
secrets: bulkDeletedSecrets.map(({ key }) => ({ secretKey: key, type: SecretType.Shared }))
});
@@ -348,13 +343,12 @@ export const ActionBar = ({
try {
const secretsToMove = Object.values(selectedSecrets);
const { isDestinationUpdated, isSourceUpdated } = await moveSecrets({
projectSlug,
shouldOverwrite,
sourceEnvironment: environment,
sourceSecretPath: secretPath,
destinationEnvironment,
destinationSecretPath,
projectId: workspaceId,
projectId,
secretIds: secretsToMove.map((sec) => sec.id)
});
@@ -448,7 +442,7 @@ export const ActionBar = ({
const { secrets: batchSecrets } = await fetchDashboardProjectSecretsByKeys({
secretPath: normalizedPath,
environment,
projectId: workspaceId,
projectId,
keys: batch
});
@@ -566,7 +560,7 @@ export const ActionBar = ({
name: folderName,
path: parentPath,
environment,
projectId: workspaceId
projectId
});
createdFolders.add(fullPath);
@@ -598,7 +592,7 @@ export const ActionBar = ({
Object.entries(groupedCreateSecrets).map(([path, secrets]) =>
createSecretBatch({
secretPath: path,
workspaceId,
projectId,
environment,
secrets
})
@@ -628,7 +622,7 @@ export const ActionBar = ({
Object.entries(groupedUpdateSecrets).map(([path, secrets]) =>
updateSecretBatch({
secretPath: path,
workspaceId,
projectId,
environment,
secrets
})
@@ -638,13 +632,12 @@ export const ActionBar = ({
// Invalidate appropriate queries to refresh UI
queryClient.invalidateQueries({
queryKey: secretKeys.getProjectSecret({ workspaceId, environment, secretPath })
queryKey: secretKeys.getProjectSecret({ projectId, environment, secretPath })
});
queryClient.invalidateQueries({});
queryKey: dashboardKeys.getDashboardSecrets({ projectId, secretPath });
queryClient.invalidateQueries({
queryKey: dashboardKeys.getDashboardSecrets({ projectId: workspaceId, secretPath })
});
queryClient.invalidateQueries({
queryKey: secretApprovalRequestKeys.count({ workspaceId })
queryKey: secretApprovalRequestKeys.count({ projectId })
});
// Close the modal and show notification
@@ -677,8 +670,8 @@ export const ActionBar = ({
className="w-2/5"
value={filter.searchFilter}
onChange={onSearchChange}
environments={[currentWorkspace.environments.find((env) => env.slug === environment)!]}
projectId={workspaceId}
environments={[currentProject.environments.find((env) => env.slug === environment)!]}
projectId={projectId}
tags={tags}
/>
<div>
@@ -1134,8 +1127,8 @@ export const ActionBar = ({
{/* all the side triggers from actions like modals etc */}
<CreateSecretImportForm
environment={environment}
workspaceId={workspaceId}
secretPath={secretPath}
projectId={projectId}
onUpgradePlan={() => handlePopUpOpen("upgradePlan")}
isOpen={popUp.addSecretImport.isOpen}
onClose={() => handlePopUpClose("addSecretImport")}
@@ -1144,7 +1137,7 @@ export const ActionBar = ({
<CreateDynamicSecretForm
isOpen={popUp.addDynamicSecret.isOpen}
onToggle={(isOpen) => handlePopUpToggle("addDynamicSecret", isOpen)}
projectSlug={projectSlug}
projectSlug={currentProject.slug}
environments={[{ slug: environment, name: environment, id: "not-used" }]}
secretPath={secretPath}
isSingleEnvironmentMode
@@ -1190,8 +1183,8 @@ export const ActionBar = ({
onToggle={(isOpen) => handlePopUpToggle("replicateFolder", isOpen)}
onParsedEnv={handleParsedEnvMultiFolder}
environment={environment}
environments={currentWorkspace.environments}
workspaceId={workspaceId}
environments={currentProject.environments}
projectId={projectId}
secretPath={secretPath}
/>
{subscription && (
@@ -19,7 +19,7 @@ import {
} from "@app/components/v2";
import { useCreateDynamicSecret } from "@app/hooks/api";
import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";
import { WorkspaceEnv } from "@app/hooks/api/types";
import { ProjectEnv } from "@app/hooks/api/types";
const formSchema = z.object({
provider: z.object({
@@ -63,7 +63,7 @@ type Props = {
onCancel: () => void;
secretPath: string;
projectSlug: string;
environments: WorkspaceEnv[];
environments: ProjectEnv[];
isSingleEnvironmentMode?: boolean;
};
@@ -20,7 +20,7 @@ import {
DynamicSecretAwsIamAuth,
DynamicSecretProviders
} from "@app/hooks/api/dynamicSecret/types";
import { WorkspaceEnv } from "@app/hooks/api/types";
import { ProjectEnv } from "@app/hooks/api/types";
import { MetadataForm } from "../../DynamicSecretListView/MetadataForm";
@@ -112,7 +112,7 @@ type Props = {
onCancel: () => void;
secretPath: string;
projectSlug: string;
environments: WorkspaceEnv[];
environments: ProjectEnv[];
isSingleEnvironmentMode?: boolean;
};
@@ -18,7 +18,7 @@ import { Tooltip } from "@app/components/v2/Tooltip";
import { useCreateDynamicSecret } from "@app/hooks/api";
import { useGetDynamicSecretProviderData } from "@app/hooks/api/dynamicSecret/queries";
import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";
import { WorkspaceEnv } from "@app/hooks/api/types";
import { ProjectEnv } from "@app/hooks/api/types";
const formSchema = z.object({
selectedUsers: z.array(
@@ -66,7 +66,7 @@ type Props = {
onCancel: () => void;
secretPath: string;
projectSlug: string;
environments: WorkspaceEnv[];
environments: ProjectEnv[];
isSingleEnvironmentMode?: boolean;
};
@@ -19,7 +19,7 @@ import {
} from "@app/components/v2";
import { useCreateDynamicSecret } from "@app/hooks/api";
import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";
import { WorkspaceEnv } from "@app/hooks/api/types";
import { ProjectEnv } from "@app/hooks/api/types";
import { slugSchema } from "@app/lib/schemas";
const formSchema = z.object({
@@ -66,7 +66,7 @@ type Props = {
onCancel: () => void;
secretPath: string;
projectSlug: string;
environments: WorkspaceEnv[];
environments: ProjectEnv[];
isSingleEnvironmentMode?: boolean;
};
@@ -24,7 +24,7 @@ import {
} from "@app/components/v2";
import { useCreateDynamicSecret } from "@app/hooks/api";
import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";
import { WorkspaceEnv } from "@app/hooks/api/types";
import { ProjectEnv } from "@app/hooks/api/types";
import { slugSchema } from "@app/lib/schemas";
// Component for managing scopes and collections within a bucket
@@ -265,7 +265,7 @@ type Props = {
onCancel: () => void;
secretPath: string;
projectSlug: string;
environments: WorkspaceEnv[];
environments: ProjectEnv[];
isSingleEnvironmentMode?: boolean;
};
@@ -24,7 +24,7 @@ import { AnimatePresence, motion } from "framer-motion";
import { Modal, ModalContent } from "@app/components/v2";
import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";
import { WorkspaceEnv } from "@app/hooks/api/types";
import { ProjectEnv } from "@app/hooks/api/types";
import { AwsElastiCacheInputForm } from "./AwsElastiCacheInputForm";
import { AwsIamInputForm } from "./AwsIamInputForm";
@@ -51,7 +51,7 @@ type Props = {
isOpen?: boolean;
onToggle: (isOpen: boolean) => void;
projectSlug: string;
environments: WorkspaceEnv[];
environments: ProjectEnv[];
secretPath: string;
isSingleEnvironmentMode?: boolean;
};
@@ -20,7 +20,7 @@ import {
} from "@app/components/v2";
import { useCreateDynamicSecret } from "@app/hooks/api";
import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";
import { WorkspaceEnv } from "@app/hooks/api/types";
import { ProjectEnv } from "@app/hooks/api/types";
import { slugSchema } from "@app/lib/schemas";
const authMethods = [
@@ -87,7 +87,7 @@ type Props = {
onCancel: () => void;
secretPath: string;
projectSlug: string;
environments: WorkspaceEnv[];
environments: ProjectEnv[];
isSingleEnvironmentMode?: boolean;
};
@@ -8,7 +8,7 @@ import { createNotification } from "@app/components/notifications";
import { Button, FilterableSelect, FormControl, Input } from "@app/components/v2";
import { useCreateDynamicSecret } from "@app/hooks/api";
import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";
import { WorkspaceEnv } from "@app/hooks/api/types";
import { ProjectEnv } from "@app/hooks/api/types";
const validateTTL = (val: string, ctx: z.RefinementCtx) => {
if (!val) return;
@@ -49,7 +49,7 @@ type Props = {
onCancel: () => void;
secretPath: string;
projectSlug: string;
environments: WorkspaceEnv[];
environments: ProjectEnv[];
isSingleEnvironmentMode?: boolean;
};
@@ -16,7 +16,7 @@ import {
} from "@app/components/v2";
import { useCreateDynamicSecret } from "@app/hooks/api";
import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";
import { WorkspaceEnv } from "@app/hooks/api/types";
import { ProjectEnv } from "@app/hooks/api/types";
const formSchema = z.object({
provider: z.object({
@@ -44,7 +44,7 @@ type Props = {
onCancel: () => void;
secretPath: string;
projectSlug: string;
environments: WorkspaceEnv[];
environments: ProjectEnv[];
isSingleEnvironmentMode?: boolean;
};
@@ -28,7 +28,7 @@ import {
DynamicSecretProviders,
KubernetesDynamicSecretCredentialType
} from "@app/hooks/api/dynamicSecret/types";
import { WorkspaceEnv } from "@app/hooks/api/types";
import { ProjectEnv } from "@app/hooks/api/types";
import { slugSchema } from "@app/lib/schemas";
enum RoleType {
@@ -150,7 +150,7 @@ type Props = {
onCancel: () => void;
secretPath: string;
projectSlug: string;
environments: WorkspaceEnv[];
environments: ProjectEnv[];
isSingleEnvironmentMode?: boolean;
};
@@ -16,7 +16,7 @@ import {
} from "@app/components/v2";
import { useCreateDynamicSecret } from "@app/hooks/api";
import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";
import { WorkspaceEnv } from "@app/hooks/api/types";
import { ProjectEnv } from "@app/hooks/api/types";
import { slugSchema } from "@app/lib/schemas";
enum CredentialType {
@@ -89,7 +89,7 @@ type Props = {
onCancel: () => void;
secretPath: string;
projectSlug: string;
environments: WorkspaceEnv[];
environments: ProjectEnv[];
isSingleEnvironmentMode?: boolean;
};
@@ -23,7 +23,7 @@ import {
} from "@app/components/v2";
import { useCreateDynamicSecret } from "@app/hooks/api";
import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";
import { WorkspaceEnv } from "@app/hooks/api/types";
import { ProjectEnv } from "@app/hooks/api/types";
import { slugSchema } from "@app/lib/schemas";
const formSchema = z.object({
@@ -77,7 +77,7 @@ type Props = {
onCancel: () => void;
secretPath: string;
projectSlug: string;
environments: WorkspaceEnv[];
environments: ProjectEnv[];
isSingleEnvironmentMode?: boolean;
};
@@ -18,7 +18,7 @@ import {
} from "@app/components/v2";
import { useCreateDynamicSecret } from "@app/hooks/api";
import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";
import { WorkspaceEnv } from "@app/hooks/api/types";
import { ProjectEnv } from "@app/hooks/api/types";
import { slugSchema } from "@app/lib/schemas";
const formSchema = z.object({
@@ -67,7 +67,7 @@ type Props = {
onCancel: () => void;
secretPath: string;
projectSlug: string;
environments: WorkspaceEnv[];
environments: ProjectEnv[];
isSingleEnvironmentMode?: boolean;
};
@@ -18,7 +18,7 @@ import {
} from "@app/components/v2";
import { useCreateDynamicSecret } from "@app/hooks/api";
import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";
import { WorkspaceEnv } from "@app/hooks/api/types";
import { ProjectEnv } from "@app/hooks/api/types";
import { slugSchema } from "@app/lib/schemas";
const formSchema = z.object({
@@ -71,7 +71,7 @@ type Props = {
onCancel: () => void;
secretPath: string;
projectSlug: string;
environments: WorkspaceEnv[];
environments: ProjectEnv[];
isSingleEnvironmentMode?: boolean;
};
@@ -19,7 +19,7 @@ import {
} from "@app/components/v2";
import { useCreateDynamicSecret } from "@app/hooks/api";
import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";
import { WorkspaceEnv } from "@app/hooks/api/types";
import { ProjectEnv } from "@app/hooks/api/types";
import { slugSchema } from "@app/lib/schemas";
const formSchema = z.object({
@@ -64,7 +64,7 @@ type Props = {
onCancel: () => void;
secretPath: string;
projectSlug: string;
environments: WorkspaceEnv[];
environments: ProjectEnv[];
isSingleEnvironmentMode?: boolean;
};
@@ -18,7 +18,7 @@ import {
} from "@app/components/v2";
import { useCreateDynamicSecret } from "@app/hooks/api";
import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";
import { WorkspaceEnv } from "@app/hooks/api/types";
import { ProjectEnv } from "@app/hooks/api/types";
import { slugSchema } from "@app/lib/schemas";
const formSchema = z.object({
@@ -62,7 +62,7 @@ type Props = {
onCancel: () => void;
secretPath: string;
projectSlug: string;
environments: WorkspaceEnv[];
environments: ProjectEnv[];
isSingleEnvironmentMode?: boolean;
};
@@ -19,7 +19,7 @@ import {
} from "@app/components/v2";
import { useCreateDynamicSecret } from "@app/hooks/api";
import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";
import { WorkspaceEnv } from "@app/hooks/api/types";
import { ProjectEnv } from "@app/hooks/api/types";
import { slugSchema } from "@app/lib/schemas";
const formSchema = z.object({
@@ -64,7 +64,7 @@ type Props = {
onCancel: () => void;
secretPath: string;
projectSlug: string;
environments: WorkspaceEnv[];
environments: ProjectEnv[];
isSingleEnvironmentMode?: boolean;
};
@@ -18,7 +18,7 @@ import {
} from "@app/components/v2";
import { useCreateDynamicSecret } from "@app/hooks/api";
import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";
import { WorkspaceEnv } from "@app/hooks/api/types";
import { ProjectEnv } from "@app/hooks/api/types";
import { slugSchema } from "@app/lib/schemas";
const formSchema = z.object({
@@ -62,7 +62,7 @@ type Props = {
onCancel: () => void;
secretPath: string;
projectSlug: string;
environments: WorkspaceEnv[];
environments: ProjectEnv[];
isSingleEnvironmentMode?: boolean;
};
@@ -29,7 +29,7 @@ import {
} from "@app/context/OrgPermissionContext/types";
import { gatewaysQueryKeys, useCreateDynamicSecret } from "@app/hooks/api";
import { DynamicSecretProviders, SqlProviders } from "@app/hooks/api/dynamicSecret/types";
import { WorkspaceEnv } from "@app/hooks/api/types";
import { ProjectEnv } from "@app/hooks/api/types";
import { slugSchema } from "@app/lib/schemas";
import { MetadataForm } from "../../DynamicSecretListView/MetadataForm";
@@ -110,7 +110,7 @@ type Props = {
onCancel: () => void;
secretPath: string;
projectSlug: string;
environments: WorkspaceEnv[];
environments: ProjectEnv[];
isSingleEnvironmentMode?: boolean;
};
@@ -13,7 +13,7 @@ import {
} from "@app/components/v2";
import { useCreateDynamicSecret } from "@app/hooks/api";
import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";
import { WorkspaceEnv } from "@app/hooks/api/types";
import { ProjectEnv } from "@app/hooks/api/types";
import { slugSchema } from "@app/lib/schemas";
enum ConfigType {
@@ -66,7 +66,7 @@ type Props = {
onCancel: () => void;
secretPath: string;
projectSlug: string;
environments: WorkspaceEnv[];
environments: ProjectEnv[];
isSingleEnvironmentMode?: boolean;
};
@@ -27,7 +27,7 @@ import {
} from "@app/context/OrgPermissionContext/types";
import { gatewaysQueryKeys, useCreateDynamicSecret } from "@app/hooks/api";
import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";
import { WorkspaceEnv } from "@app/hooks/api/types";
import { ProjectEnv } from "@app/hooks/api/types";
const passwordRequirementsSchema = z
.object({
@@ -91,7 +91,7 @@ type Props = {
onCancel: () => void;
secretPath: string;
projectSlug: string;
environments: WorkspaceEnv[];
environments: ProjectEnv[];
isSingleEnvironmentMode?: boolean;
};
@@ -14,7 +14,7 @@ import {
SelectItem
} from "@app/components/v2";
import { SecretPathInput } from "@app/components/v2/SecretPathInput";
import { useSubscription, useWorkspace } from "@app/context";
import { useSubscription, useProject } from "@app/context";
import { useCreateSecretImport } from "@app/hooks/api";
const typeSchema = z.object({
@@ -32,7 +32,7 @@ type TFormSchema = z.infer<typeof typeSchema>;
type Props = {
environment: string;
workspaceId: string;
projectId: string;
secretPath?: string;
// modal props
isOpen?: boolean;
@@ -43,7 +43,7 @@ type Props = {
export const CreateSecretImportForm = ({
environment,
workspaceId,
projectId: workspaceId,
secretPath = "/",
isOpen,
onClose,
@@ -57,8 +57,8 @@ export const CreateSecretImportForm = ({
watch,
formState: { isSubmitting }
} = useForm<TFormSchema>({ resolver: zodResolver(typeSchema) });
const { currentWorkspace } = useWorkspace();
const environments = currentWorkspace?.environments || [];
const { currentProject } = useProject();
const environments = currentProject?.environments || [];
const selectedEnvironment = watch("environment");
const { subscription } = useSubscription();
@@ -12,7 +12,7 @@ import {
SelectItem
} from "@app/components/v2";
import { SecretPathInput } from "@app/components/v2/SecretPathInput";
import { useWorkspace } from "@app/context";
import { useProject } from "@app/context";
import { UsePopUpState } from "@app/hooks/usePopUp";
type Props = {
@@ -47,8 +47,8 @@ export const MoveSecretsModal = ({ popUp, handlePopUpToggle, onMoveApproved }: P
formState: { isSubmitting }
} = useForm<TFormSchema>({ resolver: zodResolver(formSchema) });
const { currentWorkspace } = useWorkspace();
const environments = currentWorkspace?.environments || [];
const { currentProject } = useProject();
const environments = currentProject?.environments || [];
const selectedEnvironment = watch("environment");
const handleFormSubmit = (data: TFormSchema) => {
@@ -48,7 +48,7 @@ type Props = {
env: Record<string, Record<string, { value: string; comments: string[]; secretPath?: string }>>
) => void;
environments?: { name: string; slug: string }[];
workspaceId: string;
projectId: string;
environment: string;
secretPath: string;
};
@@ -64,7 +64,7 @@ type SecretStructure = {
export const ReplicateFolderFromBoard = ({
environments = [],
workspaceId,
projectId: workspaceId,
isOpen,
onToggle,
onParsedEnv
@@ -245,7 +245,7 @@ const ResourceChange: React.FC<ResourceChangeProps> = ({
const handleDeletePending = useCallback(
(changeType: string, id: string) => {
removePendingChange(id, changeType, {
workspaceId,
projectId: workspaceId,
environment,
secretPath
});
@@ -291,7 +291,7 @@ export const CommitForm: React.FC<CommitFormProps> = ({
}
await onCommit(pendingChanges, commitMessage);
clearAllPendingChanges({
workspaceId,
projectId: workspaceId,
environment,
secretPath
});
@@ -336,7 +336,7 @@ export const CommitForm: React.FC<CommitFormProps> = ({
<Button
size="sm"
onClick={() =>
clearAllPendingChanges({ workspaceId, environment, secretPath })
clearAllPendingChanges({ projectId: workspaceId, environment, secretPath })
}
isDisabled={totalChangesCount === 0}
variant="outline_bg"
@@ -38,7 +38,7 @@ import {
Tooltip,
Tr
} from "@app/components/v2";
import { useWorkspace } from "@app/context";
import { useProject } from "@app/context";
import {
getUserTablePreference,
PreferenceKey,
@@ -49,7 +49,7 @@ import { useGetImportedSecretsAllEnvs } from "@app/hooks/api";
import { useGetProjectSecretsOverview } from "@app/hooks/api/dashboard";
import { DashboardSecretsOrderBy } from "@app/hooks/api/dashboard/types";
import { OrderByDirection } from "@app/hooks/api/generic/types";
import { WorkspaceEnv } from "@app/hooks/api/workspace/types";
import { ProjectEnv } from "@app/hooks/api/projects/types";
import { useResizableColWidth } from "@app/hooks/useResizableColWidth";
import {
useDynamicSecretOverview,
@@ -89,10 +89,10 @@ const DEFAULT_FILTER_STATE = {
const COL_WIDTH_OFFSET = 220;
export const CompareEnvironments = ({ secretPath }: Props) => {
const { currentWorkspace } = useWorkspace();
const compareEnvironmentsKey = `compare-environments-${currentWorkspace.id}`;
const { currentProject } = useProject();
const compareEnvironmentsKey = `compare-environments-${currentProject.id}`;
const [selectedEnvironments, setSelectedEnvironments] = useState<WorkspaceEnv[]>(() => {
const [selectedEnvironments, setSelectedEnvironments] = useState<ProjectEnv[]>(() => {
try {
const storedEnvironments = JSON.parse(localStorage.getItem(compareEnvironmentsKey) ?? "[]");
@@ -104,12 +104,12 @@ export const CompareEnvironments = ({ secretPath }: Props) => {
}
});
return currentWorkspace.environments.filter((env) => potentialEnvs.includes(env.id));
return currentProject.environments.filter((env) => potentialEnvs.includes(env.id));
}
} catch {
// do nothing and proceed
}
return currentWorkspace.environments.slice(0, 2);
return currentProject.environments.slice(0, 2);
});
const [filter, setFilter] = useState<Filter>(DEFAULT_FILTER_STATE);
@@ -133,7 +133,7 @@ export const CompareEnvironments = ({ secretPath }: Props) => {
setUserTablePreference("secretCompareTable", PreferenceKey.PerPage, newPerPage);
};
const workspaceId = currentWorkspace.id;
const workspaceId = currentProject.id;
const [searchFilter, setSearchFilter] = useState("");
const [debouncedSearchFilter] = useDebounce(searchFilter);
const [debouncedSelectedEnvironments] = useDebounce(selectedEnvironments);
@@ -153,12 +153,12 @@ export const CompareEnvironments = ({ secretPath }: Props) => {
} = useGetImportedSecretsAllEnvs({
projectId: workspaceId,
path: secretPath,
environments: (currentWorkspace.environments || []).map(({ slug }) => slug)
environments: (currentProject.environments || []).map(({ slug }) => slug)
});
const compareEnvironments = selectedEnvironments.length
? selectedEnvironments
: currentWorkspace.environments;
: currentProject.environments;
const isFilteredByResources = Object.values(filter).some(Boolean);
const { isPending: isOverviewLoading, data: overview } = useGetProjectSecretsOverview(
@@ -579,12 +579,12 @@ export const CompareEnvironments = ({ secretPath }: Props) => {
<FilterableSelect
value={selectedEnvironments}
onChange={(value) => {
const selected = value as MultiValue<WorkspaceEnv>;
const selected = value as MultiValue<ProjectEnv>;
setSelectedEnvironments((selected as WorkspaceEnv[]) ?? []);
setSelectedEnvironments((selected as ProjectEnv[]) ?? []);
}}
placeholder="Leave blank to compare all environments"
options={currentWorkspace.environments}
options={currentProject.environments}
getOptionValue={(option) => option.slug}
getOptionLabel={(option) => option.name}
isMulti
@@ -17,7 +17,7 @@ import {
} from "@app/context/ProjectPermissionContext/types";
import { useToggle } from "@app/hooks";
import { SecretV3RawSanitized } from "@app/hooks/api/secrets/types";
import { WorkspaceEnv } from "@app/hooks/api/types";
import { ProjectEnv } from "@app/hooks/api/types";
import { HIDDEN_SECRET_VALUE } from "@app/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretItem";
import { EnvironmentStatus, EnvironmentStatusCell, ResourceNameCell } from "../shared";
@@ -32,7 +32,7 @@ type Props = {
getImportedSecretByKey: (
env: string,
secretName: string
) => { secret?: SecretV3RawSanitized; environmentInfo?: WorkspaceEnv } | undefined;
) => { secret?: SecretV3RawSanitized; environmentInfo?: ProjectEnv } | undefined;
colWidth: number;
tableWidth: number;
};
@@ -32,7 +32,7 @@ type TFormSchema = z.infer<typeof typeSchema>;
type Props = {
environment: string;
workspaceId: string;
projectId: string;
secretPath?: string;
// modal props
autoCapitalize?: boolean;
@@ -42,7 +42,7 @@ type Props = {
export const CreateSecretForm = ({
environment,
workspaceId,
projectId,
secretPath = "/",
autoCapitalize = true,
isProtectedBranch = false,
@@ -66,7 +66,7 @@ export const CreateSecretForm = ({
const { permission } = useProjectPermission();
const canReadTags = permission.can(ProjectPermissionActions.Read, ProjectPermissionSub.Tags);
const { data: projectTags, isPending: isTagsLoading } = useGetWsTags(
canReadTags ? workspaceId : ""
canReadTags ? projectId : ""
);
const secretKeyInputRef = useRef<HTMLInputElement>(null);
@@ -80,7 +80,7 @@ export const CreateSecretForm = ({
try {
const parsedSlug = slugSchema.parse(slug);
await createWsTag.mutateAsync({
workspaceID: workspaceId,
projectId,
tagSlug: parsedSlug,
tagColor: ""
});
@@ -106,7 +106,8 @@ export const CreateSecretForm = ({
resourceType: "secret"
};
addPendingChange(pendingSecretCreate, {
workspaceId,
projectId,
environment,
secretPath
});
@@ -116,7 +117,7 @@ export const CreateSecretForm = ({
}
await createSecretV3({
environment,
workspaceId,
projectId,
secretPath,
secretKey: key,
secretValue: value || "",
@@ -25,11 +25,11 @@ import {
ProjectPermissionActions,
ProjectPermissionSub,
useSubscription,
useWorkspace
useProject
} from "@app/context";
import { usePopUp } from "@app/hooks";
import { workspaceKeys } from "@app/hooks/api";
import { WorkspaceEnv } from "@app/hooks/api/workspace/types";
import { projectKeys } from "@app/hooks/api";
import { ProjectEnv } from "@app/hooks/api/projects/types";
import { AddEnvironmentModal } from "@app/pages/secret-manager/SettingsPage/components/EnvironmentSection/AddEnvironmentModal";
import { CompareEnvironments } from "../CompareEnvironments";
@@ -45,7 +45,7 @@ type Props = {
const TABS_TO_SHOW = 5;
export const EnvironmentTabs = ({ secretPath }: Props) => {
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const currentEnv = useParams({
from: ROUTE_PATHS.SecretManager.SecretDashboardPage.id,
select: (el) => el.envSlug
@@ -54,8 +54,8 @@ export const EnvironmentTabs = ({ secretPath }: Props) => {
const { subscription } = useSubscription();
const isMoreEnvironmentsAllowed =
subscription?.environmentLimit && currentWorkspace?.environments
? currentWorkspace.environments.length < subscription.environmentLimit
subscription?.environmentLimit && currentProject?.environments
? currentProject.environments.length < subscription.environmentLimit
: true;
const [isNavigating, setIsNavigating] = useState(false);
@@ -68,20 +68,20 @@ export const EnvironmentTabs = ({ secretPath }: Props) => {
"upgradePlan"
] as const);
const selectedIndex = currentWorkspace.environments.findIndex((env) => env.slug === currentEnv);
const selectedIndex = currentProject.environments.findIndex((env) => env.slug === currentEnv);
let tabEnvironments: WorkspaceEnv[];
let dropdownEnvironments: WorkspaceEnv[];
let tabEnvironments: ProjectEnv[];
let dropdownEnvironments: ProjectEnv[];
if (selectedIndex < TABS_TO_SHOW) {
tabEnvironments = currentWorkspace.environments.slice(0, TABS_TO_SHOW);
dropdownEnvironments = currentWorkspace.environments.slice(TABS_TO_SHOW);
tabEnvironments = currentProject.environments.slice(0, TABS_TO_SHOW);
dropdownEnvironments = currentProject.environments.slice(TABS_TO_SHOW);
} else {
tabEnvironments = [
...currentWorkspace.environments.slice(0, TABS_TO_SHOW - 1),
currentWorkspace.environments[selectedIndex]
...currentProject.environments.slice(0, TABS_TO_SHOW - 1),
currentProject.environments[selectedIndex]
];
dropdownEnvironments = currentWorkspace.environments
dropdownEnvironments = currentProject.environments
.slice(TABS_TO_SHOW - 1)
.filter((env) => env.slug !== currentEnv);
}
@@ -96,7 +96,7 @@ export const EnvironmentTabs = ({ secretPath }: Props) => {
to: ROUTE_PATHS.SecretManager.SecretDashboardPage.path,
params: {
envSlug,
projectId: currentWorkspace.id
projectId: currentProject.id
},
search: (prev) => prev
});
@@ -199,7 +199,7 @@ export const EnvironmentTabs = ({ secretPath }: Props) => {
</Tooltip>
</Tab>
)}
{currentWorkspace.environments.length > 1 && (
{currentProject.environments.length > 1 && (
<Tab className="ml-auto" value={COMPARE_ENVIRONMENT_TAB}>
<div className="flex items-center gap-x-2 whitespace-nowrap">
<FontAwesomeIcon icon={faArrowRightArrowLeft} />
@@ -232,7 +232,7 @@ export const EnvironmentTabs = ({ secretPath }: Props) => {
onOpenChange={(isOpen) => handlePopUpToggle("createEnvironment", isOpen)}
onComplete={async (env) => {
await queryClient.refetchQueries({
queryKey: workspaceKeys.getWorkspaceById(currentWorkspace.id)
queryKey: projectKeys.getProjectById(currentProject.id)
});
handleSelect(env.slug);
}}
@@ -89,7 +89,7 @@ export const FolderListView = ({
};
addPendingChange(updatedCreate, {
workspaceId,
projectId: workspaceId,
environment,
secretPath
});
@@ -106,7 +106,7 @@ export const FolderListView = ({
};
addPendingChange(updateChange, {
workspaceId,
projectId: workspaceId,
environment,
secretPath
});
@@ -140,7 +140,7 @@ export const FolderListView = ({
const handleDeletePending = (id: string) => {
removePendingChange(id, "folder", {
workspaceId,
projectId: workspaceId,
environment,
secretPath
});
@@ -161,7 +161,7 @@ export const FolderListView = ({
};
addPendingChange(pendingFolderDelete, {
workspaceId,
projectId: workspaceId,
environment,
secretPath
});
@@ -53,7 +53,7 @@ type TSecOverwriteOpt = { update: TParsedEnv; create: TParsedEnv };
type Props = {
isSmaller: boolean;
environments?: { name: string; slug: string }[];
workspaceId: string;
projectId: string;
environment: string;
secretPath: string;
isProtectedBranch?: boolean;
@@ -140,7 +140,7 @@ const MatrixImportModalTableRow = ({
export const SecretDropzone = ({
isSmaller,
environments = [],
workspaceId,
projectId,
environment,
secretPath,
isProtectedBranch = false
@@ -196,7 +196,7 @@ export const SecretDropzone = ({
const { secrets: existingSecrets } = await fetchDashboardProjectSecretsByKeys({
secretPath,
environment,
projectId: workspaceId,
projectId: projectId,
keys: envSecretKeys
});
@@ -334,7 +334,7 @@ export const SecretDropzone = ({
if (Object.keys(create || {}).length) {
await createSecretBatch({
secretPath,
workspaceId,
projectId,
environment,
secrets: Object.entries(create).map(([secretKey, secData]) => ({
type: SecretType.Shared,
@@ -347,7 +347,7 @@ export const SecretDropzone = ({
if (Object.keys(update || {}).length) {
await updateSecretBatch({
secretPath,
workspaceId,
projectId,
environment,
secrets: Object.entries(update).map(([secretKey, secData]) => ({
type: SecretType.Shared,
@@ -358,13 +358,13 @@ export const SecretDropzone = ({
});
}
queryClient.invalidateQueries({
queryKey: secretKeys.getProjectSecret({ workspaceId, environment, secretPath })
queryKey: secretKeys.getProjectSecret({ projectId, environment, secretPath })
});
queryClient.invalidateQueries({
queryKey: dashboardKeys.getDashboardSecrets({ projectId: workspaceId, secretPath })
queryKey: dashboardKeys.getDashboardSecrets({ projectId: projectId, secretPath })
});
queryClient.invalidateQueries({
queryKey: secretApprovalRequestKeys.count({ workspaceId })
queryKey: secretApprovalRequestKeys.count({ projectId })
});
handlePopUpClose("confirmUpload");
createNotification({
@@ -464,7 +464,7 @@ export const SecretDropzone = ({
onParsedEnv={handleParsedEnv}
environment={environment}
environments={environments}
workspaceId={workspaceId}
workspaceId={projectId}
secretPath={secretPath}
isSmaller={isSmaller}
/>
@@ -21,7 +21,7 @@ import { twMerge } from "tailwind-merge";
import { createNotification } from "@app/components/notifications";
import { ProjectPermissionCan } from "@app/components/permissions";
import { EmptyState, IconButton, SecretInput, TableContainer, Tooltip } from "@app/components/v2";
import { ProjectPermissionActions, ProjectPermissionSub, useWorkspace } from "@app/context";
import { ProjectPermissionActions, ProjectPermissionSub, useProject } from "@app/context";
import { useToggle } from "@app/hooks";
import { useResyncSecretReplication } from "@app/hooks/api";
import { TSecretImport } from "@app/hooks/api/types";
@@ -82,7 +82,7 @@ export const SecretImportItem = ({
lastReplicated,
importEnv
} = secretImport as TSecretImport;
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const [isExpanded, setIsExpanded] = useToggle();
const { attributes, listeners, transform, transition, setNodeRef, isDragging } = useSortable({
id
@@ -118,7 +118,7 @@ export const SecretImportItem = ({
id,
environment,
path: secretPath,
projectId: currentWorkspace?.id || ""
projectId: currentProject?.id || ""
});
createNotification({
text: "Please refresh the dashboard to view changes",
@@ -18,7 +18,7 @@ import { usePopUp } from "@app/hooks";
import { useDeleteSecretImport, useUpdateSecretImport } from "@app/hooks/api";
import { ReservedFolders } from "@app/hooks/api/secretFolders/types";
import { TSecretImport } from "@app/hooks/api/secretImports/types";
import { SecretV3RawSanitized, WorkspaceEnv } from "@app/hooks/api/types";
import { SecretV3RawSanitized, ProjectEnv } from "@app/hooks/api/types";
import { formatReservedPaths } from "@app/lib/fn/string";
import { SecretImportItem } from "./SecretImportItem";
@@ -26,7 +26,7 @@ import { SecretImportItem } from "./SecretImportItem";
const SECRET_IN_DASHBOARD = "Present In Dashboard";
type TImportedSecrets = Array<{
environmentInfo: WorkspaceEnv;
environmentInfo: ProjectEnv;
secretPath: string;
folderId: string;
secrets: SecretV3RawSanitized[];
@@ -4,7 +4,7 @@ import { faFileImport, faKey, faSync, faWarning } from "@fortawesome/free-solid-
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { Table, TBody, Td, Th, THead, Tooltip, Tr } from "@app/components/v2";
import { useWorkspace } from "@app/context";
import { useProject } from "@app/context";
import { UsedBySecretSyncs } from "@app/hooks/api/dashboard/types";
enum ItemType {
@@ -44,7 +44,7 @@ export const CollapsibleSecretImports: React.FC<CollapsibleSecretImportsProps> =
secretsToDelete,
onlyReferences
}) => {
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const truncatePath = (path: string, maxLength = 24): string => {
if (path.length <= maxLength) return path;
@@ -62,7 +62,7 @@ export const CollapsibleSecretImports: React.FC<CollapsibleSecretImportsProps> =
const handlePathClick = (item: FlatItem) => {
if (item.type === ItemType.SecretSync) {
window.open(
`/secret-manager/${currentWorkspace.id}/integrations/secret-syncs/${item.destination}/${item.id}`,
`/secret-manager/${currentProject.id}/integrations/secret-syncs/${item.destination}/${item.id}`,
"_blank",
"noopener,noreferrer"
);
@@ -78,7 +78,7 @@ export const CollapsibleSecretImports: React.FC<CollapsibleSecretImportsProps> =
}
const encodedPath = encodeURIComponent(pathToNavigate);
window.open(
`/secret-manager/${currentWorkspace.id}/secrets/${item.environment.slug}?secretPath=${encodedPath}`,
`/secret-manager/${currentProject.id}/secrets/${item.environment.slug}?secretPath=${encodedPath}`,
"_blank"
);
};
@@ -21,7 +21,7 @@ import {
SelectItem,
TextArea
} from "@app/components/v2";
import { useWorkspace } from "@app/context";
import { useProject } from "@app/context";
import { useGetWorkspaceUsers } from "@app/hooks/api";
import { dashboardKeys } from "@app/hooks/api/dashboard/queries";
import { useCreateReminder, useDeleteReminder } from "@app/hooks/api/reminders";
@@ -52,7 +52,7 @@ interface ReminderFormProps {
isOpen: boolean;
reminderId?: string;
onOpenChange: () => void;
workspaceId: string;
projectId: string;
environment: string;
secretPath: string;
secretId: string;
@@ -118,8 +118,8 @@ const useReminderForm = (reminderData?: Reminder) => {
// Custom hook for workspace members
const useWorkspaceMembers = () => {
const { currentWorkspace } = useWorkspace();
const { data: members = [] } = useGetWorkspaceUsers(currentWorkspace?.id);
const { currentProject } = useProject();
const { data: members = [] } = useGetWorkspaceUsers(currentProject?.id);
const memberOptions = useMemo(
(): RecipientOption[] =>
@@ -137,7 +137,7 @@ const useWorkspaceMembers = () => {
export const CreateReminderForm = ({
isOpen,
onOpenChange,
workspaceId,
projectId: projectId,
environment,
secretPath,
secretId,
@@ -185,12 +185,12 @@ export const CreateReminderForm = ({
const invalidateQueries = () => {
queryClient.invalidateQueries({
queryKey: dashboardKeys.getDashboardSecrets({
projectId: workspaceId,
projectId,
secretPath
})
});
queryClient.invalidateQueries({
queryKey: secretKeys.getProjectSecret({ workspaceId, environment, secretPath })
queryKey: secretKeys.getProjectSecret({ projectId, environment, secretPath })
});
queryClient.invalidateQueries({
queryKey: reminderKeys.getReminder(secretId)
@@ -56,7 +56,7 @@ import {
ProjectPermissionActions,
ProjectPermissionSub,
useProjectPermission,
useWorkspace
useProject
} from "@app/context";
import { ProjectPermissionSecretActions } from "@app/context/ProjectPermissionContext/types";
import { getProjectBaseURL } from "@app/helpers/project";
@@ -120,7 +120,7 @@ export const SecretDetailSidebar = ({
] as const);
const { permission } = useProjectPermission();
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const tagFields = useFieldArray({
control,
@@ -187,7 +187,7 @@ export const SecretDetailSidebar = ({
});
const { data: secretAccessList, isPending } = useGetSecretAccessList({
workspaceId: currentWorkspace.id,
projectId: currentProject.id,
environment,
secretPath,
secretKey
@@ -252,9 +252,9 @@ export const SecretDetailSidebar = ({
) => {
switch (actorType) {
case ActorType.USER:
return `/projects/secret-management/${currentWorkspace.id}/members/${membershipId}`;
return `/projects/secret-management/${currentProject.id}/members/${membershipId}`;
case ActorType.IDENTITY:
return `/projects/secret-management/${currentWorkspace.id}/identities/${actorId}`;
return `/projects/secret-management/${currentProject.id}/identities/${actorId}`;
default:
return null;
}
@@ -367,16 +367,14 @@ export const SecretDetailSidebar = ({
/>
<Tooltip
content={
!currentWorkspace.secretSharing
!currentProject.secretSharing
? "This project does not allow secret sharing."
: "You don't have permission to view the secret value."
}
isDisabled={!secret?.secretValueHidden && currentWorkspace.secretSharing}
isDisabled={!secret?.secretValueHidden && currentProject.secretSharing}
>
<Button
isDisabled={
secret?.secretValueHidden || !currentWorkspace.secretSharing
}
isDisabled={secret?.secretValueHidden || !currentProject.secretSharing}
className="px-2 py-[0.43rem] font-normal"
variant="outline_bg"
leftIcon={<FontAwesomeIcon icon={faShare} />}
@@ -848,10 +846,10 @@ export const SecretDetailSidebar = ({
>
<Link
to={
`${getProjectBaseURL(currentWorkspace.type)}/members/$membershipId` as const
`${getProjectBaseURL(currentProject.type)}/members/$membershipId` as const
}
params={{
projectId: currentWorkspace.id,
projectId: currentProject.id,
membershipId: user.membershipId
}}
className="text-secondary/80 rounded-md border border-mineshaft-600 bg-mineshaft-700 px-1 py-0.5 text-sm hover:text-mineshaft-100"
@@ -882,10 +880,10 @@ export const SecretDetailSidebar = ({
>
<Link
to={
`${getProjectBaseURL(currentWorkspace.type)}/identities/$identityId` as const
`${getProjectBaseURL(currentProject.type)}/identities/$identityId` as const
}
params={{
projectId: currentWorkspace.id,
projectId: currentProject.id,
identityId: identity.id
}}
className="text-secondary/80 rounded-md border border-mineshaft-600 bg-mineshaft-700 px-1 py-0.5 text-sm hover:text-mineshaft-100"
@@ -28,7 +28,7 @@ import {
ProjectPermissionActions,
ProjectPermissionSub,
useProjectPermission,
useWorkspace
useProject
} from "@app/context";
import { usePopUp, useToggle } from "@app/hooks";
import { SecretV3RawSanitized } from "@app/hooks/api/secrets/types";
@@ -112,7 +112,7 @@ export const SecretItem = memo(
"editSecret",
"reminder"
] as const);
const { currentWorkspace } = useWorkspace();
const { currentProject } = useProject();
const { permission } = useProjectPermission();
const { isRotatedSecret } = secret;
const { removePendingChange } = useBatchModeActions();
@@ -122,7 +122,7 @@ export const SecretItem = memo(
const handleDeletePending = (pendingSecret: SecretV3RawSanitized) => {
removePendingChange(pendingSecret.id, "secret", {
workspaceId: currentWorkspace.id,
projectId: currentProject.id,
environment,
secretPath
});
@@ -393,7 +393,7 @@ export const SecretItem = memo(
<Input
autoComplete="off"
isReadOnly={isReadOnly || isRotatedSecret}
autoCapitalization={currentWorkspace?.autoCapitalization}
autoCapitalization={currentProject?.autoCapitalization}
variant="plain"
isDisabled={isOverridden}
placeholder={error?.message}
@@ -677,7 +677,7 @@ export const SecretItem = memo(
)}
</ProjectPermissionCan>
<IconButton
isDisabled={secret.secretValueHidden || !currentWorkspace.secretSharing}
isDisabled={secret.secretValueHidden || !currentProject.secretSharing}
className="w-0 overflow-hidden p-0 group-hover:w-5"
variant="plain"
size="md"
@@ -974,7 +974,7 @@ export const SecretItem = memo(
<CreateReminderForm
isOpen={popUp.reminder.isOpen}
onOpenChange={() => handlePopUpToggle("reminder")}
workspaceId={currentWorkspace.id}
projectId={currentProject.id}
environment={environment}
secretPath={secretPath}
secretId={secret?.id}
@@ -37,7 +37,7 @@ import { FontAwesomeSpriteSymbols } from "./SecretListView.utils";
type Props = {
secrets?: SecretV3RawSanitized[];
environment: string;
workspaceId: string;
projectId: string;
secretPath?: string;
tags?: WsTag[];
isVisible?: boolean;
@@ -57,7 +57,7 @@ type Props = {
export const SecretListView = ({
secrets = [],
environment,
workspaceId,
projectId: projectId,
secretPath = "/",
tags: wsTags = [],
isVisible,
@@ -93,7 +93,7 @@ export const SecretListView = ({
message:
"You have unsaved changes. If you leave now, your work will be lost. Do you want to continue?",
context: {
workspaceId,
projectId: projectId,
environment,
secretPath
}
@@ -140,7 +140,7 @@ export const SecretListView = ({
if (operation === "delete") {
await deleteSecretV3({
environment,
workspaceId,
projectId,
secretPath,
secretKey: key,
type,
@@ -161,7 +161,7 @@ export const SecretListView = ({
await updateSecretV3({
environment,
workspaceId,
projectId,
secretPath,
secretKey: key,
...(!isRotatedSecret && {
@@ -183,7 +183,7 @@ export const SecretListView = ({
await createSecretV3(
{
environment,
workspaceId,
projectId,
secretPath,
secretKey: key,
secretValue: value || "",
@@ -337,7 +337,7 @@ export const SecretListView = ({
};
addPendingChange(updatedCreate, {
workspaceId,
projectId: projectId,
environment,
secretPath
});
@@ -369,7 +369,7 @@ export const SecretListView = ({
};
addPendingChange(updateChange, {
workspaceId,
projectId: projectId,
environment,
secretPath
});
@@ -400,27 +400,39 @@ export const SecretListView = ({
}
queryClient.invalidateQueries({
queryKey: dashboardKeys.getDashboardSecrets({
projectId: workspaceId,
projectId,
secretPath
})
});
queryClient.invalidateQueries({
queryKey: secretKeys.getProjectSecret({ workspaceId, environment, secretPath })
queryKey: secretKeys.getProjectSecret({ projectId, environment, secretPath })
});
queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.list({ workspaceId, environment, directory: secretPath })
queryKey: secretSnapshotKeys.list({
projectId,
environment,
directory: secretPath
})
});
queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.count({ workspaceId, environment, directory: secretPath })
queryKey: secretSnapshotKeys.count({
projectId,
environment,
directory: secretPath
})
});
queryClient.invalidateQueries({
queryKey: commitKeys.count({ projectId: workspaceId, environment, directory: secretPath })
queryKey: commitKeys.count({ projectId: projectId, environment, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.history({ workspaceId, environment, directory: secretPath })
queryKey: commitKeys.history({
projectId,
environment,
directory: secretPath
})
});
queryClient.invalidateQueries({
queryKey: secretApprovalRequestKeys.count({ workspaceId })
queryKey: secretApprovalRequestKeys.count({ projectId })
});
if (!isReminderEvent) {
handlePopUpClose("secretDetail");
@@ -450,7 +462,7 @@ export const SecretListView = ({
});
}
},
[environment, secretPath, isProtectedBranch, isBatchMode, workspaceId, addPendingChange]
[environment, secretPath, isProtectedBranch, isBatchMode, projectId, addPendingChange]
);
const handleSecretDelete = useCallback(async () => {
@@ -467,7 +479,7 @@ export const SecretListView = ({
};
addPendingChange(deleteChange, {
workspaceId,
projectId: projectId,
environment,
secretPath
});
@@ -480,25 +492,33 @@ export const SecretListView = ({
await handleSecretOperation("delete", SecretType.Shared, key, { secretId });
// wrap this in another function and then reuse
queryClient.invalidateQueries({
queryKey: dashboardKeys.getDashboardSecrets({ projectId: workspaceId, secretPath })
queryKey: dashboardKeys.getDashboardSecrets({ projectId: projectId, secretPath })
});
queryClient.invalidateQueries({
queryKey: secretKeys.getProjectSecret({ workspaceId, environment, secretPath })
queryKey: secretKeys.getProjectSecret({ projectId, environment, secretPath })
});
queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.list({ workspaceId, environment, directory: secretPath })
queryKey: secretSnapshotKeys.list({
projectId,
environment,
directory: secretPath
})
});
queryClient.invalidateQueries({
queryKey: secretSnapshotKeys.count({ workspaceId, environment, directory: secretPath })
queryKey: secretSnapshotKeys.count({
projectId,
environment,
directory: secretPath
})
});
queryClient.invalidateQueries({
queryKey: commitKeys.count({ projectId: workspaceId, environment, directory: secretPath })
queryKey: commitKeys.count({ projectId: projectId, environment, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: commitKeys.history({ workspaceId, environment, directory: secretPath })
queryKey: commitKeys.history({ projectId, environment, directory: secretPath })
});
queryClient.invalidateQueries({
queryKey: secretApprovalRequestKeys.count({ workspaceId })
queryKey: secretApprovalRequestKeys.count({ projectId })
});
handlePopUpClose("deleteSecret");
handlePopUpClose("secretDetail");
@@ -521,7 +541,7 @@ export const SecretListView = ({
secretPath,
isProtectedBranch,
isBatchMode,
workspaceId,
projectId,
addPendingChange
]);
@@ -22,7 +22,7 @@ import { renderIcon, SecretItem, TDiffModes, TDiffView } from "./SecretItem";
type Props = {
snapshotId: string;
environment: string;
workspaceId: string;
projectId: string;
secretPath?: string;
secrets?: SecretV3RawSanitized[];
folders?: TSecretFolder[];
@@ -43,7 +43,7 @@ const deepCompareSecrets = (lhs: SecretV3RawSanitized, rhs: SecretV3RawSanitized
export const SnapshotView = ({
snapshotId,
environment,
workspaceId,
projectId,
secretPath,
secrets = [],
folders = [],
@@ -130,7 +130,7 @@ export const SnapshotView = ({
}
try {
await performRollback({
workspaceId,
projectId,
snapshotId: snapshotData.id,
environment,
directory: secretPath