mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-24 17:48:30 +02:00
Fix commit-and-push loading state
This commit is contained in:
@@ -51,6 +51,14 @@ export function useGit(dir: string) {
|
|||||||
mutationFn: (args) => invoke('plugin:yaak-git|commit', { dir, ...args }),
|
mutationFn: (args) => invoke('plugin:yaak-git|commit', { dir, ...args }),
|
||||||
onSuccess,
|
onSuccess,
|
||||||
}),
|
}),
|
||||||
|
commitAndPush: useMutation<PushResult, string, { message: string }>({
|
||||||
|
mutationKey: ['git', 'commitpush', dir],
|
||||||
|
mutationFn: async (args) => {
|
||||||
|
await invoke('plugin:yaak-git|commit', { dir, ...args });
|
||||||
|
return invoke('plugin:yaak-git|push', { dir });
|
||||||
|
},
|
||||||
|
onSuccess,
|
||||||
|
}),
|
||||||
fetchAll: useMutation<string, string, void>({
|
fetchAll: useMutation<string, string, void>({
|
||||||
mutationKey: ['git', 'checkout', dir],
|
mutationKey: ['git', 'checkout', dir],
|
||||||
mutationFn: () => invoke('plugin:yaak-git|fetch_all', { dir }),
|
mutationFn: () => invoke('plugin:yaak-git|fetch_all', { dir }),
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ interface TreeNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function GitCommitDialog({ syncDir, onDone, workspace }: Props) {
|
export function GitCommitDialog({ syncDir, onDone, workspace }: Props) {
|
||||||
const [{ status }, { commit, add, unstage, push }] = useGit(syncDir);
|
const [{ status }, { commit, commitAndPush, add, unstage, push }] = useGit(syncDir);
|
||||||
const [message, setMessage] = useState<string>('');
|
const [message, setMessage] = useState<string>('');
|
||||||
|
|
||||||
const handleCreateCommit = async () => {
|
const handleCreateCommit = async () => {
|
||||||
@@ -53,8 +53,7 @@ export function GitCommitDialog({ syncDir, onDone, workspace }: Props) {
|
|||||||
|
|
||||||
const handleCreateCommitAndPush = async () => {
|
const handleCreateCommitAndPush = async () => {
|
||||||
try {
|
try {
|
||||||
await commit.mutateAsync({ message });
|
await commitAndPush.mutateAsync({ message });
|
||||||
await push.mutateAsync();
|
|
||||||
showToast({ id: 'git-push-success', message: 'Pushed changes', color: 'success' });
|
showToast({ id: 'git-push-success', message: 'Pushed changes', color: 'success' });
|
||||||
onDone();
|
onDone();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -66,10 +65,13 @@ export function GitCommitDialog({ syncDir, onDone, workspace }: Props) {
|
|||||||
const allEntries = [];
|
const allEntries = [];
|
||||||
const yaakEntries = [];
|
const yaakEntries = [];
|
||||||
const externalEntries = [];
|
const externalEntries = [];
|
||||||
|
|
||||||
for (const entry of status.data?.entries ?? []) {
|
for (const entry of status.data?.entries ?? []) {
|
||||||
allEntries.push(entry);
|
allEntries.push(entry);
|
||||||
if (entry.next == null && entry.prev == null) {
|
if (entry.next == null && entry.prev == null) {
|
||||||
externalEntries.push(entry);
|
externalEntries.push(entry);
|
||||||
|
} else if (entry.next?.model === 'environment' || entry.prev?.model === 'environment') {
|
||||||
|
externalEntries.push(entry);
|
||||||
} else {
|
} else {
|
||||||
yaakEntries.push(entry);
|
yaakEntries.push(entry);
|
||||||
}
|
}
|
||||||
@@ -184,7 +186,7 @@ export function GitCommitDialog({ syncDir, onDone, workspace }: Props) {
|
|||||||
size="sm"
|
size="sm"
|
||||||
onClick={handleCreateCommit}
|
onClick={handleCreateCommit}
|
||||||
disabled={!hasAddedAnything}
|
disabled={!hasAddedAnything}
|
||||||
isLoading={push.isPending || commit.isPending}
|
isLoading={push.isPending || commitAndPush.isPending || commit.isPending}
|
||||||
>
|
>
|
||||||
Commit
|
Commit
|
||||||
</Button>
|
</Button>
|
||||||
@@ -193,7 +195,7 @@ export function GitCommitDialog({ syncDir, onDone, workspace }: Props) {
|
|||||||
size="sm"
|
size="sm"
|
||||||
disabled={!hasAddedAnything}
|
disabled={!hasAddedAnything}
|
||||||
onClick={handleCreateCommitAndPush}
|
onClick={handleCreateCommitAndPush}
|
||||||
isLoading={push.isPending || commit.isPending}
|
isLoading={push.isPending || commitAndPush.isPending || commit.isPending}
|
||||||
>
|
>
|
||||||
Commit and Push
|
Commit and Push
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
Reference in New Issue
Block a user