Skip to content

Commit bdd6b52

Browse files
authored
DEV: Update linting config and run gjs-codemod (#152)
1 parent bbb61fd commit bdd6b52

32 files changed

+728
-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: 487205a51d55552043bdfd9be3a37facb39076de
12
< 3.5.0.beta1-dev: 8e68082512df23fbf3bc057317267ad92f133be1
23
< 3.4.0.beta3-dev: a84123531a6865f6e76cd210e769e0ac4d729963
34
< 3.4.0.beta1-dev: 1294355185bb29e61d381d63b9b4036cc7af9fc9

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/components/follow-button.js renamed to assets/javascripts/discourse/components/follow-button.gjs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import Component from "@ember/component";
22
import { action } from "@ember/object";
33
import { alias } from "@ember/object/computed";
4+
import { and } from "truth-helpers";
5+
import DButton from "discourse/components/d-button";
46
import { ajax } from "discourse/lib/ajax";
57
import { popupAjaxError } from "discourse/lib/ajax-error";
68
import discourseComputed from "discourse/lib/decorators";
@@ -63,4 +65,15 @@ export default class FollowButton extends Component {
6365
this.set("loading", false);
6466
});
6567
}
68+
69+
<template>
70+
{{#if (and this.showButton this.canFollow)}}
71+
<DButton
72+
@label={{this.labelKey}}
73+
@icon={{this.icon}}
74+
@disabled={{this.loading}}
75+
@action={{action "toggleFollow"}}
76+
/>
77+
{{/if}}
78+
</template>
6679
}

assets/javascripts/discourse/components/follow-button.hbs

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import Component from "@ember/component";
2+
import { observes } from "@ember-decorators/object";
3+
import PreferenceCheckbox from "discourse/components/preference-checkbox";
4+
import { i18n } from "discourse-i18n";
5+
6+
const preferences = [
7+
"notify_me_when_followed",
8+
"notify_followed_user_when_followed",
9+
"notify_me_when_followed_replies",
10+
"notify_me_when_followed_creates_topic",
11+
"allow_people_to_follow_me",
12+
];
13+
14+
export default class FollowNotificationPreferences extends Component {
15+
@observes(...preferences.map((p) => `user.${p}`))
16+
_updatePreferences() {
17+
if (!this.user.custom_fields) {
18+
this.user.set("custom_fields", {});
19+
}
20+
preferences.forEach((p) => {
21+
this.user.set(`custom_fields.${p}`, this.user[p]);
22+
});
23+
}
24+
25+
<template>
26+
<div class="control-group follow-notifications">
27+
<label class="control-label">{{i18n "user.follow.label"}}</label>
28+
29+
<div class="controls">
30+
<PreferenceCheckbox
31+
@labelKey="user.follow_notifications_options.allow_people_to_follow_me"
32+
@checked={{this.user.allow_people_to_follow_me}}
33+
class="pref-allow-people-to-follow-me"
34+
/>
35+
36+
<PreferenceCheckbox
37+
@labelKey="user.follow_notifications_options.notify_me_when_followed"
38+
@checked={{this.user.notify_me_when_followed}}
39+
class="pref-notify-me-when-followed"
40+
/>
41+
42+
<PreferenceCheckbox
43+
@labelKey="user.follow_notifications_options.notify_followed_user_when_followed"
44+
@checked={{this.user.notify_followed_user_when_followed}}
45+
class="pref-notify-followed-user-when-followed"
46+
/>
47+
48+
<PreferenceCheckbox
49+
@labelKey="user.follow_notifications_options.notify_me_when_followed_replies"
50+
@checked={{this.user.notify_me_when_followed_replies}}
51+
class="pref-notify-me-when-followed-replies"
52+
/>
53+
54+
<PreferenceCheckbox
55+
@labelKey="user.follow_notifications_options.notify_me_when_followed_creates_topic"
56+
@checked={{this.user.notify_me_when_followed_creates_topic}}
57+
class="pref-notify-me-when-followed-creates-topic"
58+
/>
59+
</div>
60+
</div>
61+
</template>
62+
}

assets/javascripts/discourse/components/follow-notification-preferences.hbs

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

assets/javascripts/discourse/components/follow-notification-preferences.js

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

assets/javascripts/discourse/components/follow-users-list.js renamed to assets/javascripts/discourse/components/follow-users-list.gjs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import Component from "@ember/component";
22
import { notEmpty } from "@ember/object/computed";
3+
import UserInfo from "discourse/components/user-info";
34
import { propertyEqual } from "discourse/lib/computed";
45
import discourseComputed from "discourse/lib/decorators";
6+
import { i18n } from "discourse-i18n";
57

68
export default class FollowUsersList extends Component {
79
@notEmpty("users") hasUsers;
@@ -12,4 +14,19 @@ export default class FollowUsersList extends Component {
1214
let key = viewingSelf ? "none" : "none_other";
1315
return `user.${type}.${key}`;
1416
}
17+
18+
<template>
19+
<div class="follow-users">
20+
{{#if this.hasUsers}}
21+
{{#each this.users as |user|}}
22+
<UserInfo @user={{user}} />
23+
{{/each}}
24+
{{else}}
25+
<div class="alert alert-info">{{i18n
26+
this.noneMessage
27+
username=this.user.username
28+
}}</div>
29+
{{/if}}
30+
</div>
31+
</template>
1532
}

assets/javascripts/discourse/components/follow-users-list.hbs

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import Component from "@ember/component";
2+
import { classNames, tagName } from "@ember-decorators/component";
3+
import FollowButton from "../../components/follow-button";
4+
5+
@tagName("li")
6+
@classNames("user-card-additional-buttons-outlet", "follow-button-container")
7+
export default class FollowButtonContainer extends Component {
8+
<template><FollowButton @user={{this.user}} /></template>
9+
}

0 commit comments

Comments
 (0)