Compare commits

..

17 Commits

Author SHA1 Message Date
69c64c76dd Update 20250711005900_github-app-connection-to-environments.ts 2025-07-13 23:41:57 +04:00
89b9154467 Update 20250711005900_github-app-connection-to-environments.ts 2025-07-13 23:37:19 +04:00
ed247a794a requested changes 2025-07-13 23:36:59 +04:00
ed6a3a5784 Merge branch 'daniel/validate-db-schemas' of https://github.com/Infisical/infisical into daniel/validate-db-schemas 2025-07-13 19:57:39 +04:00
520fb6801d Update package.json 2025-07-13 19:57:25 +04:00
de6ebca351 Update .github/workflows/validate-db-schemas.yml
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2025-07-13 19:52:27 +04:00
a21ebf000f Update package.json 2025-07-13 19:52:08 +04:00
899ed14ecd Update access-approval-policies-bypassers.ts 2025-07-13 19:51:21 +04:00
ef2f4e095c Update access-approval-policies-bypassers.ts 2025-07-13 19:51:12 +04:00
7e03222104 Update validate-db-schemas.yml 2025-07-13 19:50:58 +04:00
fed264c07b Delete 20250713154007_test-migration.ts 2025-07-13 19:49:22 +04:00
01054bbae0 Create 20250713154007_test-migration.ts 2025-07-13 19:40:52 +04:00
1d0d6088f8 chore: validate db schemas CI test 2025-07-13 19:38:24 +04:00
be0ca08821 Merge pull request #4093 from Infisical/docs-update
updated changelog
2025-07-12 15:56:52 -07:00
d816e9daa1 updated changelog 2025-07-12 15:54:54 -07:00
eb4fd0085d Merge pull request #4014 from Infisical/empty-secret-value-overview-styling
improvement(frontend): make empty value circle display on overview page yellow
2025-07-11 21:13:25 -07:00
f5b95fbe25 improvment: make empty value circle display on overview page yellow 2025-07-11 21:00:32 -07:00
10 changed files with 474 additions and 261 deletions

View File

@ -0,0 +1,67 @@
name: "Validate DB schemas"
on:
pull_request:
types: [opened, synchronize]
paths:
- "backend/**"
workflow_call:
jobs:
validate-db-schemas:
name: Validate DB schemas
runs-on: ubuntu-latest
timeout-minutes: 15
env:
NODE_OPTIONS: "--max-old-space-size=8192"
REDIS_URL: redis://172.17.0.1:6379
DB_CONNECTION_URI: postgres://infisical:infisical@172.17.0.1:5432/infisical?sslmode=disable
AUTH_SECRET: something-random
ENCRYPTION_KEY: 4bnfe4e407b8921c104518903515b218
steps:
- name: ☁️ Checkout source
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: KengoTODA/actions-setup-docker-compose@v1
if: ${{ env.ACT }}
name: Install `docker compose` for local simulations
with:
version: "2.14.2"
- name: 🔧 Setup Node 20
uses: actions/setup-node@v3
with:
node-version: "20"
cache: "npm"
cache-dependency-path: backend/package-lock.json
- name: Start PostgreSQL and Redis
run: touch .env && docker compose -f docker-compose.dev.yml up -d db redis
- name: Install dependencies
run: npm install
working-directory: backend
- name: Apply migrations
run: npm run migration:latest-dev
working-directory: backend
- name: Run schema generation
run: npm run generate:schema
working-directory: backend
- name: Check for schema changes
run: |
if ! git diff --exit-code --quiet src/db/schemas; then
echo "❌ Generated schemas differ from committed schemas!"
echo "Run 'npm run generate:schema' locally and commit the changes."
git diff src/db/schemas
exit 1
fi
echo "✅ Schemas are up to date"
working-directory: backend
- name: Cleanup
if: always()
run: |
docker compose -f "docker-compose.dev.yml" down

View File

@ -46,3 +46,4 @@ cli/detect/config/gitleaks.toml:gcp-api-key:582
.github/workflows/helm-release-infisical-core.yml:generic-api-key:47
backend/src/services/smtp/smtp-service.ts:generic-api-key:79
frontend/src/components/secret-syncs/forms/SecretSyncDestinationFields/CloudflarePagesSyncFields.tsx:cloudflare-api-key:7
.github/workflows/validate-db-schemas.yml:generic-api-key:21

View File

