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(), router: service(),
availableEvents: null, availableEvents: null,
buttonText: 'Save',
successText: 'Saved',
confirm() {}, confirm() {},
@ -24,6 +26,13 @@ export default ModalComponent.extend({
]; ];
}, },
didReceiveAttrs() {
if (this.webhook.isNew) {
this.set('buttonText', 'Create');
this.set('successText', 'Created');
}
},
actions: { actions: {
selectEvent(value) { selectEvent(value) {
this.webhook.set('event', value); this.webhook.set('event', value);
@ -31,11 +40,11 @@ export default ModalComponent.extend({
}, },
confirm() { confirm() {
this.createWebhook.perform(); this.saveWebhook.perform();
} }
}, },
createWebhook: task(function* () { saveWebhook: task(function* () {
try { try {
let webhook = yield this.confirm(); let webhook = yield this.confirm();
let integration = yield webhook.get('integration'); 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> <h1>New webhook</h1>
</header> </header>
<button class="close" href="" title="Close" {{action "closeModal"}}>{{svg-jar "close"}}</button> <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"> <button {{action "closeModal"}} class="gh-btn" data-test-button="cancel-new-webhook">
<span>Cancel</span> <span>Cancel</span>
</button> </button>
{{gh-task-button "Create" {{gh-task-button buttonText
successText="Created" successText=successText
task=createWebhook task=saveWebhook
class="gh-btn gh-btn-green gh-btn-icon" class="gh-btn gh-btn-green gh-btn-icon"
data-test-button="create-webhook"}} data-test-button="save-webhook"}}
</div> </div>

View file

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

View file

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