-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UX: improve UI of software update page & display more info. #214
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,72 @@ | ||
<tr> | ||
<tr class="repo {{if @repo.hasNewVersion 'new-version'}}"> | ||
<td> | ||
{{#if this.officialRepoBadge}} | ||
{{d-icon | ||
this.officialRepoBadge | ||
translatedTitle=this.officialRepoBadgeTitle | ||
class="check-circle" | ||
}} | ||
<div class="repo__name"> | ||
{{#if @repo.linkUrl}} | ||
<a href={{@repo.linkUrl}} rel="noopener noreferrer" target="_blank"> | ||
{{@repo.nameTitleized}} | ||
</a> | ||
{{else}} | ||
{{@repo.nameTitleized}} | ||
{{/if}} | ||
</div> | ||
{{#if @repo.author}} | ||
<div class="repo__author"> | ||
{{@repo.author}} | ||
</div> | ||
{{/if}} | ||
{{#if @repo.plugin}} | ||
<div class="repo__about"> | ||
{{@repo.plugin.about}} | ||
{{#if @repo.linkUrl}} | ||
<a href={{@repo.linkUrl}} rel="noopener noreferrer" target="_blank"> | ||
{{i18n "admin.plugins.learn_more"}} | ||
</a> | ||
{{/if}} | ||
</div> | ||
{{/if}} | ||
{{#if @repo.hasNewVersion}} | ||
<div class="repo__new-version"> | ||
{{i18n "admin.docker.new_version_available"}} | ||
</div> | ||
{{/if}} | ||
</td> | ||
|
||
<td> | ||
<a href={{@repo.url}}>{{@repo.name}}</a> | ||
<span class="current commit-hash" title={{@repo.version}}> | ||
{{@repo.prettyVersion}} | ||
</span> | ||
</td> | ||
|
||
<td>{{format-date @repo.latest.date leaveAgo="true"}}</td> | ||
<td> | ||
<ul class="repo__latest-version"> | ||
<li> | ||
<span class="new commit-hash" title={{@repo.latestVersion}}> | ||
{{@repo.prettyLatestVersion}} | ||
</span> | ||
</li> | ||
<li class="new-commits"> | ||
{{new-commits | ||
@repo.latest.commits_behind | ||
@repo.version | ||
@repo.latest.version | ||
@repo.url | ||
}} | ||
</li> | ||
</ul> | ||
</td> | ||
<td class="repo__status"> | ||
{{#if @repo.checkingStatus}} | ||
{{i18n "admin.docker.checking"}} | ||
{{else if @repo.upToDate}} | ||
{{i18n "admin.docker.up_to_date"}} | ||
{{else}} | ||
<div class="new-version"> | ||
<h4>{{i18n "admin.docker.new_version_available"}}</h4> | ||
|
||
<ul> | ||
<li> | ||
{{i18n "admin.docker.latest_version"}} | ||
<span class="new commit-hash" title={{@repo.latestVersion}}> | ||
{{@repo.prettyLatestVersion}} | ||
</span> | ||
</li> | ||
<li> | ||
{{i18n "admin.docker.last_updated"}} | ||
{{#if @repo.latest.date}} | ||
{{format-date @repo.latest.date}} | ||
{{else}} | ||
— | ||
{{/if}} | ||
</li> | ||
<li class="new-commits"> | ||
{{new-commits | ||
@repo.latest.commits_behind | ||
@repo.version | ||
@repo.latest.version | ||
@repo.url | ||
}} | ||
</li> | ||
</ul> | ||
|
||
<DButton | ||
@action={{this.upgrade}} | ||
@disabled={{this.upgradeDisabled}} | ||
@translatedLabel={{this.upgradeButtonLabel}} | ||
class="upgrade-button" | ||
/> | ||
</div> | ||
<DButton | ||
@action={{this.upgrade}} | ||
@disabled={{this.upgradeDisabled}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another note that all of this |
||
@translatedLabel={{this.upgradeButtonLabel}} | ||
class="upgrade-button" | ||
/> | ||
{{/if}} | ||
</td> | ||
</tr> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
import { tracked } from "@glimmer/tracking"; | ||
import { cached, tracked } from "@glimmer/tracking"; | ||
import { capitalize } from "@ember/string"; | ||
import { TrackedObject } from "@ember-compat/tracked-built-ins"; | ||
import { ajax } from "discourse/lib/ajax"; | ||
import I18n from "discourse-i18n"; | ||
import AdminPlugin from "admin/models/admin-plugin"; | ||
|
||
let loaded = []; | ||
export let needsImageUpgrade = false; | ||
|
@@ -74,6 +77,7 @@ export default class Repo { | |
@tracked checking = false; | ||
@tracked lastCheckedAt = null; | ||
@tracked latest = new TrackedObject({}); | ||
@tracked plugin = null; | ||
|
||
// model attributes | ||
@tracked name = null; | ||
|
@@ -94,15 +98,59 @@ export default class Repo { | |
} | ||
} | ||
|
||
if (attributes.plugin) { | ||
this.plugin = AdminPlugin.create(attributes.plugin); | ||
} | ||
|
||
for (const [key, value] of Object.entries(attributes)) { | ||
if (key === "latest") { | ||
if (["latest", "plugin"].includes(key)) { | ||
continue; | ||
} | ||
|
||
this[key] = value; | ||
} | ||
} | ||
|
||
@cached | ||
get nameTitleized() { | ||
if (this.plugin) { | ||
return this.plugin.nameTitleized; | ||
} | ||
|
||
let name = this.name | ||
.split(/[-_]/) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm just wondering why you need this other stuff? Everything on this page is either Discourse or a plugin isn't it? |
||
.map((word) => { | ||
return capitalize(word); | ||
}) | ||
.join(" "); | ||
|
||
// Cuts down on repetition. | ||
const discoursePrefix = "Discourse "; | ||
if (name.startsWith(discoursePrefix)) { | ||
name = name.slice(discoursePrefix.length); | ||
} | ||
|
||
return name; | ||
} | ||
|
||
get linkUrl() { | ||
if (this.plugin) { | ||
return this.plugin.linkUrl; | ||
} | ||
|
||
return this.url; | ||
} | ||
|
||
get author() { | ||
if (this.plugin) { | ||
return this.plugin.author; | ||
} else if (this.name === "docker_manager") { | ||
return I18n.t("admin.plugins.author", { author: "Discourse" }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is unnecessary -- docker_manager is an official plugin owned by us, so it should do this by default with |
||
} | ||
|
||
return null; | ||
} | ||
|
||
get checkingStatus() { | ||
return this.unloaded || this.checking; | ||
} | ||
|
@@ -111,6 +159,10 @@ export default class Repo { | |
return !this.upgrading && this.version === this.latest?.version; | ||
} | ||
|
||
get hasNewVersion() { | ||
return !this.checkingStatus && !this.upToDate; | ||
} | ||
|
||
get prettyVersion() { | ||
return this.pretty_version || this.version?.substring(0, 8); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,21 @@ | ||
<h1>{{i18n "admin.docker.update_title"}}</h1> | ||
<div class="updates-heading"> | ||
<h3>{{i18n "admin.docker.update_title"}}</h3> | ||
{{#unless this.outdated}} | ||
<button | ||
disabled={{this.upgradeAllButtonDisabled}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not use |
||
id="upgrade-all" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should definitely be changing the code variables and functions from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And CSS classes |
||
class="btn btn-primary" | ||
type="button" | ||
{{on "click" this.upgradeAllButton}} | ||
> | ||
{{#if this.allUpToDate}} | ||
{{i18n "admin.docker.all_up_to_date"}} | ||
{{else}} | ||
{{i18n "admin.docker.update_all"}} | ||
{{/if}} | ||
</button> | ||
{{/unless}} | ||
</div> | ||
|
||
{{#if this.outdated}} | ||
<h2>{{i18n "admin.docker.outdated_image_header"}}</h2> | ||
|
@@ -18,25 +35,14 @@ | |
</a> | ||
</p> | ||
{{else}} | ||
<button | ||
disabled={{this.upgradeAllButtonDisabled}} | ||
id="upgrade-all" | ||
class="btn" | ||
type="button" | ||
{{on "click" this.upgradeAllButton}} | ||
> | ||
{{#if this.allUpToDate}} | ||
{{i18n "admin.docker.all_up_to_date"}} | ||
{{else}} | ||
{{i18n "admin.docker.update_all"}} | ||
{{/if}} | ||
</button> | ||
|
||
<table class="table" id="repos"> | ||
<table class="table admin-repos" id="repos"> | ||
<thead> | ||
<th></th> | ||
<th style="width: 50%">{{i18n "admin.docker.repository"}}</th> | ||
<th>{{i18n "admin.docker.status"}}</th> | ||
<th style="width: 40%">{{i18n "admin.docker.repo.name"}}</th> | ||
<th>{{i18n "admin.docker.repo.commit_hash"}}</th> | ||
<th>{{i18n "admin.docker.repo.last_updated"}}</th> | ||
<th>{{i18n "admin.docker.repo.latest_version"}}</th> | ||
<th align="center">{{i18n "admin.docker.repo.status"}}</th> | ||
</thead> | ||
<tbody> | ||
{{#each this.model as |repo|}} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,13 @@ def repos | |
official: Plugin::Metadata::OFFICIAL_PLUGINS.include?(r.name), | ||
} | ||
|
||
plugin = Discourse.visible_plugins.find { |p| p.path == "#{r.path}/plugin.rb" } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or maybe this is an existing problem -- either way we should account for this. |
||
result[:plugin] = AdminPluginSerializer.new( | ||
plugin, | ||
scope: guardian, | ||
root: false, | ||
) if plugin.present? | ||
|
||
result[:fork] = true if result[:official] && | ||
!r.url.starts_with?("https://github.com/discourse/") | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please convert this component to a
.gjs
component while you are at it?