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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
f5f20274
Commit
f5f20274
authored
May 25, 2017
by
kushalpandya
Committed by
Jarka Kadlecova
Jun 01, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Integrations Bundle
parent
338a73ec
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
106 additions
and
0 deletions
+106
-0
app/assets/javascripts/integrations/index.js
app/assets/javascripts/integrations/index.js
+6
-0
app/assets/javascripts/integrations/integration_settings_form.js
...ets/javascripts/integrations/integration_settings_form.js
+100
-0
No files found.
app/assets/javascripts/integrations/index.js
0 → 100644
View file @
f5f20274
/* eslint-disable no-new */
import
IntegrationSettingsForm
from
'
./integration_settings_form
'
;
$
(()
=>
{
new
IntegrationSettingsForm
(
'
.js-integration-settings-from
'
);
});
app/assets/javascripts/integrations/integration_settings_form.js
0 → 100644
View file @
f5f20274
/* global Flash */
export
default
class
IntegrationSettingsForm
{
constructor
(
formSelector
)
{
this
.
$form
=
$
(
formSelector
);
// Form Metadata
this
.
endPoint
=
this
.
$form
.
attr
(
'
action
'
);
// Form Child Elements
this
.
$serviceToggle
=
this
.
$form
.
find
(
'
#service_active
'
);
this
.
$submitBtn
=
this
.
$form
.
find
(
'
button[type="submit"]
'
);
this
.
$submitBtnLoader
=
this
.
$submitBtn
.
find
(
'
.js-btn-spinner
'
);
this
.
$submitBtnLabel
=
this
.
$submitBtn
.
find
(
'
.js-btn-label
'
);
// Class Member methods
this
.
handleServiceToggle
=
this
.
handleServiceToggle
.
bind
(
this
);
this
.
handleSettingsSave
=
this
.
handleSettingsSave
.
bind
(
this
);
this
.
init
();
}
init
()
{
// Initialize View
this
.
toggleSubmitBtnLabel
(
this
.
$serviceToggle
.
is
(
'
:checked
'
));
// Bind Event Listeners
this
.
$serviceToggle
.
on
(
'
change
'
,
this
.
handleServiceToggle
);
this
.
$submitBtn
.
on
(
'
click
'
,
this
.
handleSettingsSave
);
}
handleSettingsSave
(
e
)
{
if
(
this
.
$serviceToggle
.
is
(
'
:checked
'
))
{
e
.
preventDefault
();
this
.
testSettings
(
this
.
$form
.
serialize
());
}
}
handleServiceToggle
(
e
)
{
this
.
toggleSubmitBtnLabel
(
$
(
e
.
currentTarget
).
is
(
'
:checked
'
));
}
/**
* Toggle Submit button label based on Integration status
*/
toggleSubmitBtnLabel
(
serviceActive
)
{
this
.
$submitBtnLabel
.
text
(
serviceActive
?
'
Test settings and save changes
'
:
'
Save changes
'
);
}
/**
* Toggle Submit button state based on provided boolean value of `saveTestActive`
* When enabled, it does two things, and reverts back when disabled
*
* 1. It shows load spinner on submit button
* 2. Makes submit button disabled
*/
toggleSubmitBtnState
(
saveTestActive
)
{
if
(
saveTestActive
)
{
this
.
$submitBtn
.
disable
();
this
.
$submitBtnLoader
.
removeClass
(
'
hidden
'
);
}
else
{
this
.
$submitBtn
.
enable
();
this
.
$submitBtnLoader
.
addClass
(
'
hidden
'
);
}
}
/* eslint-disable promise/catch-or-return, no-new */
/**
* Test Integration config
*/
testSettings
(
formData
)
{
this
.
toggleSubmitBtnState
(
true
);
$
.
ajax
({
type
:
'
PUT
'
,
url
:
`
${
this
.
endPoint
}
/test`
,
data
:
formData
,
})
.
done
((
res
)
=>
{
if
(
res
.
error
)
{
new
Flash
(
`
${
res
.
message
}
.`
,
null
,
null
,
{
title
:
'
Save anyway
'
,
clickHandler
:
()
=>
{
this
.
$form
.
submit
();
},
});
}
else
{
this
.
$form
.
submit
();
}
})
.
fail
(()
=>
{
new
Flash
(
'
Something went wrong on our end.
'
);
})
.
always
(()
=>
{
this
.
toggleSubmitBtnState
(
false
);
});
}
}
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