This repository has been archived by the owner on Apr 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 474
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e70e78c
commit 0428092
Showing
9 changed files
with
207 additions
and
73 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
app/assets/javascripts/modules/webhooks/components/new-webhook-header-form.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import BaseComponent from '~/base/component'; | ||
|
||
const WEBHOOK_FORM_FIELDS = '.form-control'; | ||
|
||
// NewWebhookHeaderForm component refers to the new webhook header form | ||
class NewWebhookHeaderForm extends BaseComponent { | ||
elements() { | ||
this.$fields = this.$el.find(WEBHOOK_FORM_FIELDS); | ||
} | ||
|
||
toggle() { | ||
this.$el.toggle(400, 'swing', () => { | ||
const visible = this.$el.is(':visible'); | ||
|
||
if (visible) { | ||
this.$fields.first().focus(); | ||
} | ||
|
||
this.$fields.val(''); | ||
layout_resizer(); | ||
}); | ||
} | ||
} | ||
|
||
export default NewWebhookHeaderForm; |
35 changes: 35 additions & 0 deletions
35
app/assets/javascripts/modules/webhooks/components/webhook-headers-panel.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import BaseComponent from '~/base/component'; | ||
|
||
import NewWebhookHeaderForm from './new-webhook-header-form'; | ||
|
||
const TOGGLE_LINK = '#add_webhook_header_btn'; | ||
const TOGGLE_LINK_ICON = `${TOGGLE_LINK} i`; | ||
const NEW_WEBHOOK_HEADER_FORM = '#add_webhook_header_form'; | ||
|
||
// WebhookHeadersPanel component that lists webhook headers | ||
// and contains new webhook header form. | ||
class WebhookHeadersPanel extends BaseComponent { | ||
elements() { | ||
this.$toggle = this.$el.find(TOGGLE_LINK); | ||
this.$toggleIcon = this.$el.find(TOGGLE_LINK_ICON); | ||
this.$form = this.$el.find(NEW_WEBHOOK_HEADER_FORM); | ||
} | ||
|
||
events() { | ||
this.$el.on('click', TOGGLE_LINK, e => this.onToggleLinkClick(e)); | ||
} | ||
|
||
mount() { | ||
this.newForm = new NewWebhookHeaderForm(this.$form); | ||
} | ||
|
||
onToggleLinkClick() { | ||
const wasVisible = this.$form.is(':visible'); | ||
|
||
this.newForm.toggle(); | ||
this.$toggleIcon.toggleClass('fa-minus-circle', !wasVisible); | ||
this.$toggleIcon.toggleClass('fa-plus-circle', wasVisible); | ||
} | ||
} | ||
|
||
export default WebhookHeadersPanel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
<% if @webhook_header.errors.any? %> | ||
$('#alert p').html("<%= escape_javascript(@webhook_header.errors.full_messages.join('<br/>')) %>"); | ||
$('#alert').fadeIn(); | ||
$('#float-alert p').html("<%= escape_javascript(@webhook_header.errors.full_messages.join('<br/>')) %>"); | ||
$('#float-alert').fadeIn(setTimeOutAlertDelay()); | ||
<% else %> | ||
$("#webhook_header_<%= @webhook_header.id %>").remove(); | ||
$('#alert p').html("Header '<%= @webhook_header.name %>' was removed successfully"); | ||
$('#alert').fadeIn(); | ||
$('#float-alert p').html("Header '<%= @webhook_header.name %>' was removed successfully"); | ||
$('#float-alert').fadeIn(setTimeOutAlertDelay()); | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters