Skip to content

Commit 2dc78b6

Browse files
authored
Merge pull request #1019 from quirrel-dev/fix-1014
fix: don't show "endpoint" input field for instances with fixed endpoint
2 parents 6e9a2f6 + e49a6e2 commit 2dc78b6

File tree

3 files changed

+79
-70
lines changed

3 files changed

+79
-70
lines changed

development-ui/src/components/EndpointModal.tsx

Lines changed: 76 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { useState } from "react";
1+
import { useContext, useState } from "react";
2+
import { ConfigContext } from "..";
23
import { useQuirrel } from "../hooks/useQuirrel";
34
import { connectionDetailsToHash } from "../lib/encrypted-connection-details";
45
import { Modal } from "./Modal";
@@ -20,8 +21,11 @@ export function EndpointModal() {
2021
const [showModal, setShowModal] = useState(false);
2122

2223
const { connectedTo, connectTo } = useQuirrel();
24+
const { fixedEndpoint } = useContext(ConfigContext);
2325

24-
const [endpoint, setEndpoint] = useState(connectedTo?.baseUrl ?? "");
26+
const [endpoint, setEndpoint] = useState(
27+
connectedTo?.baseUrl ?? fixedEndpoint ?? ""
28+
);
2529
const [token, setToken] = useState(connectedTo?.token ?? "");
2630
const [encryptionSecret, setEncryptionSecret] = useState(
2731
connectedTo?.encryptionSecret ?? ""
@@ -82,76 +86,80 @@ export function EndpointModal() {
8286
Connect to Quirrel Instance
8387
</h3>
8488
<div className="mt-2 space-y-2">
85-
<span className="space-x-2 text-blue-400 text-xs">
86-
<button
87-
onClick={() => setEndpoint("http://localhost:9181")}
88-
className="inline-flex items-center hover:text-blue-300 focus:outline-none"
89-
>
90-
<svg
91-
xmlns="http://www.w3.org/2000/svg"
92-
fill="none"
93-
viewBox="0 0 24 24"
94-
stroke="currentColor"
95-
className="h-3 inline m-1"
89+
{!fixedEndpoint && (
90+
<span className="space-x-2 text-blue-400 text-xs">
91+
<button
92+
onClick={() => setEndpoint("http://localhost:9181")}
93+
className="inline-flex items-center hover:text-blue-300 focus:outline-none"
9694
>
97-
<path
98-
strokeLinecap="round"
99-
strokeLinejoin="round"
100-
strokeWidth={2}
101-
d="M19.428 15.428a2 2 0 00-1.022-.547l-2.387-.477a6 6 0 00-3.86.517l-.318.158a6 6 0 01-3.86.517L6.05 15.21a2 2 0 00-1.806.547M8 4h8l-1 1v5.172a2 2 0 00.586 1.414l5 5c1.26 1.26.367 3.414-1.415 3.414H4.828c-1.782 0-2.674-2.154-1.414-3.414l5-5A2 2 0 009 10.172V5L8 4z"
102-
/>
103-
</svg>
104-
localhost
105-
</button>
106-
<button
107-
onClick={() => setEndpoint("https://api.quirrel.dev")}
108-
className="inline-flex items-center hover:text-blue-300 focus:outline-none"
109-
>
110-
<svg
111-
xmlns="http://www.w3.org/2000/svg"
112-
fill="none"
113-
viewBox="0 0 24 24"
114-
stroke="currentColor"
115-
className="h-3 inline m-1"
95+
<svg
96+
xmlns="http://www.w3.org/2000/svg"
97+
fill="none"
98+
viewBox="0 0 24 24"
99+
stroke="currentColor"
100+
className="h-3 inline m-1"
101+
>
102+
<path
103+
strokeLinecap="round"
104+
strokeLinejoin="round"
105+
strokeWidth={2}
106+
d="M19.428 15.428a2 2 0 00-1.022-.547l-2.387-.477a6 6 0 00-3.86.517l-.318.158a6 6 0 01-3.86.517L6.05 15.21a2 2 0 00-1.806.547M8 4h8l-1 1v5.172a2 2 0 00.586 1.414l5 5c1.26 1.26.367 3.414-1.415 3.414H4.828c-1.782 0-2.674-2.154-1.414-3.414l5-5A2 2 0 009 10.172V5L8 4z"
107+
/>
108+
</svg>
109+
localhost
110+
</button>
111+
<button
112+
onClick={() => setEndpoint("https://api.quirrel.dev")}
113+
className="inline-flex items-center hover:text-blue-300 focus:outline-none"
116114
>
117-
<path
118-
strokeLinecap="round"
119-
strokeLinejoin="round"
120-
strokeWidth={2}
121-
d="M3 15a4 4 0 004 4h9a5 5 0 10-.1-9.999 5.002 5.002 0 10-9.78 2.096A4.001 4.001 0 003 15z"
122-
/>
123-
</svg>
124-
quirrel.dev
125-
</button>
126-
<button
127-
onClick={() => {
128-
setEndpoint("");
129-
}}
130-
className="inline-flex items-center hover:text-blue-300 focus:outline-none"
131-
>
132-
<svg
133-
xmlns="http://www.w3.org/2000/svg"
134-
viewBox="0 0 20 20"
135-
fill="currentColor"
136-
className="h-3 inline m-1"
115+
<svg
116+
xmlns="http://www.w3.org/2000/svg"
117+
fill="none"
118+
viewBox="0 0 24 24"
119+
stroke="currentColor"
120+
className="h-3 inline m-1"
121+
>
122+
<path
123+
strokeLinecap="round"
124+
strokeLinejoin="round"
125+
strokeWidth={2}
126+
d="M3 15a4 4 0 004 4h9a5 5 0 10-.1-9.999 5.002 5.002 0 10-9.78 2.096A4.001 4.001 0 003 15z"
127+
/>
128+
</svg>
129+
quirrel.dev
130+
</button>
131+
<button
132+
onClick={() => {
133+
setEndpoint("");
134+
}}
135+
className="inline-flex items-center hover:text-blue-300 focus:outline-none"
137136
>
138-
<path
139-
fillRule="evenodd"
140-
d="M2 5a2 2 0 012-2h12a2 2 0 012 2v2a2 2 0 01-2 2H4a2 2 0 01-2-2V5zm14 1a1 1 0 11-2 0 1 1 0 012 0zM2 13a2 2 0 012-2h12a2 2 0 012 2v2a2 2 0 01-2 2H4a2 2 0 01-2-2v-2zm14 1a1 1 0 11-2 0 1 1 0 012 0z"
141-
clipRule="evenodd"
142-
/>
143-
</svg>
144-
On-Premise
145-
</button>
146-
</span>
137+
<svg
138+
xmlns="http://www.w3.org/2000/svg"
139+
viewBox="0 0 20 20"
140+
fill="currentColor"
141+
className="h-3 inline m-1"
142+
>
143+
<path
144+
fillRule="evenodd"
145+
d="M2 5a2 2 0 012-2h12a2 2 0 012 2v2a2 2 0 01-2 2H4a2 2 0 01-2-2V5zm14 1a1 1 0 11-2 0 1 1 0 012 0zM2 13a2 2 0 012-2h12a2 2 0 012 2v2a2 2 0 01-2 2H4a2 2 0 01-2-2v-2zm14 1a1 1 0 11-2 0 1 1 0 012 0z"
146+
clipRule="evenodd"
147+
/>
148+
</svg>
149+
On-Premise
150+
</button>
151+
</span>
152+
)}
147153

148-
<input
149-
placeholder="Endpoint"
150-
name="endpoint"
151-
value={endpoint}
152-
onChange={(evt) => setEndpoint(evt.target.value)}
153-
className="border-gray-300 placeholder-gray-500 appearance-none relative block w-full px-3 py-2 border text-gray-900 rounded-md focus:outline-none focus:shadow-outline-blue focus:border-blue-300 focus:z-10 sm:text-sm sm:leading-5"
154-
/>
154+
{!fixedEndpoint && (
155+
<input
156+
placeholder="Endpoint"
157+
name="endpoint"
158+
value={endpoint}
159+
onChange={(evt) => setEndpoint(evt.target.value)}
160+
className="border-gray-300 placeholder-gray-500 appearance-none relative block w-full px-3 py-2 border text-gray-900 rounded-md focus:outline-none focus:shadow-outline-blue focus:border-blue-300 focus:z-10 sm:text-sm sm:leading-5"
161+
/>
162+
)}
155163

156164
<input
157165
placeholder="Token"

development-ui/src/hooks/useQuirrel.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ function useQuirrelClient() {
292292
async function isHealthy(
293293
baseUrl: string
294294
): Promise<{ isHealthy: boolean; stopPolling?: boolean }> {
295+
baseUrl = withoutTrailingSlash(baseUrl);
295296
const connectsToLocalhost = baseUrl.includes("localhost");
296297
try {
297298
const res = await fetch(baseUrl + "/health");
@@ -450,7 +451,7 @@ export function QuirrelProvider(props: PropsWithChildren<{}>) {
450451
const result = await loadInitialJobs(getClient);
451452
if (result === "unauthorized") {
452453
window.alert(
453-
"Connection couldn't be established, you're unauthorized. Please check the token."
454+
"Please authenticate with your QUIRREL_TOKEN via the top-left connection menu."
454455
);
455456
return "stopPolling";
456457
}

src/api/shared/dx-logger.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export class DxLogger implements Logger {
1616
Welcome to the Quirrel development server.
1717
1818
Open your browser and go to
19-
{yellow https://ui.quirrel.dev}
19+
{yellow http://${address}}
2020
to get a better overview over pending jobs.
2121
${
2222
telemetryEnabled

0 commit comments

Comments
 (0)