FIX: Remote themes Github link should go to custom branch #9184
This commit is contained in:
parent
0b2e6f4301
commit
48d690ae01
|
@ -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);
|
||||
|
|
|
@ -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}}
|
||||
|
|
|
@ -47,7 +47,7 @@ class BasicThemeSerializer < ApplicationSerializer
|
|||
end
|
||||
|
||||
class 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_version
|
||||
|
||||
|
|
|
@ -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"
|
||||
);
|
||||
});
|
Loading…
Reference in New Issue