Commit Graph

48096 Commits

Author SHA1 Message Date
Martin Brennan cf5fa23cd3
DEV: Remove old secure_media setting (#20259)
This has been renamed to secure_uploads since
8ebd5edd1e
2023-02-14 09:41:18 +10:00
Krzysztof Kotlarek ca7131648f
FIX: edit custom section title (#20258)
When custom section is edited, it should say "Edit custom section" instead of "Add custom section"
2023-02-14 10:24:45 +11:00
Jarek Radosz 2d99e508c6
DEV: Add a plugin outlet for admin upgrade-header (#20274) 2023-02-14 00:03:46 +01:00
Kris 1c64b2dd95
UX: allow sidebar to appear inline down to 768px (#20271)
* UX: allow sidebar to appear inline down to 768px

* test fix

* fix typos
2023-02-14 09:51:42 +11:00
dependabot[bot] 9cb0ebcd58
Build(deps): Bump nokogiri from 1.14.1 to 1.14.2 (#20272)
Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.14.1 to 1.14.2.
- [Release notes](https://github.com/sparklemotion/nokogiri/releases)
- [Changelog](https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md)
- [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.14.1...v1.14.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-13 23:28:09 +01:00
David Taylor 3bfd8c7192
DEV: Modernise and colocate UserField component (#20267)
Dynamically setting the `layoutName` is not compatible with template colocation. Instead, we can give each field type a dedicated component and make `<UserField` a wrapper which renders the correct implementation.
2023-02-13 19:06:23 +00:00
David Taylor 87f9583dcf
DEV: Modernise CustomHtml implementation (#20266)
Dynamically setting `layoutName` is not compatible with template colocation. This commit updates `<CustomHTML` to remove the `custom-html-container.hbs` template, and instead dynamically sets the `layout` property as required. Once the deprecated 'custom hbs' feature is removed, this can be updated to be a regular colocated component template.
2023-02-13 18:58:59 +00:00
Joffrey JAFFEUX a5e45d90fe
DEV: removes github page documentation page generation (#20268)
It was causing errors on C, will need to investigate a better solution in the future.
2023-02-13 19:39:05 +01:00
Penar Musaraj 4072786f5b
DEV: Support using Ember components in dialog service (#20230)
We often have the need to use rich HTML in dialog messages (to show lists, icons, etc.). Previously, our only option was to wrap the message in an `htmlSafe()` call. This PR adds the ability to pass a component name and model to the dialog, which means that we can write the HTML in regular Ember components. 

Example, whereas previously we would do this: 

```
    this.dialog.deleteConfirm({
      message: htmlSafe(`<li>Some text</li>`),
    });
```

instead we can now do this: 

```javascript
import SecondFactorConfirmPhrase from "discourse/components/dialog-messages/second-factor-confirm-phrase";

...

this.dialog.deleteConfirm({
  title: I18n.t("user.second_factor.disable_confirm"),
  bodyComponent: SecondFactorConfirmPhrase,
  bodyComponentModel: model,
})
```

The model passed to the component is optional and will be available as `@model` in the Handlebars template.
2023-02-13 13:03:31 -05:00
Rafael dos Santos Silva 6e8e4430dd
DEV: TaffyDB is MIT licensed per it's repo (#20265) 2023-02-13 14:51:22 -03:00
David Taylor 5dc2c0b5a2
DEV: Deprecate CustomHTML hbs templates (#20264)
This is an old system for introducing custom content into Discourse. Nowadays, plugins and themes should be using Plugin Outlets for this.
2023-02-13 17:41:32 +00:00
Loïc Guitaut 5f4623ba47 DEV: Refactor `UpdateUserLastRead` a little
We’re now using `contract` as the first step and validations for
mandatory parameters have been added.

To simplify specs a bit, we only assert the service contract is run as
expected without testing each validation case. We’re now testing the
contract itself in isolation.
2023-02-13 17:03:41 +01:00
Martin Brennan 60ad836313
DEV: Chat service object initial implementation (#19814)
This is a combined work of Martin Brennan, Loïc Guitaut, and Joffrey Jaffeux.

---

This commit implements a base service object when working in chat. The documentation is available at https://discourse.github.io/discourse/chat/backend/Chat/Service.html

Generating documentation has been made as part of this commit with a bigger goal in mind of generally making it easier to dive into the chat project.

Working with services generally involves 3 parts:

- The service object itself, which is a series of steps where few of them are specialized (model, transaction, policy)

```ruby
class UpdateAge
  include Chat::Service::Base

  model :user, :fetch_user
  policy :can_see_user
  contract
  step :update_age

  class Contract
    attribute :age, :integer
  end

  def fetch_user(user_id:, **)
    User.find_by(id: user_id)
  end

  def can_see_user(guardian:, **)
    guardian.can_see_user(user)
  end

  def update_age(age:, **)
    user.update!(age: age)
  end
end
```

- The `with_service` controller helper, handling success and failure of the service within a service and making easy to return proper response to it from the controller

```ruby
def update
  with_service(UpdateAge) do
    on_success { render_serialized(result.user, BasicUserSerializer, root: "user") }
  end
end
```

- Rspec matchers and steps inspector, improving the dev experience while creating specs for a service

```ruby
RSpec.describe(UpdateAge) do
  subject(:result) do
    described_class.call(guardian: guardian, user_id: user.id, age: age)
  end

  fab!(:user) { Fabricate(:user) }
  fab!(:current_user) { Fabricate(:admin) }

  let(:guardian) { Guardian.new(current_user) }
  let(:age) { 1 }

   it { expect(user.reload.age).to eq(age) }
end
```

Note in case of unexpected failure in your spec, the output will give all the relevant information:

```
  1) UpdateAge when no channel_id is given is expected to fail to find a model named 'user'
     Failure/Error: it { is_expected.to fail_to_find_a_model(:user) }

       Expected model 'foo' (key: 'result.model.user') was not found in the result object.

       [1/4] [model] 'user' 
       [2/4] [policy] 'can_see_user'
       [3/4] [contract] 'default'
       [4/4] [step] 'update_age'

       /Users/joffreyjaffeux/Code/pr-discourse/plugins/chat/app/services/update_age.rb:32:in `fetch_user': missing keyword: :user_id (ArgumentError)
       	from /Users/joffreyjaffeux/Code/pr-discourse/plugins/chat/app/services/base.rb:202:in `instance_exec'
       	from /Users/joffreyjaffeux/Code/pr-discourse/plugins/chat/app/services/base.rb:202:in `call'
       	from /Users/joffreyjaffeux/Code/pr-discourse/plugins/chat/app/services/base.rb:219:in `call'
       	from /Users/joffreyjaffeux/Code/pr-discourse/plugins/chat/app/services/base.rb:417:in `block in run!'
       	from /Users/joffreyjaffeux/Code/pr-discourse/plugins/chat/app/services/base.rb:417:in `each'
       	from /Users/joffreyjaffeux/Code/pr-discourse/plugins/chat/app/services/base.rb:417:in `run!'
       	from /Users/joffreyjaffeux/Code/pr-discourse/plugins/chat/app/services/base.rb:411:in `run'
       	from <internal:kernel>:90:in `tap'
       	from /Users/joffreyjaffeux/Code/pr-discourse/plugins/chat/app/services/base.rb:302:in `call'
       	from /Users/joffreyjaffeux/Code/pr-discourse/plugins/chat/spec/services/update_age_spec.rb:15:in `block (3 levels) in <main>'
```
2023-02-13 13:09:57 +01:00
dependabot[bot] 81a4d75f06
Build(deps): Bump puma from 6.0.2 to 6.1.0 (#20250)
Bumps [puma](https://github.com/puma/puma) from 6.0.2 to 6.1.0.
- [Release notes](https://github.com/puma/puma/releases)
- [Changelog](https://github.com/puma/puma/blob/master/History.md)
- [Commits](https://github.com/puma/puma/compare/v6.0.2...v6.1.0)

---
updated-dependencies:
- dependency-name: puma
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-13 13:07:15 +01:00
David Taylor b718e3fffc DEV: Remove layoutName references to site-settings component template 2023-02-13 11:42:38 +00:00
David Taylor 076af132a1 DEV: Colocate all admin component templates 2023-02-13 11:42:38 +00:00
David Taylor 8efb787d87
DEV: Introduce support for Glimmer PluginOutlet connectors (#20108)
Previously, all plugin connector templates would be rendered using the PluginConnector classic component definition. This commit introduces three key changes:

1. PluginOutlets can be passed `@defaultGlimmer={{true}}`, which will cause all connectors to be rendered as highly-performant 'template only glimmer components'. For now, to avoid breaking backwards compatibility, this is only intended for use on newly introduced PluginOutlets.

2. Connector js files can now directly export component definitions. This allows connectors on existing outlets to start using Glimmer components (template-only, or otherwise) straight away. It also makes it much more ergonomic to introduce custom logic to outlets. `shouldRender` continues to be supported (as a static class method).

3. Outlet arguments are now made available as `@outletArgs` in classic, glimmer and template-only-glimmer connectors. In glimmer and template-only-glimmer connectors, this is the only way to access the outlet's arguments. In classic connectors, the old methods still function - `@outletArgs` exists as a path for incremental migration
2023-02-13 09:43:16 +00:00
Martin Brennan e502175f62
FIX: Category settings migration failing on '' integer (#20261)
Fixes migration introduced in a90ad52dff,
some category custom fields like `num_auto_bump_daily` which should be
an integer are actually empty string ''.
2023-02-13 18:07:46 +10:00
Martin Brennan 7a593e2fb5
DEV: Use internal __autoloads for zeitwork reload check (#20260)
Since ad6c028484
in the zeitwork repo which was introduced to discourse/discourse in PR #20253,
the `autoloads` attribute on the loader has been marked `internal`, which means
that it errors if we try to access it directly.

Instead we should access it via the "mangled" version so it is clear
we're accessing an internal property, which is `__autoloads`.

Without this, any time a ruby file is saved the
000-development_reload_warnings.rb initializer will error.
2023-02-13 16:26:40 +10:00
Ted Johansson 25a226279a
DEV: Replace #pluck_first freedom patch with AR #pick in core (#19893)
The #pluck_first freedom patch, first introduced by @danielwaterworth has served us well, and is used widely throughout both core and plugins. It seems to have been a common enough use case that Rails 6 introduced it's own method #pick with the exact same implementation. This allows us to retire the freedom patch and switch over to the built-in ActiveRecord method.

There is no replacement for #pluck_first!, but a quick search shows we are using this in a very limited capacity, and in some cases incorrectly (by assuming a nil return rather than an exception), which can quite easily be replaced with #pick plus some extra handling.
2023-02-13 12:39:45 +08:00
Ted Johansson a90ad52dff
DEV: Add dedicated category settings model - Part 1 (#20211)
This is the first in a multi-part change to move the custom fields to a new table. It includes:

- Adding a new CategorySetting model and corresponding table.
- Populating it with data from the category_custom_fields table.
2023-02-13 12:37:59 +08:00
Krzysztof Kotlarek 010370f8b1
FIX: error anonymous when tl4_delete_posts_and_topics setting (#20257)
Bug introduced in this PR: https://github.com/discourse/discourse/pull/19946

When the setting is enabled, an error is triggered for anonymous users.
2023-02-13 15:34:04 +11:00
dependabot[bot] 6c9f84b302
Build(deps): Bump redis from 4.8.0 to 4.8.1 (#20251)
Bumps [redis](https://github.com/redis/redis-rb) from 4.8.0 to 4.8.1.
- [Release notes](https://github.com/redis/redis-rb/releases)
- [Changelog](https://github.com/redis/redis-rb/blob/master/CHANGELOG.md)
- [Commits](https://github.com/redis/redis-rb/compare/v4.8.0...v4.8.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-13 01:14:19 +01:00
Gerhard Schlager 71658e63f7 DEV: Fix typo
@discourse-translator-bot keep_translations_and_approvals
2023-02-13 00:46:33 +01:00
Gerhard Schlager 57e3d2268a UX: Fix confusing error message 2023-02-13 00:46:33 +01:00
Gerhard Schlager 1ef38054ab UX: Add missing backtick to string 2023-02-13 00:46:33 +01:00
Gerhard Schlager 32c014647d
Remove unused string (#20256)
"block" was renamed to "silence" in 1f14350220, but we missed removing that string
2023-02-13 00:46:10 +01:00
Gerhard Schlager 1d7e21a338
DEV: Replace concatenated string (#20254) 2023-02-13 00:45:55 +01:00
dependabot[bot] 0525e2fb98
Build(deps-dev): Bump syntax_tree from 5.3.0 to 6.0.0 (#20247)
Bumps [syntax_tree](https://github.com/kddnewton/syntax_tree) from 5.3.0 to 6.0.0.
- [Release notes](https://github.com/kddnewton/syntax_tree/releases)
- [Changelog](https://github.com/ruby-syntax-tree/syntax_tree/blob/main/CHANGELOG.md)
- [Commits](https://github.com/kddnewton/syntax_tree/compare/v5.3.0...v6.0.0)

---
updated-dependencies:
- dependency-name: syntax_tree
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-13 00:20:06 +01:00
dependabot[bot] 2eb74d1f07
Build(deps): Bump zeitwerk from 2.6.6 to 2.6.7 (#20253)
Bumps [zeitwerk](https://github.com/fxn/zeitwerk) from 2.6.6 to 2.6.7.
- [Release notes](https://github.com/fxn/zeitwerk/releases)
- [Changelog](https://github.com/fxn/zeitwerk/blob/main/CHANGELOG.md)
- [Commits](https://github.com/fxn/zeitwerk/compare/v2.6.6...v2.6.7)

---
updated-dependencies:
- dependency-name: zeitwerk
  dependency-type: indirect
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-13 00:18:16 +01:00
dependabot[bot] 7f6559a038
Build(deps): Bump eslint in /app/assets/javascripts (#20249)
Bumps [eslint](https://github.com/eslint/eslint) from 8.33.0 to 8.34.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v8.33.0...v8.34.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-13 00:17:33 +01:00
dependabot[bot] 3e94903203
Build(deps): Bump parser from 3.2.0.0 to 3.2.1.0 (#20248)
Bumps [parser](https://github.com/whitequark/parser) from 3.2.0.0 to 3.2.1.0.
- [Release notes](https://github.com/whitequark/parser/releases)
- [Changelog](https://github.com/whitequark/parser/blob/master/CHANGELOG.md)
- [Commits](https://github.com/whitequark/parser/compare/v3.2.0.0...v3.2.1.0)

---
updated-dependencies:
- dependency-name: parser
  dependency-type: indirect
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-13 00:17:12 +01:00
Joffrey JAFFEUX e4738cb1bc
FIX: correctly listens to chat notifications (#20246)
This change will ensure we enter and subscribe to presence channels on start and will use the correct "change" events from presence channel to update state.
2023-02-12 23:26:11 +01:00
Sam 5fb6dd9bfa
FIX: account for cursor drift when completing terms (#19660)
Previously after uploads completed post raw would drift.
If you autocompleted text after the upload stub got replaced it would
insert in the wrong position.
2023-02-13 09:25:12 +11: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
Gerhard Schlager d84d38cbe7
FIX: Replace hard-coded string with translation (#20245) 2023-02-11 14:50:53 +01:00
Kris 8bc9acc414
A11Y: Header icons should be buttons, not links (#20242) 2023-02-10 13:55:51 -05:00
Kris 3e826a67d1
A11Y: add aria-label to header notification counts (#20231) 2023-02-10 13:11:20 -05:00
Penar Musaraj 827df072a6
DEV: Fix a flakey test (#20241)
The `Composer - current time` test would sometimes fail due to a
1-second difference. We don't really need per-second fidelity here, the
key thing this needs to test is that the shortcut works and adds today's
date. I have updated the test to reflect that.
2023-02-10 11:37:11 -05:00
chapoi 47abe61994
UX: add flex alignment for form actions (#20240) 2023-02-10 07:35:18 -06:00
dependabot[bot] ae03d25cdd
Build(deps): Bump regexp_parser from 2.6.2 to 2.7.0 (#20233)
Bumps [regexp_parser](https://github.com/ammar/regexp_parser) from 2.6.2 to 2.7.0.
- [Release notes](https://github.com/ammar/regexp_parser/releases)
- [Changelog](https://github.com/ammar/regexp_parser/blob/master/CHANGELOG.md)
- [Commits](https://github.com/ammar/regexp_parser/compare/v2.6.2...v2.7.0)

---
updated-dependencies:
- dependency-name: regexp_parser
  dependency-type: indirect
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-10 13:04:53 +01:00
Jan Cernik 8121565631
FIX: Chat's user autocomplete threw errors (#20236) 2023-02-10 11:41:46 +01:00
Martin Brennan c9776fe84d
DEV: Change setActiveChannel to get/set in services/chat (#20237)
Per PR comment in #20209, we don't need to do setActiveChannel,
we can just use native get/set instead.
2023-02-10 11:41:29 +01:00
Krzysztof Kotlarek cbd021db15
FIX: add index to sidebar_section_link (#20234)
Index on linkable_type and linkable_id should increase performance of this subquery https://github.com/discourse/discourse/blob/main/app/services/sidebar_site_settings_backfiller.rb#L86

Also, distinct is removing duplicates which are unnecessary.
2023-02-10 11:14:22 +11:00
Keegan George 6338287e89
UX: Easily toggle badges in admin badge list (#20225) 2023-02-09 11:36:27 -08:00
Penar Musaraj 58123e8089
Revert "UX: flex horizontal form controls (#20098)" (#20228)
This reverts commit 15b546978f.
2023-02-09 12:35:15 -05:00
David Taylor 25fabccd59
DEV: Enable parallel babel processing in ember-cli (#20215)
Ember CLI will automatically run babel transformations in parallel when the config is 'serializable', and can therefore be applied in multiple processes automatically. If any plugin is defined in an unserializable way, parallelisation will be disabled.

Our discourse-widget-hbs transformer was causing parallelisation to be disabled. This commit fixes that, and also enables the throwUnlessParallelizable flag so that we catch this kind of issue more easily in future.

This commit also refactors our deprecation silencing system into its own file, and uses a fake babel plugin to ensure deprecations are silenced in babel worker processes.

In our GitHub CI jobs, this doubles the speed of ember builds (1m30s -> 45s). It should also improve production deploy times, and cold-start dev builds.
2023-02-09 16:24:24 +00:00
David Taylor db42917563
DEV: Resolve user_option deprecations (#20192) 2023-02-09 16:05:42 +00:00
dependabot[bot] a8b145547e
Build(deps): Bump @babel/standalone in /app/assets/javascripts (#20153)
Bumps [@babel/standalone](https://github.com/babel/babel/tree/HEAD/packages/babel-standalone) from 7.20.14 to 7.20.15.
- [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.20.15/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>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-09 14:51:03 +00:00
Andrei Prigorshnev 0dcfd7ddec
DEV: correct a relationship – a chat message may have several mentions (#20219)
This change only makes the model reflect correctly what's 
already happening in the database. Note that there are no calls 
to chat_message.chat_mention in Core and plugins so this 
change should be safe.

Also note, that at the moment we use the chat_mentions db 
table only to support notifications about mentions, but 
we're going to start using it for other cases. This commit is 
the first step in that direction.
2023-02-09 17:44:04 +04:00