-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split node diff into multiple components
- Loading branch information
1 parent
e7eb35e
commit a224f19
Showing
7 changed files
with
136 additions
and
68 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
frontend/app/src/entities/diff/api/update-diff-from-api.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import graphqlClient from "@/shared/api/graphql/graphqlClientApollo"; | ||
import { gql } from "@apollo/client"; | ||
|
||
export const DIFF_UPDATE = gql` | ||
mutation DIFF_UPDATE($branchName: String!, $waitForCompletion: Boolean) { | ||
DiffUpdate(data: { branch: $branchName, wait_for_completion: $waitForCompletion }) { | ||
ok | ||
} | ||
} | ||
`; | ||
|
||
export type UpdateDiffFromApiParams = { | ||
branchName: string; | ||
waitForCompletion: boolean; | ||
}; | ||
|
||
export const updateDiffFromApi = ({ branchName, waitForCompletion }: UpdateDiffFromApiParams) => { | ||
return graphqlClient.mutate({ | ||
mutation: DIFF_UPDATE, | ||
variables: { | ||
branchName, | ||
waitForCompletion, | ||
}, | ||
}); | ||
}; |
8 changes: 8 additions & 0 deletions
8
frontend/app/src/entities/diff/domain/update-diff.mutation.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { updateDiff } from "@/entities/diff/domain/update-diff"; | ||
import { useMutation } from "@tanstack/react-query"; | ||
|
||
export function useUpdateDiffMutation() { | ||
return useMutation({ | ||
mutationFn: (branchName: string) => updateDiff(branchName), | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { updateDiffFromApi } from "@/entities/diff/api/update-diff-from-api"; | ||
|
||
export type UpdateDiff = (branchName: string) => Promise<void>; | ||
|
||
export const updateDiff: UpdateDiff = async (branchName) => { | ||
await updateDiffFromApi({ branchName, waitForCompletion: true }); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { DiffRefreshButton } from "@/entities/diff/ui/diff-refresh-button"; | ||
import LoadingScreen from "@/shared/components/loading-screen"; | ||
import { Badge } from "@/shared/components/ui/badge"; | ||
import { Icon } from "@iconify-icon/react"; | ||
|
||
export interface DiffComputingProps { | ||
sourceBranch: string; | ||
destinationBranch: string; | ||
} | ||
|
||
export function DiffComputing({ sourceBranch, destinationBranch }: DiffComputingProps) { | ||
return ( | ||
<div className="flex flex-col items-center mt-10 gap-5"> | ||
<LoadingScreen hideText /> | ||
|
||
<h1 className="font-semibold"> | ||
We are computing the diff between | ||
<Badge variant="blue"> | ||
<Icon icon={"mdi:layers-triple"} className="mr-1" /> | ||
{sourceBranch} | ||
</Badge> | ||
and | ||
<Badge variant="green"> | ||
<Icon icon={"mdi:layers-triple"} className="mr-1" /> | ||
{destinationBranch} | ||
</Badge> | ||
</h1> | ||
|
||
<div className="text-center"> | ||
<p>This process may take a few seconds to a few minutes.</p> | ||
<p>Once completed, you'll be able to view the detailed changes.</p> | ||
</div> | ||
|
||
<DiffRefreshButton branchName={destinationBranch} /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { DiffRefreshButton } from "@/entities/diff/ui/diff-refresh-button"; | ||
import { Tooltip } from "@/shared/components/ui/tooltip"; | ||
import { formatFullDate, formatRelativeTimeFromNow } from "@/shared/utils/date"; | ||
import { Icon } from "@iconify-icon/react"; | ||
|
||
export interface DiffEmptyProps { | ||
branchName: string; | ||
lastRefreshedAt: Date; | ||
} | ||
|
||
export function DiffEmpty({ branchName, lastRefreshedAt }: DiffEmptyProps) { | ||
return ( | ||
<div className="flex flex-col items-center mt-10 gap-5"> | ||
<div className="p-3 rounded-full bg-white inline-flex"> | ||
<Icon icon="mdi:circle-off-outline" className="text-2xl text-custom-blue-800" /> | ||
</div> | ||
|
||
<h1 className="font-semibold text-lg">No changes detected</h1> | ||
<div className="text-center"> | ||
<p> | ||
The last comparison was made{" "} | ||
<Tooltip enabled content={formatFullDate(lastRefreshedAt)}> | ||
<span className="font-semibold">{formatRelativeTimeFromNow(lastRefreshedAt)}</span> | ||
</Tooltip> | ||
. | ||
</p> | ||
<p>If you have made any changes, please refresh the diff:</p> | ||
</div> | ||
|
||
<DiffRefreshButton branchName={branchName} /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { useUpdateDiffMutation } from "@/entities/diff/domain/update-diff.mutation"; | ||
import { Button } from "@/shared/components/buttons/button-primitive"; | ||
import { classNames } from "@/shared/utils/common"; | ||
import { Icon } from "@iconify-icon/react"; | ||
|
||
export function DiffRefreshButton({ branchName }: { branchName: string }) { | ||
const updateDiffMutation = useUpdateDiffMutation(); | ||
|
||
return ( | ||
<Button variant="primary-outline" onClick={() => updateDiffMutation.mutate(branchName)}> | ||
<Icon | ||
icon="mdi:reload" | ||
className={classNames("mr-1", updateDiffMutation.isPending && "animate-spin")} | ||
/> | ||
{updateDiffMutation.isPending ? "Refreshing..." : "Refresh"} | ||
</Button> | ||
); | ||
} |