Skip to content

Commit 89d3a0c

Browse files
author
Paul Korzhyk
committed
Fix the "Update" button in the server dialog
1 parent 0f4d9ab commit 89d3a0c

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

client/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@
208208
"redux-persist": "^5.4.0",
209209
"redux-thunk": "^2.3.0",
210210
"screenfull": "^3.3.2",
211-
"url-search-params": "^0.10.0",
212211
"uuid": "^3.1.0"
213212
}
214213
}

client/src/actions/url.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const updateUrl = url => async (dispatch, getState) => {
3232
url,
3333
});
3434

35-
checkHealth(url)(dispatch, getState);
35+
dispatch(checkHealth(url));
3636
};
3737

3838
export const checkHealth = (url, onFailure) => async (dispatch, getState) => {
@@ -44,6 +44,7 @@ export const checkHealth = (url, onFailure) => async (dispatch, getState) => {
4444
dispatch(updateConnectedState(true));
4545
} catch (err) {
4646
console.error(err);
47+
console.error("Unable to connect to the server at " + url);
4748
dispatch(updateConnectedState(false));
4849
onFailure && onFailure();
4950
} finally {

client/src/components/SidebarUpdateUrl.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ export default function SidebarUpdateUrl({
8787
size={5}
8888
value={urlInput}
8989
onChange={e => setUrlInput(e.target.value)}
90-
onDoubleClick={e => handleSubmit(e.target.value)}
90+
onDoubleClick={e => {
91+
setUrlInput(e.target.value);
92+
handleSubmit(e.target.value);
93+
}}
9194
onKeyPress={handleKeyPress}
9295
style={{
9396
width: "100%",
@@ -102,7 +105,7 @@ export default function SidebarUpdateUrl({
102105
</div>
103106
<Button
104107
variant="primary"
105-
onClick={handleSubmit}
108+
onClick={e => handleSubmit()}
106109
disabled={!urlInput.trim()}
107110
>
108111
Update

client/src/lib/helpers.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
import * as dgraph from "dgraph-js-http";
1010
import memoizeOne from "memoize-one";
11-
import URLSearchParams from "url-search-params";
1211

1312
export function createCookie(name, val, days, options = {}) {
1413
const cookie = [`${name}=${val}`, "path=/"];
@@ -70,7 +69,11 @@ export function serverLatency(latencyObj) {
7069

7170
const createDgraphClient = memoizeOne(async url => {
7271
const stub = new dgraph.DgraphClientStub(url);
73-
await stub.detectApiVersion();
72+
try {
73+
await stub.detectApiVersion();
74+
} catch (err) {
75+
// Ignore error, it's probably a bad URL
76+
}
7477

7578
return {
7679
client: new dgraph.DgraphClient(stub),
@@ -118,8 +121,7 @@ export async function executeAlter(url, schema) {
118121
}
119122

120123
export function getAddrParam() {
121-
const params = new URLSearchParams(window.location.search);
122-
const addrParam = params.get("addr");
124+
const addrParam = new URLSearchParams(window.location.search).get("addr");
123125
return addrParam ? ensureSlash(addrParam) : "";
124126
}
125127

0 commit comments

Comments
 (0)