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 470
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
84472e1
commit e70e78c
Showing
17 changed files
with
413 additions
and
128 deletions.
There are no files selected for viewing
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
22 changes: 22 additions & 0 deletions
22
app/assets/javascripts/modules/webhooks/components/edit-webhook-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,22 @@ | ||
import BaseComponent from '~/base/component'; | ||
|
||
const WEBHOOK_FORM_FIELDS = 'input.form-control, textarea'; | ||
|
||
// EditWebhookForm component refers to the webhook form | ||
class EditWebhookForm extends BaseComponent { | ||
elements() { | ||
this.$fields = this.$el.find(WEBHOOK_FORM_FIELDS); | ||
} | ||
|
||
toggle() { | ||
this.$el.toggle(); | ||
|
||
const visible = this.$el.is(':visible'); | ||
|
||
if (visible) { | ||
this.$fields.first().focus(); | ||
} | ||
} | ||
} | ||
|
||
export default EditWebhookForm; |
25 changes: 25 additions & 0 deletions
25
app/assets/javascripts/modules/webhooks/components/new-webhook-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 = 'input.form-control, textarea'; | ||
|
||
// NewWebhookForm component refers to the new webhook form | ||
class NewWebhookForm 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 NewWebhookForm; |
34 changes: 34 additions & 0 deletions
34
app/assets/javascripts/modules/webhooks/components/webhook-details.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,34 @@ | ||
import BaseComponent from '~/base/component'; | ||
|
||
import EditWebhookForm from './edit-webhook-form'; | ||
|
||
const TOGGLE_LINK = '.edit-webhook-link'; | ||
const EDIT_WEBHOOK_FORM = '.edit-webhook-form'; | ||
const WEBHOOK_INFORMATION = '.webhook_information'; | ||
|
||
// WebhooksDetails component handles details panel | ||
// and edit webhook form | ||
class WebhooksDetails extends BaseComponent { | ||
elements() { | ||
this.$toggle = this.$el.find(TOGGLE_LINK); | ||
this.$form = this.$el.find(EDIT_WEBHOOK_FORM); | ||
this.$webhookInformation = this.$el.find(WEBHOOK_INFORMATION); | ||
} | ||
|
||
events() { | ||
this.$toggle.on('click', () => this.onEditClick()); | ||
} | ||
|
||
mount() { | ||
this.form = new EditWebhookForm(this.$form); | ||
} | ||
|
||
onEditClick() { | ||
this.$webhookInformation.toggle(); | ||
this.form.toggle(); | ||
|
||
layout_resizer(); | ||
} | ||
} | ||
|
||
export default WebhooksDetails; |
35 changes: 35 additions & 0 deletions
35
app/assets/javascripts/modules/webhooks/components/webhooks-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 NewWebhookForm from './new-webhook-form'; | ||
|
||
const TOGGLE_LINK = '#add_webhook_btn'; | ||
const TOGGLE_LINK_ICON = `${TOGGLE_LINK} i`; | ||
const NEW_WEBHOOK_FORM = '#add_webhook_form'; | ||
|
||
// WebhooksPanel component that lists normal webhook | ||
// and contains new webhook form. | ||
class WebhooksPanel 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_FORM); | ||
} | ||
|
||
events() { | ||
this.$el.on('click', TOGGLE_LINK, e => this.onToggleLinkClick(e)); | ||
} | ||
|
||
mount() { | ||
this.newForm = new NewWebhookForm(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 WebhooksPanel; |
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,20 @@ | ||
import WebhookShowPage from './pages/show'; | ||
import WebhooksIndexPage from './pages/index'; | ||
|
||
const WEBHOOK_SHOW_ROUTE = 'webhooks/show'; | ||
const WEBHOOK_INDEX_ROUTE = 'webhooks/index'; | ||
|
||
$(() => { | ||
const $body = $('body'); | ||
const route = $body.data('route'); | ||
|
||
if (route === WEBHOOK_SHOW_ROUTE) { | ||
// eslint-disable-next-line | ||
new WebhookShowPage($body); | ||
} | ||
|
||
if (route === WEBHOOK_INDEX_ROUTE) { | ||
// eslint-disable-next-line | ||
new WebhooksIndexPage($body); | ||
} | ||
}); |
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,20 @@ | ||
import BaseComponent from '~/base/component'; | ||
|
||
import WebhooksPanel from '../components/webhooks-panel'; | ||
|
||
const WEBHOOKS_PANEL = '.webhooks-wrapper'; | ||
|
||
// WebhooksIndexPage component responsible to instantiate | ||
// the namespace's webhooks index page components and | ||
// handle interactions. | ||
class WebhooksIndexPage extends BaseComponent { | ||
elements() { | ||
this.$webhooksPanel = this.$el.find(WEBHOOKS_PANEL); | ||
} | ||
|
||
mount() { | ||
this.webhooksPanel = new WebhooksPanel(this.$webhooksPanel); | ||
} | ||
} | ||
|
||
export default WebhooksIndexPage; |
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,19 @@ | ||
import BaseComponent from '~/base/component'; | ||
|
||
import WebhookDetails from '../components/webhook-details'; | ||
|
||
const WEBHOOK_DETAILS = '.webhook-details'; | ||
|
||
// WebhookShowPage component responsible to instantiate | ||
// the user's edit page components and handle interactions. | ||
class WebhookShowPage extends BaseComponent { | ||
elements() { | ||
this.$details = this.$el.find(WEBHOOK_DETAILS); | ||
} | ||
|
||
mount() { | ||
this.details = new WebhookDetails(this.$details); | ||
} | ||
} | ||
|
||
export default WebhookShowPage; |
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.errors.any? %> | ||
$('#alert p').html("<%= escape_javascript(@webhook.errors.full_messages.join('<br/>')) %>"); | ||
$('#alert').fadeIn(); | ||
$('#float-alert p').html("<%= escape_javascript(@webhook.errors.full_messages.join('<br/>')) %>"); | ||
$('#float-alert').fadeIn(setTimeOutAlertDelay()); | ||
<% else %> | ||
$("#webhook_<%= @webhook.id %>").remove(); | ||
$('#alert p').html("Webhook '<%= @webhook.host %>' has been removed successfully"); | ||
$('#alert').fadeIn(); | ||
$('#float-alert p').html("Webhook '<%= @webhook.host %>' has been removed successfully"); | ||
$('#float-alert').fadeIn(setTimeOutAlertDelay()); | ||
<% end %> |
Oops, something went wrong.