mirror of
https://github.com/discourse/discourse-solved.git
synced 2025-07-02 03:42:12 +00:00
DEV: Update linting config and run gjs-codemod (#370)
This commit is contained in:
parent
a7bc394bdc
commit
94f0c5a315
@ -1,3 +1,4 @@
|
||||
< 3.5.0.beta5-dev: a8c534f11832d6bb8590ce5001119654fe6f335f
|
||||
< 3.5.0.beta3-dev: 4f0234f5be3aaa77db277e0f224cd9750d2713cd
|
||||
< 3.5.0.beta2-dev: e82c6ae1ca38ccebb34669148f8de93a3028906e
|
||||
< 3.5.0.beta1-dev: 5450a5ef4e2ae35185320fc6af9678621026e148
|
||||
|
44
Gemfile.lock
44
Gemfile.lock
@ -14,30 +14,31 @@ GEM
|
||||
securerandom (>= 0.3)
|
||||
tzinfo (~> 2.0, >= 2.0.5)
|
||||
uri (>= 0.13.1)
|
||||
ast (2.4.2)
|
||||
base64 (0.2.0)
|
||||
benchmark (0.4.0)
|
||||
bigdecimal (3.1.9)
|
||||
ast (2.4.3)
|
||||
base64 (0.3.0)
|
||||
benchmark (0.4.1)
|
||||
bigdecimal (3.2.0)
|
||||
concurrent-ruby (1.3.5)
|
||||
connection_pool (2.5.0)
|
||||
drb (2.2.1)
|
||||
connection_pool (2.5.3)
|
||||
drb (2.2.3)
|
||||
i18n (1.14.7)
|
||||
concurrent-ruby (~> 1.0)
|
||||
json (2.10.2)
|
||||
language_server-protocol (3.17.0.4)
|
||||
json (2.12.2)
|
||||
language_server-protocol (3.17.0.5)
|
||||
lint_roller (1.1.0)
|
||||
logger (1.6.6)
|
||||
logger (1.7.0)
|
||||
minitest (5.25.5)
|
||||
parallel (1.26.3)
|
||||
parser (3.3.7.1)
|
||||
parallel (1.27.0)
|
||||
parser (3.3.8.0)
|
||||
ast (~> 2.4.1)
|
||||
racc
|
||||
prettier_print (1.2.1)
|
||||
prism (1.4.0)
|
||||
racc (1.8.1)
|
||||
rack (3.1.12)
|
||||
rack (3.1.15)
|
||||
rainbow (3.1.1)
|
||||
regexp_parser (2.10.0)
|
||||
rubocop (1.74.0)
|
||||
rubocop (1.75.8)
|
||||
json (~> 2.3)
|
||||
language_server-protocol (~> 3.17.0.2)
|
||||
lint_roller (~> 1.1.0)
|
||||
@ -45,11 +46,12 @@ GEM
|
||||
parser (>= 3.3.0.2)
|
||||
rainbow (>= 2.2.2, < 4.0)
|
||||
regexp_parser (>= 2.9.3, < 3.0)
|
||||
rubocop-ast (>= 1.38.0, < 2.0)
|
||||
rubocop-ast (>= 1.44.0, < 2.0)
|
||||
ruby-progressbar (~> 1.7)
|
||||
unicode-display_width (>= 2.4.0, < 4.0)
|
||||
rubocop-ast (1.38.1)
|
||||
parser (>= 3.3.1.0)
|
||||
rubocop-ast (1.44.1)
|
||||
parser (>= 3.3.7.2)
|
||||
prism (~> 1.4)
|
||||
rubocop-capybara (2.22.1)
|
||||
lint_roller (~> 1.1)
|
||||
rubocop (~> 1.72, >= 1.72.1)
|
||||
@ -65,13 +67,13 @@ GEM
|
||||
rubocop-factory_bot (2.27.1)
|
||||
lint_roller (~> 1.1)
|
||||
rubocop (~> 1.72, >= 1.72.1)
|
||||
rubocop-rails (2.30.3)
|
||||
rubocop-rails (2.32.0)
|
||||
activesupport (>= 4.2.0)
|
||||
lint_roller (~> 1.1)
|
||||
rack (>= 1.1)
|
||||
rubocop (>= 1.72.1, < 2.0)
|
||||
rubocop-ast (>= 1.38.0, < 2.0)
|
||||
rubocop-rspec (3.5.0)
|
||||
rubocop (>= 1.75.0, < 2.0)
|
||||
rubocop-ast (>= 1.44.0, < 2.0)
|
||||
rubocop-rspec (3.6.0)
|
||||
lint_roller (~> 1.1)
|
||||
rubocop (~> 1.72, >= 1.72.1)
|
||||
rubocop-rspec_rails (2.31.0)
|
||||
@ -97,4 +99,4 @@ DEPENDENCIES
|
||||
syntax_tree
|
||||
|
||||
BUNDLED WITH
|
||||
2.6.6
|
||||
2.6.9
|
||||
|
@ -21,4 +21,5 @@ const SolvedStatus = <template>
|
||||
>{{icon "far-square"}}</span>
|
||||
{{~/if~}}
|
||||
</template>;
|
||||
|
||||
export default SolvedStatus;
|
||||
|
@ -1,7 +1,9 @@
|
||||
import Component from "@glimmer/component";
|
||||
import { hash } from "@ember/helper";
|
||||
import { action } from "@ember/object";
|
||||
import { service } from "@ember/service";
|
||||
import { i18n } from "discourse-i18n";
|
||||
import ComboBox from "select-kit/components/combo-box";
|
||||
|
||||
const QUERY_PARAM_VALUES = {
|
||||
solved: "yes",
|
||||
@ -57,4 +59,19 @@ export default class SolvedStatusFilter extends Component {
|
||||
queryParams: { solved: QUERY_PARAM_VALUES[newStatus] },
|
||||
});
|
||||
}
|
||||
|
||||
<template>
|
||||
{{#if this.siteSettings.solved_enabled}}
|
||||
<li>
|
||||
<ComboBox
|
||||
@content={{this.statuses}}
|
||||
@value={{this.status}}
|
||||
@valueProperty="value"
|
||||
@options={{hash caretDownIcon="caret-right" caretUpIcon="caret-down"}}
|
||||
@onChange={{this.changeStatus}}
|
||||
class="solved-status-filter"
|
||||
/>
|
||||
</li>
|
||||
{{/if}}
|
||||
</template>
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
{{#if this.siteSettings.solved_enabled}}
|
||||
<li>
|
||||
<ComboBox
|
||||
@content={{this.statuses}}
|
||||
@value={{this.status}}
|
||||
@valueProperty="value"
|
||||
@options={{hash caretDownIcon="caret-right" caretUpIcon="caret-down"}}
|
||||
@onChange={{this.changeStatus}}
|
||||
class="solved-status-filter"
|
||||
/>
|
||||
</li>
|
||||
{{/if}}
|
@ -0,0 +1,55 @@
|
||||
import Component from "@ember/component";
|
||||
import { on } from "@ember/modifier";
|
||||
import { action } from "@ember/object";
|
||||
import { classNames, tagName } from "@ember-decorators/component";
|
||||
import { i18n } from "discourse-i18n";
|
||||
|
||||
@tagName("")
|
||||
@classNames("category-custom-settings-outlet", "solved-settings")
|
||||
export default class SolvedSettings extends Component {
|
||||
@action
|
||||
onChangeSetting(value) {
|
||||
this.set(
|
||||
"category.custom_fields.enable_accepted_answers",
|
||||
value ? "true" : "false"
|
||||
);
|
||||
}
|
||||
|
||||
<template>
|
||||
<h3>{{i18n "solved.title"}}</h3>
|
||||
|
||||
{{#unless this.siteSettings.allow_solved_on_all_topics}}
|
||||
<section class="field">
|
||||
<div class="enable-accepted-answer">
|
||||
<label class="checkbox-label">
|
||||
<input
|
||||
{{on "change" (action "onChangeSetting" value="target.checked")}}
|
||||
checked={{this.category.enable_accepted_answers}}
|
||||
type="checkbox"
|
||||
/>
|
||||
{{i18n "solved.allow_accepted_answers"}}
|
||||
</label>
|
||||
</div>
|
||||
</section>
|
||||
{{/unless}}
|
||||
|
||||
<section class="field auto-close-solved-topics">
|
||||
<label for="auto-close-solved-topics">
|
||||
{{i18n "solved.solved_topics_auto_close_hours"}}
|
||||
</label>
|
||||
<input
|
||||
{{on
|
||||
"input"
|
||||
(action
|
||||
(mut this.category.custom_fields.solved_topics_auto_close_hours)
|
||||
value="target.value"
|
||||
)
|
||||
}}
|
||||
value={{this.category.custom_fields.solved_topics_auto_close_hours}}
|
||||
type="number"
|
||||
min="0"
|
||||
id="auto-close-solved-topics"
|
||||
/>
|
||||
</section>
|
||||
</template>
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
<h3>{{i18n "solved.title"}}</h3>
|
||||
|
||||
{{#unless this.siteSettings.allow_solved_on_all_topics}}
|
||||
<section class="field">
|
||||
<div class="enable-accepted-answer">
|
||||
<label class="checkbox-label">
|
||||
<input
|
||||
{{on "change" (action "onChangeSetting" value="target.checked")}}
|
||||
checked={{this.category.enable_accepted_answers}}
|
||||
type="checkbox"
|
||||
/>
|
||||
{{i18n "solved.allow_accepted_answers"}}
|
||||
</label>
|
||||
</div>
|
||||
</section>
|
||||
{{/unless}}
|
||||
|
||||
<section class="field auto-close-solved-topics">
|
||||
<label for="auto-close-solved-topics">
|
||||
{{i18n "solved.solved_topics_auto_close_hours"}}
|
||||
</label>
|
||||
<input
|
||||
{{on
|
||||
"input"
|
||||
(action
|
||||
(mut this.category.custom_fields.solved_topics_auto_close_hours)
|
||||
value="target.value"
|
||||
)
|
||||
}}
|
||||
value={{this.category.custom_fields.solved_topics_auto_close_hours}}
|
||||
type="number"
|
||||
min="0"
|
||||
id="auto-close-solved-topics"
|
||||
/>
|
||||
</section>
|
@ -1,10 +0,0 @@
|
||||
export default {
|
||||
actions: {
|
||||
onChangeSetting(value) {
|
||||
this.set(
|
||||
"category.custom_fields.enable_accepted_answers",
|
||||
value ? "true" : "false"
|
||||
);
|
||||
},
|
||||
},
|
||||
};
|
@ -1,5 +0,0 @@
|
||||
{{#if this.topic.accepted_answer}}
|
||||
<p class="solved">
|
||||
{{html-safe this.topic.acceptedAnswerHtml}}
|
||||
</p>
|
||||
{{/if}}
|
@ -0,0 +1,63 @@
|
||||
import Component from "@ember/component";
|
||||
import { later } from "@ember/runloop";
|
||||
import { classNames, tagName } from "@ember-decorators/component";
|
||||
import TopicNavigationPopup from "discourse/components/topic-navigation-popup";
|
||||
import { isTesting } from "discourse/lib/environment";
|
||||
import { i18n } from "discourse-i18n";
|
||||
|
||||
const ONE_WEEK = 7 * 24 * 60 * 60 * 1000; // milliseconds
|
||||
const MAX_DURATION_WITH_NO_ANSWER = ONE_WEEK;
|
||||
const DISPLAY_DELAY = isTesting() ? 0 : 2000;
|
||||
|
||||
@tagName("div")
|
||||
@classNames("topic-navigation-outlet", "no-answer")
|
||||
export default class NoAnswer extends Component {
|
||||
static shouldRender(args, context) {
|
||||
return !context.site.mobileView;
|
||||
}
|
||||
|
||||
init() {
|
||||
super.init(...arguments);
|
||||
this.set("show", false);
|
||||
this.setProperties({
|
||||
oneWeek: ONE_WEEK,
|
||||
show: false,
|
||||
});
|
||||
later(() => {
|
||||
if (!this.element || this.isDestroying || this.isDestroyed) {
|
||||
return;
|
||||
}
|
||||
const topic = this.topic;
|
||||
const currentUser = this.currentUser;
|
||||
|
||||
// show notice if:
|
||||
// - user can accept answer
|
||||
// - it does not have an accepted answer
|
||||
// - topic is old
|
||||
// - topic has at least one reply from another user that can be accepted
|
||||
if (
|
||||
!topic.accepted_answer &&
|
||||
currentUser &&
|
||||
topic.user_id === currentUser.id &&
|
||||
moment() - moment(topic.created_at) > MAX_DURATION_WITH_NO_ANSWER &&
|
||||
topic.postStream.posts.some(
|
||||
(post) => post.user_id !== currentUser.id && post.can_accept_answer
|
||||
)
|
||||
) {
|
||||
this.set("show", true);
|
||||
}
|
||||
}, DISPLAY_DELAY);
|
||||
}
|
||||
|
||||
<template>
|
||||
{{#if this.show}}
|
||||
<TopicNavigationPopup
|
||||
@popupId="solved-notice"
|
||||
@dismissDuration={{this.oneWeek}}
|
||||
>
|
||||
<h3>{{i18n "solved.no_answer.title"}}</h3>
|
||||
<p>{{i18n "solved.no_answer.description"}}</p>
|
||||
</TopicNavigationPopup>
|
||||
{{/if}}
|
||||
</template>
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
{{#if this.show}}
|
||||
<TopicNavigationPopup
|
||||
@popupId="solved-notice"
|
||||
@dismissDuration={{this.oneWeek}}
|
||||
>
|
||||
<h3>{{i18n "solved.no_answer.title"}}</h3>
|
||||
<p>{{i18n "solved.no_answer.description"}}</p>
|
||||
</TopicNavigationPopup>
|
||||
{{/if}}
|
@ -1,50 +0,0 @@
|
||||
import { later } from "@ember/runloop";
|
||||
import { isTesting } from "discourse/lib/environment";
|
||||
|
||||
const ONE_WEEK = 7 * 24 * 60 * 60 * 1000; // milliseconds
|
||||
const MAX_DURATION_WITH_NO_ANSWER = ONE_WEEK;
|
||||
const DISPLAY_DELAY = isTesting() ? 0 : 2000;
|
||||
|
||||
export default {
|
||||
shouldRender(args, component) {
|
||||
return !component.site.mobileView;
|
||||
},
|
||||
|
||||
setupComponent(args, component) {
|
||||
component.set("show", false);
|
||||
component.setProperties({
|
||||
oneWeek: ONE_WEEK,
|
||||
show: false,
|
||||
});
|
||||
|
||||
later(() => {
|
||||
if (
|
||||
!component.element ||
|
||||
component.isDestroying ||
|
||||
component.isDestroyed
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const topic = args.topic;
|
||||
const currentUser = component.currentUser;
|
||||
|
||||
// show notice if:
|
||||
// - user can accept answer
|
||||
// - it does not have an accepted answer
|
||||
// - topic is old
|
||||
// - topic has at least one reply from another user that can be accepted
|
||||
if (
|
||||
!topic.accepted_answer &&
|
||||
currentUser &&
|
||||
topic.user_id === currentUser.id &&
|
||||
moment() - moment(topic.created_at) > MAX_DURATION_WITH_NO_ANSWER &&
|
||||
topic.postStream.posts.some(
|
||||
(post) => post.user_id !== currentUser.id && post.can_accept_answer
|
||||
)
|
||||
) {
|
||||
component.set("show", true);
|
||||
}
|
||||
}, DISPLAY_DELAY);
|
||||
},
|
||||
};
|
@ -0,0 +1,20 @@
|
||||
import Component from "@glimmer/component";
|
||||
import { LinkTo } from "@ember/routing";
|
||||
import { service } from "@ember/service";
|
||||
import icon from "discourse/helpers/d-icon";
|
||||
import { i18n } from "discourse-i18n";
|
||||
|
||||
export default class SolvedList extends Component {
|
||||
@service siteSettings;
|
||||
|
||||
<template>
|
||||
{{#if this.siteSettings.solved_enabled}}
|
||||
<li class="user-activity-bottom-outlet solved-list">
|
||||
<LinkTo @route="userActivity.solved">
|
||||
{{icon "square-check"}}
|
||||
{{i18n "solved.title"}}
|
||||
</LinkTo>
|
||||
</li>
|
||||
{{/if}}
|
||||
</template>
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
{{#if this.siteSettings.solved_enabled}}
|
||||
<li class="user-activity-bottom-outlet solved-list">
|
||||
<LinkTo @route="userActivity.solved">
|
||||
{{d-icon "square-check"}}
|
||||
{{i18n "solved.title"}}
|
||||
</LinkTo>
|
||||
</li>
|
||||
{{/if}}
|
@ -1,6 +0,0 @@
|
||||
import Component from "@glimmer/component";
|
||||
import { service } from "@ember/service";
|
||||
|
||||
export default class SolvedList extends Component {
|
||||
@service siteSettings;
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
import Component from "@ember/component";
|
||||
import { classNames, tagName } from "@ember-decorators/component";
|
||||
import { i18n } from "discourse-i18n";
|
||||
|
||||
@tagName("div")
|
||||
@classNames("user-card-metadata-outlet", "accepted-answers")
|
||||
export default class AcceptedAnswers extends Component {
|
||||
<template>
|
||||
{{#if this.user.accepted_answers}}
|
||||
<span class="desc">{{i18n "solutions"}}</span>
|
||||
<span>{{this.user.accepted_answers}}</span>
|
||||
{{/if}}
|
||||
</template>
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
{{#if this.user.accepted_answers}}
|
||||
<span class="desc">{{i18n "solutions"}}</span>
|
||||
<span>{{this.user.accepted_answers}}</span>
|
||||
{{/if}}
|
@ -0,0 +1,25 @@
|
||||
import Component from "@glimmer/component";
|
||||
import { LinkTo } from "@ember/routing";
|
||||
import { service } from "@ember/service";
|
||||
import { and } from "truth-helpers";
|
||||
import UserStat from "discourse/components/user-stat";
|
||||
|
||||
export default class SolvedCount extends Component {
|
||||
@service siteSettings;
|
||||
|
||||
<template>
|
||||
{{#if
|
||||
(and this.siteSettings.solved_enabled @outletArgs.model.solved_count)
|
||||
}}
|
||||
<li class="user-summary-stat-outlet solved-count linked-stat">
|
||||
<LinkTo @route="userActivity.solved">
|
||||
<UserStat
|
||||
@value={{@outletArgs.model.solved_count}}
|
||||
@label="solved.solution_summary"
|
||||
@icon="square-check"
|
||||
/>
|
||||
</LinkTo>
|
||||
</li>
|
||||
{{/if}}
|
||||
</template>
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
{{#if (and this.siteSettings.solved_enabled @outletArgs.model.solved_count)}}
|
||||
<li class="user-summary-stat-outlet solved-count linked-stat">
|
||||
<LinkTo @route="userActivity.solved">
|
||||
<UserStat
|
||||
@value={{@outletArgs.model.solved_count}}
|
||||
@label="solved.solution_summary"
|
||||
@icon="square-check"
|
||||
/>
|
||||
</LinkTo>
|
||||
</li>
|
||||
{{/if}}
|
@ -1,6 +0,0 @@
|
||||
import Component from "@glimmer/component";
|
||||
import { service } from "@ember/service";
|
||||
|
||||
export default class SolvedCount extends Component {
|
||||
@service siteSettings;
|
||||
}
|
@ -88,7 +88,7 @@ aside.quote.accepted-answer {
|
||||
margin-bottom: auto;
|
||||
margin-right: 0.25em;
|
||||
|
||||
@media (min-width: 480px) {
|
||||
@media (width >= 480px) {
|
||||
width: auto;
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
{
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"@discourse/lint-configs": "2.11.1",
|
||||
"ember-template-lint": "7.0.1",
|
||||
"eslint": "9.22.0",
|
||||
"@discourse/lint-configs": "2.23.0",
|
||||
"ember-template-lint": "7.7.0",
|
||||
"eslint": "9.28.0",
|
||||
"prettier": "3.5.3",
|
||||
"stylelint": "16.16.0"
|
||||
"stylelint": "16.20.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 22",
|
||||
|
872
pnpm-lock.yaml
generated
872
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user