From 2bea70a54781852bd42732faf4945fb38dadc585 Mon Sep 17 00:00:00 2001
From: Vinoth Kannan
+
\ No newline at end of file
+
diff --git a/admin/assets/javascripts/discourse/models/repo.js b/admin/assets/javascripts/discourse/models/repo.js
index c23d9bf3..b5123d27 100644
--- a/admin/assets/javascripts/discourse/models/repo.js
+++ b/admin/assets/javascripts/discourse/models/repo.js
@@ -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,8 +98,12 @@ 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;
}
@@ -103,6 +111,46 @@ export default class Repo {
}
}
+ @cached
+ get nameTitleized() {
+ if (this.plugin) {
+ return this.plugin.nameTitleized;
+ }
+
+ let name = this.name
+ .split(/[-_]/)
+ .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" });
+ }
+
+ 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);
}
diff --git a/admin/assets/javascripts/discourse/templates/update-index.hbs b/admin/assets/javascripts/discourse/templates/update-index.hbs
index 3b0595ab..612086fa 100644
--- a/admin/assets/javascripts/discourse/templates/update-index.hbs
+++ b/admin/assets/javascripts/discourse/templates/update-index.hbs
@@ -1,4 +1,21 @@
-
- {{#if this.officialRepoBadge}}
- {{d-icon
- this.officialRepoBadge
- translatedTitle=this.officialRepoBadgeTitle
- class="check-circle"
- }}
+
- {{@repo.name}}
{{@repo.prettyVersion}}
+ {{format-date @repo.latest.date leaveAgo="true"}}
+
+
+
+
{{#if @repo.checkingStatus}}
{{i18n "admin.docker.checking"}}
{{else if @repo.upToDate}}
{{i18n "admin.docker.up_to_date"}}
{{else}}
-
-{{i18n "admin.docker.new_version_available"}}
-
-
-
-
- {{i18n "admin.docker.update_title"}}
+{{i18n "admin.docker.update_title"}}
+ {{#unless this.outdated}}
+
+ {{/unless}}
+{{i18n "admin.docker.outdated_image_header"}}
@@ -18,25 +35,14 @@
- | {{i18n "admin.docker.repository"}} | -{{i18n "admin.docker.status"}} | +{{i18n "admin.docker.repo.name"}} | +{{i18n "admin.docker.repo.commit_hash"}} | +{{i18n "admin.docker.repo.last_updated"}} | +{{i18n "admin.docker.repo.latest_version"}} | +{{i18n "admin.docker.repo.status"}} | {{#each this.model as |repo|}} diff --git a/app/controllers/docker_manager/admin_controller.rb b/app/controllers/docker_manager/admin_controller.rb index fa4397d1..0dcea311 100644 --- a/app/controllers/docker_manager/admin_controller.rb +++ b/app/controllers/docker_manager/admin_controller.rb @@ -21,6 +21,9 @@ def repos official: Plugin::Metadata::OFFICIAL_PLUGINS.include?(r.name), } + plugin = Discourse.visible_plugins.find { |p| p.path == "#{r.path}/plugin.rb" } + 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/") diff --git a/assets/stylesheets/common/docker-manager.scss b/assets/stylesheets/common/docker-manager.scss index bb32c40f..55c281f8 100644 --- a/assets/stylesheets/common/docker-manager.scss +++ b/assets/stylesheets/common/docker-manager.scss @@ -92,10 +92,6 @@ } } - #upgrade-all { - float: right; - } - #banner { margin: 1rem 0; @@ -147,4 +143,67 @@ } } } + + .repo__name { + font-weight: bold; + } + + .repo__author { + font-size: var(--font-down-2); + padding: 0 0 .25em 0; + } + + .repo__new-version { + font-size: var(--font-down-1); + font-weight: bold; + padding: .25em 0 0 0; + } + + .repo__about { + padding: .25em 0 .25em 0; + + a { + color: var(--primary-700); + text-decoration: underline; + } + } + + ul.repo__latest-version { + list-style: none; + margin: 0; + } + + tr.repo { + td { + padding: 1em 0; + } + + &.new-version { + background-color: var(--tertiary-very-low); + + td:first-child { + border-left: solid 3px var(--tertiary); + } + } + + td.repo__status { + text-align: right; + padding-right: 0.5em; + } + } + + .updates-heading { + display: flex; + justify-content: space-between; + margin: 2em 0; + + h3 { + line-height: 40px; + margin-bottom: 0; + } + } + + .admin-repos th:last-child { + text-align: center; + } } diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 64845906..b057366b 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -36,8 +36,14 @@ en: update_repo: "Update %{name}" update_successful: "Update completed successfully!" update_tab: "Update Discourse" - update_title: "Update Discourse" + update_title: "Updates" updating: "Updating…" + repo: + name: "Name" + commit_hash: "Commit Hash" + last_updated: "Last Updated" + latest_version: "Latest Version" + status: "Status" logs: staff_actions: From dfb3f8f56178afd42877ddca9439cfd01117d516 Mon Sep 17 00:00:00 2001 From: Vinoth Kannan
{{#if @repo.linkUrl}}
-
+
{{@repo.nameTitleized}}
{{else}}
@@ -22,11 +18,7 @@
{{@repo.plugin.about}}
{{#if @repo.linkUrl}}
-
+
{{i18n "admin.plugins.learn_more"}}
{{/if}}
@@ -77,4 +69,4 @@
/>
{{/if}}
|
-
+
\ No newline at end of file
diff --git a/admin/assets/javascripts/discourse/models/repo.js b/admin/assets/javascripts/discourse/models/repo.js
index b5123d27..c3c540e1 100644
--- a/admin/assets/javascripts/discourse/models/repo.js
+++ b/admin/assets/javascripts/discourse/models/repo.js
@@ -118,11 +118,11 @@ export default class Repo {
}
let name = this.name
- .split(/[-_]/)
- .map((word) => {
- return capitalize(word);
- })
- .join(" ");
+ .split(/[-_]/)
+ .map((word) => {
+ return capitalize(word);
+ })
+ .join(" ");
// Cuts down on repetition.
const discoursePrefix = "Discourse ";
From 8750082a12216cf4972831ba34746fb45ccae5d0 Mon Sep 17 00:00:00 2001
From: Vinoth Kannan - - {{@repo.prettyVersion}} - + {{commit-url + "current" + @repo.version + @repo.prettyVersion + @repo.url + }} | {{format-date @repo.latest.date leaveAgo="true"}} |
|
-
\ No newline at end of file
+
diff --git a/admin/assets/javascripts/discourse/helpers/commit-url.js b/admin/assets/javascripts/discourse/helpers/commit-url.js
new file mode 100644
index 00000000..c561e6b1
--- /dev/null
+++ b/admin/assets/javascripts/discourse/helpers/commit-url.js
@@ -0,0 +1,19 @@
+import { helper as buildHelper } from "@ember/component/helper";
+import { htmlSafe } from "@ember/template";
+
+export default buildHelper(function (params) {
+ const [_class, version, prettyVersion, url] = params;
+
+ if (!prettyVersion) {
+ return "";
+ }
+
+ if (!url) {
+ return prettyVersion;
+ }
+
+ const _url = url.substr(0, url.search(/(\.git)?$/));
+ const description = `${prettyVersion}`;
+
+ return new htmlSafe(description);
+});
diff --git a/assets/stylesheets/common/docker-manager.scss b/assets/stylesheets/common/docker-manager.scss
index 259ddc05..e5dccdf5 100644
--- a/assets/stylesheets/common/docker-manager.scss
+++ b/assets/stylesheets/common/docker-manager.scss
@@ -73,7 +73,7 @@
}
}
- span.commit-hash {
+ .commit-hash {
color: #959595;
}
---|