Skip to content

Commit 28929ea

Browse files
committed
web,graphql: Fix add connection error, hide merge/resolve button for doltgres
1 parent 30b02de commit 28929ea

File tree

5 files changed

+21
-13
lines changed

5 files changed

+21
-13
lines changed

graphql-server/src/queryFactory/doltgres/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ export class DoltgresQueryFactory
345345
return this.queryMultiple(
346346
async query => {
347347
await query("BEGIN");
348-
await query("SET autocommit TO 0");
348+
// await query("SET autocommit off");
349349

350350
const msg = `Merge branch ${args.fromBranchName}`;
351351
const params = [msg];

web/renderer/components/pageComponents/ConnectionsPage/ExistingConnections/Item.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1+
import { DatabaseTypeLabel } from "@components/ConnectionsAndDatabases/DatabaseTypeLabel";
12
import { getDatabaseType } from "@components/DatabaseTypeLabel";
23
import { Button, ErrorMsg, Loader } from "@dolthub/react-components";
34
import { DatabaseConnectionFragment } from "@gen/graphql-types";
45
import { IoMdClose } from "@react-icons/all-files/io/IoMdClose";
6+
import cx from "classnames";
57
import Image from "next/legacy/image";
68
import { SyntheticEvent, useState } from "react";
7-
import cx from "classnames";
8-
import { DatabaseTypeLabel } from "@components/ConnectionsAndDatabases/DatabaseTypeLabel";
9-
import useAddConnection from "./useAddConnection";
109
import css from "./index.module.css";
10+
import useAddConnection from "./useAddConnection";
1111

1212
const forElectron = process.env.NEXT_PUBLIC_FOR_ELECTRON === "true";
1313

@@ -84,7 +84,7 @@ export default function Item({
8484
{conn.name}
8585
</Button.Link>
8686
</div>
87-
<ErrorMsg err={err || startDoltServerError} className={css.err} />
87+
<ErrorMsg err={err ?? startDoltServerError} className={css.err} />
8888
</div>
8989
</div>
9090
</li>

web/renderer/components/pageComponents/ConnectionsPage/ExistingConnections/index.module.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
}
116116

117117
.err {
118-
@apply text-center;
118+
@apply text-center pt-0;
119119
}
120120

121121
.leftLine {

web/renderer/components/pageComponents/ConnectionsPage/ExistingConnections/useAddConnection.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
useAddDatabaseConnectionMutation,
44
useDoltServerStatusQuery,
55
} from "@gen/graphql-types";
6+
import useMutation from "@hooks/useMutation";
67
import { ApolloErrorType } from "@lib/errors/types";
78
import { maybeDatabase } from "@lib/urls";
89
import { useRouter } from "next/router";
@@ -18,19 +19,23 @@ export default function useAddConnection(
1819
conn: DatabaseConnectionFragment,
1920
): ReturnType {
2021
const router = useRouter();
21-
const [addDb, res] = useAddDatabaseConnectionMutation();
22+
const { mutateFn: addDb, ...res } = useMutation({
23+
hook: useAddDatabaseConnectionMutation,
24+
});
2225
const doltServerStatus = useDoltServerStatusQuery({
2326
variables: conn,
2427
});
28+
2529
const onAdd = async () => {
2630
try {
27-
const db = await addDb({ variables: conn });
28-
await res.client.clearStore();
29-
if (!db.data) {
31+
const { data, success } = await addDb({ variables: conn });
32+
if (!success || !data) {
3033
return;
3134
}
35+
await res.client.cache.reset();
36+
3237
const { href, as } = maybeDatabase(
33-
db.data.addDatabaseConnection.currentDatabase,
38+
data.addDatabaseConnection.currentDatabase,
3439
);
3540
router.push(href, as).catch(console.error);
3641
} catch {
@@ -40,7 +45,7 @@ export default function useAddConnection(
4045

4146
return {
4247
onAdd,
43-
err: res.error || doltServerStatus.error,
48+
err: res.err ?? doltServerStatus.error,
4449
loading: res.loading,
4550
doltServerIsActive: !!doltServerStatus.data?.doltServerStatus.active,
4651
};

web/renderer/components/pageComponents/DatabasePage/ForPulls/PullActions/Merge/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import HeaderUserCheckbox from "@components/HeaderUserCheckbox";
22
import { Button, SmallLoader } from "@dolthub/react-components";
33
import { ConflictResolveType, PullDetailsFragment } from "@gen/graphql-types";
4+
import useDatabaseDetails from "@hooks/useDatabaseDetails";
45
import { ApolloErrorType } from "@lib/errors/types";
56
import { PullDiffParams } from "@lib/params";
67
import { FiGitPullRequest } from "@react-icons/all-files/fi/FiGitPullRequest";
@@ -109,10 +110,11 @@ type MergeButtonProps = {
109110

110111
function MergeButton(props: MergeButtonProps) {
111112
const [modalOpen, setModalOpen] = useState(false);
113+
const { isPostgres } = useDatabaseDetails();
112114

113115
return (
114116
<div aria-label="merge-button-container">
115-
{props.disabled ? (
117+
{props.disabled && !isPostgres ? (
116118
<>
117119
<Button
118120
className={css.merge}
@@ -132,6 +134,7 @@ function MergeButton(props: MergeButtonProps) {
132134
className={css.merge}
133135
onClick={props.onClick}
134136
data-cy="merge-button"
137+
disabled={props.disabled}
135138
green
136139
>
137140
{props.loading ? "Merging..." : "Merge"}

0 commit comments

Comments
 (0)