Commit Graph

19408 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
Kris d3663a143b
FIX: variable name typo (#18752) 2022-10-25 17:59:09 -04:00
Isaac Janzen 2737bc55bb
DEV: Update docs for composerBeforeSave (#18746)
* DEV: Update docs for composerBeforeSave
2022-10-25 14:19:45 -05:00
Kris d0f88da9c9
FEATURE: control topic width with variables (#18743) 2022-10-25 14:45:37 -04: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
Jarek Radosz ab330a98ad
UX: Fix user status display in autocomplete (#18726)
A follow-up to c421dc0b28
2022-10-24 21:34:41 +02:00
Jarek Radosz c421dc0b28
UX: Improve autocomplete styling (#18723)
1. Restore the original text color (`--primary-high`)
2. Fix the double bottom border
3. Make the padding around icons even
2022-10-24 19:37:01 +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
Kris c937b6dd36
FIX: set max-width on category logo img (#18703) 2022-10-21 12:01:26 -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
Kris ab217d8ae0
FIX: set width on category logo img, not container (#18676) 2022-10-20 13:20:17 -04:00
Keegan George 3e6b22db69
A11Y: Sortable header elements should have pointer (#18672) 2022-10-20 09:28:03 -07: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
Kris 99d9c933c6
FIX: ensure dropdown is above sibling labels (#18658) 2022-10-18 18:18:23 -04: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
Keegan George 5c7d951330
FIX: User card focus state appearing on click (#18650) 2022-10-18 11:15:42 -07:00
Keegan George 83c43bae2a
A11Y: Improve user card appearance in WHCM (#18648) 2022-10-18 11:05:14 -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
Keegan George 897bcacdda
A11Y: Improve topic timeline in WHCM (#18647) 2022-10-18 10:35:01 -07:00