* wip: group mentions
* Apply fixes from StyleCI
* chore: format
* group mention autocomplete
* chore: format
* remove console.log
* implement notifications
* prevent guest and member groups from being mentioned
* Update extensions/mentions/less/forum.less
Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
* rename displayname to groupname
* Update extensions/mentions/src/Formatter/FormatGroupMentions.php
Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
* remove redundant unparse
* simplify migrations
* add group deleted translation
* Apply fixes from StyleCI
* handle everything falsy
* Include icon in group mention preview
* remove box-shadow from autocomplete group results
* Add color to preview
* chore: format
* Remove box shadow from group autocomplete results
* Update extensions/mentions/migrations/2022_10_21_000000_create_post_mentions_groups_table.php
Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
* remove unneeded migration
* prevent former group icon from beingdisplayed
* add group searcher with permissions
* Apply fixes from StyleCI
* Search groups based on canSearchGroups permission
* Don't include virtual groups in results
* Add search groups translation
* Revert "remove unneeded migration"
This reverts commit 9347665baa.
* Revert "Update extensions/mentions/migrations/2022_10_21_000000_create_post_mentions_groups_table.php"
This reverts commit 8406d51df2.
* add searchGroups permission to tests
* Apply fixes from StyleCI
* Add default searchGroups permission
* Apply fixes from StyleCI
* Update extensions/mentions/js/src/forum/addComposerAutocomplete.js
Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
* Update extensions/mentions/migrations/2022_10_21_000000_create_post_mentions_groups_table.php
Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
* remove unneeded migration, correct table table
* correct table name in down migration
* Remove group searcher
* Apply fixes from StyleCI
* Remove group searching from composer autocomplete
* Add mentionGroups permission
* Apply fixes from StyleCI
* prevent post preview from rendering a group mention when user does not have permission
* remove test changes
* wip: expose ServerRequestInterface to textformatter parse()
* Apply fixes from StyleCI
* Set post content properly
* php 7.x compatibility
* begin adding groupmention tests
* Apply fixes from StyleCI
* test virtual groups don't mention
* Apply fixes from StyleCI
* Update framework/core/tests/integration/api/groups/ListTest.php
Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
* Update framework/core/tests/integration/api/groups/ListTest.php
Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
* Update framework/core/tests/integration/api/groups/ListTest.php
Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
* Update framework/core/tests/integration/api/groups/ListTest.php
Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
* Update framework/core/tests/integration/api/groups/ListTest.php
Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
* Update extensions/mentions/extend.php
Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
* Update extensions/mentions/extend.php
Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
* requested changes
* Update framework/core/tests/integration/api/groups/ListTest.php
Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
* Update framework/core/tests/integration/api/groups/ListTest.php
Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
* Update framework/core/src/Search/SearchServiceProvider.php
Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
* Update framework/core/src/Extend/Formatter.php
Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
* remove default permission migration
* try using datetime column instead of timestamp
* Apply fixes from StyleCI
* chore: remove commented code
* add tests
* Apply fixes from StyleCI
* Pass actor to parser instead of ServerRequest
* Allow for to be null
* Update framework/core/src/Extend/Formatter.php
Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
* pass actor instead of request
* Apply fixes from StyleCI
* actor instead of request
* remove serverrequest
* Apply fixes from StyleCI
* remove dupe actor
* Update extensions/mentions/src/Formatter/CheckPermissions.php
Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
* fix type in comment
* group does not have the relation, post does
* test: invalid, deleted, fresh data mentions
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
* Apply fixes from StyleCI
* fix: group mentions don't work when editing posts
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
Co-authored-by: StyleCI Bot <bot@styleci.io>
Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
* test: editing a post with deleted author and mentions
* fix(mentions): accessing `id` of null `user` relation
Signed-off-by: Sami Mazouz <ilyasmazouz@gmail.com>
* test: list posts with mentions filter and `createdAt` sort
* fix: multiple `createdAt` columns in query causes conflicts
* chore: link to pull request for context
Signed-off-by: Sami Mazouz <ilyasmazouz@gmail.com>
* chore: yarn workspaces means we only need a single `yarn.lock`
* fix: add a `cache_dependency_path` workflow input
* fix: re-introduce `env.cache_dependency_path`
With all the commits below, we resolve all outstanding typing issues in the repo, and CI jobs run green.
* fix: Convert DashboardPage and DashboardWidget to TypeScript
* fix: fix type errors in package manager ext
* fix: Convert Post component to TypeScript
* fix: avatar typings should accept null user
* fix: convert Notification component to TypeScript
* fix: properly use `typeof` in ForumApplication
* feat: make Notification content attr generic
* chore: format Notification component
* fix: Convert DiscussionRenamedNotification to TypeScript
* fix(pusher) move shims to a location where they get applied
* fix(pusher): fix some typing errors
* fix(akismet): fix some typing issues
* chore: update core dist typings
* chore(pusher): format
* fix: anchorScroll should accept string selectors
* fix: more accurately represent ApiQueryParamsPlural
* fix: convert PostStreamState to TypeScript
* chore(core): rebuild typings
* feat: allow extending app.routes
* fix: more flexible typings for highlight.ts
* fix: use primitive `number` type for Discussion typings
* fix: convert DiscussionListItem to TypeScript
* chore: rebuild core typings
* fix: final pusher type fixes
* feat: start tags TypeScript conversion
* fix: require-dev tags in pusher for CI TypeScript purposes.
* chore(core): format
* chore(tags): build dist typings
* feat(pusher): use dist types from tags.
* feat: convert flags to TypeScript
* chore(flags): generate dist typings
* fix(akismet): last type errors
* chore: update .yarn-integrity
* chore: partially run flarum-cli audit infra --fix
The tsconfig changes from that command are ignored, since we don't yet support "replacable sections" that would let us add custom config.
* chore: use type imports
* fix: broader gitattributes
* chore: run flarum-cli audit infra --monorepo --fix
* feat: make `app.data` typings extensible
* chore(core): format
* chore: boost tags TypeScript coverage
* fix(tags): further increase type coverage.
Closes https://github.com/flarum/core/issues/3070
If the user doesn't have permission to search users, there will currently be browser errors, as the current implementation will still attempt to search and autocomplete. In this PR, we check for permission before searching. The dropdown will still support autocomplete of users currently participating in the discussion.
* Add Prettier
* Update dependencies; add typescript setup
* Add tsconfig
* Rewrite some mentions frontend into TS
* Fix use of username instead of display name
* Change back to JS
* Remove commented code
* Update function name to match filename
* Update getMentionText.js
* Simplify condition
* Bump packages to stable versions; use prettier package
* Make functions use camel case
* Update js/package.json
Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
* Don't access data directly
* Update js/src/forum/addComposerAutocomplete.js
Co-authored-by: Alexander Skvortsov <38059171+askvortsov1@users.noreply.github.com>
* Update tsconfig.json
Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
Co-authored-by: Alexander Skvortsov <38059171+askvortsov1@users.noreply.github.com>
* fix: Use proper mentionsUsers serializer
The only reason we haven't seen any issues with this up until now is because we have not has to include the relationship in any responses.
* fix: User/Post mentions showing as deleted after saving
The reason this happens is because the modified relationship is not refreshed, so the formatter doesn't recognize the new mentions as valid.
* perf: Eager load related mentions from the extender
These missing relations caused more queries to be called, the more mentions posts have the more queries produced.
* perf: Eager load models in show endpoints
Can't use the extender for that
* Convert user mentions to new `@"Display Name"#ID` format
* Handle deleted user's mentions
* Convert post mentions to `@"Display Name"#pID` format
* Handle deleted user's post mentions and deleted posts mentions
* Clean display name of `"#{letters}{numbers}` (replace with underscore _)
* Adapt integration tests to new mention formats
* Use a deleted attribute for user mentions
* Introduce cleanDisplayName util
* Detect new format with autocomplete
* Slug needed on rendering only
* Invalidate user mention tag when ID is invalid
This used to be implicitly done, when there was a username attribute configured, formatter would check that all attributes are available and if not invalidate.
since we now only have `displayname` and `id` attributes which are both available from the regex matching, formatter doesn't implicitly invalidate anymore and therefore validates ANY matches. So we explicitly invalidate the tag when the ID does not match a user.
* Allow username mention format with a setting
* Add tests for turning setting on/off
* Move setting check to tag filter
Because the configurator caches, changing the setting only takes effect after the cache is cleared.
* fix: showing autocomplete at the right moment
* Add dockblocks to explain unparsing process
The previous solution didn't properly account for document scroll, so when replying to posts, the parent offset would be extremely large, and it'd fall back to the top coordinate, which is out of bounds on small screens.