@ -4,6 +4,61 @@ title: "Changelog"
The changelog below reflects new product developments and updates on a monthly basis.
## July 2025
- Improved speed performance of audit log filtering.
- Revamped password reset flow pages.
- Added support for [Bitbucket for Secret Scanning](https://infisical.com/docs/documentation/platform/secret-scanning/bitbucket).
- Released Secret Sync for [Zabbix](https://infisical.com/docs/integrations/secret-syncs/zabbix).
## June 2025
- Released Secret Sync for [1Password](https://infisical.com/docs/integrations/secret-syncs/1password), [Heroku](https://infisical.com/docs/integrations/secret-syncs/heroku), [Fly.io](https://infisical.com/docs/integrations/secret-syncs/flyio), and [Render](https://infisical.com/docs/integrations/secret-syncs/render).
- Added support for [Kubernetes dynamic secrets](https://infisical.com/docs/documentation/platform/dynamic-secrets/kubernetes) to generate service account tokens
- Released Secret Rotation for [MySQL](https://infisical.com/docs/documentation/platform/secret-rotation/mysql-credentials) and [OracleDB](https://infisical.com/docs/documentation/platform/secret-rotation/oracledb-credentials) as well as Dynamic Secrets for [Vertica](https://infisical.com/docs/documentation/platform/dynamic-secrets/vertica) and [GitHub App Tokens](https://infisical.com/docs/documentation/platform/dynamic-secrets/github).
- Added support for Azure Auth in ESO.
- [Kubernetes auth](https://infisical.com/docs/documentation/platform/identities/kubernetes-auth) now supports gateway as a token reviewer.
- Revamped [Infisical CLI](https://infisical.com/docs/cli/commands/login) to auto-open login link.
- Rolled out [Infisical Packer integration](https://infisical.com/docs/integrations/frameworks/packer).
- Released [AliCloud Authentication method](https://infisical.com/docs/documentation/platform/identities/alicloud-auth).
- Added support for [multi-step approval workflows](https://infisical.com/docs/documentation/platform/pr-workflows).
- Revamped UI for Access Controls, Access Tree, Policies, and Approval Workflows.
- Released [TLS Certificate Authentication method](https://infisical.com/docs/documentation/platform/identities/tls-cert-auth).
- Added ability to copy session tokens in the Infisical Dashboard.
- Expanded resource support for [Infisical Terraform Provider](https://infisical.com/docs/integrations/frameworks/terraform).
## May 2025
- Added support for [Microsoft Teams integration](https://infisical.com/docs/documentation/platform/workflow-integrations/microsoft-teams-integration).
- Released [Infisical Gateway](https://infisical.com/docs/documentation/platform/gateways/overview) for accessing private network resources from Infisical.
- Added support for [Host Groups](https://infisical.com/docs/documentation/platform/ssh/host-groups) in Infisical SSH.
- Updated the designs of all emails send by Infisical.
- Added secret rotation support for [Azure Client](https://infisical.com/docs/documentation/platform/secret-rotation/azure-client-secret).
- Released secret sync for [HashiCorp Vault](https://infisical.com/docs/integrations/secret-syncs/hashicorp-vault).
- Made significant improvements to [Infisical Secret Scanning](https://infisical.com/docs/documentation/platform/secret-scanning/overview).
- Released [Infisical ACME Client](https://infisical.com/docs/documentation/platform/pki/acme-ca#certificates-with-acme-ca).
- [Access requests](https://infisical.com/docs/documentation/platform/access-controls/access-requests) now support "break-glass" policies.
- Updated [Point-in-time Recovery](https://infisical.com/docs/documentation/platform/pit-recovery) UI/UX.
- Redesigned [Approval Workflows and Change Requests](https://infisical.com/docs/documentation/platform/pr-workflows) user interface.
## April 2025
- Released ability to [request access to projects](https://infisical.com/docs/documentation/platform/access-controls/project-access-requests#project-access-requests).
- Updated UI for Audit Logs and Log Filtering.
- Launched [Infisical SSH V2](https://infisical.com/docs/documentation/platform/ssh/overview).
- Developer [Infisical MCP](https://github.com/Infisical/infisical-mcp-server).
- Added support for [Spotify Backstage Infisical plugin](https://infisical.com/docs/integrations/external/backstage).
- Added secret syncs for Terraform Cloud, Vercel, Windmill, TeamCity, and Camunda.
- Released [Auth0 Client Secret Rotation](https://infisical.com/docs/documentation/platform/secret-rotation/auth0-client-secret).
- Launched [Infisical C++ SDK](https://github.com/Infisical/infisical-cpp-sdk).
- Service tokens will now get expiry notifications.
- Added Infisical [Linux binary](https://infisical.com/docs/self-hosting/reference-architectures/linux-deployment-ha#linux-ha).
- Released ability to perform user impersonation.
- Added support for [LDAP password rotation](https://infisical.com/docs/documentation/platform/secret-rotation/ldap-password).
## March 2025
- Released [Infisical Gateway](https://infisical.com/docs/documentation/platform/gateways/overview) for secure access to private resources without needing direct inbound connections to private networks.

View File

@ -1,9 +1,8 @@
import { useInfiniteQuery, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { format } from "date-fns";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { Commit, CommitHistoryItem, CommitWithChanges, RollbackPreview } from "./types";
import { CommitHistoryItem, CommitWithChanges, RollbackPreview } from "./types";
export const commitKeys = {
count: ({
@ -243,6 +242,7 @@ export const useGetFolderCommitHistory = ({
workspaceId,
environment,
directory,
offset = 0,
limit = 20,
search,
sort = "desc"
@ -250,33 +250,22 @@ export const useGetFolderCommitHistory = ({
workspaceId: string;
environment: string;
directory: string;
offset?: number;
limit?: number;
search?: string;
sort?: "asc" | "desc";
}) => {
return useInfiniteQuery({
initialPageParam: 0,
queryKey: [commitKeys.history({ workspaceId, environment, directory }), limit, search, sort],
queryFn: ({ pageParam }) =>
fetchFolderCommitHistory(workspaceId, environment, directory, pageParam, limit, search, sort),
enabled: Boolean(workspaceId && environment),
select: (data) => {
return (data?.pages ?? [])
?.map((page) => page.commits)
.flat()
.reduce(
(acc, commit) => {
const date = format(new Date(commit.createdAt), "MMM d, yyyy");
if (!acc[date]) {
acc[date] = [];
}
acc[date].push(commit);
return acc;
},
{} as Record<string, Commit[]>
);
},
getNextPageParam: (lastPage, pages) => (lastPage.hasMore ? pages.length * limit : undefined)
return useQuery({
queryKey: [
commitKeys.history({ workspaceId, environment, directory }),
offset,
limit,
search,
sort
],
queryFn: () =>
fetchFolderCommitHistory(workspaceId, environment, directory, offset, limit, search, sort),
enabled: Boolean(workspaceId && environment)
});
};

View File

@ -62,16 +62,3 @@ export type RollbackPreview = {
folderPath: string;
changes: RollbackChange[];
};
interface CommitActorMetadata {
email?: string;
name?: string;
}
export interface Commit {
id: string;
message: string;
createdAt: string;
actorType: string;
actorMetadata?: CommitActorMetadata;
}

View File

@ -1,10 +1,5 @@
import { useEffect, useState } from "react";
import {
faAngleDown,
faChevronLeft,
faCodeCommit,
faWarning
} from "@fortawesome/free-solid-svg-icons";
import { faAngleDown } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { DropdownMenuItem } from "@radix-ui/react-dropdown-menu";
import { useSearch } from "@tanstack/react-router";
@ -12,14 +7,12 @@ import { useSearch } from "@tanstack/react-router";
import { createNotification } from "@app/components/notifications";
import { ProjectPermissionCan } from "@app/components/permissions";
import {
Button,
ContentLoader,
DeleteActionModal,
DropdownMenu,
DropdownMenuContent,
DropdownMenuTrigger,
EmptyState,
PageHeader
IconButton,
Spinner
} from "@app/components/v2";
import { ROUTE_PATHS } from "@app/const/routes";
import {
@ -115,25 +108,25 @@ export const CommitDetailsTab = ({
// If no commit is selected or data is loading, show appropriate message
if (!selectedCommitId) {
return (
<EmptyState className="mt-40" title="Select a commit to view details." icon={faCodeCommit}>
<Button className="mt-4" colorSchema="secondary" onClick={() => goBackToHistory()}>
Back to Commits
</Button>
</EmptyState>
<div className="flex h-64 items-center justify-center">
<p className="text-gray-400">Select a commit to view details</p>
</div>
);
}
if (isLoading) {
return <ContentLoader />;
return (
<div className="flex h-64 items-center justify-center">
<Spinner size="lg" />
</div>
);
}
if (!commitDetails) {
return (
<EmptyState className="mt-40" title="No details found for this commit." icon={faCodeCommit}>
<Button className="mt-4" colorSchema="secondary" onClick={() => goBackToHistory()}>
Back to Commits
</Button>
</EmptyState>
<div className="flex h-64 items-center justify-center">
<p className="text-gray-400">No details found for this commit</p>
</div>
);
}
@ -145,11 +138,9 @@ export const CommitDetailsTab = ({
} catch (error) {
console.error("Failed to parse commit details:", error);
return (
<EmptyState className="mt-40" title="Error parsing commit details." icon={faWarning}>
<Button className="mt-4" colorSchema="secondary" onClick={() => goBackToHistory()}>
Back to Commits
</Button>
</EmptyState>
<div className="flex h-64 items-center justify-center">
<p className="text-gray-400">Error parsing commit details</p>
</div>
);
}
@ -232,12 +223,13 @@ export const CommitDetailsTab = ({
// Render an item from the merged list
const renderMergedItem = (item: MergedItem): JSX.Element => {
return (
<SecretVersionDiffView
key={item.id}
item={item}
isCollapsed={collapsedItems[item.id]}
onToggleCollapse={(id) => toggleItemCollapsed(id)}
/>
<div key={item.id} className="mb-2">
<SecretVersionDiffView
item={item}
isCollapsed={collapsedItems[item.id]}
onToggleCollapse={(id) => toggleItemCollapsed(id)}
/>
</div>
);
};
@ -248,104 +240,114 @@ export const CommitDetailsTab = ({
"Unknown";
return (
<>
<Button
variant="link"
type="submit"
leftIcon={<FontAwesomeIcon icon={faChevronLeft} />}
onClick={() => {
goBackToHistory();
}}
>
Commit History
</Button>
<PageHeader
title={`${parsedCommitDetails.changes?.message}` || "No message"}
description={
<>
Commited by {actorDisplay} on{" "}
{formatDisplayDate(parsedCommitDetails.changes?.createdAt || new Date().toISOString())}
{parsedCommitDetails.changes?.isLatest && (
<span className="ml-1 text-mineshaft-400">(Latest)</span>
)}
</>
}
>
<ProjectPermissionCan
I={ProjectPermissionCommitsActions.PerformRollback}
a={ProjectPermissionSub.Commits}
>
{(isAllowed) => (
<DropdownMenu>
<DropdownMenuTrigger
asChild
disabled={!isAllowed}
className={`${!isAllowed ? "cursor-not-allowed" : ""}`}
>
<Button
rightIcon={<FontAwesomeIcon className="ml-2" icon={faAngleDown} />}
variant="solid"
className="h-min"
colorSchema="secondary"
>
Restore Options
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end" className="max-w-sm bg-bunker-500" sideOffset={2}>
{!parsedCommitDetails.changes.isLatest && (
<DropdownMenuItem
className="group cursor-pointer border-b border-mineshaft-600 px-3 py-3 transition-colors hover:bg-mineshaft-700"
onClick={() => goToRollbackPreview()}
>
<div className="flex items-center space-x-3">
<div className="flex flex-col">
<span className="text-sm font-medium text-white">
Roll back to this commit
</span>
<span className="whitespace-normal break-words text-xs leading-snug text-gray-400">
Return this folder to its exact state at the time of this commit,
discarding all other changes made after it
</span>
</div>
</div>
</DropdownMenuItem>
<div className="w-full">
<div>
<div className="flex justify-between pb-2">
<div className="w-5/6">
<div>
<div className="flex items-center">
<h1 className="mr-4 truncate text-3xl font-semibold text-white">
{parsedCommitDetails.changes?.message || "No message"}
</h1>
</div>
</div>
<div className="font-small mb-4 mt-2 flex items-center text-sm">
<p>
<span> Commited by </span>
<b>{actorDisplay}</b>
<span> on </span>
<b>
{formatDisplayDate(
parsedCommitDetails.changes?.createdAt || new Date().toISOString()
)}
</b>
{parsedCommitDetails.changes?.isLatest && (
<span className="ml-1 italic text-gray-400">(Latest)</span>
)}
<DropdownMenuItem
className="group cursor-pointer px-3 py-3 transition-colors hover:bg-mineshaft-700"
onClick={() => handlePopUpOpen("revertChanges")}
>
<div className="flex items-center space-x-3">
<div className="flex flex-col">
<span className="text-sm font-medium text-white">Revert changes</span>
<span className="whitespace-normal break-words text-xs leading-snug text-gray-400">
Will restore to the previous version of affected resources
</span>
</div>
</div>
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
)}
</ProjectPermissionCan>
</PageHeader>
<div className="flex w-full flex-col rounded-lg border border-mineshaft-600 bg-mineshaft-900 pt-4">
<div className="mx-4 flex items-center justify-between border-b border-mineshaft-400 pb-4">
<h3 className="text-lg font-semibold text-mineshaft-100">Commit Changes</h3>
</p>
</div>
</div>
<div className="flex items-center justify-start">
<ProjectPermissionCan
I={ProjectPermissionCommitsActions.PerformRollback}
a={ProjectPermissionSub.Commits}
>
{(isAllowed) => (
<DropdownMenu>
<DropdownMenuTrigger
asChild
disabled={!isAllowed}
className={`${!isAllowed ? "cursor-not-allowed" : ""}`}
>
<IconButton
ariaLabel="commit-options"
variant="outline_bg"
className="h-10 rounded border border-mineshaft-600 bg-mineshaft-800 px-4 py-2 text-sm font-medium"
>
<p className="mr-2">Restore Options</p>
<FontAwesomeIcon icon={faAngleDown} />
</IconButton>
</DropdownMenuTrigger>
<DropdownMenuContent
align="end"
sideOffset={2}
className="animate-in fade-in-50 zoom-in-95 min-w-[240px] rounded-md bg-mineshaft-800 p-1 shadow-lg"
style={{ marginTop: "0" }}
>
{!parsedCommitDetails.changes.isLatest && (
<DropdownMenuItem
className="group cursor-pointer rounded-md px-3 py-3 transition-colors hover:bg-mineshaft-700"
onClick={() => goToRollbackPreview()}
>
<div className="flex items-center space-x-3">
<div className="flex flex-col">
<span className="text-sm font-medium text-white">
Roll back to this commit
</span>
<span className="max-w-[180px] whitespace-normal break-words text-xs leading-snug text-gray-400">
Return this folder to its exact state at the time of this commit,
discarding all other changes made after it
</span>
</div>
</div>
</DropdownMenuItem>
)}
<DropdownMenuItem
className="group cursor-pointer rounded-md px-3 py-3 transition-colors hover:bg-mineshaft-700"
onClick={() => handlePopUpOpen("revertChanges")}
>
<div className="flex items-center space-x-3">
<div className="flex flex-col">
<span className="text-sm font-medium text-white">Revert changes</span>
<span className="max-w-[180px] whitespace-normal break-words text-xs leading-snug text-gray-400">
Will restore to the previous version of affected resources
</span>
</div>
</div>
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
)}
</ProjectPermissionCan>
</div>
</div>
<div className="flex flex-col overflow-hidden px-4">
<div className="thin-scrollbar overflow-y-auto py-4">
{sortedChangedItems.length > 0 ? (
sortedChangedItems.map((item) => renderMergedItem(item))
) : (
<EmptyState
title="No changes found."
className="h-full pb-0 pt-28"
icon={faCodeCommit}
/>
)}
<div className="py-2">
<div className="overflow-hidden">
<div className="space-y-2">
{sortedChangedItems.length > 0 ? (
sortedChangedItems.map((item) => renderMergedItem(item))
) : (
<div className="flex h-32 items-center justify-center rounded-lg border border-mineshaft-600 bg-mineshaft-800">
<p className="text-gray-400">No changed items found</p>
</div>
)}
</div>
</div>
</div>
</div>
<DeleteActionModal
isOpen={popUp.revertChanges.isOpen}
deleteKey="revert"
@ -355,6 +357,6 @@ export const CommitDetailsTab = ({
onDeleteApproved={handleRevertChanges}
buttonText="Yes, revert changes"
/>
</>
</div>
);
};

View File

@ -225,12 +225,15 @@ const renderJsonWithDiffs = (
const getLineClass = (different: boolean) => {
if (!different) return "flex";
return isOldVersion
? "flex bg-red-500/50 rounded-sm text-red-300"
: "flex bg-green-500/50 rounded-sm text-green-300";
return isOldVersion ? "flex bg-red-950 text-red-300" : "flex bg-green-950 text-green-300";
};
const prefix = isDifferent ? (isOldVersion ? " -" : " +") : " ";
const getHighlightClass = (different: boolean) => {
if (!different) return "";
return isOldVersion ? "bg-red-900 rounded px-1" : "bg-green-900 rounded px-1";
};
const prefix = isDifferent ? (isOldVersion ? "-" : "+") : " ";
const keyDisplay = keyName ? `"${keyName}": ` : "";
const comma = !isLastItem ? "," : "";
@ -252,8 +255,8 @@ const renderJsonWithDiffs = (
<div className="w-4 flex-shrink-0">{prefix}</div>
<div>
{indent}
{keyName && <span>{keyDisplay}</span>}
<span>{valueDisplay}</span>
{keyName && <span className={getHighlightClass(isDifferent)}>{keyDisplay}</span>}
<span className={getHighlightClass(isDifferent)}>{valueDisplay}</span>
{comma}
</div>
</div>
@ -266,8 +269,8 @@ const renderJsonWithDiffs = (
<div className="w-4 flex-shrink-0">{prefix}</div>
<div>
{indent}
{keyName && <span>{keyDisplay}</span>}
<span>[]</span>
{keyName && <span className={getHighlightClass(isDifferent)}>{keyDisplay}</span>}
<span className={getHighlightClass(isDifferent)}>[]</span>
{comma}
</div>
</div>
@ -280,8 +283,8 @@ const renderJsonWithDiffs = (
<div className="w-4 flex-shrink-0">{prefix}</div>
<div>
{indent}
{keyName && <span>{keyDisplay}</span>}
<span>{"{}"}</span>
{keyName && <span className={getHighlightClass(isDifferent)}>{keyDisplay}</span>}
<span className={getHighlightClass(isDifferent)}>{"{}"}</span>
{comma}
</div>
</div>
@ -317,12 +320,16 @@ const renderJsonWithDiffs = (
<div key={reactKey}>
<div className={getLineClass(isContainerAddedOrRemoved)}>
<div className="w-4 flex-shrink-0">
{isContainerAddedOrRemoved ? (isOldVersion ? " -" : " +") : " "}
{isContainerAddedOrRemoved ? (isOldVersion ? "-" : "+") : " "}
</div>
<div>
{indent}
{keyName && <span>{keyDisplay}</span>}
<span>[</span>
{keyName && (
<span className={isContainerAddedOrRemoved ? getHighlightClass(true) : ""}>
{keyDisplay}
</span>
)}
<span className={isContainerAddedOrRemoved ? getHighlightClass(true) : ""}>[</span>
</div>
</div>
@ -350,11 +357,11 @@ const renderJsonWithDiffs = (
<div className={getLineClass(isContainerAddedOrRemoved)}>
<div className="w-4 flex-shrink-0">
{isContainerAddedOrRemoved ? (isOldVersion ? " -" : " +") : " "}
{isContainerAddedOrRemoved ? (isOldVersion ? "-" : "+") : " "}
</div>
<div>
{indent}
<span>]</span>
<span className={isContainerAddedOrRemoved ? getHighlightClass(true) : ""}>]</span>
{comma}
</div>
</div>
@ -369,12 +376,16 @@ const renderJsonWithDiffs = (
<div key={reactKey}>
<div className={getLineClass(isContainerAddedOrRemoved)}>
<div className="w-4 flex-shrink-0">
{isContainerAddedOrRemoved ? (isOldVersion ? " -" : " +") : " "}
{isContainerAddedOrRemoved ? (isOldVersion ? "-" : "+") : " "}
</div>
<div>
{indent}
{keyName && <span>{keyDisplay}</span>}
<span>{"{"}</span>
{keyName && (
<span className={isContainerAddedOrRemoved ? getHighlightClass(true) : ""}>
{keyDisplay}
</span>
)}
<span className={isContainerAddedOrRemoved ? getHighlightClass(true) : ""}>{"{"}</span>
</div>
</div>
@ -403,11 +414,11 @@ const renderJsonWithDiffs = (
<div className={getLineClass(isContainerAddedOrRemoved)}>
<div className="w-4 flex-shrink-0">
{isContainerAddedOrRemoved ? (isOldVersion ? " -" : " +") : " "}
{isContainerAddedOrRemoved ? (isOldVersion ? "-" : "+") : " "}
</div>
<div>
{indent}
<span>{"}"}</span>
<span className={isContainerAddedOrRemoved ? getHighlightClass(true) : ""}>{"}"}</span>
{comma}
</div>
</div>
@ -614,21 +625,22 @@ export const SecretVersionDiffView = ({
};
return (
<div className="overflow-hidden border border-b-0 border-mineshaft-600 bg-mineshaft-800 first:rounded-t last:rounded-b last:border-b">
<div className="overflow-hidden rounded-lg border border-mineshaft-600 bg-mineshaft-800">
{showHeader && renderHeader()}
{!collapsed && (
<div className="border-t border-mineshaft-700 bg-mineshaft-900 p-3 text-mineshaft-100">
<div className="flex gap-3">
<div className="border-t border-mineshaft-700 bg-mineshaft-900 px-6 py-4">
<div className="grid grid-cols-2 gap-4">
<div
ref={oldContainerRef}
className="thin-scrollbar max-h-96 flex-1 overflow-auto whitespace-pre"
className="thin-scrollbar max-h-96 overflow-auto whitespace-pre rounded border border-mineshaft-600 bg-mineshaft-900 p-4"
>
{oldVersionContent}
</div>
<div className="max-h-96 w-[0.05rem] self-stretch bg-mineshaft-600" />
<div
ref={newContainerRef}
className="thin-scrollbar max-h-96 flex-1 overflow-auto whitespace-pre"
className="thin-scrollbar max-h-96 overflow-auto whitespace-pre rounded border border-mineshaft-600 bg-mineshaft-900 p-4"
>
{newVersionContent}
</div>

View File

@ -52,7 +52,7 @@ export const CommitsPage = () => {
title="Commits"
description="Track, inspect, and restore your secrets and folders with confidence. View the complete history of changes made to your environment, examine specific modifications at each commit point, and preview the exact impact before rolling back to previous states."
/>
<NoticeBannerV2 title="Secret Snapshots Update" className="mb-2">
<NoticeBannerV2 title="" className="mb-2">
<p className="my-1 text-sm text-mineshaft-300">
Secret Snapshots have been officially renamed to Commits. Going forward, all secret
changes will be tracked as Commits. If you made changes before this update, you can

View File

@ -1,17 +1,29 @@
import { useCallback, useEffect, useRef, useState } from "react";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import {
faArrowDownWideShort,
faArrowUpWideShort,
faCodeCommit,
faCopy,
faSearch
} from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { formatDistanceToNow } from "date-fns";
import { format, formatDistanceToNow } from "date-fns";
import { Button, ContentLoader, EmptyState, IconButton, Input } from "@app/components/v2";
import { Button, Input, Spinner } from "@app/components/v2";
import { CopyButton } from "@app/components/v2/CopyButton";
import { Commit, useGetFolderCommitHistory } from "@app/hooks/api/folderCommits";
import { useGetFolderCommitHistory } from "@app/hooks/api/folderCommits";
interface CommitActorMetadata {
email?: string;
name?: string;
}
interface Commit {
id: string;
message: string;
createdAt: string;
actorType: string;
actorMetadata?: CommitActorMetadata;
}
const formatTimeAgo = (timestamp: string): string => {
return formatDistanceToNow(new Date(timestamp), { addSuffix: true });
@ -28,40 +40,58 @@ const CommitItem = ({
onSelectCommit: (commitId: string, tab: string) => void;
}) => {
return (
<button
type="button"
onClick={(e) => {
e.stopPropagation();
onSelectCommit(commit.id, "tab-commit-details");
}}
className="w-full border border-b-0 border-mineshaft-600 bg-mineshaft-800 first:rounded-t-md last:rounded-b-md last:border-b"
>
<div className="flex gap-2 px-4 py-3 transition-colors duration-200 hover:bg-zinc-800">
<div className="flex min-w-0 flex-1 flex-col items-start">
<p className="block w-full truncate text-left text-sm text-mineshaft-100">
{commit.message}
</p>
<p className="text-left text-xs text-mineshaft-300">
{commit.actorMetadata?.email || commit.actorMetadata?.name || commit.actorType}{" "}
committed <time dateTime={commit.createdAt}>{formatTimeAgo(commit.createdAt)}</time>
</p>
</div>
<div className="flex items-center space-x-2">
<code className="mt-0.5 font-mono text-xs text-mineshaft-400">
{commit.id?.substring(0, 11)}
</code>
<CopyButton
value={commit.id}
name={commit.id}
size="xs"
variant="plain"
color="text-mineshaft-400"
icon={faCopy}
/>
<div className="border-b border-zinc-800 last:border-b-0">
<div className="px-4 py-4 transition-colors duration-200 hover:bg-zinc-800">
<div className="flex flex-col sm:flex-row sm:justify-between">
<div className="w-5/6 flex-1">
<div className="flex items-center">
<Button
variant="link"
className="truncate text-left text-white hover:underline"
isFullWidth
onClick={(e) => {
e.stopPropagation();
onSelectCommit(commit.id, "tab-commit-details");
}}
>
{commit.message}
</Button>
</div>
<p className="text-white-400 mt-2 flex flex-wrap items-center gap-4 text-sm">
<span className="flex items-center text-mineshaft-300">
{commit.actorMetadata?.email || commit.actorMetadata?.name || commit.actorType}
<p className="ml-1 mr-1">committed</p>
<time dateTime={commit.createdAt}>{formatTimeAgo(commit.createdAt)}</time>
</span>
</p>
</div>
<div className="mt-2 flex w-1/6 items-center justify-end sm:mt-0">
<div className="flex items-center space-x-1">
<Button
variant="link"
className="text-white hover:underline"
onClick={(e) => {
e.stopPropagation();
onSelectCommit(commit.id, "tab-commit-details");
}}
>
<code className="text-white-400 px-3 py-1 font-mono text-sm">
{commit.id?.substring(0, 11)}
</code>
</Button>
<CopyButton
value={commit.id}
name={commit.id}
size="sm"
variant="plain"
color="text-mineshaft-400"
icon={faCopy}
/>
</div>
</div>
</div>
</div>
</button>
</div>
);
};
@ -78,16 +108,24 @@ const DateGroup = ({
onSelectCommit: (commitId: string, tab: string) => void;
}) => {
return (
<div className="mt-4 first:mt-0">
<div className="mb-4 ml-[0.15rem] flex items-center">
<FontAwesomeIcon icon={faCodeCommit} className="text-mineshaft-400" />
<h2 className="ml-4 text-sm text-mineshaft-400">Commits on {date}</h2>
<div className="mb-8 last:mb-0 last:pb-2">
<div className="mb-4 flex items-center">
<div className="relative mr-3 flex h-6 w-6 items-center justify-center">
<div className="z-10 h-3 w-3 rounded-full border-2 border-mineshaft-600 bg-bunker-800" />
<div className="absolute left-0 right-0 top-1/2 h-0.5 -translate-y-1/2 bg-mineshaft-600" />
</div>
<h2 className="text-sm text-white">Commits on {date}</h2>
</div>
<div className="relative">
<div className="absolute bottom-0 left-3 top-0 w-[0.1rem] bg-mineshaft-500" />
<div className="absolute bottom-0 left-3 top-0 w-0.5 bg-mineshaft-600" />
<div className="ml-10">
{commits.map((commit) => (
<CommitItem key={commit.id} commit={commit} onSelectCommit={onSelectCommit} />
<div key={commit.id} className="relative mb-3 pb-1">
<div className="overflow-hidden rounded-md border border-solid border-mineshaft-600">
<CommitItem commit={commit} onSelectCommit={onSelectCommit} />
</div>
</div>
))}
</div>
</div>
@ -109,8 +147,10 @@ export const CommitHistoryTab = ({
const [searchTerm, setSearchTerm] = useState("");
const [debouncedSearchTerm, setDebouncedSearchTerm] = useState("");
const [sortDirection, setSortDirection] = useState<"asc" | "desc">("desc");
const [offset, setOffset] = useState(0);
const [allCommits, setAllCommits] = useState<Commit[]>([]);
const debounceTimeoutRef = useRef<NodeJS.Timeout>();
const limit = 10;
const limit = 5;
// Debounce search term
useEffect(() => {
@ -130,20 +170,55 @@ export const CommitHistoryTab = ({
}, [searchTerm]);
const {
data: groupedCommits,
data: response,
isLoading,
fetchNextPage,
isFetchingNextPage,
hasNextPage
isFetching
} = useGetFolderCommitHistory({
workspaceId: projectId,
environment,
directory: secretPath,
offset,
limit,
search: debouncedSearchTerm,
sort: sortDirection
});
const commits = response?.commits || [];
const hasMore = response?.hasMore || false;
// Reset accumulated commits when search or sort changes
useEffect(() => {
setAllCommits([]);
setOffset(0);
}, [debouncedSearchTerm, sortDirection]);
// Accumulate commits instead of replacing them
useEffect(() => {
if (commits.length > 0) {
if (offset === 0) {
// First load or after search/sort change - replace all commits
setAllCommits(commits);
} else {
// Subsequent loads - append new commits
setAllCommits((prev) => [...prev, ...commits]);
}
}
}, [commits, offset]);
const groupedCommits = useMemo(() => {
return allCommits.reduce(
(acc, commit) => {
const date = format(new Date(commit.createdAt), "MMM d, yyyy");
if (!acc[date]) {
acc[date] = [];
}
acc[date].push(commit);
return acc;
},
{} as Record<string, Commit[]>
);
}, [allCommits]);
const handleSort = useCallback(() => {
setSortDirection((prev) => (prev === "desc" ? "asc" : "desc"));
}, []);
@ -152,39 +227,50 @@ export const CommitHistoryTab = ({
setSearchTerm(value);
}, []);
const loadMoreCommits = useCallback(() => {
if (hasMore && !isFetching) {
setOffset((prev) => prev + limit);
}
}, [hasMore, isFetching, limit]);
return (
<div className="mt-4 w-full rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
<p className="mb-4 text-xl font-semibold text-mineshaft-100">Commit History</p>
<div className="w-full">
<div className="mb-4 flex flex-col sm:flex-row sm:justify-end">
<div className="flex w-full flex-wrap items-center gap-2">
<div className="relative flex-grow">
<Input
leftIcon={<FontAwesomeIcon icon={faSearch} aria-hidden="true" />}
placeholder="Search commits..."
className="h-10 w-full rounded-md border-transparent bg-zinc-800 pl-9 pr-3 text-sm text-white placeholder-gray-400 focus:border-gray-600 focus:ring-primary-500/20"
onChange={(e) => handleSearch(e.target.value)}
value={searchTerm}
aria-label="Search commits"
/>
<div className="absolute left-3 top-1/2 -translate-y-1/2 transform text-gray-400">
<FontAwesomeIcon icon={faSearch} aria-hidden="true" />
</div>
</div>
<IconButton
<Button
variant="outline_bg"
size="sm"
className="flex h-[2.4rem] items-center justify-center gap-2 rounded-md"
size="md"
className="flex h-10 items-center justify-center gap-2 rounded-md bg-zinc-800 px-4 py-2 text-sm text-white transition-colors duration-200 hover:bg-zinc-700 focus:outline-none focus:ring-2 focus:ring-primary-500"
onClick={handleSort}
ariaLabel={`Sort by date ${sortDirection === "desc" ? "ascending" : "descending"}`}
aria-label={`Sort by date ${sortDirection === "desc" ? "ascending" : "descending"}`}
>
<FontAwesomeIcon
icon={sortDirection === "desc" ? faArrowDownWideShort : faArrowUpWideShort}
aria-hidden="true"
/>
</IconButton>
</Button>
</div>
</div>
{isLoading ? (
<ContentLoader className="h-80" />
{isLoading && offset === 0 ? (
<div className="flex h-64 items-center justify-center">
<Spinner size="lg" aria-label="Loading commits" />
</div>
) : (
<div>
{groupedCommits && Object.keys(groupedCommits).length > 0 ? (
<div className="space-y-8">
{Object.keys(groupedCommits).length > 0 ? (
<>
{Object.entries(groupedCommits).map(([date, dateCommits]) => (
<DateGroup
@ -196,20 +282,34 @@ export const CommitHistoryTab = ({
))}
</>
) : (
<EmptyState title="No commits found." icon={faCodeCommit} />
<div className="text-white-400 flex min-h-40 flex-col items-center justify-center rounded-lg bg-zinc-900 py-8 text-center">
<FontAwesomeIcon
icon={faSearch}
className="text-white-500 mb-3 text-3xl"
aria-hidden="true"
/>
<p>No matching commits found. Try a different search term.</p>
</div>
)}
{hasNextPage && (
{hasMore && (
<div className="flex justify-center pb-2">
<Button
variant="outline_bg"
size="sm"
className="ml-10 mt-4 w-full"
onClick={() => fetchNextPage()}
disabled={isFetchingNextPage}
isLoading={isFetchingNextPage}
size="md"
className="rounded-md bg-zinc-900 px-6 py-2 text-sm font-medium text-white transition-colors duration-200 hover:bg-zinc-800 focus:outline-none focus:ring-2 focus:ring-primary-500"
onClick={loadMoreCommits}
disabled={isFetching}
aria-label="Load more commits"
>
Load More Commits
{isFetching ? (
<>
<Spinner size="sm" className="mr-2" />
Loading...
</>
) : (
"Load more commits"
)}
</Button>
</div>
)}

View File

@ -174,7 +174,7 @@ export const SecretOverviewTableRow = ({
)}
{isSecretEmpty && (
<Tooltip content="Empty value">
<FontAwesomeIcon size="sm" icon={faCircle} />
<FontAwesomeIcon size="sm" icon={faCircle} className="text-yellow" />
</Tooltip>
)}
</div>