Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
greg
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
it-bott-integrasjoner
greg
Commits
cdc62c2e
Verified
Commit
cdc62c2e
authored
3 years ago
by
Andreas Ellewsen
Browse files
Options
Downloads
Patches
Plain Diff
Use FormHelperText for error messages
parent
4cd02e73
No related branches found
No related tags found
1 merge request
!293
Make type and ou choices required in new role form
Pipeline
#119281
passed
3 years ago
Stage: venv update
Stage: tests and linting
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend/src/routes/sponsor/guest/newGuestRole/index.tsx
+13
-9
13 additions, 9 deletions
frontend/src/routes/sponsor/guest/newGuestRole/index.tsx
with
13 additions
and
9 deletions
frontend/src/routes/sponsor/guest/newGuestRole/index.tsx
+
13
−
9
View file @
cdc62c2e
...
...
@@ -18,6 +18,7 @@ import {
FormControlLabel
,
Box
,
Typography
,
FormHelperText
,
}
from
'
@mui/material
'
import
Page
from
'
components/page
'
import
{
Guest
}
from
'
interfaces
'
...
...
@@ -175,7 +176,10 @@ function NewGuestRole({ guest, reloadGuestInfo }: NewGuestRoleProps) {
</
MenuItem
>
)
}
const
hasRoleTypeError
=
errors
&&
errors
.
type
&&
errors
.
type
.
type
===
'
required
'
const
hasOuChoiceError
=
errors
&&
errors
.
orgunit
&&
errors
.
orgunit
.
type
===
'
required
'
return
(
<
Page
>
<
SponsorInfoButtons
...
...
@@ -195,7 +199,7 @@ function NewGuestRole({ guest, reloadGuestInfo }: NewGuestRoleProps) {
control
=
{
control
}
rules
=
{
{
required
:
true
}
}
render
=
{
()
=>
(
<
FormControl
>
<
FormControl
error
=
{
hasRoleTypeError
}
>
<
InputLabel
id
=
"roletype-select-label"
>
{
t
(
'
input.roleType
'
)
}
</
InputLabel
>
...
...
@@ -214,10 +218,10 @@ function NewGuestRole({ guest, reloadGuestInfo }: NewGuestRoleProps) {
</
FormControl
>
)
}
/>
{
errors
.
type
&&
errors
.
type
.
type
===
'
required
'
&&
(
<
Box
sx
=
{
{
typography
:
'
caption
'
,
color
:
'
error.main
'
}
}
>
{
hasRoleTypeError
&&
(
<
FormHelperText
error
>
{
t
(
'
validation.typeMustBeChosen
'
)
}
</
Box
>
</
FormHelperText
>
)
}
<
Controller
...
...
@@ -225,7 +229,7 @@ function NewGuestRole({ guest, reloadGuestInfo }: NewGuestRoleProps) {
control
=
{
control
}
rules
=
{
{
required
:
true
}
}
render
=
{
()
=>
(
<
FormControl
>
<
FormControl
error
=
{
hasOuChoiceError
}
>
<
InputLabel
id
=
"ou-select-label-id"
>
{
t
(
'
common:ou
'
)
}
</
InputLabel
>
...
...
@@ -246,10 +250,10 @@ function NewGuestRole({ guest, reloadGuestInfo }: NewGuestRoleProps) {
</
FormControl
>
)
}
/>
{
errors
.
orgunit
&&
errors
.
orgunit
.
type
===
'
required
'
&&
(
<
Box
sx
=
{
{
typography
:
'
caption
'
,
color
:
'
error.main
'
}
}
>
{
hasOuChoiceError
&&
(
<
FormHelperText
error
>
{
t
(
'
validation.ouMustBeChosen
'
)
}
</
Box
>
</
FormHelperText
>
)
}
<
Controller
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment