Skip to content

Commit 238616f

Browse files
authored
DEV: Update linting config and run gjs-codemod (#101)
1 parent 07e636b commit 238616f

20 files changed

+875
-817
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: e71a243cfca147d8ac24b504044614ce5fd09cef
12
< 3.5.0.beta1-dev: 54a7970fd9ae1609e453199aeba5fe582b5e3672
23
< 3.4.0.beta2-dev: 1eef24bc58166e366a66676cae1990f9308b95e7
34
< 3.4.0.beta1-dev: 0beedd0add742911ac8fa2969d74ca050c8d7417

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
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import Component from "@ember/component";
2+
import { action, computed } from "@ember/object";
3+
import { tagName } from "@ember-decorators/component";
4+
import DButton from "discourse/components/d-button";
5+
import icon from "discourse/helpers/d-icon";
6+
7+
@tagName("")
8+
export default class TeambuildChoice extends Component {
9+
@computed("progress.completed.[]")
10+
get completed() {
11+
return this.progress.isComplete(this.target, this.userId);
12+
}
13+
14+
@action
15+
complete() {
16+
this.progress.complete(this.target, this.userId);
17+
}
18+
19+
@action
20+
undo() {
21+
this.progress.undo(this.target, this.userId);
22+
}
23+
24+
<template>
25+
<div
26+
class="teambuild-choice {{if this.completed 'completed' 'incomplete'}}"
27+
>
28+
<div class="controls">
29+
{{#if this.readOnly}}
30+
{{#if this.completed}}
31+
{{icon "check"}}
32+
{{/if}}
33+
{{else}}
34+
{{#if this.completed}}
35+
<DButton
36+
@icon="check"
37+
@action={{this.undo}}
38+
@title="discourse_teambuild.progress.mark_incomplete"
39+
class="btn-primary"
40+
/>
41+
{{else}}
42+
<DButton
43+
@icon="circle"
44+
@action={{this.complete}}
45+
@title="discourse_teambuild.progress.mark_complete"
46+
/>
47+
{{/if}}
48+
{{/if}}
49+
</div>
50+
<div class="choice-label">{{this.label}}</div>
51+
</div>
52+
</template>
53+
}

assets/javascripts/discourse/components/teambuild-choice.hbs

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

assets/javascripts/discourse/components/teambuild-choice.js

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
import Component, { Input } from "@ember/component";
2+
import { concat, fn } from "@ember/helper";
3+
import { action, computed } from "@ember/object";
4+
import { equal, or } from "@ember/object/computed";
5+
import { underscore } from "@ember/string";
6+
import { tagName } from "@ember-decorators/component";
7+
import BufferedProxy from "ember-buffered-proxy/proxy";
8+
import DButton from "discourse/components/d-button";
9+
import RadioButton from "discourse/components/radio-button";
10+
import replaceEmoji from "discourse/helpers/replace-emoji";
11+
import { popupAjaxError } from "discourse/lib/ajax-error";
12+
import { i18n } from "discourse-i18n";
13+
import ComboBox from "select-kit/components/combo-box";
14+
import { Types } from "discourse/plugins/discourse-teambuild/discourse/models/teambuild-target";
15+
16+
@tagName("")
17+
export default class TeambuildTarget extends Component {
18+
editSelected = false;
19+
20+
@equal("buffered.target_type_id", Types.USER_GROUP) needsGroup;
21+
@or("editSelected", "target.isNew") editing;
22+
23+
@computed("target")
24+
get buffered() {
25+
return BufferedProxy.create({
26+
content: this.get("target"),
27+
});
28+
}
29+
30+
@computed("editing", "index")
31+
get canMoveUp() {
32+
return !this.editing && this.index > 0;
33+
}
34+
35+
@computed("editing", "index", "length")
36+
get canMoveDown() {
37+
return !this.editing && this.index < this.length - 1;
38+
}
39+
40+
get targetTypes() {
41+
return Object.keys(Types).map((key) => {
42+
return { id: Types[key], name: underscore(key) };
43+
});
44+
}
45+
46+
@computed(
47+
"buffered.name",
48+
"target.isSaving",
49+
"needsGroup",
50+
"buffered.group_id"
51+
)
52+
get saveDisabled() {
53+
if (this.target.isSaving) {
54+
return true;
55+
}
56+
57+
let name = this.get("buffered.name");
58+
if (!name || name.length === 0) {
59+
return true;
60+
}
61+
62+
if (this.needsGroup && !this.get("buffered.group_id")) {
63+
return true;
64+
}
65+
66+
return false;
67+
}
68+
69+
@action
70+
save() {
71+
this.target
72+
.save(this.buffered.getProperties("name", "target_type_id", "group_id"))
73+
.then(() => {
74+
this.set("editSelected", false);
75+
})
76+
.catch(popupAjaxError);
77+
}
78+
79+
@action
80+
cancel() {
81+
if (this.target.isNew) {
82+
return this.removeTarget();
83+
} else {
84+
this.set("editSelected", false);
85+
this.buffered.discardChanges();
86+
}
87+
}
88+
89+
@action
90+
destroyTarget() {
91+
this.target.destroyRecord().then(() => this.removeTarget());
92+
}
93+
94+
<template>
95+
<div class="teambuild-target {{if this.editing 'editing'}}">
96+
<div class="target-details">
97+
{{#if this.editing}}
98+
<div class="fields">
99+
<div class="target-types">
100+
{{#each this.targetTypes as |type|}}
101+
<label>
102+
<RadioButton
103+
@value={{type.id}}
104+
@selection={{this.buffered.target_type_id}}
105+
@onChange={{fn (mut this.buffered.target_type_id) type.id}}
106+
class={{type.name}}
107+
/>
108+
{{i18n
109+
(concat "discourse_teambuild.targets.types." type.name)
110+
}}
111+
</label>
112+
{{/each}}
113+
</div>
114+
115+
<div class="target-name">
116+
<Input
117+
@value={{this.buffered.name}}
118+
placeholder={{i18n "discourse_teambuild.targets.name"}}
119+
autofocus="true"
120+
/>
121+
</div>
122+
123+
{{#if this.needsGroup}}
124+
<ComboBox
125+
@content={{this.groups}}
126+
@value={{this.buffered.group_id}}
127+
@none="discourse_teambuild.targets.choose_group"
128+
/>
129+
{{/if}}
130+
</div>
131+
{{else}}
132+
<div class="target-name">
133+
{{replaceEmoji this.target.name}}
134+
</div>
135+
<div class="target-group-name">
136+
{{this.target.group_name}}
137+
</div>
138+
{{/if}}
139+
</div>
140+
<div class="controls">
141+
{{#if this.canMoveUp}}
142+
<DButton @icon="arrow-up" @action={{this.moveUp}} />
143+
{{/if}}
144+
145+
{{#if this.canMoveDown}}
146+
<DButton @icon="arrow-down" @action={{this.moveDown}} />
147+
{{/if}}
148+
149+
{{#if this.editing}}
150+
<DButton
151+
@icon="check"
152+
@title="discourse_teambuild.targets.save"
153+
@action={{this.save}}
154+
@disabled={{this.saveDisabled}}
155+
class="btn-primary save"
156+
/>
157+
158+
<DButton
159+
@icon="xmark"
160+
@action={{this.cancel}}
161+
@title="discourse_teambuild.targets.cancel"
162+
class="btn-danger cancel"
163+
/>
164+
{{else}}
165+
<DButton
166+
@icon="pencil"
167+
@title="discourse_teambuild.targets.edit"
168+
@action={{fn (mut this.editSelected) true}}
169+
class="edit"
170+
/>
171+
172+
<DButton
173+
@icon="trash-can"
174+
@title="discourse_teambuild.targets.delete"
175+
@action={{this.destroyTarget}}
176+
class="btn-danger destroy"
177+
/>
178+
{{/if}}
179+
</div>
180+
</div>
181+
</template>
182+
}

0 commit comments

Comments
 (0)