mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-24 01:28:35 +02:00
Show push errors in commit dialog
This commit is contained in:
@@ -12,7 +12,7 @@ import classNames from 'classnames';
|
|||||||
|
|
||||||
import { useMemo, useState } from 'react';
|
import { useMemo, useState } from 'react';
|
||||||
import { fallbackRequestName } from '../lib/fallbackRequestName';
|
import { fallbackRequestName } from '../lib/fallbackRequestName';
|
||||||
import {showErrorToast, showToast} from '../lib/toast';
|
import { showErrorToast, showToast } from '../lib/toast';
|
||||||
import { Banner } from './core/Banner';
|
import { Banner } from './core/Banner';
|
||||||
import { Button } from './core/Button';
|
import { Button } from './core/Button';
|
||||||
import type { CheckboxProps } from './core/Checkbox';
|
import type { CheckboxProps } from './core/Checkbox';
|
||||||
@@ -43,19 +43,23 @@ export function GitCommitDialog({ syncDir, onDone, workspace }: Props) {
|
|||||||
const [message, setMessage] = useState<string>('');
|
const [message, setMessage] = useState<string>('');
|
||||||
|
|
||||||
const handleCreateCommit = async () => {
|
const handleCreateCommit = async () => {
|
||||||
await commit.mutateAsync({ message });
|
try {
|
||||||
onDone();
|
await commit.mutateAsync({ message });
|
||||||
|
onDone();
|
||||||
|
} catch (err) {
|
||||||
|
showErrorToast('git-commit-error', String(err));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCreateCommitAndPush = async () => {
|
const handleCreateCommitAndPush = async () => {
|
||||||
await commit.mutateAsync({ message });
|
try {
|
||||||
await push.mutateAsync(undefined, {
|
await commit.mutateAsync({ message });
|
||||||
onError(err) {
|
await push.mutateAsync();
|
||||||
showErrorToast('git-push-error', String(err));
|
showToast({ id: 'git-push-success', message: 'Pushed changes', color: 'success' });
|
||||||
}
|
onDone();
|
||||||
});
|
} catch (err) {
|
||||||
showToast({ id: 'git-push-success', message: 'Pushed changes', color: 'success' });
|
showErrorToast('git-commit-and-push-error', String(err));
|
||||||
onDone();
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const { internalEntries, externalEntries, allEntries } = useMemo(() => {
|
const { internalEntries, externalEntries, allEntries } = useMemo(() => {
|
||||||
@@ -145,16 +149,18 @@ export function GitCommitDialog({ syncDir, onDone, workspace }: Props) {
|
|||||||
firstSlot={({ style }) => (
|
firstSlot={({ style }) => (
|
||||||
<div style={style} className="h-full overflow-y-auto -ml-1 pb-3">
|
<div style={style} className="h-full overflow-y-auto -ml-1 pb-3">
|
||||||
<TreeNodeChildren node={tree} depth={0} onCheck={checkNode} />
|
<TreeNodeChildren node={tree} depth={0} onCheck={checkNode} />
|
||||||
{externalEntries.length > 0 && (
|
{externalEntries.find((e) => e.status !== 'current') && (
|
||||||
<Separator className="mt-3 mb-1">External file changes</Separator>
|
<>
|
||||||
|
<Separator className="mt-3 mb-1">External file changes</Separator>
|
||||||
|
{externalEntries.map((entry) => (
|
||||||
|
<ExternalTreeNode
|
||||||
|
key={entry.relaPath + entry.status}
|
||||||
|
entry={entry}
|
||||||
|
onCheck={checkEntry}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
{externalEntries.map((entry) => (
|
|
||||||
<ExternalTreeNode
|
|
||||||
key={entry.relaPath + entry.status}
|
|
||||||
entry={entry}
|
|
||||||
onCheck={checkEntry}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
secondSlot={({ style }) => (
|
secondSlot={({ style }) => (
|
||||||
|
|||||||
Reference in New Issue
Block a user