Commit Graph

15989 Commits

Author SHA1 Message Date
Jarek Radosz f822a933fa
DEV: Clean up pre-initializers (#18680) 2022-10-26 09:19:54 +08:00
Andrei Prigorshnev 9129f18815
DEV: make possible to pass both async and sync callbacks to the user status modal (#18712) 2022-10-26 08:59:08 +08:00
Isaac Janzen 2737bc55bb
DEV: Update docs for composerBeforeSave (#18746)
* DEV: Update docs for composerBeforeSave
2022-10-25 14:19:45 -05:00
Jarek Radosz 3949efb45f
FIX: Reset error props on Topic model (#18739)
If there's an error loading a topic, and later you load it successfully - the the stale error message would still briefly show up every time you navigate to that topic
2022-10-25 12:17:00 +02:00
Alan Guo Xiang Tan d85c89ba6d
FIX: Category chooser not updating selection when editing reviewable (#18737) 2022-10-25 09:13:37 +08:00
Kris b6f5b236b3
UX: drag new user menus, scroll primary user nav (#18690) 2022-10-25 07:22:02 +08:00
Jarek Radosz 589a249a65
FIX: Correctly reset `controllerReady` prop (#18727) 2022-10-24 23:00:37 +02:00
David Taylor 4c4ac9cc47
Revert "DEV: Normalize event handling to improve Glimmer + Classic component compat (#18490)" (#18725)
This reverts commit 28be5d3037 and fcb4675415

This caused qunit timeouts in our internal CI environments. Not sure of the exact cause yet, but we're reverting for now while we investigate.
2022-10-24 18:30:08 +01:00
David Taylor fcb4675415
DEV: Ensure event-handling reopens are only performed once (#18722)
In test mode we reinitialize the Application for every test. We only want to apply the class reopens once to avoid performance regressions and memory leaks in the test suite.
2022-10-24 17:13:54 +01:00
Dan Gebhardt 28be5d3037
DEV: Normalize event handling to improve Glimmer + Classic component compat (#18490)
Classic Ember components (i.e. "@ember/component") rely upon "event
delegation" to listen for events at the application root and then dispatch
those events to any event handlers defined on individual Classic components.
This coordination is handled by Ember's EventDispatcher.

In contrast, Glimmer components (i.e. "@glimmer/component") expect event
listeners to be added to elements using modifiers (such as `{{on "click"}}`).
These event listeners are added directly to DOM elements using
`addEventListener`. There is no need for an event dispatcher.

Issues may arise when using Classic and Glimmer components together, since it
requires reconciling the two event handling approaches. For instance, event
propagation may not work as expected when a Classic component is nested
inside a Glimmer component.

`normalizeEmberEventHandling` helps an application standardize upon the
Glimmer event handling approach by eliminating usage of event delegation and
instead rewiring Classic components to directly use `addEventListener`.

Specifically, it performs the following:

- Invokes `eliminateClassicEventDelegation()` to remove all events associated
  with Ember's EventDispatcher to reduce its runtime overhead and ensure that
  it is effectively not in use.

- Invokes `rewireClassicComponentEvents(app)` to rewire each Classic
  component to add its own event listeners for standard event handlers (e.g.
  `click`, `mouseDown`, `submit`, etc.).

- Configures an instance initializer that invokes
  `rewireActionModifier(appInstance)` to redefine the `action` modifier with
    a substitute that uses `addEventListener`.

Additional changes include:
* d-button: only preventDefault / stopPropagation for handled actions
   This allows unhandled events to propagate as expected.
* d-editor: avoid adding duplicate event listener for tests
   This extra event listener causes duplicate paste events in tests.
* group-manage-email-settings: Monitor `input` instead of `change` event for checkboxes
2022-10-24 16:06:11 +01:00
Kris a5a3749325
DEV: remove old CustomHTML outlet (#18711) 2022-10-24 10:48:48 -04:00
dependabot[bot] 6c224929d7
Build(deps): Bump qunit from 2.19.2 to 2.19.3 in /app/assets/javascripts (#18714)
Bumps [qunit](https://github.com/qunitjs/qunit) from 2.19.2 to 2.19.3.
- [Release notes](https://github.com/qunitjs/qunit/releases)
- [Changelog](https://github.com/qunitjs/qunit/blob/main/History.md)
- [Commits](https://github.com/qunitjs/qunit/compare/2.19.2...2.19.3)

---
updated-dependencies:
- dependency-name: qunit
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-24 10:48:03 +02:00
David Taylor 0a33c507d9
DEV: Improve colocated component rootName logic (#18708)
The complex regex-based detection was based on Ember CLI's implementation, which is necessarily generic and needs to auto-detect the name. In our case, we know the name of the plugin so we can just pass it in - no need for dynamic detection. This resolves issues when there are other files in the `discourse/plugins/{name}` directory which are sorted before `discourse/`
2022-10-21 20:20:46 +01:00
Kris db0dbdf89a
DEV: add plugin outlet to sidebar footer (#18707) 2022-10-21 15:07:12 -04:00
Penar Musaraj 414d3b8185
A11Y: Add title to drafts remove icon button (#18706) 2022-10-21 14:32:58 -04:00
Penar Musaraj 28bb81b50a
A11Y: Add `for` attributes for location, website in profile (#18705) 2022-10-21 14:32:45 -04:00
David Taylor 7e23662a44
DEV: Remove unneeded `templateOnly()` stubs (#18701)
Lone hbs files in the `/components` are automatically assumed to be template-only Glimmer components. The `templateOnly()` stub is only required when templates are in the `/templates/components` directory.
2022-10-21 15:12:53 +01:00
dependabot[bot] 5827d1eecc
Build(deps): Bump @babel/standalone from 7.19.3 to 7.19.6 in /app/assets/javascripts (#18689)
Bumps [@babel/standalone](https://github.com/babel/babel/tree/HEAD/packages/babel-standalone) from 7.19.3 to 7.19.6.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.19.6/packages/babel-standalone)

---
updated-dependencies:
- dependency-name: "@babel/standalone"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Tweak whitespace expectations in tests

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: David Taylor <david@taylorhq.com>
2022-10-21 14:48:27 +01:00
dependabot[bot] 290da76981
Build(deps): Bump @babel/core in /app/assets/javascripts (#18687)
Bumps [@babel/core](https://github.com/babel/babel/tree/HEAD/packages/babel-core) from 7.19.3 to 7.19.6.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.19.6/packages/babel-core)

---
updated-dependencies:
- dependency-name: "@babel/core"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-21 14:47:04 +01:00
Martin Brennan d379edec8d
FIX: Clientside checks for personal_message_enabled_groups (#18691)
The clientside allowPersonalMessages function introduced
in e62e93f83a sometimes did not
work correctly, because the currentUser.groups property
only contained **visible** groups for the current user, which
could exclude auto groups that had their permissions set to
be owner-only visible.

It was unnecessary to add this anyway since we already have
can_send_private_messages on the CurrentUserSerializer. It's
better the backend does this calculation anyway. Use that
in the clientside code instead and get rid of allowPersonalMessages
2022-10-21 14:38:33 +10:00
Penar Musaraj a14825836f
UX: Show category edit button when in tag intersection (#18679)
Given that the category structure is generally speaking the backbone of most Discourse instances, it makes sense to show the edit button for the category even when the user is in a category/tag intersection route.
2022-10-20 15:04:21 -04:00
Jarek Radosz 8304f40f84
FIX: Correctly debounce various functions (#18673)
Debouncing inline anonymous functions does not work.

This fixes all instances of that error by extracting the function or using the new `@debounce(delay)` decorator
2022-10-20 13:28:09 +02:00
Osama Sayegh ce53152e53
DEV: Include theme_uploads and theme_uploads_local objects in theme tests (#18645)
Our theme system injects a magical `settings` object at the top of themes JS modules to allow theme authors to access the settings as configured by admins in the UI. Within this `settings` object, there are a couple of special objects `theme_uploads` and `theme_uploads_local` that contain URLs for all the assets/uploads that the theme has.

For test modules/files, the theme system also injects a `settings` object at the top of tests modules, but it's not the same object as the object that's injected in non-test files. The difference is that in tests we want the settings to have their default values as opposed to any custom values that may exist in the site's database. This ensures that test results are consistent no matter the site that runs them.

However, the `settings` object in tests files currently doesn't have the special objects `theme_uploads` and `theme_uploads_local` which means that if a theme includes an asset that's lazy-loaded, it's not possible to write tests for anything that depends on the lazy-loaded asset because the theme will not be able to load the asset during the tests since `theme_uploads_local` and `theme_uploads` don't exist. This PR adds these special objects inside the `settings` object for test files.

Internal topic: t/71825/52.
2022-10-20 08:00:29 +03:00
Bianca Nenciu 66904f2cd2
FEATURE: Add button to reset seen popups (#18586) 2022-10-20 09:06:39 +08:00
Kris f1f2c1acd4
UX: extend horizontal user nav to all user pages (#18674) 2022-10-20 09:05:51 +08:00
Jarek Radosz 09e4eb4137
DEV: Introduce a `@debounce(delay)` decorator (#18667)
An example from tests:

```js
class TestStub {
  counter = 0;

  @debounce(50)
  increment() {
    this.counter++;
  }
}

const stub = new TestStub();

stub.increment();
stub.increment();
stub.increment();
await settled();

assert.strictEqual(stub.counter, 1);
```
2022-10-19 20:43:58 +02:00
David Taylor 9a4072fe31
DEV: Load plugin CSS in tests (#18668) 2022-10-19 18:10:06 +01:00
Penar Musaraj a96f22cd67
FIX: Calculate header offset once on load (#18669)
Multiple things in the app need the height of the header to be correct (for example, scrolling to a post), so we need the header offset calculation. However, we shouldn't be calculating it on scroll, it's too resource intensive and it causes flickering on iPads (and possible other devices too).

This commit removes header offset calculation on scroll and adds a one-time calculation as soon as the header is first rendered. This ensures that users get scrolled to the correct post even if they open it in a new tab.
2022-10-19 12:07:44 -04:00
David Taylor 58e59e3579
DEV: Remove all use of Ember/jQuery globals in core (#18670) 2022-10-19 17:04:49 +01:00
David Taylor 91b991320c
DEV: Enable ember-qunit's `TestIsolationValidation` feature (#18666)
This ensures ember's runloop is settled before starting the next test.
2022-10-19 12:07:04 +01:00
Jarek Radosz a53eb0882a
DEV: Prevent potential site state leaks in tests (#18663)
If one were to modify nested objects in `Site.current()` those changes would be carried over subsequent tests.
2022-10-19 11:46:01 +02:00
Jeff Wong 437de6338e DEV: add currentPath arg to above-site-header plugin outlet 2022-10-18 21:25:46 -07:00
Martin Brennan 7c25597da2
FEATURE: Generic hashtag autocomplete part 1 (#18592)
This commit adds a new `/hashtag/search` endpoint and both
relevant JS and ruby plugin APIs to handle plugins adding their
own data sources and priority orders for types of things to search
when `#` is pressed.

A `context` param is added to `setupHashtagAutocomplete` which
a corresponding chat PR https://github.com/discourse/discourse-chat/pull/1302
will now use.

The UI calls `registerHashtagSearchParam` for each context that will
require a `#` search (e.g. the topic composer), for each type of record that
the context needs to search for, as well as a priority order for that type. Core
uses this call to add the `category` and `tag` data sources to the topic composer.

The `register_hashtag_data_source` ruby plugin API call is for plugins to
add a new data source for the hashtag searching endpoint, e.g. discourse-chat
may add a `channel` data source.

This functionality is hidden behind the `enable_experimental_hashtag_autocomplete`
flag, except for the change to `setupHashtagAutocomplete` since only core and
discourse-chat are using that function. Note this PR does **not** include required
changes for hashtag lookup or new styling.
2022-10-19 14:03:57 +10:00
Krzysztof Kotlarek 45bdfa1c84
FIX: sidebar_list_destination on CurrentUserSerializer (#18660)
Before, `sidebar_list_destination` was an attribute on UserOptionSerializer. The problem was that this attribute was added to user model only when the user entered the preferences panel. We want that attribute to be available all the time, therefore it was moved to CurrentUserSerializer.
2022-10-19 11:48:36 +11:00
Keegan George dcbfbbf19d
A11Y: Add `aria-label` to topic post badges (#18657) 2022-10-18 15:14:27 -07:00
Keegan George a8af510636
A11Y: Return focus to header search button upon escape of search (#18656) 2022-10-18 15:01:09 -07:00
Krzysztof Kotlarek 799fa8d6f9
FIX: sidebar list destination for tracked and tags (#18639)
Follow up for https://github.com/discourse/discourse/pull/18594

Same solution for tracked and tag links.
2022-10-19 08:19:50 +11:00
Keegan George 8791b6d5ee
A11Y: Improve group search accessibility (#18651) 2022-10-18 12:55:44 -07:00
Penar Musaraj a2596fb306
A11Y: Add aria labels for posts in group activity (#18601)
This view can show multiple posts from the same topic and the aria labels
will now include the post number to more easily differentiate posts in
screen readers.
2022-10-18 13:58:26 -04:00
David Taylor be3d6a56ce
DEV: Introduce minification and source maps for Theme JS (#18646)
Theme javascript is now minified using Terser, just like our core/plugin JS bundles. This reduces the amount of data sent over the network.

This commit also introduces sourcemaps for theme JS. Browser developer tools will now be able show each source file separately when browsing, and also in backtraces.

For theme test JS, the sourcemap is inlined for simplicity. Network load is not a concern for tests.
2022-10-18 18:20:10 +01:00
Keegan George e23b247690
UX: Fix alt text cancel button in dark mode (#18644) 2022-10-18 09:40:29 -07:00
David Taylor f7fdaa97d1
DEV: Replace mini-loader with Ember's `loader.js` library (#18643)
We already have this as a dependency, so it makes sense to use it rather than using our own not-quite-spec-compliant implementation
2022-10-18 14:53:06 +01:00
Jarek Radosz b6297f5dd4
DEV: Remove the router testing hack (#18640)
Doesn't seem to be needed anymore (and it doesn't work anymore with some stuff I'm updating)
2022-10-18 14:34:33 +02:00
David Taylor cb87067c77 DEV: Introduce support for template colocation in themes 2022-10-18 10:10:49 +01:00
Martin Brennan 9879cb0e68
FIX: Clarify security key copy (#18636)
In user preferences, we want to make it more obvious
that a security key is a physical device, and also
you can use your phone.
2022-10-18 16:30:48 +10:00
Krzysztof Kotlarek 243efa8931
FEATURE: allow user to set preferred sidebar list destination (#18594)
User can choose between latest or new/unread and that preference will affect behavior of sidebar links.
2022-10-18 13:21:52 +11:00
Jordan Vidrine daa8aedccf
Revert "UX: Simplify bootstrap mode visuals (#18626)" (#18638)
This reverts commit 868ab26fb3.
2022-10-18 13:19:15 +11:00
Jordan Vidrine a6d5b82886
Revert "UX: Change button to grey (#18635)" (#18637)
This reverts commit 0fe9095bad.
2022-10-18 13:18:11 +11:00
Keegan George 4907b7fa1d
DEV: Listen for escape key on hamburger & user menu (#18629) 2022-10-18 09:36:18 +08:00
Keegan George b8fcf1932e
A11Y: Bookmarks modal (#18630)
* A11Y: Add label to delete button

* A11Y: Add title attribute to options button
2022-10-18 09:34:02 +08:00