UX: Don't link to theme source unless it's http(s)

UX: Don’t link to theme source unless it’s http(s)

diff --git a/app/assets/javascripts/admin/controllers/admin-customize-themes-show.js.es6 b/app/assets/javascripts/admin/controllers/admin-customize-themes-show.js.es6
index f572813..b54d1e9 100644
--- a/app/assets/javascripts/admin/controllers/admin-customize-themes-show.js.es6
+++ b/app/assets/javascripts/admin/controllers/admin-customize-themes-show.js.es6
@@ -147,6 +147,10 @@ export default Ember.Controller.extend({
       "scss"
     );
   },
+  sourceIsHttp: Ember.computed.match(
+    "model.remote_theme.remote_url",
+    /^http(s)?:\/\//
+  ),
   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.hbs
index 2a2bfa0..d904f7d 100644
--- a/app/assets/javascripts/admin/templates/customize-themes-show.hbs
+++ b/app/assets/javascripts/admin/templates/customize-themes-show.hbs
@@ -38,7 +38,11 @@
   {{#if model.remote_theme}}
 
     {{#if model.remote_theme.remote_url}}
-      <a class="remote-url" href="{{model.remote_theme.remote_url}}">{{i18n "admin.customize.theme.source_url"}} {{d-icon "link"}}</a>
+      {{#if sourceIsHttp}}
+        <a class="remote-url" href="{{model.remote_theme.remote_url}}">{{i18n "admin.customize.theme.source_url"}} {{d-icon "link"}}</a>
+      {{else}}
+        <div class="remote-url"><code>{{model.remote_theme.remote_url}}</code></div>
+      {{/if}}
     {{/if}}
     {{#if model.remote_theme.about_url}}
     <a class="url about-url" href="{{model.remote_theme.about_url}}">{{i18n "admin.customize.theme.about_theme"}} {{d-icon "link"}}</a>
diff --git a/app/assets/stylesheets/common/admin/customize.scss b/app/assets/stylesheets/common/admin/customize.scss
index 068f144..ccc8eed 100644
--- a/app/assets/stylesheets/common/admin/customize.scss
+++ b/app/assets/stylesheets/common/admin/customize.scss
@@ -140,9 +140,14 @@
       }
     }
 
-    .remote-url,
-    .about-url,
-    .license-url {
+    div.remote-url {
+      font-size: $font-down-1;
+      margin-bottom: 7px;
+    }
+
+    a.remote-url,
+    a.about-url,
+    a.license-url {
       display: inline-block;
       margin-right: 10px;
     }

GitHub sha: e67474da

This commit has been mentioned on Discourse Meta. There might be relevant details there:

You don’t need the parenthesis here :wink: /^https?:\/\// works the same

1 Like