Commit Graph

223 Commits

Author SHA1 Message Date
Jarek Radosz 584a3a4237
DEV: Remove unneeded optional chaining operators (#21019)
(and fix a typo, and remove an unnecessary `this.element` check)
2023-04-07 14:10:49 +02:00
Osama Sayegh 78befbc53e
DEV: Remove `{{user-selector}}` (#17753)
`{{user-selector}}` was deprecated in 293fd1f743 more than 2 years ago and it's time we deleted it.
2023-03-29 11:49:47 +03:00
Blake Erickson a373bf2a01 SECURITY: XSS on chat excerpts
Non-markdown tags weren't being escaped in chat excerpts. This could be
triggered by editing a chat message containing a tag (self XSS), or by
replying to a chat message with a tag (XSS).

Co-authored-by: Jan Cernik <jancernik12@gmail.com>
2023-03-16 15:27:09 -06:00
David Taylor 059ac3d31a
DEV: Unsilence and resolve setting-on-hash deprecation (#20611)
Select-kit was mutating a passed-in options hash to apply its own deprecations. This commit updates it to apply deprecated changes to the downstream `this.selectKit.options` object instead.
2023-03-09 13:44:31 +00:00
David Battersby 8eb2fa5fa9
FEATURE: add new tags from edit tag synonyms page (#20553)
Feature to allow adding new tags from the edit tag synonyms tag search field.
Previously new tags had to be created from the topic composer, and then added via the edit tag synonyms page.

/t/92741
2023-03-08 14:26:20 +08:00
Joffrey JAFFEUX c52570ddc4
FIX: prevents mouseover to gain focus on sk row (#20550)
This was causing unattended effects on other elements. eg: the select-kit header input could lose focus when the list filtered would change size and cause the cursor to be positioned over a row.
2023-03-07 09:27:38 +11:00
Keegan George 6108eee31d
DEV: Apply form template to categories (#20337) 2023-02-23 11:18:14 -08:00
Krzysztof Kotlarek 85fbe3f628
FIX: IconPicker option to display only available icons (#20235)
Not all icons are shipped by default. Sidebar section icon picker should only display available icons.
2023-02-13 09:24:47 +11:00
Krzysztof Kotlarek f1a52db0a0
Revert "FIX: IconPicker option to display only available icons (#20226)" (#20227)
This reverts commit fc166258d3.
2023-02-09 15:20:34 +11:00
Krzysztof Kotlarek fc166258d3
FIX: IconPicker option to display only available icons (#20226)
Not all icons are shipped by default. Sidebar section icon picker should only display available icons.
2023-02-09 14:20:04 +11:00
David Taylor fa30ab4ed7 DEV: Correct hbs prettier violations 2023-02-02 13:03:11 +00:00
chapoi d59ed1cbfe
UX: fix alignment issues with autocomplete (#19828) 2023-01-16 09:09:23 +11:00
Joffrey JAFFEUX a444023113
DEV: adds row index support (#19871)
This commits adds a data-index attribute on each `select-kit-row` DOM node and also makes available `this.index` in each `select-kit-row` template.
2023-01-13 16:39:21 +01:00
Joffrey JAFFEUX f525f722ea
DEV: adds expandedOnInsert option to sk (#19870)
Allows to display a select-kit component expanded by default.

Usage:

```
<SingleSelect
  @value={{this.value}}
  @content={{this.content}}
  @options={{hash expandedOnInsert=true}}
/>
```
2023-01-13 16:13:13 +01:00
David Taylor c8e2e37fa7 DEV: Apply prettier to hbs files 2022-12-28 13:11:12 +00:00
Bianca Nenciu 8f9933d1dd
DEV: Add default results option to user-chooser (#19521)
defaultSearchResults search option can be used to show a list of results
by default, before any search ran, when the filter is empty.
2022-12-21 14:47:47 +02:00
Bianca Nenciu 7d7551adfc
DEV: Remove user options from current user serializer (#19089)
User options were serialized at the root level of CurrentUserSerializer,
but UserSerializer has a user_option field. This inconsistency caused
issues in the past because user_option fields had to be duplicated on
the frontend.
2022-12-05 18:25:30 +02:00
Jarek Radosz 59f1d01381
DEV: Convert `SiteSettings` to a tracked object (#19015)
TrackedObject allows us to reference SiteSettings in autotracking contexts (e.g. JS getters referenced from a Glimmer template) without the need for EmberObject's `get()`  function. TrackedObject is backwards-compatible with Ember's legacy reactivity model, so it can be referenced in things like computed properties.

Co-authored-by: David Taylor <david@taylorhq.com>
2022-11-17 18:44:23 +01:00
David Taylor 392bafcd7e
DEV: Add unique ids to deprecations (#19019)
This will improve the QUnit deprecation summaries introduced via 8c48285145
2022-11-16 10:00:39 +00:00
Blake Erickson 7be53b1588
FEATURE: Default Composer Category Site Setting (#18967)
* FEATURE: Default Composer Category Site Setting

- Create the default_composer_category site setting
- Replace general_category_id logic for auto selecting the composer
  category
- Prevent Uncategorized from being selected if not allowed
- Add default_composer_category option to seeded categories
- Create a migration to populate the default_composer_category site
  setting if there is a general_category_id populated
- Added some tests

* Add missing translation for the new site setting

* fix some js tests

* Just check that the header value is null
2022-11-14 11:09:57 -07:00
Joffrey JAFFEUX c0a4823203
UX: tweaks to msg actions menu (#18966)
- allows to scroll while hovering the menu
- correctly changes message background color while hovering menu
- prevents a bug where it would sometimes close the menu while moving from menu to the 3 dots expanded dropdown. This was caused by the gap between header/body of the 3 dots dropdown, which would sometimes allow to create a mouseover event on a possible different underlying message
- removes recent/favorite reactions on drawer mode
- grayscale reactions until hover
- boxshadow on msgactions container
- removes useless code
2022-11-10 07:42:37 +01:00
Keegan George 1b22ff461b
FIX: Prevent layout shift while traversing dropdown (#18624) 2022-10-17 11:40:03 -07:00
Isaac Janzen 231dc10bbd
Add replaceContent selectKit modifier (#18569)
Add the ability to modify a selectKit's content with `replaceContent`

Eg.

```
      api.modifySelectKit("combo-box").replaceContent(() => {
        return {
          id: "foo",
          name: "Foo",
        };
      });
```

will override existing content to only include the passed object
2022-10-12 13:38:42 -05:00
Penar Musaraj a1d67122b1
DEV: Refactor the last few bootbox dialogs (#18416) 2022-10-07 11:38:27 -04:00
Dan Gebhardt 03b7b7d1bc
DEV: Remove usage of {{action}} modifiers - Take 2 (#18476)
This PR enables the [`no-action-modifiers`](https://github.com/ember-template-lint/ember-template-lint/blob/master/docs/rule/no-action-modifiers.md) template lint rule and removes all usages of the `{{action}}` modifier in core.

In general, instances of `{{action "x"}}` have been replaced with `{{on "click" (action "x")}}`. 

In many cases, such as for `a` elements, we also need to prevent default event handling to avoid unwanted side effects. While the `{{action}}` modifier internally calls `event.preventDefault()`, we need to handle these cases more explicitly. For this purpose, this PR also adds the [ember-event-helpers](https://github.com/buschtoens/ember-event-helpers) dependency so we can use the `prevent-default` handler. For instance:

```
<a href {{on "click" (prevent-default (action "x"))}}>Do X</a>
```

Note that `action` has not in general been refactored away as a helper yet. In general, all event handlers should be methods on the corresponding component and referenced directly (e.g. `{{on "click" this.doSomething}}`). However, the `action` helper is used extensively throughout the codebase and often references methods in the `actions` hash on controllers or routes. Thus this refactor will also be extensive and probably deserves a separate PR.

Note: This work was done to complement #17767 by minimizing the potential impact of the `action` modifier override, which uses private API and arguably should be replaced with an AST transform.

This is a followup to #18333, which had to be reverted because it did not account for the default treatment of modifier keys by the {{action}} modifier.

Commits:
* Enable `no-action-modifiers` template lint rule
* Replace {{action "x"}} with {{on "click" (action "x")}}
* Remove unnecessary action helper usage
* Remove ctl+click tests for user-menu
   These tests now break in Chrome when used with addEventListener. As per the comment, they can probably be safely removed.
* Prevent default event handlers to avoid unwanted side effects
   Uses `event.preventDefault()` in event handlers to prevent default event handling. This had been done automatically by the `action` modifier, but is not always desirable or necessary.
* Restore UserCardContents#showUser action to avoid regression
   By keeping the `showUser` action, we can avoid a breaking change for plugins that rely upon it, while not interfering with the `showUser` argument that's been passed.
* Revert EditCategoryTab#selectTab -> EditCategoryTab#select
   Avoid potential breaking change in themes / plugins
* Restore GroupCardContents#showGroup action to avoid regression
   By keeping the `showGroup` action, we can avoid a breaking change for plugins that rely upon it, while not interfering with the `showGroup` argument that's been passed.
* Restore SecondFactorAddTotp#showSecondFactorKey action to avoid regression
   By keeping the `showSecondFactorKey` action, we can avoid a breaking change for plugins that rely upon it, while not interfering with the `showSecondFactorKey` property that's maintained on the controller.
* Refactor away from `actions` hash in ChooseMessage component
* Modernize EmojiPicker#onCategorySelection usage
* Modernize SearchResultEntry#logClick usage
* Modernize Discovery::Categories#showInserted usage
* Modernize Preferences::Account#resendConfirmationEmail usage
* Modernize MultiSelect::SelectedCategory#onSelectedNameClick usage
* Favor fn over action in SelectedChoice component
* Modernize WizardStep event handlers
* Favor fn over action usage in buttons
* Restore Login#forgotPassword action to avoid possible regression
* Introduce modKeysPressed utility
   Returns an array of modifier keys that are pressed during a given `MouseEvent` or `KeyboardEvent`.
* Don't interfere with click events on links with `href` values when modifier keys are pressed
2022-10-05 13:08:54 +01:00
David Taylor 585c584fdb
Revert "DEV: Remove usage of `{{action}}` modifiers (#18333)" (#18469)
This reverts commit ba27ee1637.

We found some issues with handling of cmd/ctrl/shift + click on `<a` elements
2022-10-04 12:27:26 +01:00
Dan Gebhardt ba27ee1637
DEV: Remove usage of `{{action}}` modifiers (#18333)
This PR enables the [`no-action-modifiers`](https://github.com/ember-template-lint/ember-template-lint/blob/master/docs/rule/no-action-modifiers.md) template lint rule and removes all usages of the `{{action}}` modifier in core.

In general, instances of `{{action "x"}}` have been replaced with `{{on "click" (action "x")}}`. 

In many cases, such as for `a` elements, we also need to prevent default event handling to avoid unwanted side effects. While the `{{action}}` modifier internally calls `event.preventDefault()`, we need to handle these cases more explicitly. For this purpose, this PR also adds the [ember-event-helpers](https://github.com/buschtoens/ember-event-helpers) dependency so we can use the `prevent-default` handler. For instance:

```
<a href {{on "click" (prevent-default (action "x"))}}>Do X</a>
```

Note that `action` has not in general been refactored away as a helper yet. In general, all event handlers should be methods on the corresponding component and referenced directly (e.g. `{{on "click" this.doSomething}}`). However, the `action` helper is used extensively throughout the codebase and often references methods in the `actions` hash on controllers or routes. Thus this refactor will also be extensive and probably deserves a separate PR.

Note: This work was done to complement #17767 by minimizing the potential impact of the `action` modifier override, which uses private API and arguably should be replaced with an AST transform.

Commits:
* Enable `no-action-modifiers` template lint rule
* Replace {{action "x"}} with {{on "click" (action "x")}}
* Remove unnecessary action helper usage
* Remove ctl+click tests for user-menu
   These tests now break in Chrome when used with addEventListener. As per the comment, they can probably be safely removed.
* Prevent default event handlers to avoid unwanted side effects
   Uses `event.preventDefault()` in event handlers to prevent default event handling. This had been done automatically by the `action` modifier, but is not always desirable or necessary.
* Restore UserCardContents#showUser action to avoid regression
   By keeping the `showUser` action, we can avoid a breaking change for plugins that rely upon it, while not interfering with the `showUser` argument that's been passed.
* Revert EditCategoryTab#selectTab -> EditCategoryTab#select
   Avoid potential breaking change in themes / plugins
* Restore GroupCardContents#showGroup action to avoid regression
   By keeping the `showGroup` action, we can avoid a breaking change for plugins that rely upon it, while not interfering with the `showGroup` argument that's been passed.
* Restore SecondFactorAddTotp#showSecondFactorKey action to avoid regression
   By keeping the `showSecondFactorKey` action, we can avoid a breaking change for plugins that rely upon it, while not interfering with the `showSecondFactorKey` property that's maintained on the controller.
* Refactor away from `actions` hash in ChooseMessage component
* Modernize EmojiPicker#onCategorySelection usage
* Modernize SearchResultEntry#logClick usage
* Modernize Discovery::Categories#showInserted usage
* Modernize Preferences::Account#resendConfirmationEmail usage
* Modernize MultiSelect::SelectedCategory#onSelectedNameClick usage
* Favor fn over action in SelectedChoice component
* Modernize WizardStep event handlers
* Favor fn over action usage in buttons
* Restore Login#forgotPassword action to avoid possible regression
2022-10-04 10:42:46 +02:00
Blake Erickson 6affbabfd3
FIX: New general category changes preventing topic create (#18459)
* FIX: New general category changes preventing topic create

Follow up to: #18383

The logic in the previous commit was checking for null, but we are
seeding the SiteSetting.general_category_id with an id of -1 so we need
to check for a positive value as well as checking for null.

See: https://meta.discourse.org/t/240661

* Add js test for presence of category… dropdown option
2022-10-03 12:19:41 -06:00
Blake Erickson 3b86974367
FEATURE: Make General the default category (#18383)
* FEATURE: Make General the default category

* Set general as the default category in the composer model instead

* use semicolon

* Enable allow_uncategorized_topics in create_post spec helper for now

* Check if general_category_id is set

* Enable allow_uncategorized_topics for test env

* Provide an option to the create_post helper to not set allow_uncategorized_topics

* Add tests to check that category… is not present and that General is selected automatically
2022-09-30 12:20:21 -06:00
Roman Rizzi ba139b8c23
REFACTOR: Improve reusability by Decoupling flag modal from flag target. (#18251)
* REFACTOR: Improve reusability by Decoupling flag modal from flag target.

We want chat message's flags to have the same features as topic and posts' flags, but we prefer not having to duplicate core's logic. This PR moves target specific bits to different classes, allowing plugins to flag custom things by
providing their own.

* A couple of fixes for the flag modal:

- Make sure buttons are disabled until a flag type is selected.
- Don't throw an error when checking if the user can undo an action on a deleted topic.
- Disable flagging on deleted topics.
2022-09-29 11:57:36 -03:00
Andrei Prigorshnev 833c8055e1
FEATURE: Optionally show user status on email group user chooser (#18367) 2022-09-28 17:31:20 +04:00
Penar Musaraj 4e1b9a225e
DEV: Reduce width calculations for SK dropdowns (#18263)
Previously we were calculating both the minimum and maximum widths for
SK dropdowns using this Popper modifier. The max. width calculation was
causing issues with dropdowns in Firefox and was also sluggish when
rendering.

This switches to using CSS calculations for max. widths. It adds a 600px
global maximum and targeted maximums for the category composer dropdown
and the bookmark list dropdowns.
2022-09-20 22:59:47 -04:00
Isaac Janzen ce30422d6c
DEV: Add select-kit option to hide values from preview (#18002)
* DEV: Add select-kit option to hide values from preview
2022-08-19 11:39:58 -05:00
Joffrey JAFFEUX 2003c2d4cd
FIX: prevents android keyboard to be hidden instantly on sk focus (#17810) 2022-08-05 13:09:38 -04:00
Joffrey JAFFEUX 43b8cfeae3
FIX: improves handling of filter with invalid tag chars (#17640)
Tags mixin is already filtering a lot of data from the user submitted filter in `createContentFromInput()` which can lead to sk receiving an empty filter while the input actually has a value.
2022-07-25 12:00:52 +02:00
Jarek Radosz 9028df0fda
DEV: Use `includes()` instead of `indexOf() >= 0` (#17553)
Missed those cases in #17541
2022-07-19 10:27:40 +08:00
Jarek Radosz 0db6ae1e1f
DEV: Fix typos and other spell-checker warnings (#17554) 2022-07-19 10:27:10 +08:00
Joffrey JAFFEUX c94a011d9f
FIX: prevents multi-select to use noneItem for its list (#17523) 2022-07-18 11:26:12 +02:00
Joffrey JAFFEUX ab05d931a0
DEV: updates popper to 2.11.5 (#17522)
This commit also removes a modifier used in select-kit which was causing issues with this update and doesn’t appear to be needed anymore.
2022-07-18 11:06:19 +02:00
Jarek Radosz 057d6b406d
DEV: Extensively use `includes()` (#17541)
Also, the change in insert-hyperlink (from `this.linkUrl.indexOf("http") === -1` to `!this.linkUrl.startsWith("http")`) was intentional fix: we don't want to prevent users from looking up topics with http in their titles.
2022-07-17 20:48:36 +02:00
Joffrey JAFFEUX a939609d32
FIX: fixes few regressions in select-kit (#17453)
- following c3fd91670e `paste` has been typoed into `pase`
- adds two tests for pasting in `multi-select` and `email-group-user-chooser`
- selectKitOptions would not be following the right overriding order
- `category-selector` was using `selectKitOptions` directly which shouldn't be the case as it's not using computed values
- apparently since a recent ember upgrade, paste event is not providing `originalEvent` anymore and `clipboardData` should be retrieved directly on the event
2022-07-12 21:38:17 +02:00
Jarek Radosz c3fd91670e
DEV: Update linting setup and fix issues (#17345)
Re-lands #16119 and #17298

* Update eslint-config-discourse
* Update linting workflow
* Prettier-ignore stuff
* Update template-lint config
* Auto-fix template issues
* Fix various template issues
  Mostly incorrect attributes and unused templates
* Prettier js files
* Fix template auto-fix regressions
* Small css tweak

Co-authored-by: Peter Wagenet <peter.wagenet@gmail.com>
2022-07-06 10:37:54 +02:00
Peter Wagenet 371bbadb92
No implicit this codemod (#17235)
* Run no-implicit-this codemod for app templates
* Run tagless-ember-components-codemod for plugins
* Turn on no-implicit-this lint
2022-07-05 19:41:31 +02:00
Peter Wagenet 7caaee27cc
DEV: Generate template backing classes for app (#17300)
```sh
npx ember-holy-futuristic-template-namespacing-batman-codemod ensure-template-only-has-backing-class
```

We would like to colocate templates but, when no backing class exists, colocated templates extend `templateOnly` instead of `Ember.Component`. Generating the backing class helps avoid any behavioral changes.

We can also run the `tagless-ember-components-codemod` to put the tags into the templates at which point we could convert these back to template-only components.
2022-07-04 01:27:29 +02:00
Jarek Radosz 16ea7ab248
DEV: Run angle-brackets codemod (#17286)
Co-authored-by: Peter Wagenet <peter.wagenet@gmail.com>
2022-06-30 12:30:50 +02:00
Alan Guo Xiang Tan 3266350e80
FEATURE: Decouple category/tag presence in sidebar from notifi level (#17273) 2022-06-30 14:54:20 +08:00
Jarek Radosz 011a16cb8a
DEV: Rename `translatedtitle` to `translatedTitle` (#17160) 2022-06-20 12:28:05 -06:00
Jarek Radosz 36c2284dea
DEV: Fix typos "formated" -> "formatted" (#17156)
(nothing in all-the* relies on these)
2022-06-20 20:02:05 +02:00
Isaac Janzen 1ada3a9404
DEV: Remove use of run-loop-and-computed-dot-access (#17113)
Context: https://deprecations.emberjs.com/v3.x/#toc_deprecated-run-loop-and-computed-dot-access
2022-06-17 09:43:13 -05:00
Osama Sayegh b0a896a10f
UX: Skip special paste handling in email-group-user-chooser when maximum is 1 (#17124)
`email-group-user-chooser` currently handles paste events to allow users to paste multiple entries at once instead of entering them one by one. This behavior makes sense when the component is used in scenarios where it makes sense to provide multiple entries such as the recipients field when creating a PM. However, for instances where the component accepts only 1 entry, it doesn't make a lot of sense to do custom handling of paste events.

This commit makes our paste event handler a NOOP when the component is configured to accept only 1 entry in which case pasting will simply input the value into the component's search field.
2022-06-17 16:53:50 +03:00