Skip to content
GitLab
Next
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
GitLab
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Privacy statement
Keyboard shortcuts
?
What's new
4
Snippets
Groups
Projects
Show more breadcrumbs
GitLab.org
GitLab
Commits
40bcda62
Verified
Commit
40bcda62
authored
4 years ago
by
Thomas Randolph
Browse files
Options
Downloads
Patches
Plain Diff
Add server-sent name-field validation errors
parent
34ac2c84
No related branches found
No related tags found
1 merge request
!39389
Move "Add Approver" Name Validation Error into Form
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ee/app/assets/javascripts/approvals/components/rule_form.vue
+30
-7
30 additions, 7 deletions
ee/app/assets/javascripts/approvals/components/rule_form.vue
with
30 additions
and
7 deletions
ee/app/assets/javascripts/approvals/components/rule_form.vue
+
30
−
7
View file @
40bcda62
...
...
@@ -13,6 +13,10 @@ const DEFAULT_NAME_FOR_LICENSE_REPORT = 'License-Check';
const
DEFAULT_NAME_FOR_VULNERABILITY_CHECK
=
'
Vulnerability-Check
'
;
const
READONLY_NAMES
=
[
DEFAULT_NAME_FOR_LICENSE_REPORT
,
DEFAULT_NAME_FOR_VULNERABILITY_CHECK
];
function
mapServerResponseToValidationErrors
(
messages
)
{
return
Object
.
entries
(
messages
).
flatMap
(([
key
,
msgs
])
=>
msgs
.
map
(
msg
=>
`
${
key
}
${
msg
}
`
));
}
export
default
{
components
:
{
ApproversList
,
...
...
@@ -50,6 +54,7 @@ export default {
showValidation
:
false
,
isFallback
:
false
,
containsHiddenGroups
:
false
,
serverValidationErrors
:
[],
...
this
.
getInitialData
(),
};
// TODO: Remove feature flag in https://gitlab.com/gitlab-org/gitlab/-/issues/235114
...
...
@@ -98,11 +103,17 @@ export default {
return
invalidObject
;
},
invalidName
()
{
if
(
!
this
.
isMultiSubmission
)
{
return
''
;
let
error
=
''
;
if
(
this
.
isMultiSubmission
)
{
if
(
this
.
serverValidationErrors
.
includes
(
'
name has already been taken
'
))
{
error
=
__
(
'
Rule name is already taken.
'
);
}
else
if
(
!
this
.
name
)
{
error
=
__
(
'
Please provide a name
'
);
}
}
return
!
this
.
name
?
__
(
'
Please provide a name
'
)
:
''
;
return
error
;
},
invalidApprovalsRequired
()
{
if
(
!
isNumber
(
this
.
approvalsRequired
))
{
...
...
@@ -204,15 +215,27 @@ export default {
* - Multi rule?
*/
submit
()
{
let
submission
;
this
.
serverValidationErrors
=
[];
if
(
!
this
.
validate
())
{
return
Promise
.
resolve
();
submission
=
Promise
.
resolve
();
}
else
if
(
this
.
isFallbackSubmission
)
{
return
this
.
submitFallback
();
submission
=
this
.
submitFallback
();
}
else
if
(
!
this
.
isMultiSubmission
)
{
return
this
.
submitSingleRule
();
submission
=
this
.
submitSingleRule
();
}
else
{
submission
=
this
.
submitRule
();
}
return
this
.
submitRule
();
submission
.
catch
(
failureResponse
=>
{
this
.
serverValidationErrors
=
mapServerResponseToValidationErrors
(
failureResponse
?.
response
?.
data
?.
message
||
{},
);
});
return
submission
;
},
/**
* Submit the rule, by either put-ing or post-ing.
...
...
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