Skip to content

Commit 94f0c5a

Browse files
authored
DEV: Update linting config and run gjs-codemod (#370)
1 parent a7bc394 commit 94f0c5a

File tree

23 files changed

+660
-620
lines changed

23 files changed

+660
-620
lines changed

.discourse-compatibility

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
< 3.5.0.beta5-dev: a8c534f11832d6bb8590ce5001119654fe6f335f
12
< 3.5.0.beta3-dev: 4f0234f5be3aaa77db277e0f224cd9750d2713cd
23
< 3.5.0.beta2-dev: e82c6ae1ca38ccebb34669148f8de93a3028906e
34
< 3.5.0.beta1-dev: 5450a5ef4e2ae35185320fc6af9678621026e148

Gemfile.lock

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,42 +14,44 @@ GEM
1414
securerandom (>= 0.3)
1515
tzinfo (~> 2.0, >= 2.0.5)
1616
uri (>= 0.13.1)
17-
ast (2.4.2)
18-
base64 (0.2.0)
19-
benchmark (0.4.0)
20-
bigdecimal (3.1.9)
17+
ast (2.4.3)
18+
base64 (0.3.0)
19+
benchmark (0.4.1)
20+
bigdecimal (3.2.0)
2121
concurrent-ruby (1.3.5)
22-
connection_pool (2.5.0)
23-
drb (2.2.1)
22+
connection_pool (2.5.3)
23+
drb (2.2.3)
2424
i18n (1.14.7)
2525
concurrent-ruby (~> 1.0)
26-
json (2.10.2)
27-
language_server-protocol (3.17.0.4)
26+
json (2.12.2)
27+
language_server-protocol (3.17.0.5)
2828
lint_roller (1.1.0)
29-
logger (1.6.6)
29+
logger (1.7.0)
3030
minitest (5.25.5)
31-
parallel (1.26.3)
32-
parser (3.3.7.1)
31+
parallel (1.27.0)
32+
parser (3.3.8.0)
3333
ast (~> 2.4.1)
3434
racc
3535
prettier_print (1.2.1)
36+
prism (1.4.0)
3637
racc (1.8.1)
37-
rack (3.1.12)
38+
rack (3.1.15)
3839
rainbow (3.1.1)
3940
regexp_parser (2.10.0)
40-
rubocop (1.74.0)
41+
rubocop (1.75.8)
4142
json (~> 2.3)
4243
language_server-protocol (~> 3.17.0.2)
4344
lint_roller (~> 1.1.0)
4445
parallel (~> 1.10)
4546
parser (>= 3.3.0.2)
4647
rainbow (>= 2.2.2, < 4.0)
4748
regexp_parser (>= 2.9.3, < 3.0)
48-
rubocop-ast (>= 1.38.0, < 2.0)
49+
rubocop-ast (>= 1.44.0, < 2.0)
4950
ruby-progressbar (~> 1.7)
5051
unicode-display_width (>= 2.4.0, < 4.0)
51-
rubocop-ast (1.38.1)
52-
parser (>= 3.3.1.0)
52+
rubocop-ast (1.44.1)
53+
parser (>= 3.3.7.2)
54+
prism (~> 1.4)
5355
rubocop-capybara (2.22.1)
5456
lint_roller (~> 1.1)
5557
rubocop (~> 1.72, >= 1.72.1)
@@ -65,13 +67,13 @@ GEM
6567
rubocop-factory_bot (2.27.1)
6668
lint_roller (~> 1.1)
6769
rubocop (~> 1.72, >= 1.72.1)
68-
rubocop-rails (2.30.3)
70+
rubocop-rails (2.32.0)
6971
activesupport (>= 4.2.0)
7072
lint_roller (~> 1.1)
7173
rack (>= 1.1)
72-
rubocop (>= 1.72.1, < 2.0)
73-
rubocop-ast (>= 1.38.0, < 2.0)
74-
rubocop-rspec (3.5.0)
74+
rubocop (>= 1.75.0, < 2.0)
75+
rubocop-ast (>= 1.44.0, < 2.0)
76+
rubocop-rspec (3.6.0)
7577
lint_roller (~> 1.1)
7678
rubocop (~> 1.72, >= 1.72.1)
7779
rubocop-rspec_rails (2.31.0)
@@ -97,4 +99,4 @@ DEPENDENCIES
9799
syntax_tree
98100

99101
BUNDLED WITH
100-
2.6.6
102+
2.6.9

assets/javascripts/discourse/connectors/after-topic-status/solved-status.gjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ const SolvedStatus = <template>
2121
>{{icon "far-square"}}</span>
2222
{{~/if~}}
2323
</template>;
24+
2425
export default SolvedStatus;

assets/javascripts/discourse/connectors/bread-crumbs-right/solved-status-filter.js renamed to assets/javascripts/discourse/connectors/bread-crumbs-right/solved-status-filter.gjs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import Component from "@glimmer/component";
2+
import { hash } from "@ember/helper";
23
import { action } from "@ember/object";
34
import { service } from "@ember/service";
45
import { i18n } from "discourse-i18n";
6+
import ComboBox from "select-kit/components/combo-box";
57

68
const QUERY_PARAM_VALUES = {
79
solved: "yes",
@@ -57,4 +59,19 @@ export default class SolvedStatusFilter extends Component {
5759
queryParams: { solved: QUERY_PARAM_VALUES[newStatus] },
5860
});
5961
}
62+
63+
<template>
64+
{{#if this.siteSettings.solved_enabled}}
65+
<li>
66+
<ComboBox
67+
@content={{this.statuses}}
68+
@value={{this.status}}
69+
@valueProperty="value"
70+
@options={{hash caretDownIcon="caret-right" caretUpIcon="caret-down"}}
71+
@onChange={{this.changeStatus}}
72+
class="solved-status-filter"
73+
/>
74+
</li>
75+
{{/if}}
76+
</template>
6077
}

assets/javascripts/discourse/connectors/bread-crumbs-right/solved-status-filter.hbs

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import Component from "@ember/component";
2+
import { on } from "@ember/modifier";
3+
import { action } from "@ember/object";
4+
import { classNames, tagName } from "@ember-decorators/component";
5+
import { i18n } from "discourse-i18n";
6+
7+
@tagName("")
8+
@classNames("category-custom-settings-outlet", "solved-settings")
9+
export default class SolvedSettings extends Component {
10+
@action
11+
onChangeSetting(value) {
12+
this.set(
13+
"category.custom_fields.enable_accepted_answers",
14+
value ? "true" : "false"
15+
);
16+
}
17+
18+
<template>
19+
<h3>{{i18n "solved.title"}}</h3>
20+
21+
{{#unless this.siteSettings.allow_solved_on_all_topics}}
22+
<section class="field">
23+
<div class="enable-accepted-answer">
24+
<label class="checkbox-label">
25+
<input
26+
{{on "change" (action "onChangeSetting" value="target.checked")}}
27+
checked={{this.category.enable_accepted_answers}}
28+
type="checkbox"
29+
/>
30+
{{i18n "solved.allow_accepted_answers"}}
31+
</label>
32+
</div>
33+
</section>
34+
{{/unless}}
35+
36+
<section class="field auto-close-solved-topics">
37+
<label for="auto-close-solved-topics">
38+
{{i18n "solved.solved_topics_auto_close_hours"}}
39+
</label>
40+
<input
41+
{{on
42+
"input"
43+
(action
44+
(mut this.category.custom_fields.solved_topics_auto_close_hours)
45+
value="target.value"
46+
)
47+
}}
48+
value={{this.category.custom_fields.solved_topics_auto_close_hours}}
49+
type="number"
50+
min="0"
51+
id="auto-close-solved-topics"
52+
/>
53+
</section>
54+
</template>
55+
}

assets/javascripts/discourse/connectors/category-custom-settings/solved-settings.hbs

Lines changed: 0 additions & 35 deletions
This file was deleted.

assets/javascripts/discourse/connectors/category-custom-settings/solved-settings.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

assets/javascripts/discourse/connectors/topic-after-cooked/solved-panel.hbs

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import Component from "@ember/component";
2+
import { later } from "@ember/runloop";
3+
import { classNames, tagName } from "@ember-decorators/component";
4+
import TopicNavigationPopup from "discourse/components/topic-navigation-popup";
5+
import { isTesting } from "discourse/lib/environment";
6+
import { i18n } from "discourse-i18n";
7+
8+
const ONE_WEEK = 7 * 24 * 60 * 60 * 1000; // milliseconds
9+
const MAX_DURATION_WITH_NO_ANSWER = ONE_WEEK;
10+
const DISPLAY_DELAY = isTesting() ? 0 : 2000;
11+
12+
@tagName("div")
13+
@classNames("topic-navigation-outlet", "no-answer")
14+
export default class NoAnswer extends Component {
15+
static shouldRender(args, context) {
16+
return !context.site.mobileView;
17+
}
18+
19+
init() {
20+
super.init(...arguments);
21+
this.set("show", false);
22+
this.setProperties({
23+
oneWeek: ONE_WEEK,
24+
show: false,
25+
});
26+
later(() => {
27+
if (!this.element || this.isDestroying || this.isDestroyed) {
28+
return;
29+
}
30+
const topic = this.topic;
31+
const currentUser = this.currentUser;
32+
33+
// show notice if:
34+
// - user can accept answer
35+
// - it does not have an accepted answer
36+
// - topic is old
37+
// - topic has at least one reply from another user that can be accepted
38+
if (
39+
!topic.accepted_answer &&
40+
currentUser &&
41+
topic.user_id === currentUser.id &&
42+
moment() - moment(topic.created_at) > MAX_DURATION_WITH_NO_ANSWER &&
43+
topic.postStream.posts.some(
44+
(post) => post.user_id !== currentUser.id && post.can_accept_answer
45+
)
46+
) {
47+
this.set("show", true);
48+
}
49+
}, DISPLAY_DELAY);
50+
}
51+
52+
<template>
53+
{{#if this.show}}
54+
<TopicNavigationPopup
55+
@popupId="solved-notice"
56+
@dismissDuration={{this.oneWeek}}
57+
>
58+
<h3>{{i18n "solved.no_answer.title"}}</h3>
59+
<p>{{i18n "solved.no_answer.description"}}</p>
60+
</TopicNavigationPopup>
61+
{{/if}}
62+
</template>
63+
}

assets/javascripts/discourse/connectors/topic-navigation/no-answer.hbs

Lines changed: 0 additions & 9 deletions
This file was deleted.

assets/javascripts/discourse/connectors/topic-navigation/no-answer.js

Lines changed: 0 additions & 50 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import Component from "@glimmer/component";
2+
import { LinkTo } from "@ember/routing";
3+
import { service } from "@ember/service";
4+
import icon from "discourse/helpers/d-icon";
5+
import { i18n } from "discourse-i18n";
6+
7+
export default class SolvedList extends Component {
8+
@service siteSettings;
9+
10+
<template>
11+
{{#if this.siteSettings.solved_enabled}}
12+
<li class="user-activity-bottom-outlet solved-list">
13+
<LinkTo @route="userActivity.solved">
14+
{{icon "square-check"}}
15+
{{i18n "solved.title"}}
16+
</LinkTo>
17+
</li>
18+
{{/if}}
19+
</template>
20+
}

0 commit comments

Comments
 (0)