DEV: Clean up the code (#245)
gjs, helper invocation case, typos, latest license template, unnecessary tracking, concatClass, unnecessary service injection, new imports, whitespace, pure function helper, htmlSafe calling convention, this. in template, unused vars in ruby, update linting, qunit-dom
This commit is contained in:
parent
06cc8dba9d
commit
ea174f7e36
67
Gemfile.lock
67
Gemfile.lock
|
@ -1,82 +1,79 @@
|
||||||
GEM
|
GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
activesupport (7.1.3.3)
|
activesupport (7.2.1.1)
|
||||||
base64
|
base64
|
||||||
bigdecimal
|
bigdecimal
|
||||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
concurrent-ruby (~> 1.0, >= 1.3.1)
|
||||||
connection_pool (>= 2.2.5)
|
connection_pool (>= 2.2.5)
|
||||||
drb
|
drb
|
||||||
i18n (>= 1.6, < 2)
|
i18n (>= 1.6, < 2)
|
||||||
|
logger (>= 1.4.2)
|
||||||
minitest (>= 5.1)
|
minitest (>= 5.1)
|
||||||
mutex_m
|
securerandom (>= 0.3)
|
||||||
tzinfo (~> 2.0)
|
tzinfo (~> 2.0, >= 2.0.5)
|
||||||
ast (2.4.2)
|
ast (2.4.2)
|
||||||
base64 (0.2.0)
|
base64 (0.2.0)
|
||||||
bigdecimal (3.1.8)
|
bigdecimal (3.1.8)
|
||||||
concurrent-ruby (1.2.3)
|
concurrent-ruby (1.3.4)
|
||||||
connection_pool (2.4.1)
|
connection_pool (2.4.1)
|
||||||
drb (2.2.1)
|
drb (2.2.1)
|
||||||
i18n (1.14.5)
|
i18n (1.14.6)
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
json (2.7.2)
|
json (2.7.2)
|
||||||
language_server-protocol (3.17.0.3)
|
language_server-protocol (3.17.0.3)
|
||||||
minitest (5.23.1)
|
logger (1.6.1)
|
||||||
mutex_m (0.2.0)
|
minitest (5.25.1)
|
||||||
parallel (1.24.0)
|
parallel (1.26.3)
|
||||||
parser (3.3.1.0)
|
parser (3.3.5.0)
|
||||||
ast (~> 2.4.1)
|
ast (~> 2.4.1)
|
||||||
racc
|
racc
|
||||||
prettier_print (1.2.1)
|
prettier_print (1.2.1)
|
||||||
racc (1.8.0)
|
racc (1.8.1)
|
||||||
rack (3.0.11)
|
rack (3.1.8)
|
||||||
rainbow (3.1.1)
|
rainbow (3.1.1)
|
||||||
regexp_parser (2.9.2)
|
regexp_parser (2.9.2)
|
||||||
rexml (3.3.6)
|
rubocop (1.67.0)
|
||||||
strscan
|
|
||||||
rubocop (1.64.0)
|
|
||||||
json (~> 2.3)
|
json (~> 2.3)
|
||||||
language_server-protocol (>= 3.17.0)
|
language_server-protocol (>= 3.17.0)
|
||||||
parallel (~> 1.10)
|
parallel (~> 1.10)
|
||||||
parser (>= 3.3.0.2)
|
parser (>= 3.3.0.2)
|
||||||
rainbow (>= 2.2.2, < 4.0)
|
rainbow (>= 2.2.2, < 4.0)
|
||||||
regexp_parser (>= 1.8, < 3.0)
|
regexp_parser (>= 2.4, < 3.0)
|
||||||
rexml (>= 3.2.5, < 4.0)
|
rubocop-ast (>= 1.32.2, < 2.0)
|
||||||
rubocop-ast (>= 1.31.1, < 2.0)
|
|
||||||
ruby-progressbar (~> 1.7)
|
ruby-progressbar (~> 1.7)
|
||||||
unicode-display_width (>= 2.4.0, < 3.0)
|
unicode-display_width (>= 2.4.0, < 3.0)
|
||||||
rubocop-ast (1.31.3)
|
rubocop-ast (1.32.3)
|
||||||
parser (>= 3.3.1.0)
|
parser (>= 3.3.1.0)
|
||||||
rubocop-capybara (2.20.0)
|
rubocop-capybara (2.21.0)
|
||||||
rubocop (~> 1.41)
|
rubocop (~> 1.41)
|
||||||
rubocop-discourse (3.8.0)
|
rubocop-discourse (3.8.2)
|
||||||
activesupport (>= 6.1)
|
activesupport (>= 6.1)
|
||||||
rubocop (>= 1.59.0)
|
rubocop (>= 1.59.0)
|
||||||
rubocop-capybara (>= 2.0.0)
|
rubocop-capybara (>= 2.0.0)
|
||||||
rubocop-factory_bot (>= 2.0.0)
|
rubocop-factory_bot (>= 2.0.0)
|
||||||
rubocop-rails (>= 2.25.0)
|
rubocop-rails (>= 2.25.0)
|
||||||
rubocop-rspec (>= 2.25.0)
|
rubocop-rspec (>= 3.0.1)
|
||||||
rubocop-factory_bot (2.25.1)
|
rubocop-rspec_rails (>= 2.30.0)
|
||||||
rubocop (~> 1.41)
|
rubocop-factory_bot (2.26.1)
|
||||||
rubocop-rails (2.25.0)
|
rubocop (~> 1.61)
|
||||||
|
rubocop-rails (2.26.2)
|
||||||
activesupport (>= 4.2.0)
|
activesupport (>= 4.2.0)
|
||||||
rack (>= 1.1)
|
rack (>= 1.1)
|
||||||
rubocop (>= 1.33.0, < 2.0)
|
rubocop (>= 1.52.0, < 2.0)
|
||||||
rubocop-ast (>= 1.31.1, < 2.0)
|
rubocop-ast (>= 1.31.1, < 2.0)
|
||||||
rubocop-rspec (2.29.2)
|
rubocop-rspec (3.1.0)
|
||||||
rubocop (~> 1.40)
|
rubocop (~> 1.61)
|
||||||
rubocop-capybara (~> 2.17)
|
rubocop-rspec_rails (2.30.0)
|
||||||
rubocop-factory_bot (~> 2.22)
|
rubocop (~> 1.61)
|
||||||
rubocop-rspec_rails (~> 2.28)
|
rubocop-rspec (~> 3, >= 3.0.1)
|
||||||
rubocop-rspec_rails (2.28.3)
|
|
||||||
rubocop (~> 1.40)
|
|
||||||
ruby-progressbar (1.13.0)
|
ruby-progressbar (1.13.0)
|
||||||
strscan (3.1.0)
|
securerandom (0.3.1)
|
||||||
syntax_tree (6.2.0)
|
syntax_tree (6.2.0)
|
||||||
prettier_print (>= 1.2.0)
|
prettier_print (>= 1.2.0)
|
||||||
tzinfo (2.0.6)
|
tzinfo (2.0.6)
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
unicode-display_width (2.5.0)
|
unicode-display_width (2.6.0)
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
ruby
|
ruby
|
||||||
|
|
29
LICENSE
29
LICENSE
|
@ -1,20 +1,21 @@
|
||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2014 Civilized Discourse Construction Kit, Inc.
|
Copyright (c) Civilized Discourse Construction Kit, Inc.
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
this software and associated documentation files (the "Software"), to deal in
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
the Software without restriction, including without limitation the rights to
|
in the Software without restriction, including without limitation the rights
|
||||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
subject to the following conditions:
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
The above copyright notice and this permission notice shall be included in
|
||||||
copies or substantial portions of the Software.
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
import Component from "@glimmer/component";
|
||||||
|
import didInsert from "@ember/render-modifiers/modifiers/did-insert";
|
||||||
|
import didUpdate from "@ember/render-modifiers/modifiers/did-update";
|
||||||
|
import { bind } from "discourse-common/utils/decorators";
|
||||||
|
|
||||||
|
export default class Console extends Component {
|
||||||
|
@bind
|
||||||
|
scrollToBottom(element) {
|
||||||
|
if (this.args.followOutput) {
|
||||||
|
element.scrollTop = element.scrollHeight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div
|
||||||
|
class="console-logs"
|
||||||
|
{{didInsert this.scrollToBottom}}
|
||||||
|
{{didUpdate this.scrollToBottom @output}}
|
||||||
|
>
|
||||||
|
{{~@output~}}
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
}
|
|
@ -1,7 +0,0 @@
|
||||||
<div
|
|
||||||
class="console-logs"
|
|
||||||
{{did-insert this.scrollToBottom}}
|
|
||||||
{{did-update this.scrollToBottom @output}}
|
|
||||||
>
|
|
||||||
{{~@output~}}
|
|
||||||
</div>
|
|
|
@ -1,11 +0,0 @@
|
||||||
import Component from "@glimmer/component";
|
|
||||||
import { bind } from "discourse-common/utils/decorators";
|
|
||||||
|
|
||||||
export default class Console extends Component {
|
|
||||||
@bind
|
|
||||||
scrollToBottom(element) {
|
|
||||||
if (this.args.followOutput) {
|
|
||||||
element.scrollTop = element.scrollHeight;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,5 +1,6 @@
|
||||||
import Component from "@glimmer/component";
|
import Component from "@glimmer/component";
|
||||||
import { htmlSafe } from "@ember/template";
|
import { htmlSafe } from "@ember/template";
|
||||||
|
import concatClass from "discourse/helpers/concat-class";
|
||||||
|
|
||||||
export default class ProgressBar extends Component {
|
export default class ProgressBar extends Component {
|
||||||
get active() {
|
get active() {
|
||||||
|
@ -15,4 +16,10 @@ export default class ProgressBar extends Component {
|
||||||
|
|
||||||
return htmlSafe(`width: ${percent}%`);
|
return htmlSafe(`width: ${percent}%`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class={{concatClass "progress-bar" (if this.active "active")}}>
|
||||||
|
<div class="progress-bar-inner" style={{this.barStyle}}></div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
}
|
}
|
|
@ -1,3 +0,0 @@
|
||||||
<div class="progress-bar {{if this.active 'active'}}">
|
|
||||||
<div class="progress-bar-inner" style={{this.barStyle}}></div>
|
|
||||||
</div>
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
import Component from "@glimmer/component";
|
||||||
|
import { LinkTo } from "@ember/routing";
|
||||||
|
import { service } from "@ember/service";
|
||||||
|
import i18n from "discourse-common/helpers/i18n";
|
||||||
|
|
||||||
|
export default class UpgradeNotice extends Component {
|
||||||
|
@service currentUser;
|
||||||
|
|
||||||
|
<template>
|
||||||
|
{{#if this.currentUser.admin}}
|
||||||
|
{{#unless @versionCheck.upToDate}}
|
||||||
|
<div class="upgrades-banner">
|
||||||
|
{{i18n "admin.docker.outdated_notice"}}
|
||||||
|
|
||||||
|
<LinkTo @route="update">
|
||||||
|
{{i18n "admin.docker.perform_update"}}
|
||||||
|
</LinkTo>
|
||||||
|
</div>
|
||||||
|
{{/unless}}
|
||||||
|
{{/if}}
|
||||||
|
</template>
|
||||||
|
}
|
|
@ -1,11 +0,0 @@
|
||||||
{{#if this.currentUser.admin}}
|
|
||||||
{{#unless @versionCheck.upToDate}}
|
|
||||||
<div class="upgrades-banner">
|
|
||||||
{{i18n "admin.docker.outdated_notice"}}
|
|
||||||
|
|
||||||
<LinkTo @route="update">
|
|
||||||
{{i18n "admin.docker.perform_update"}}
|
|
||||||
</LinkTo>
|
|
||||||
</div>
|
|
||||||
{{/unless}}
|
|
||||||
{{/if}}
|
|
|
@ -1,6 +0,0 @@
|
||||||
import Component from "@glimmer/component";
|
|
||||||
import { inject as service } from "@ember/service";
|
|
||||||
|
|
||||||
export default class UpgradeNotice extends Component {
|
|
||||||
@service currentUser;
|
|
||||||
}
|
|
|
@ -1,13 +1,12 @@
|
||||||
import Component from "@glimmer/component";
|
import Component from "@glimmer/component";
|
||||||
import { action } from "@ember/object";
|
import { action } from "@ember/object";
|
||||||
import { inject as service } from "@ember/service";
|
import { service } from "@ember/service";
|
||||||
import DButton from "discourse/components/d-button";
|
import DButton from "discourse/components/d-button";
|
||||||
import FormatDate from "discourse/helpers/format-date";
|
import formatDate from "discourse/helpers/format-date";
|
||||||
import icon from "discourse-common/helpers/d-icon";
|
import icon from "discourse-common/helpers/d-icon";
|
||||||
import i18n from "discourse-common/helpers/i18n";
|
import i18n from "discourse-common/helpers/i18n";
|
||||||
import I18n from "I18n";
|
import commitUrl from "../helpers/commit-url";
|
||||||
import CommitUrl from "../helpers/commit-url";
|
import newCommits from "../helpers/new-commits";
|
||||||
import NewCommits from "../helpers/new-commits";
|
|
||||||
|
|
||||||
export default class RepoStatus extends Component {
|
export default class RepoStatus extends Component {
|
||||||
@service router;
|
@service router;
|
||||||
|
@ -33,9 +32,9 @@ export default class RepoStatus extends Component {
|
||||||
|
|
||||||
get upgradeButtonLabel() {
|
get upgradeButtonLabel() {
|
||||||
if (this.args.repo.upgrading) {
|
if (this.args.repo.upgrading) {
|
||||||
return I18n.t("admin.docker.updating");
|
return i18n("admin.docker.updating");
|
||||||
} else {
|
} else {
|
||||||
return I18n.t("admin.docker.update_action");
|
return i18n("admin.docker.update_action");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,14 +51,17 @@ export default class RepoStatus extends Component {
|
||||||
<div class="d-admin-row__overview-name">
|
<div class="d-admin-row__overview-name">
|
||||||
{{@repo.nameTitleized}}
|
{{@repo.nameTitleized}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{#if @repo.author}}
|
{{#if @repo.author}}
|
||||||
<div class="d-admin-row__overview-author">
|
<div class="d-admin-row__overview-author">
|
||||||
{{@repo.author}}
|
{{@repo.author}}
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{#if @repo.plugin}}
|
{{#if @repo.plugin}}
|
||||||
<div class="d-admin-row__overview-about">
|
<div class="d-admin-row__overview-about">
|
||||||
{{@repo.plugin.about}}
|
{{@repo.plugin.about}}
|
||||||
|
|
||||||
{{#if @repo.linkUrl}}
|
{{#if @repo.linkUrl}}
|
||||||
<a
|
<a
|
||||||
href={{@repo.linkUrl}}
|
href={{@repo.linkUrl}}
|
||||||
|
@ -72,6 +74,7 @@ export default class RepoStatus extends Component {
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{#if @repo.hasNewVersion}}
|
{{#if @repo.hasNewVersion}}
|
||||||
<div class="repo__new-version">
|
<div class="repo__new-version">
|
||||||
{{i18n "admin.docker.new_version_available"}}
|
{{i18n "admin.docker.new_version_available"}}
|
||||||
|
@ -83,14 +86,14 @@ export default class RepoStatus extends Component {
|
||||||
<div class="d-admin-row__mobile-label">
|
<div class="d-admin-row__mobile-label">
|
||||||
{{i18n "admin.docker.repo.commit_hash"}}
|
{{i18n "admin.docker.repo.commit_hash"}}
|
||||||
</div>
|
</div>
|
||||||
{{CommitUrl "current" @repo.version @repo.prettyVersion @repo.url}}
|
{{commitUrl "current" @repo.version @repo.prettyVersion @repo.url}}
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="d-admin-row__detail">
|
<td class="d-admin-row__detail">
|
||||||
<div class="d-admin-row__mobile-label">
|
<div class="d-admin-row__mobile-label">
|
||||||
{{i18n "admin.docker.repo.last_updated"}}
|
{{i18n "admin.docker.repo.last_updated"}}
|
||||||
</div>
|
</div>
|
||||||
{{FormatDate @repo.latest.date leaveAgo="true"}}
|
{{formatDate @repo.latest.date leaveAgo="true"}}
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="d-admin-row__detail">
|
<td class="d-admin-row__detail">
|
||||||
|
@ -99,7 +102,7 @@ export default class RepoStatus extends Component {
|
||||||
</div>
|
</div>
|
||||||
<div class="repo__latest-version">
|
<div class="repo__latest-version">
|
||||||
<div>
|
<div>
|
||||||
{{CommitUrl
|
{{commitUrl
|
||||||
"new"
|
"new"
|
||||||
@repo.latest.version
|
@repo.latest.version
|
||||||
@repo.prettyLatestVersion
|
@repo.prettyLatestVersion
|
||||||
|
@ -107,7 +110,7 @@ export default class RepoStatus extends Component {
|
||||||
}}
|
}}
|
||||||
</div>
|
</div>
|
||||||
<div class="new-commits">
|
<div class="new-commits">
|
||||||
{{NewCommits
|
{{newCommits
|
||||||
@repo.latest.commits_behind
|
@repo.latest.commits_behind
|
||||||
@repo.version
|
@repo.version
|
||||||
@repo.latest.version
|
@repo.latest.version
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { cached } from "@glimmer/tracking";
|
import { cached } from "@glimmer/tracking";
|
||||||
import Controller from "@ember/controller";
|
import Controller from "@ember/controller";
|
||||||
import { action } from "@ember/object";
|
import { action } from "@ember/object";
|
||||||
import { inject as service } from "@ember/service";
|
import { service } from "@ember/service";
|
||||||
import { needsImageUpgrade } from "../models/repo";
|
import { needsImageUpgrade } from "../models/repo";
|
||||||
|
|
||||||
export default class UpgradeIndex extends Controller {
|
export default class UpgradeIndex extends Controller {
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
import Controller from "@ember/controller";
|
import Controller from "@ember/controller";
|
||||||
import { action } from "@ember/object";
|
import { action } from "@ember/object";
|
||||||
import { inject as service } from "@ember/service";
|
import { service } from "@ember/service";
|
||||||
import { makeArray } from "discourse-common/lib/helpers";
|
import { makeArray } from "discourse-common/lib/helpers";
|
||||||
import I18n from "I18n";
|
import I18n from "discourse-i18n";
|
||||||
import Repo from "../models/repo";
|
import Repo from "../models/repo";
|
||||||
|
|
||||||
export default class UpgradeShow extends Controller {
|
export default class UpgradeShow extends Controller {
|
||||||
@service messageBus;
|
|
||||||
@service dialog;
|
@service dialog;
|
||||||
@service upgradeStore;
|
@service upgradeStore;
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@ import { action } from "@ember/object";
|
||||||
import { TrackedArray } from "@ember-compat/tracked-built-ins";
|
import { TrackedArray } from "@ember-compat/tracked-built-ins";
|
||||||
|
|
||||||
export default class Upgrade extends Controller {
|
export default class Upgrade extends Controller {
|
||||||
@tracked banner = new TrackedArray([]);
|
|
||||||
@tracked bannerDismissed = false;
|
@tracked bannerDismissed = false;
|
||||||
|
banner = new TrackedArray();
|
||||||
|
|
||||||
get showBanner() {
|
get showBanner() {
|
||||||
if (this.bannerDismissed) {
|
if (this.bannerDismissed) {
|
||||||
|
|
|
@ -10,7 +10,7 @@ export default function commitUrl(cssClass, version, prettyVersion, url) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const repoUrl = url.substr(0, url.search(/(\.git)?$/));
|
const repoUrl = url.substr(0, url.search(/(\.git)?$/));
|
||||||
const description = `<a class='${cssClass} commit-hash' title='${version}' href='${repoUrl}/commit/${version}'>${prettyVersion}</a>`;
|
return htmlSafe(
|
||||||
|
`<a class='${cssClass} commit-hash' title='${version}' href='${repoUrl}/commit/${version}'>${prettyVersion}</a>`
|
||||||
return new htmlSafe(description);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
import { helper as buildHelper } from "@ember/component/helper";
|
|
||||||
import { htmlSafe } from "@ember/template";
|
import { htmlSafe } from "@ember/template";
|
||||||
import I18n from "I18n";
|
import I18n from "discourse-i18n";
|
||||||
|
|
||||||
export default buildHelper(function (params) {
|
|
||||||
const [commitsBehind, oldSha, newSha, url] = params;
|
|
||||||
|
|
||||||
|
export default function newCommits(commitsBehind, oldSha, newSha, url) {
|
||||||
if (!commitsBehind) {
|
if (!commitsBehind) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -13,7 +10,7 @@ export default buildHelper(function (params) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
let description = I18n.t("admin.docker.commits", {
|
const description = I18n.t("admin.docker.commits", {
|
||||||
count: commitsBehind,
|
count: commitsBehind,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -22,7 +19,7 @@ export default buildHelper(function (params) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const _url = url.substr(0, url.search(/(\.git)?$/));
|
const _url = url.substr(0, url.search(/(\.git)?$/));
|
||||||
description = `<a href='${_url}/compare/${oldSha}...${newSha}'>${description}</a>`;
|
return htmlSafe(
|
||||||
|
`<a href='${_url}/compare/${oldSha}...${newSha}'>${description}</a>`
|
||||||
return new htmlSafe(description);
|
);
|
||||||
});
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import Route from "@ember/routing/route";
|
import Route from "@ember/routing/route";
|
||||||
import { inject as service } from "@ember/service";
|
import { service } from "@ember/service";
|
||||||
import Repo from "../models/repo";
|
import Repo from "../models/repo";
|
||||||
|
|
||||||
export default class UpgradeShow extends Route {
|
export default class UpgradeShow extends Route {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import Route from "@ember/routing/route";
|
import Route from "@ember/routing/route";
|
||||||
import { inject as service } from "@ember/service";
|
import { service } from "@ember/service";
|
||||||
import { bind } from "discourse-common/utils/decorators";
|
import { bind } from "discourse-common/utils/decorators";
|
||||||
import I18n from "I18n";
|
import I18n from "discourse-i18n";
|
||||||
import Repo from "../models/repo";
|
import Repo from "../models/repo";
|
||||||
|
|
||||||
export default class Upgrade extends Route {
|
export default class Upgrade extends Route {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
<DockerManager::Console @output={{model.output}} />
|
<DockerManager::Console @output={{this.model.output}} />
|
|
@ -9,7 +9,7 @@ module DockerManager::FallbackCompatibilityParser
|
||||||
|
|
||||||
begin
|
begin
|
||||||
version_list = YAML.safe_load(version_list)
|
version_list = YAML.safe_load(version_list)
|
||||||
rescue Psych::SyntaxError, Psych::DisallowedClass => e
|
rescue Psych::SyntaxError, Psych::DisallowedClass
|
||||||
end
|
end
|
||||||
|
|
||||||
raise Discourse::InvalidVersionListError unless version_list.is_a?(Hash)
|
raise Discourse::InvalidVersionListError unless version_list.is_a?(Hash)
|
||||||
|
@ -18,7 +18,7 @@ module DockerManager::FallbackCompatibilityParser
|
||||||
version_list
|
version_list
|
||||||
.transform_keys do |v|
|
.transform_keys do |v|
|
||||||
Gem::Requirement.parse(v)
|
Gem::Requirement.parse(v)
|
||||||
rescue Gem::Requirement::BadRequirementError => e
|
rescue Gem::Requirement::BadRequirementError
|
||||||
raise Discourse::InvalidVersionListError, "Invalid version specifier: #{v}"
|
raise Discourse::InvalidVersionListError, "Invalid version specifier: #{v}"
|
||||||
end
|
end
|
||||||
.sort_by do |parsed_requirement, _|
|
.sort_by do |parsed_requirement, _|
|
||||||
|
@ -61,12 +61,12 @@ module DockerManager::FallbackCompatibilityParser
|
||||||
# Find a compatible resource from a git repo
|
# Find a compatible resource from a git repo
|
||||||
def self.find_compatible_git_resource(path)
|
def self.find_compatible_git_resource(path)
|
||||||
return unless File.directory?("#{path}/.git")
|
return unless File.directory?("#{path}/.git")
|
||||||
compat_resource, std_error, s =
|
compat_resource, _, s =
|
||||||
Open3.capture3(
|
Open3.capture3(
|
||||||
"git -C '#{path}' show HEAD@{upstream}:#{Discourse::VERSION_COMPATIBILITY_FILENAME}",
|
"git -C '#{path}' show HEAD@{upstream}:#{Discourse::VERSION_COMPATIBILITY_FILENAME}",
|
||||||
)
|
)
|
||||||
self.find_compatible_resource(compat_resource) if s.success?
|
self.find_compatible_resource(compat_resource) if s.success?
|
||||||
rescue Discourse::InvalidVersionListError => e
|
rescue Discourse::InvalidVersionListError
|
||||||
$stderr.puts "Invalid version list in #{path}"
|
$stderr.puts "Invalid version list in #{path}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -178,7 +178,7 @@ class DockerManager::GitRepo
|
||||||
|
|
||||||
def run(cmd)
|
def run(cmd)
|
||||||
@memoize[cmd] ||= begin
|
@memoize[cmd] ||= begin
|
||||||
stdout, stderr, status = Open3.capture3("git #{cmd}", chdir: path)
|
stdout, _, status = Open3.capture3("git #{cmd}", chdir: path)
|
||||||
status == 0 ? stdout.strip : nil
|
status == 0 ? stdout.strip : nil
|
||||||
end
|
end
|
||||||
rescue => e
|
rescue => e
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"private": true,
|
"private": true,
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@discourse/lint-configs": "1.3.10",
|
"@discourse/lint-configs": "1.4.2",
|
||||||
"ember-template-lint": "6.0.0",
|
"ember-template-lint": "6.0.0",
|
||||||
"eslint": "8.57.1",
|
"eslint": "8.57.1",
|
||||||
"prettier": "2.8.8",
|
"prettier": "2.8.8",
|
||||||
|
|
|
@ -12,8 +12,8 @@ importers:
|
||||||
specifier: ^7.25.7
|
specifier: ^7.25.7
|
||||||
version: 7.25.7(@babel/core@7.25.8)
|
version: 7.25.7(@babel/core@7.25.8)
|
||||||
'@discourse/lint-configs':
|
'@discourse/lint-configs':
|
||||||
specifier: 1.3.10
|
specifier: 1.4.2
|
||||||
version: 1.3.10(ember-template-lint@6.0.0)(eslint@8.57.1)(prettier@2.8.8)
|
version: 1.4.2(ember-template-lint@6.0.0)(eslint@8.57.1)(prettier@2.8.8)
|
||||||
ember-template-lint:
|
ember-template-lint:
|
||||||
specifier: 6.0.0
|
specifier: 6.0.0
|
||||||
version: 6.0.0
|
version: 6.0.0
|
||||||
|
@ -152,11 +152,11 @@ packages:
|
||||||
resolution: {integrity: sha512-JWtuCu8VQsMladxVz/P4HzHUGCAwpuqacmowgXFs5XjxIgKuNjnLokQzuVjlTvIzODaDmpjT3oxcC48vyk9EWg==}
|
resolution: {integrity: sha512-JWtuCu8VQsMladxVz/P4HzHUGCAwpuqacmowgXFs5XjxIgKuNjnLokQzuVjlTvIzODaDmpjT3oxcC48vyk9EWg==}
|
||||||
engines: {node: '>=6.9.0'}
|
engines: {node: '>=6.9.0'}
|
||||||
|
|
||||||
'@discourse/lint-configs@1.3.10':
|
'@discourse/lint-configs@1.4.2':
|
||||||
resolution: {integrity: sha512-PQ56xx4UfceLR/wJm7ig1JRNKkLVYPAeyp5bV6k6jQhpVr9TeZdobeCfGbVtKG6hhuaQ4aECPjRf/MoNw00/cw==}
|
resolution: {integrity: sha512-AhwEfqy7ByheuNEhioXlkcgrbvzQY8yFbSWwtqAB0GXsp4UNaMZFyjdMoPFgaUDdUzjY/eKFFZ/j4FkA9EY4qA==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
ember-template-lint: 6.0.0
|
ember-template-lint: 6.0.0
|
||||||
eslint: 8.57.0
|
eslint: 8.57.1
|
||||||
prettier: 2.8.8
|
prettier: 2.8.8
|
||||||
|
|
||||||
'@ember-data/rfc395-data@0.0.4':
|
'@ember-data/rfc395-data@0.0.4':
|
||||||
|
@ -1947,7 +1947,7 @@ snapshots:
|
||||||
'@babel/helper-validator-identifier': 7.25.7
|
'@babel/helper-validator-identifier': 7.25.7
|
||||||
to-fast-properties: 2.0.0
|
to-fast-properties: 2.0.0
|
||||||
|
|
||||||
'@discourse/lint-configs@1.3.10(ember-template-lint@6.0.0)(eslint@8.57.1)(prettier@2.8.8)':
|
'@discourse/lint-configs@1.4.2(ember-template-lint@6.0.0)(eslint@8.57.1)(prettier@2.8.8)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@babel/core': 7.25.8
|
'@babel/core': 7.25.8
|
||||||
'@babel/eslint-parser': 7.25.8(@babel/core@7.25.8)(eslint@8.57.1)
|
'@babel/eslint-parser': 7.25.8(@babel/core@7.25.8)(eslint@8.57.1)
|
||||||
|
|
|
@ -195,7 +195,7 @@ module GitHelpers
|
||||||
def git(*commands)
|
def git(*commands)
|
||||||
Dir.chdir(@path) do
|
Dir.chdir(@path) do
|
||||||
commands.map do |command|
|
commands.map do |command|
|
||||||
stdout, stderr, status = Open3.capture3("git #{command}".strip)
|
stdout, _, status = Open3.capture3("git #{command}".strip)
|
||||||
status.success? ? stdout : (raise RuntimeError)
|
status.success? ? stdout : (raise RuntimeError)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,7 +8,7 @@ RSpec.describe "Admin update", type: :system do
|
||||||
|
|
||||||
before { sign_in(admin) }
|
before { sign_in(admin) }
|
||||||
|
|
||||||
xit "displays the admin update page with the right respositories" do
|
xit "displays the admin update page with the right repositories" do
|
||||||
visit("/admin/update")
|
visit("/admin/update")
|
||||||
|
|
||||||
expect(page).to have_css("h3", exact_text: I18n.t("js.admin.docker.update_title"))
|
expect(page).to have_css("h3", exact_text: I18n.t("js.admin.docker.update_title"))
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
import { getOwner } from "@ember/application";
|
import { getOwner } from "@ember/owner";
|
||||||
import { render, settled } from "@ember/test-helpers";
|
import { render, settled } from "@ember/test-helpers";
|
||||||
import { setupRenderingTest } from "ember-qunit";
|
import { setupRenderingTest } from "ember-qunit";
|
||||||
import hbs from "htmlbars-inline-precompile";
|
import hbs from "htmlbars-inline-precompile";
|
||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
import { query } from "discourse/tests/helpers/qunit-helpers";
|
|
||||||
|
|
||||||
const repoProps = {
|
const repoProps = {
|
||||||
unloaded: false,
|
unloaded: false,
|
||||||
|
@ -46,7 +45,7 @@ const managerProps = {
|
||||||
module("Integration | Component | RepoStatus", function (hooks) {
|
module("Integration | Component | RepoStatus", function (hooks) {
|
||||||
setupRenderingTest(hooks);
|
setupRenderingTest(hooks);
|
||||||
|
|
||||||
test("it renders correctly", async function (assert) {
|
test("renders correctly", async function (assert) {
|
||||||
const store = getOwner(this).lookup("service:store");
|
const store = getOwner(this).lookup("service:store");
|
||||||
this.set("repo", store.createRecord("repo", repoProps));
|
this.set("repo", store.createRecord("repo", repoProps));
|
||||||
this.set("managerRepo", store.createRecord("repo", managerProps));
|
this.set("managerRepo", store.createRecord("repo", managerProps));
|
||||||
|
@ -65,26 +64,24 @@ module("Integration | Component | RepoStatus", function (hooks) {
|
||||||
assert
|
assert
|
||||||
.dom("div.new-commits a")
|
.dom("div.new-commits a")
|
||||||
.hasText("3 new commits", "shows number of new commits");
|
.hasText("3 new commits", "shows number of new commits");
|
||||||
assert.strictEqual(
|
assert
|
||||||
query("div.new-commits a").href.trim(),
|
.dom("div.new-commits a")
|
||||||
"https://github.com/discourse/discourse/compare/8f65e4f...2b006c0",
|
.hasAttribute(
|
||||||
"links to GitHub diff page"
|
"href",
|
||||||
);
|
"https://github.com/discourse/discourse/compare/8f65e4f...2b006c0",
|
||||||
|
"links to GitHub diff page"
|
||||||
|
);
|
||||||
|
|
||||||
this.repo.pretty_version = null;
|
this.repo.pretty_version = null;
|
||||||
this.repo.latest.pretty_version = null;
|
this.repo.latest.pretty_version = null;
|
||||||
await settled();
|
await settled();
|
||||||
|
|
||||||
assert.strictEqual(
|
assert
|
||||||
query("a.current.commit-hash").textContent.trim(),
|
.dom("a.current.commit-hash")
|
||||||
"8f65e4f",
|
.hasText("8f65e4f", "commit hash is used when tag version is absent");
|
||||||
"commit hash is used when tag version is absent"
|
assert
|
||||||
);
|
.dom("a.new.commit-hash")
|
||||||
assert.strictEqual(
|
.hasText("2b006c0", "commit hash is used when tag version is absent");
|
||||||
query("a.new.commit-hash").textContent.trim(),
|
|
||||||
"2b006c0",
|
|
||||||
"commit hash is used when tag version is absent"
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("official plugin", async function (assert) {
|
test("official plugin", async function (assert) {
|
||||||
|
@ -97,11 +94,9 @@ module("Integration | Component | RepoStatus", function (hooks) {
|
||||||
hbs`<RepoStatus @repo={{this.repo}} @managerRepo={{this.managerRepo}} />`
|
hbs`<RepoStatus @repo={{this.repo}} @managerRepo={{this.managerRepo}} />`
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.strictEqual(
|
assert
|
||||||
query("div.d-admin-row__overview-author").textContent.trim(),
|
.dom("div.d-admin-row__overview-author")
|
||||||
"By Discourse",
|
.hasText("By Discourse", "shows plugin author");
|
||||||
"shows plugin author"
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("update button", async function (assert) {
|
test("update button", async function (assert) {
|
||||||
|
|
Loading…
Reference in New Issue