Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Donald Haase
Cockatrice
Commits
a65ce869
Unverified
Commit
a65ce869
authored
Jun 15, 2021
by
Joseph Chamish
Committed by
GitHub
Jun 15, 2021
Browse files
selection of known hosts to form (#4379)
parent
c9ddd042
Changes
3
Hide whitespace changes
Inline
Side-by-side
webclient/src/forms/ConnectForm/ConnectForm.css
View file @
a65ce869
...
...
@@ -11,4 +11,8 @@
.connectForm-submit.MuiButton-root
{
display
:
block
;
margin
:
20px
auto
0
;
}
.selectKnownHosts-items
{
margin-bottom
:
4px
;
}
\ No newline at end of file
webclient/src/forms/ConnectForm/ConnectForm.tsx
View file @
a65ce869
// eslint-disable-next-line
import
React
,
{
Component
}
from
"
react
"
;
import
React
,
{
useState
}
from
"
react
"
;
import
{
connect
}
from
"
react-redux
"
;
import
{
Form
,
Field
,
reduxForm
}
from
"
redux-form
"
import
{
Form
,
Field
,
reduxForm
,
change
}
from
"
redux-form
"
import
Button
from
"
@material-ui/core/Button
"
;
import
{
InputField
}
from
"
components
"
;
import
{
FormKey
}
from
'
types
'
;
import
{
FormKey
,
KnownHost
,
KnownHosts
}
from
'
types
'
;
import
"
./ConnectForm.css
"
;
import
{
Select
,
MenuItem
}
from
"
@material-ui/core
"
;
const
ConnectForm
=
({
handleSubmit
})
=>
(
<
Form
className
=
"connectForm"
onSubmit
=
{
handleSubmit
}
>
<
div
className
=
"connectForm-item"
>
<
Field
label
=
"Host"
name
=
"host"
component
=
{
InputField
}
/>
</
div
>
<
div
className
=
"connectForm-item"
>
<
Field
label
=
"Port"
name
=
"port"
component
=
{
InputField
}
/>
</
div
>
<
div
className
=
"connectForm-item"
>
<
Field
label
=
"User"
name
=
"user"
component
=
{
InputField
}
autoComplete
=
"username"
/>
</
div
>
<
div
className
=
"connectForm-item"
>
<
Field
label
=
"Pass"
name
=
"pass"
type
=
"password"
component
=
{
InputField
}
autoComplete
=
"current-password"
/>
</
div
>
<
Button
className
=
"connectForm-submit"
color
=
"primary"
variant
=
"contained"
type
=
"submit"
>
Connect
</
Button
>
</
Form
>
);
const
ConnectForm
=
(
props
)
=>
{
const
{
handleSubmit
,
dispatch
}
=
props
;
const
[
knownHosts
,
setKnownHosts
]
=
useState
(
KnownHost
.
ROOSTER
);
const
handleChange
=
(
event
)
=>
{
setKnownHosts
(
event
.
target
.
value
);
dispatch
(
change
(
FormKey
.
CONNECT
,
'
host
'
,
KnownHosts
[
event
.
target
.
value
].
host
));
dispatch
(
change
(
FormKey
.
CONNECT
,
'
port
'
,
KnownHosts
[
event
.
target
.
value
].
port
))
};
return
(
<
Form
className
=
"connectForm"
onSubmit
=
{
handleSubmit
}
>
<
div
className
=
"connectForm-item"
>
<
Select
labelId
=
"selectedKnownHosts-label"
id
=
"selectedKnownHosts-label"
className
=
"selectKnownHosts-items"
value
=
{
knownHosts
}
fullWidth
=
{
true
}
onChange
=
{
handleChange
}
>
<
MenuItem
value
=
{
KnownHost
.
ROOSTER
}
>
{
KnownHost
.
ROOSTER
}
</
MenuItem
>
<
MenuItem
value
=
{
KnownHost
.
TETRARCH
}
>
{
KnownHost
.
TETRARCH
}
</
MenuItem
>
</
Select
>
</
div
>
<
div
className
=
"connectForm-item"
>
<
Field
label
=
"Host"
name
=
"host"
component
=
{
InputField
}
/>
</
div
>
<
div
className
=
"connectForm-item"
>
<
Field
label
=
"Port"
name
=
"port"
component
=
{
InputField
}
/>
</
div
>
<
div
className
=
"connectForm-item"
>
<
Field
label
=
"User"
name
=
"user"
component
=
{
InputField
}
autoComplete
=
"username"
/>
</
div
>
<
div
className
=
"connectForm-item"
>
<
Field
label
=
"Pass"
name
=
"pass"
type
=
"password"
component
=
{
InputField
}
autoComplete
=
"current-password"
/>
</
div
>
<
Button
className
=
"connectForm-submit"
color
=
"primary"
variant
=
"contained"
type
=
"submit"
>
Connect
</
Button
>
</
Form
>
);
}
const
propsMap
=
{
form
:
FormKey
.
CONNECT
...
...
webclient/src/types/server.tsx
View file @
a65ce869
...
...
@@ -16,6 +16,16 @@ export enum StatusEnumLabel {
"
Disconnecting
"
=
99
}
export
enum
KnownHost
{
ROOSTER
=
'
Rooster
'
,
TETRARCH
=
'
Tetrarch
'
,
}
export
const
KnownHosts
=
{
[
KnownHost
.
ROOSTER
]:
{
port
:
443
,
host
:
'
server.cockatrice.us
'
,
},
[
KnownHost
.
TETRARCH
]:
{
port
:
443
,
host
:
'
mtg.tetrarch.co/servatrice
'
},
}
export
const
getStatusEnumLabel
=
(
statusEnum
:
number
)
=>
{
if
(
StatusEnumLabel
[
statusEnum
]
!==
undefined
)
{
return
StatusEnumLabel
[
statusEnum
];
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment