From 86f3e747991bd10d7a60bfe9f669def876393229 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Mon, 10 Jun 2019 13:24:15 -0400 Subject: [PATCH] DEV: Allow `{{d-button}}` to include a href --- .../discourse/components/d-button.js.es6 | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/discourse/components/d-button.js.es6 b/app/assets/javascripts/discourse/components/d-button.js.es6 index c41ad2a53ee..2665e6e83b0 100644 --- a/app/assets/javascripts/discourse/components/d-button.js.es6 +++ b/app/assets/javascripts/discourse/components/d-button.js.es6 @@ -1,4 +1,5 @@ import { default as computed } from "ember-addons/ember-computed-decorators"; +import DiscourseURL from "discourse/lib/url"; export default Ember.Component.extend({ // subclasses need this @@ -53,12 +54,20 @@ export default Ember.Component.extend({ }, click() { - if (typeof this.action === "string") { - this.sendAction("action", this.actionParam); - } else if (typeof this.action === "object" && this.action.value) { - this.action.value(this.actionParam); - } else if (typeof this.action === "function") { - this.action(this.actionParam); + let { action } = this; + + if (action) { + if (typeof action === "string") { + this.sendAction("action", this.actionParam); + } else if (typeof action === "object" && action.value) { + action.value(this.actionParam); + } else if (typeof this.action === "function") { + action(this.actionParam); + } + } + + if (this.href && this.href.length) { + DiscourseURL.routeTo(this.href); } return false;