1
- import { useState } from "react" ;
1
+ import { useContext , useState } from "react" ;
2
+ import { ConfigContext } from ".." ;
2
3
import { useQuirrel } from "../hooks/useQuirrel" ;
3
4
import { connectionDetailsToHash } from "../lib/encrypted-connection-details" ;
4
5
import { Modal } from "./Modal" ;
@@ -20,8 +21,11 @@ export function EndpointModal() {
20
21
const [ showModal , setShowModal ] = useState ( false ) ;
21
22
22
23
const { connectedTo, connectTo } = useQuirrel ( ) ;
24
+ const { fixedEndpoint } = useContext ( ConfigContext ) ;
23
25
24
- const [ endpoint , setEndpoint ] = useState ( connectedTo ?. baseUrl ?? "" ) ;
26
+ const [ endpoint , setEndpoint ] = useState (
27
+ connectedTo ?. baseUrl ?? fixedEndpoint ?? ""
28
+ ) ;
25
29
const [ token , setToken ] = useState ( connectedTo ?. token ?? "" ) ;
26
30
const [ encryptionSecret , setEncryptionSecret ] = useState (
27
31
connectedTo ?. encryptionSecret ?? ""
@@ -82,76 +86,80 @@ export function EndpointModal() {
82
86
Connect to Quirrel Instance
83
87
</ h3 >
84
88
< 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"
96
94
>
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 "
116
114
>
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"
137
136
>
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
+ ) }
147
153
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
+ ) }
155
163
156
164
< input
157
165
placeholder = "Token"
0 commit comments