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
{
delay
}
from
'
lodash
'
;
import
{
__
,
s__
}
from
'
~/locale
'
;
import
{
__
,
s__
}
from
'
~/locale
'
;
import
toast
from
'
~/vue_shared/plugins/global_toast
'
;
import
toast
from
'
~/vue_shared/plugins/global_toast
'
;
...
@@ -8,13 +7,13 @@ import eventHub from './edit/event_hub';
...
@@ -8,13 +7,13 @@ import eventHub from './edit/event_hub';
export
default
class
IntegrationSettingsForm
{
export
default
class
IntegrationSettingsForm
{
constructor
(
formSelector
)
{
constructor
(
formSelector
)
{
this
.
$form
=
$
(
formSelector
);
this
.
$form
=
document
.
querySelector
(
formSelector
);
this
.
formActive
=
false
;
this
.
formActive
=
false
;
this
.
vue
=
null
;
this
.
vue
=
null
;
// Form Metadata
// Form Metadata
this
.
testEndPoint
=
this
.
$form
.
data
(
'
testUrl
'
)
;
this
.
testEndPoint
=
this
.
$form
.
data
set
.
testUrl
;
}
}
init
()
{
init
()
{
...
@@ -34,8 +33,7 @@ export default class IntegrationSettingsForm {
...
@@ -34,8 +33,7 @@ export default class IntegrationSettingsForm {
this
.
saveIntegration
();
this
.
saveIntegration
();
});
});
eventHub
.
$on
(
'
getJiraIssueTypes
'
,
()
=>
{
eventHub
.
$on
(
'
getJiraIssueTypes
'
,
()
=>
{
// eslint-disable-next-line no-jquery/no-serialize
this
.
getJiraIssueTypes
(
new
FormData
(
this
.
$form
));
this
.
getJiraIssueTypes
(
this
.
$form
.
serialize
());
});
});
eventHub
.
$emit
(
'
formInitialized
'
);
eventHub
.
$emit
(
'
formInitialized
'
);
...
@@ -47,11 +45,11 @@ export default class IntegrationSettingsForm {
...
@@ -47,11 +45,11 @@ export default class IntegrationSettingsForm {
// 2) If this service can be saved
// 2) If this service can be saved
// If both conditions are true, we override form submission
// If both conditions are true, we override form submission
// and save the service using provided configuration.
// 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
)
{
if
(
formValid
)
{
delay
(()
=>
{
delay
(()
=>
{
this
.
$form
.
trigger
(
'
submit
'
);
this
.
$form
.
submit
(
);
},
100
);
},
100
);
}
else
{
}
else
{
eventHub
.
$emit
(
'
validateForm
'
);
eventHub
.
$emit
(
'
validateForm
'
);
...
@@ -65,9 +63,8 @@ export default class IntegrationSettingsForm {
...
@@ -65,9 +63,8 @@ export default class IntegrationSettingsForm {
// 2) If this service can be tested
// 2) If this service can be tested
// If both conditions are true, we override form submission
// If both conditions are true, we override form submission
// and test the service using provided configuration.
// and test the service using provided configuration.
if
(
this
.
$form
.
get
(
0
).
checkValidity
())
{
if
(
this
.
$form
.
checkValidity
())
{
// eslint-disable-next-line no-jquery/no-serialize
this
.
testSettings
(
new
FormData
(
this
.
$form
));
this
.
testSettings
(
this
.
$form
.
serialize
());
}
else
{
}
else
{
eventHub
.
$emit
(
'
validateForm
'
);
eventHub
.
$emit
(
'
validateForm
'
);
this
.
vue
.
$store
.
dispatch
(
'
setIsTesting
'
,
false
);
this
.
vue
.
$store
.
dispatch
(
'
setIsTesting
'
,
false
);
...
@@ -79,9 +76,9 @@ export default class IntegrationSettingsForm {
...
@@ -79,9 +76,9 @@ export default class IntegrationSettingsForm {
*/
*/
toggleServiceState
()
{
toggleServiceState
()
{
if
(
this
.
formActive
)
{
if
(
this
.
formActive
)
{
this
.
$form
.
removeAttr
(
'
novalidate
'
);
this
.
$form
.
removeAttr
ibute
(
'
novalidate
'
);
}
else
if
(
!
this
.
$form
.
attr
(
'
novalidate
'
))
{
}
else
if
(
!
this
.
$form
.
getAttribute
(
'
novalidate
'
))
{
this
.
$form
.
attr
(
'
novalidate
'
,
'
novalidate
'
);
this
.
$form
.
setAttribute
(
'
novalidate
'
,
'
novalidate
'
);
}
}
}
}
...
...
spec/frontend/integrations/integration_settings_form_spec.js
View file @
5e721595
...
@@ -23,7 +23,7 @@ describe('IntegrationSettingsForm', () => {
...
@@ -23,7 +23,7 @@ describe('IntegrationSettingsForm', () => {
it
(
'
should initialize form element refs on class object
'
,
()
=>
{
it
(
'
should initialize form element refs on class object
'
,
()
=>
{
// Form Reference
// Form Reference
expect
(
integrationSettingsForm
.
$form
).
toBeDefined
();
expect
(
integrationSettingsForm
.
$form
).
toBeDefined
();
expect
(
integrationSettingsForm
.
$form
.
prop
(
'
nodeName
'
)).
toEqual
(
'
FORM
'
);
expect
(
integrationSettingsForm
.
$form
.
nodeName
).
toBe
(
'
FORM
'
);
expect
(
integrationSettingsForm
.
formActive
).
toBeDefined
();
expect
(
integrationSettingsForm
.
formActive
).
toBeDefined
();
});
});
...
@@ -43,14 +43,14 @@ describe('IntegrationSettingsForm', () => {
...
@@ -43,14 +43,14 @@ describe('IntegrationSettingsForm', () => {
integrationSettingsForm
.
formActive
=
true
;
integrationSettingsForm
.
formActive
=
true
;
integrationSettingsForm
.
toggleServiceState
();
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`
'
,
()
=>
{
it
(
'
should set `novalidate` attribute to form when called with `false`
'
,
()
=>
{
integrationSettingsForm
.
formActive
=
false
;
integrationSettingsForm
.
formActive
=
false
;
integrationSettingsForm
.
toggleServiceState
();
integrationSettingsForm
.
toggleServiceState
();
expect
(
integrationSettingsForm
.
$form
.
attr
(
'
novalidate
'
)).
toBeDefined
();
expect
(
integrationSettingsForm
.
$form
.
getAttribute
(
'
novalidate
'
)).
toBeDefined
();
});
});
});
});
...
@@ -67,8 +67,7 @@ describe('IntegrationSettingsForm', () => {
...
@@ -67,8 +67,7 @@ describe('IntegrationSettingsForm', () => {
integrationSettingsForm
=
new
IntegrationSettingsForm
(
'
.js-integration-settings-form
'
);
integrationSettingsForm
=
new
IntegrationSettingsForm
(
'
.js-integration-settings-form
'
);
integrationSettingsForm
.
init
();
integrationSettingsForm
.
init
();
// eslint-disable-next-line no-jquery/no-serialize
formData
=
new
FormData
(
integrationSettingsForm
.
$form
);
formData
=
integrationSettingsForm
.
$form
.
serialize
();
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
...
@@ -145,8 +144,7 @@ describe('IntegrationSettingsForm', () => {
...
@@ -145,8 +144,7 @@ describe('IntegrationSettingsForm', () => {
integrationSettingsForm
=
new
IntegrationSettingsForm
(
'
.js-integration-settings-form
'
);
integrationSettingsForm
=
new
IntegrationSettingsForm
(
'
.js-integration-settings-form
'
);
integrationSettingsForm
.
init
();
integrationSettingsForm
.
init
();
// eslint-disable-next-line no-jquery/no-serialize
formData
=
new
FormData
(
integrationSettingsForm
.
$form
);
formData
=
integrationSettingsForm
.
$form
.
serialize
();
});
});
afterEach
(()
=>
{
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