Skip to content

Commit

Permalink
DEV: Clean up the code (#245)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
CvX authored Oct 23, 2024
1 parent 06cc8db commit ea174f7
Show file tree
Hide file tree
Showing 26 changed files with 163 additions and 157 deletions.
67 changes: 32 additions & 35 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,82 +1,79 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (7.1.3.3)
activesupport (7.2.1.1)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
logger (>= 1.4.2)
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
ast (2.4.2)
base64 (0.2.0)
bigdecimal (3.1.8)
concurrent-ruby (1.2.3)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
drb (2.2.1)
i18n (1.14.5)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
json (2.7.2)
language_server-protocol (3.17.0.3)
minitest (5.23.1)
mutex_m (0.2.0)
parallel (1.24.0)
parser (3.3.1.0)
logger (1.6.1)
minitest (5.25.1)
parallel (1.26.3)
parser (3.3.5.0)
ast (~> 2.4.1)
racc
prettier_print (1.2.1)
racc (1.8.0)
rack (3.0.11)
racc (1.8.1)
rack (3.1.8)
rainbow (3.1.1)
regexp_parser (2.9.2)
rexml (3.3.6)
strscan
rubocop (1.64.0)
rubocop (1.67.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.31.1, < 2.0)
regexp_parser (>= 2.4, < 3.0)
rubocop-ast (>= 1.32.2, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.31.3)
rubocop-ast (1.32.3)
parser (>= 3.3.1.0)
rubocop-capybara (2.20.0)
rubocop-capybara (2.21.0)
rubocop (~> 1.41)
rubocop-discourse (3.8.0)
rubocop-discourse (3.8.2)
activesupport (>= 6.1)
rubocop (>= 1.59.0)
rubocop-capybara (>= 2.0.0)
rubocop-factory_bot (>= 2.0.0)
rubocop-rails (>= 2.25.0)
rubocop-rspec (>= 2.25.0)
rubocop-factory_bot (2.25.1)
rubocop (~> 1.41)
rubocop-rails (2.25.0)
rubocop-rspec (>= 3.0.1)
rubocop-rspec_rails (>= 2.30.0)
rubocop-factory_bot (2.26.1)
rubocop (~> 1.61)
rubocop-rails (2.26.2)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
rubocop (>= 1.52.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rspec (2.29.2)
rubocop (~> 1.40)
rubocop-capybara (~> 2.17)
rubocop-factory_bot (~> 2.22)
rubocop-rspec_rails (~> 2.28)
rubocop-rspec_rails (2.28.3)
rubocop (~> 1.40)
rubocop-rspec (3.1.0)
rubocop (~> 1.61)
rubocop-rspec_rails (2.30.0)
rubocop (~> 1.61)
rubocop-rspec (~> 3, >= 3.0.1)
ruby-progressbar (1.13.0)
strscan (3.1.0)
securerandom (0.3.1)
syntax_tree (6.2.0)
prettier_print (>= 1.2.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
unicode-display_width (2.6.0)

PLATFORMS
ruby
Expand Down
29 changes: 15 additions & 14 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
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
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Original file line number Diff line number Diff line change
@@ -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>
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Component from "@glimmer/component";
import { htmlSafe } from "@ember/template";
import concatClass from "discourse/helpers/concat-class";

export default class ProgressBar extends Component {
get active() {
Expand All @@ -15,4 +16,10 @@ export default class ProgressBar extends Component {

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>
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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>
}

This file was deleted.

This file was deleted.

25 changes: 14 additions & 11 deletions admin/assets/javascripts/discourse/components/repo-status.gjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import Component from "@glimmer/component";
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 FormatDate from "discourse/helpers/format-date";
import formatDate from "discourse/helpers/format-date";
import icon from "discourse-common/helpers/d-icon";
import i18n from "discourse-common/helpers/i18n";
import I18n from "I18n";
import CommitUrl from "../helpers/commit-url";
import NewCommits from "../helpers/new-commits";
import commitUrl from "../helpers/commit-url";
import newCommits from "../helpers/new-commits";

export default class RepoStatus extends Component {
@service router;
Expand All @@ -33,9 +32,9 @@ export default class RepoStatus extends Component {

get upgradeButtonLabel() {
if (this.args.repo.upgrading) {
return I18n.t("admin.docker.updating");
return i18n("admin.docker.updating");
} else {
return I18n.t("admin.docker.update_action");
return i18n("admin.docker.update_action");
}
}

Expand All @@ -52,14 +51,17 @@ export default class RepoStatus extends Component {
<div class="d-admin-row__overview-name">
{{@repo.nameTitleized}}
</div>

{{#if @repo.author}}
<div class="d-admin-row__overview-author">
{{@repo.author}}
</div>
{{/if}}

{{#if @repo.plugin}}
<div class="d-admin-row__overview-about">
{{@repo.plugin.about}}

{{#if @repo.linkUrl}}
<a
href={{@repo.linkUrl}}
Expand All @@ -72,6 +74,7 @@ export default class RepoStatus extends Component {
{{/if}}
</div>
{{/if}}

{{#if @repo.hasNewVersion}}
<div class="repo__new-version">
{{i18n "admin.docker.new_version_available"}}
Expand All @@ -83,14 +86,14 @@ export default class RepoStatus extends Component {
<div class="d-admin-row__mobile-label">
{{i18n "admin.docker.repo.commit_hash"}}
</div>
{{CommitUrl "current" @repo.version @repo.prettyVersion @repo.url}}
{{commitUrl "current" @repo.version @repo.prettyVersion @repo.url}}
</td>

<td class="d-admin-row__detail">
<div class="d-admin-row__mobile-label">
{{i18n "admin.docker.repo.last_updated"}}
</div>
{{FormatDate @repo.latest.date leaveAgo="true"}}
{{formatDate @repo.latest.date leaveAgo="true"}}
</td>

<td class="d-admin-row__detail">
Expand All @@ -99,15 +102,15 @@ export default class RepoStatus extends Component {
</div>
<div class="repo__latest-version">
<div>
{{CommitUrl
{{commitUrl
"new"
@repo.latest.version
@repo.prettyLatestVersion
@repo.url
}}
</div>
<div class="new-commits">
{{NewCommits
{{newCommits
@repo.latest.commits_behind
@repo.version
@repo.latest.version
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { cached } from "@glimmer/tracking";
import Controller from "@ember/controller";
import { action } from "@ember/object";
import { inject as service } from "@ember/service";
import { service } from "@ember/service";
import { needsImageUpgrade } from "../models/repo";

export default class UpgradeIndex extends Controller {
Expand Down
5 changes: 2 additions & 3 deletions admin/assets/javascripts/discourse/controllers/update-show.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import Controller from "@ember/controller";
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 I18n from "I18n";
import I18n from "discourse-i18n";
import Repo from "../models/repo";

export default class UpgradeShow extends Controller {
@service messageBus;
@service dialog;
@service upgradeStore;

Expand Down
2 changes: 1 addition & 1 deletion admin/assets/javascripts/discourse/controllers/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { action } from "@ember/object";
import { TrackedArray } from "@ember-compat/tracked-built-ins";

export default class Upgrade extends Controller {
@tracked banner = new TrackedArray([]);
@tracked bannerDismissed = false;
banner = new TrackedArray();

get showBanner() {
if (this.bannerDismissed) {
Expand Down
6 changes: 3 additions & 3 deletions admin/assets/javascripts/discourse/helpers/commit-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function commitUrl(cssClass, version, prettyVersion, url) {
}

const repoUrl = url.substr(0, url.search(/(\.git)?$/));
const description = `<a class='${cssClass} commit-hash' title='${version}' href='${repoUrl}/commit/${version}'>${prettyVersion}</a>`;

return new htmlSafe(description);
return htmlSafe(
`<a class='${cssClass} commit-hash' title='${version}' href='${repoUrl}/commit/${version}'>${prettyVersion}</a>`
);
}
Loading

0 comments on commit ea174f7

Please sign in to comment.