Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
5e721595
Commit
5e721595
authored
Sep 28, 2021
by
Tom Quirk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove jquery from integration settings form
parent
b51e7099
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
20 deletions
+15
-20
app/assets/javascripts/integrations/integration_settings_form.js
...ets/javascripts/integrations/integration_settings_form.js
+10
-13
spec/frontend/integrations/integration_settings_form_spec.js
spec/frontend/integrations/integration_settings_form_spec.js
+5
-7
No files found.
app/assets/javascripts/integrations/integration_settings_form.js
View file @
5e721595
import
$
from
'
jquery
'
;
import
{
delay
}
from
'
lodash
'
;
import
{
__
,
s__
}
from
'
~/locale
'
;
import
toast
from
'
~/vue_shared/plugins/global_toast
'
;
...
...
@@ -8,13 +7,13 @@ import eventHub from './edit/event_hub';
export
default
class
IntegrationSettingsForm
{
constructor
(
formSelector
)
{
this
.
$form
=
$
(
formSelector
);
this
.
$form
=
document
.
querySelector
(
formSelector
);
this
.
formActive
=
false
;
this
.
vue
=
null
;
// Form Metadata
this
.
testEndPoint
=
this
.
$form
.
data
(
'
testUrl
'
)
;
this
.
testEndPoint
=
this
.
$form
.
data
set
.
testUrl
;
}
init
()
{
...
...
@@ -34,8 +33,7 @@ export default class IntegrationSettingsForm {
this
.
saveIntegration
();
});
eventHub
.
$on
(
'
getJiraIssueTypes
'
,
()
=>
{
// eslint-disable-next-line no-jquery/no-serialize
this
.
getJiraIssueTypes
(
this
.
$form
.
serialize
());
this
.
getJiraIssueTypes
(
new
FormData
(
this
.
$form
));
});
eventHub
.
$emit
(
'
formInitialized
'
);
...
...
@@ -47,11 +45,11 @@ export default class IntegrationSettingsForm {
// 2) If this service can be saved
// If both conditions are true, we override form submission
// and save the service using provided configuration.
const
formValid
=
this
.
$form
.
get
(
0
).
checkValidity
()
||
this
.
formActive
===
false
;
const
formValid
=
this
.
$form
.
checkValidity
()
||
this
.
formActive
===
false
;
if
(
formValid
)
{
delay
(()
=>
{
this
.
$form
.
trigger
(
'
submit
'
);
this
.
$form
.
submit
(
);
},
100
);
}
else
{
eventHub
.
$emit
(
'
validateForm
'
);
...
...
@@ -65,9 +63,8 @@ export default class IntegrationSettingsForm {
// 2) If this service can be tested
// If both conditions are true, we override form submission
// and test the service using provided configuration.
if
(
this
.
$form
.
get
(
0
).
checkValidity
())
{
// eslint-disable-next-line no-jquery/no-serialize
this
.
testSettings
(
this
.
$form
.
serialize
());
if
(
this
.
$form
.
checkValidity
())
{
this
.
testSettings
(
new
FormData
(
this
.
$form
));
}
else
{
eventHub
.
$emit
(
'
validateForm
'
);
this
.
vue
.
$store
.
dispatch
(
'
setIsTesting
'
,
false
);
...
...
@@ -79,9 +76,9 @@ export default class IntegrationSettingsForm {
*/
toggleServiceState
()
{
if
(
this
.
formActive
)
{
this
.
$form
.
removeAttr
(
'
novalidate
'
);
}
else
if
(
!
this
.
$form
.
attr
(
'
novalidate
'
))
{
this
.
$form
.
attr
(
'
novalidate
'
,
'
novalidate
'
);
this
.
$form
.
removeAttr
ibute
(
'
novalidate
'
);
}
else
if
(
!
this
.
$form
.
getAttribute
(
'
novalidate
'
))
{
this
.
$form
.
setAttribute
(
'
novalidate
'
,
'
novalidate
'
);
}
}
...
...
spec/frontend/integrations/integration_settings_form_spec.js
View file @
5e721595
...
...
@@ -23,7 +23,7 @@ describe('IntegrationSettingsForm', () => {
it
(
'
should initialize form element refs on class object
'
,
()
=>
{
// Form Reference
expect
(
integrationSettingsForm
.
$form
).
toBeDefined
();
expect
(
integrationSettingsForm
.
$form
.
prop
(
'
nodeName
'
)).
toEqual
(
'
FORM
'
);
expect
(
integrationSettingsForm
.
$form
.
nodeName
).
toBe
(
'
FORM
'
);
expect
(
integrationSettingsForm
.
formActive
).
toBeDefined
();
});
...
...
@@ -43,14 +43,14 @@ describe('IntegrationSettingsForm', () => {
integrationSettingsForm
.
formActive
=
true
;
integrationSettingsForm
.
toggleServiceState
();
expect
(
integrationSettingsForm
.
$form
.
attr
(
'
novalidate
'
)).
not
.
toBeDefined
(
);
expect
(
integrationSettingsForm
.
$form
.
getAttribute
(
'
novalidate
'
)).
toBe
(
null
);
});
it
(
'
should set `novalidate` attribute to form when called with `false`
'
,
()
=>
{
integrationSettingsForm
.
formActive
=
false
;
integrationSettingsForm
.
toggleServiceState
();
expect
(
integrationSettingsForm
.
$form
.
attr
(
'
novalidate
'
)).
toBeDefined
();
expect
(
integrationSettingsForm
.
$form
.
getAttribute
(
'
novalidate
'
)).
toBeDefined
();
});
});
...
...
@@ -67,8 +67,7 @@ describe('IntegrationSettingsForm', () => {
integrationSettingsForm
=
new
IntegrationSettingsForm
(
'
.js-integration-settings-form
'
);
integrationSettingsForm
.
init
();
// eslint-disable-next-line no-jquery/no-serialize
formData
=
integrationSettingsForm
.
$form
.
serialize
();
formData
=
new
FormData
(
integrationSettingsForm
.
$form
);
});
afterEach
(()
=>
{
...
...
@@ -145,8 +144,7 @@ describe('IntegrationSettingsForm', () => {
integrationSettingsForm
=
new
IntegrationSettingsForm
(
'
.js-integration-settings-form
'
);
integrationSettingsForm
.
init
();
// eslint-disable-next-line no-jquery/no-serialize
formData
=
integrationSettingsForm
.
$form
.
serialize
();
formData
=
new
FormData
(
integrationSettingsForm
.
$form
);
});
afterEach
(()
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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