A platform for community discussion. Free, open, simple.
FIX: Remote themes Github link should go to custom branch #9184
Vinoth Kannan48d690ae01e6
diff --git a/app/assets/javascripts/admin/controllers/admin-customize-themes-show.js b/app/assets/javascripts/admin/controllers/admin-customize-themes-show.jsindex a8e25fdec98..006f1728da0 100644--- a/app/assets/javascripts/admin/controllers/admin-customize-themes-show.js+++ b/app/assets/javascripts/admin/controllers/admin-customize-themes-show.js@@ -203,6 +203,17 @@ export default Controller.extend({);},sourceIsHttp: match("model.remote_theme.remote_url", /^http(s)?:\/\//),++ @discourseComputed(+ "model.remote_theme.remote_url",+ "model.remote_theme.branch"+ )+ remoteThemeLink(remoteThemeUrl, remoteThemeBranch) {+ return remoteThemeBranch+ ? `${remoteThemeUrl.replace(/\.git$/, "")}/tree/${remoteThemeBranch}`+ : remoteThemeUrl;+ },+actions: {updateToLatest() {this.set("updatingRemote", true);diff --git a/app/assets/javascripts/admin/templates/customize-themes-show.hbs b/app/assets/javascripts/admin/templates/customize-themes-show.hbsindex b4c4e9a8f46..ed4dcf0eb18 100644--- a/app/assets/javascripts/admin/templates/customize-themes-show.hbs+++ b/app/assets/javascripts/admin/templates/customize-themes-show.hbs@@ -63,7 +63,7 @@{{#if model.remote_theme.remote_url}}{{#if sourceIsHttp}}- <a class="remote-url" href={{model.remote_theme.remote_url}}>{{i18n "admin.customize.theme.source_url"}}{{d-icon "link"}}</a>+ <a class="remote-url" href={{remoteThemeLink}}>{{i18n "admin.customize.theme.source_url"}}{{d-icon "link"}}</a>{{else}}<div class="remote-url"><code>{{model.remote_theme.remote_url}}</code></div>{{/if}}diff --git a/app/serializers/theme_serializer.rb b/app/serializers/theme_serializer.rbindex 0682f694877..7d568904541 100644--- a/app/serializers/theme_serializer.rb+++ b/app/serializers/theme_serializer.rb@@ -47,7 +47,7 @@ class BasicThemeSerializer < ApplicationSerializerendclass RemoteThemeSerializer < ApplicationSerializer- attributes :id, :remote_url, :remote_version, :local_version, :commits_behind,+ attributes :id, :remote_url, :remote_version, :local_version, :commits_behind, :branch,:remote_updated_at, :updated_at, :github_diff_link, :last_error_text, :is_git?,:license_url, :about_url, :authors, :theme_version, :minimum_discourse_version, :maximum_discourse_versiondiff --git a/test/javascripts/admin/controllers/admin-customize-themes-show-test.js.es6 b/test/javascripts/admin/controllers/admin-customize-themes-show-test.js.es6new file mode 100644index 00000000000..10cc64279ec--- /dev/null+++ b/test/javascripts/admin/controllers/admin-customize-themes-show-test.js.es6@@ -0,0 +1,49 @@+import { mapRoutes } from "discourse/mapping-router";+import Theme from "admin/models/theme";++moduleFor("controller:admin-customize-themes-show", {+ beforeEach() {+ this.registry.register("router:main", mapRoutes());+ },+ needs: ["controller:adminUser"]+});++const repoUrl = "https://github.com/discourse/discourse-brand-header.git";+const remoteTheme = Theme.create({+ id: 2,+ default: true,+ name: "default",+ remote_theme: {+ remote_url: repoUrl+ }+});++QUnit.test("can display source url for remote themes", function(assert) {+ const controller = this.subject({+ model: remoteTheme+ });++ assert.deepEqual(+ controller.get("remoteThemeLink"),+ repoUrl,+ "returns theme's repo URL"+ );+});++QUnit.test("can display source url for remote theme branches", function(+ assert+) {+ const branchUrl =+ "https://github.com/discourse/discourse-brand-header/tree/beta";+ remoteTheme["remote_theme"]["branch"] = "beta";++ const controller = this.subject({+ model: remoteTheme+ });++ assert.deepEqual(+ controller.get("remoteThemeLink"),+ branchUrl,+ "returns theme's repo URL to branch"+ );+});