0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Changed "new-webhook" modal to generic "webhook-form" modal

no issue
- the webhook form needs to be re-usable for the "edit webhook" modal
- renamed modal
- added logic to adjust the confirm button's text depending on the state of the passed in webhook model
This commit is contained in:
Kevin Ansfield 2018-10-18 18:43:34 +01:00
parent 18c75ac670
commit 9684e5e347
4 changed files with 18 additions and 9 deletions

View file

@ -10,6 +10,8 @@ export default ModalComponent.extend({
router: service(),
availableEvents: null,
buttonText: 'Save',
successText: 'Saved',
confirm() {},
@ -24,6 +26,13 @@ export default ModalComponent.extend({
];
},
didReceiveAttrs() {
if (this.webhook.isNew) {
this.set('buttonText', 'Create');
this.set('successText', 'Created');
}
},
actions: {
selectEvent(value) {
this.webhook.set('event', value);
@ -31,11 +40,11 @@ export default ModalComponent.extend({
},
confirm() {
this.createWebhook.perform();
this.saveWebhook.perform();
}
},
createWebhook: task(function* () {
saveWebhook: task(function* () {
try {
let webhook = yield this.confirm();
let integration = yield webhook.get('integration');

View file

@ -1,4 +1,4 @@
<header class="modal-header" data-test-modal="new-webhook">
<header class="modal-header" data-test-modal="webhook-form">
<h1>New webhook</h1>
</header>
<button class="close" href="" title="Close" {{action "closeModal"}}>{{svg-jar "close"}}</button>
@ -84,9 +84,9 @@
<button {{action "closeModal"}} class="gh-btn" data-test-button="cancel-new-webhook">
<span>Cancel</span>
</button>
{{gh-task-button "Create"
successText="Created"
task=createWebhook
{{gh-task-button buttonText
successText=successText
task=saveWebhook
class="gh-btn gh-btn-green gh-btn-icon"
data-test-button="create-webhook"}}
data-test-button="save-webhook"}}
</div>

View file

@ -1,4 +1,4 @@
{{gh-fullscreen-modal "new-webhook"
{{gh-fullscreen-modal "webhook-form"
model=webhook
confirm=(action "save")
close=(action "cancel")

View file

@ -50,7 +50,7 @@ export default function mockWebhooks(server) {
if (webhooks.findBy({targetUrl: attrs.targetUrl, event: attrs.event})) {
errors.push({
errorType: 'ValidationError',
message: 'Target URL has already used for this event',
message: 'Target URL has already been used for this event',
property: 'target_url'
});
}