1
0
mirror of https://github.com/flarum/core.git synced 2025-08-13 20:04:24 +02:00

Compare commits

..

130 Commits

Author SHA1 Message Date
Davide Iadeluca
a94bf44072 1.8.8 & 1.8.9 change log (#4123)
* docs: add `1.8.8` change log

* docs: add `1.8.9` change log
2024-11-20 16:14:08 +00:00
IanM
ce82834a58 chore: response can return ResponseInterface 2024-11-20 13:51:54 +00:00
Davide Iadeluca
397642ab5a [1.x] Implement Support for Translatable Validation Attribute Errors (#4070)
* chore: add validation translations

* feat: implement ability to translate validation attributes

* chore: change translation key

* style: formatting

* perf: cache `getAttributeNames`

* perf: cache `getAttributeNames`

* chore

* style: formatting
2024-11-20 08:51:17 +00:00
IanM
79e17b3bde chore: comment 8.4 for now 2024-11-19 20:11:38 +00:00
IanM
c6ba2cd0d5 chore: remove 8.4 until 1.8.9 release 2024-11-19 20:08:02 +00:00
IanM
5d6795c353 [1.x] chore: PHP 8.4 support (#4105)
* chore: php8.4 testing

* update laminas

* chore: exclude phpstan on php8.4
2024-11-19 17:26:02 +00:00
IanM
d61c3cf277 chore: change private to protected, allowing extensibility (#4119) 2024-11-19 17:24:02 +00:00
flarum-bot
a0b9add2d8 Bundled output for commit 88abe63a8f
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-11-19 17:22:16 +00:00
Davide Iadeluca
88abe63a8f fix: change condition when unread label is shown in Scrubber (#4116) 2024-11-19 17:18:11 +00:00
IanM
9d00490591 chore: bump ver (#4120) 2024-11-19 17:11:05 +00:00
flarum-bot
7c1f55d985 Bundled output for commit 345023242b
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-11-19 17:09:27 +00:00
Davide Iadeluca
345023242b [1.x] chore(core, tags): resolve a11y warnings in Admin Frontend (#4114)
* chore: add accessible label to scope removal button

* chore: add accessible label to edit tag button
2024-11-19 16:57:49 +00:00
Davide Iadeluca
00329eaee0 fix: return empty object if selected mail driver is unavailable (#4113) 2024-11-19 16:56:56 +00:00
Davide Iadeluca
6c89f8161e [1.x] fix: change length of email field (#4117)
* test: write failing tests for email length

* style: formatting

* style: formatting

* fix: change length of email field

* test: write test for email with too long local part

* style: formatting

* chore: remove unnecessary tests
2024-11-19 16:49:17 +00:00
IanM
8eb56b16cf [1.x] feat: conditional extend whenExtensionDisabled (#4107)
* feat: conditional extend whenExtensionDisabled

* Apply fixes from StyleCI

---------

Co-authored-by: StyleCI Bot <bot@styleci.io>
2024-11-12 09:40:05 +00:00
Daniël Klabbers
634132e06e chore: remove duplicated mentionsUsers relation 2024-11-06 15:59:27 +01:00
flarum-bot
6de38ff4c9 Bundled output for commit 391a8613cf
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-10-26 22:18:59 +00:00
Davide Iadeluca
391a8613cf fix: resolve regression in typing errors (#4097) 2024-10-26 23:15:50 +01:00
IanM
448f201fa6 chore: bump tsconfig version 2024-10-22 19:17:00 +01:00
flarum-bot
0694651fe9 Bundled output for commit 92b2b4aad1
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-10-22 09:18:09 +00:00
Davide Iadeluca
92b2b4aad1 [1.x] chore: resolve node deprecation warnings in workflows (#4081)
* chore: update frontend workflow

Backport of 356f97641e

* chore: bump default node version and `flarum/action-build`

* fix

* dummy commit
2024-10-22 10:14:06 +01:00
flarum-bot
0b55830693 Bundled output for commit c42f0a5d0e
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-10-21 20:40:33 +00:00
IanM
c42f0a5d0e fix: postfooter did not apply the empty subclass (#4085) 2024-10-21 21:35:52 +01:00
flarum-bot
821ca01460 Bundled output for commit 6f48557c3a
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-10-21 19:01:58 +00:00
IanM
6f48557c3a fix new search term not being passed (#4083) 2024-10-21 19:57:55 +01:00
IanM
cc1d2aaade chore: set appver to 1.8.8 (#4084) 2024-10-21 19:50:41 +01:00
IanM
3a45ebc716 [1.x] [suspend] fix: previously suspended admin users cannot remove their avatar after suspension (#4071)
* [1.x][suspend] fix: formally suspended admin users cannot remove their avatar after suspension

* Apply fixes from StyleCI

---------

Co-authored-by: StyleCI Bot <bot@styleci.io>
2024-10-15 12:10:55 +01:00
IanM
5bd7e5dfe3 chore: create changelog 2024-10-09 14:00:11 +01:00
IanM
956ac20c4c chore: bump appver 2024-10-09 10:45:06 +01:00
flarum-bot
b7e41ce82f Bundled output for commit c737d7b8f5
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-10-08 14:07:09 +00:00
IanM
c737d7b8f5 fix: basicspage broken when no displayname drivers enabled (#4062) 2024-10-08 15:00:43 +01:00
Davide Iadeluca
9295e7b96f chore(flags): require flarum/core ^1.8.6 (#4061) 2024-10-08 07:40:35 +01:00
Davide Iadeluca
9377256409 chore: 1.8.6 changelog (#4058)
* chore: `1.8.6` changelog

* chore: add recent fix

* chore: remove interim fixes
2024-10-08 07:13:56 +01:00
Davide Iadeluca
9c91c89326 [1.x] fix(core, mentions): return null if content left empty in formatter (#4059)
* test(core): implement test for creating discussion without content

* fix(core): handle `null` case in XML parser

* fix(mentions): change/remove typings in unparser

* fix(mentions): return early if xml null

* chore: fix PHPStan

* chore: move tests to mentions

* chore: remove unused import

* chore: remove unused imports

* test(mentions): implement test for post editing with content empty

* test(mentions): change post edit tests

* test(mentions): add test for creating discussion with empty string
2024-10-08 06:56:09 +01:00
flarum-bot
8169550f1c Bundled output for commit d5a1653d24
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-10-03 08:51:49 +00:00
Robert Korulczyk
d5a1653d24 [1.x] feat: allow to customize time formats through translations (#4053)
* Allow to customize time formats

* Fix CS
2024-10-03 09:47:48 +01:00
flarum-bot
db605bdbaa Bundled output for commit 1665d47adc
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-10-03 08:04:40 +00:00
IanM
1665d47adc fix: compat: still return controls view item, even if empty (#4057) 2024-10-03 09:01:17 +01:00
flarum-bot
1c71ee0968 Bundled output for commit 6846f4232c
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-10-03 06:29:46 +00:00
IanM
6846f4232c fix: js error as guest on DiscussionListItem (#4056) 2024-10-03 08:25:00 +02:00
Davide Iadeluca
88f182cc93 [1.x] [extensibility] Add (some) missing shims (#4027)
* chore: add some missing shims

* chore: remove unused import
2024-10-02 12:13:26 +01:00
flarum-bot
ed72aa0128 Bundled output for commit 12d21cdbfc
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-10-02 10:25:42 +00:00
Davide Iadeluca
12d21cdbfc [1.x] [extensibility] refactor(core): allow labels of PostStreamScrubber to be customized (#4049)
* refactor(core): allow labels to be customized

* chore: change type annotation

* chore: remove type annotations

Importing `NestedStringArray` did cause issues in the CI
2024-10-02 11:19:26 +01:00
flarum-bot
359681f3c6 Bundled output for commit 1a4c4a0275
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-10-02 09:25:35 +00:00
IanM
1a4c4a0275 feat: provide an 'actions' dropdown for extensions to add their additional buttons (#4054) 2024-10-02 10:18:00 +01:00
IanM
ea2fd2cade Revert "feat: provide an 'actions' dropdown for extensions to add their additional buttons"
This reverts commit 772852b3b3.
2024-10-02 09:53:12 +01:00
IanM
772852b3b3 feat: provide an 'actions' dropdown for extensions to add their additional buttons 2024-10-02 09:52:07 +01:00
flarum-bot
71717f9ebb Bundled output for commit 449ba48ba3
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-10-02 07:10:53 +00:00
Davide Iadeluca
449ba48ba3 [1.x] [extensibility] Export all missing modules in compat (#4044)
* chore(emoji): export missing modules in compat API

* chore(flags): export missing modules in compat API

* chore(likes): export missing modules in compat API

* chore(lock): export missing modules in compat API

* chore(markdown): export missing modules in compat API

* chore(mentions): export missing modules in compat API

* chore(nicknames): export missing modules in compat API

* chore(extension-manager): export missing modules in compat API

* chore(statistics): export missing modules in compat API

* chore(sticky): export missing modules in compat API

* chore(subscriptions): export missing modules in compat API

* chore(suspend): export missing modules in compat API

* chore(tags): export missing modules in compat API

* chore(core): export missing modules in compat API

* chore: fix tsconfig
2024-10-02 08:04:10 +01:00
flarum-bot
4d75da36b8 Bundled output for commit d4fe5f5a7a
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-10-02 06:54:38 +00:00
Davide Iadeluca
d4fe5f5a7a [1.x] [extensibility] refactor(core, flags): improve & use extensibility of CommentPost & Post (#4047)
* refactor(core): improve extensibility of `CommentPost`

* refactor(core): rename method to more appropriate name

* refactor(core): further improve extensibility of `CommentPost`

* refactor(core): improve extensibility of `Post`

* refactor(flags): use new extensibility for flagged posts
2024-10-02 07:47:05 +01:00
flarum-bot
256c1846b7 Bundled output for commit 1fee96aebe
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-09-30 14:45:34 +00:00
Davide Iadeluca
1fee96aebe fix(core): revert extensibility improvements for replyCountItem() (#4051)
This fixes a breaking change with third-party extensions calling `replyCountItem()` and not expecting it to be an array.
2024-09-30 15:38:30 +01:00
flarum-bot
b49b3104e4 Bundled output for commit 7d8cfdfaec
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-09-30 11:38:37 +00:00
Davide Iadeluca
7d8cfdfaec refactor(core): backport & improve extensibility of DiscussionListItem (#4048) 2024-09-30 12:32:23 +01:00
flarum-bot
845c38d6cb Bundled output for commit 4912a2e059
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-09-30 11:26:09 +00:00
Davide Iadeluca
4912a2e059 [1.x] [extensibility] refactor(core): improve extensibility of DiscussionPage (#4046)
* refactor(core): improve extensibility of `DiscussionPage`

* chore(core): improve type safety
2024-09-30 12:19:14 +01:00
flarum-bot
ca6d826f79 Bundled output for commit dce2549ff7
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-09-30 11:08:05 +00:00
Davide Iadeluca
dce2549ff7 [1.x] [extensibility] refactor(core): improve extensibility of IndexPage (#4045)
* refactor(core): improve extensibility of `IndexPage`

* refactor(core): refactor the extensibility refactor
2024-09-30 12:02:58 +01:00
flarum-bot
306d0bc124 Bundled output for commit e3d07cb8cc
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-09-30 10:46:59 +00:00
IanM
e3d07cb8cc feat: make it easier to add content after the first post (#4050) 2024-09-30 11:43:40 +01:00
flarum-bot
9bc8c7de99 Bundled output for commit 5076da9b38
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-09-29 19:16:08 +00:00
IanM
5076da9b38 feat: use common component for ip address display (#4042) 2024-09-29 20:12:53 +01:00
IanM
2c4d64cd20 [1.x] [extensibility] feat: allow classes that extends AbstractJob to be placed on a specified queue (#4026)
* feat: allow classes that extends AbstractJob to be placed on a specific queue

* Apply fixes from StyleCI

* php 7.3 compat

* Apply fixes from StyleCI

* change  to  to avoid conflicts with extensions that already do this

* chore: add docblock explaining that this solution only works for Redis queues

* Apply fixes from StyleCI

* chore: update docblock

* Apply fixes from StyleCI

---------

Co-authored-by: StyleCI Bot <bot@styleci.io>
2024-09-29 15:35:29 +01:00
flarum-bot
c9bd7dab1e Bundled output for commit df14216e1b
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-09-29 13:48:02 +00:00
IanM
df14216e1b chore: allow extending PostPreview content (#4043) 2024-09-29 14:44:51 +01:00
flarum-bot
de36551b45 Bundled output for commit 54fbcdedd5
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-09-29 11:30:04 +00:00
IanM
54fbcdedd5 chore: extensible TagHero (#4041) 2024-09-29 12:26:53 +01:00
flarum-bot
e9c8890686 Bundled output for commit 6dd0c0e915
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-09-29 11:12:28 +00:00
IanM
6dd0c0e915 [1.x] [extensibility] chore: make PostMeta extensible (#4040)
* chore: make PostMeta extensible

* add prio for ip item
2024-09-29 12:06:04 +01:00
flarum-bot
444df80caf Bundled output for commit 3ebd218588
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-09-29 09:03:25 +00:00
IanM
3ebd218588 chore: make WelcomeHero extensible (#4039) 2024-09-29 09:58:12 +01:00
IanM
9038ff64f8 [suspend][core] [1.x] fix: suspended users can remove avatar (#3998)
* fix: suspended users can remove avatar

* Apply fixes from StyleCI

---------

Co-authored-by: StyleCI Bot <bot@styleci.io>
2024-09-29 08:54:13 +01:00
flarum-bot
f8c30c96dc Bundled output for commit 3743bc0886
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-09-29 07:41:13 +00:00
IanM
3743bc0886 chore: point fontawesome links at v5 free (#4038) 2024-09-29 08:35:57 +01:00
flarum-bot
5855134b79 Bundled output for commit 7f657dac04
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-09-29 07:12:08 +00:00
IanM
7f657dac04 feat: make it easier to modify AppearancePage, BasicsPage, MailPage (#4037) 2024-09-29 08:07:10 +01:00
flarum-bot
84414c6699 Bundled output for commit bf0d895106
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-09-28 08:23:34 +00:00
IanM
bf0d895106 chore: fix Flarum logo url, remove huntr link 2024-09-28 09:17:05 +01:00
IanM
c942f3100d Revert "Export all missing modules in compat (#4006)" (#4032)
This reverts commit e0adf90453.
2024-09-28 09:11:37 +01:00
flarum-bot
d5882d9357 Bundled output for commit 7540ede897
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-09-28 07:59:41 +00:00
IanM
7540ede897 feat: allow modifying the discussion title on PostsUserPage (#4031) 2024-09-28 08:54:03 +01:00
flarum-bot
77d1a3d04b Bundled output for commit c79d2892de
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-09-28 06:44:31 +00:00
IanM
c79d2892de feat: [1.x] [extensibility] feat: allow to be extended (#4025) 2024-09-28 07:36:58 +01:00
IanM
46cdaf5d1a chore: bump version to 1.8.6 2024-09-28 07:31:05 +01:00
flarum-bot
4d59ec4600 Bundled output for commit e0adf90453
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-09-27 06:54:45 +00:00
Davide Iadeluca
e0adf90453 Export all missing modules in compat (#4006)
* chore(emoji): export missing modules in compat API

* chore(flags): export missing modules in compat API

* chore(likes): export missing modules in compat API

* chore(lock): export missing modules in compat API

* chore(markdown): export missing modules in compat API

* chore(mentions): export missing modules in compat API

* chore(nicknames): export missing modules in compat API

* chore(extension-manager): export missing modules in compat API

* chore(statistics): export missing modules in compat API

* chore(sticky): export missing modules in compat API

* chore(subscriptions): export missing modules in compat API

* chore(suspend): export missing modules in compat API

* chore(tags): export missing modules in compat API

* chore(core): export missing modules in compat API
2024-09-27 07:44:06 +01:00
flarum-bot
07a1781181 Bundled output for commit 80e70f4980
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-09-26 18:12:40 +00:00
80e70f4980 fix: reset admin page save button in catch (#3963) 2024-09-26 19:07:35 +01:00
StyleCI Bot
e43530e40a Apply fixes from StyleCI 2024-09-26 15:55:20 +00:00
IanM
24e88d12b8 chore: dummy commit to trigger style CI on 1.x 2024-09-26 16:38:56 +01:00
Rafał Całka
b3366e4c93 fix(tags): load correct user tag state and prevent N+1 queries in stateFor (#4008)
* fix: load tag state for correct user
* fix: prevent loading state if loaded previously
* fix(PHPStan): TagState can be null
2024-08-10 18:29:26 +01:00
Davide Iadeluca
8415d2233e ci: allow custom actions runner to be defined (#3989) 2024-05-16 17:30:30 +01:00
Daniël Klabbers
a52959ccf2 Patch vulnerability advisory (#3966)
Seems composer has a vulnerability, see https://github.com/advisories/GHSA-7c6p-848j-wh5h

Affected versions
>= 2.0.0-alpha1, < 2.2.23 -- patched in 2.2.23
>= 2.3.0-rc1, < 2.7.0 -- patched in 2.7.0

---

Let's raise the minimum to enforce the latest.

Thank you @peopleinside for reporting this.

(cherry picked from commit e771b908d5)
2024-02-22 11:43:31 +01:00
Sami Mazouz
b2044ff312 fix(em): breaks when composer deps get updated 2024-02-04 13:56:09 +01:00
IanM
50dd73b07c feat: support passing composer_auth values 2024-01-19 16:29:51 +00:00
Sami Mazouz
4f4977b7a5 fix(em): phpstan 2024-01-12 17:59:59 +01:00
Sami Mazouz
24b7dcb102 fix(em): composer.json schema issues 2024-01-12 17:57:08 +01:00
Sami Mazouz
25beb7919d fix: broken paths 2024-01-10 16:03:12 +01:00
Sami Mazouz
207032f6ff chore: rename package-manager to extension-manager 2024-01-10 15:56:32 +01:00
Davide Iadeluca
8205ae5bf5 [1.x] fix(Mentions): allow renderer to be used without context (#3953)
* fix(Mentions): allow renderer to be used without context

* test(Mentions): implement test for rendering post without context
2024-01-10 09:53:10 +00:00
flarum-bot
ac6f4d4d0c Bundled output for commit 56b2b3b2bc
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-01-06 17:07:40 +00:00
Sami Mazouz
56b2b3b2bc fix(package-manager): bugs 2024-01-06 18:00:09 +01:00
Sami Mazouz
7fb0e08c0a fix(package-manager): file not found exception 2024-01-06 13:07:02 +01:00
IanM
2a693db1b6 chore: prep 1.8.5 release 2024-01-05 15:47:32 +00:00
IanM
7d70328471 [1.x] fix: Logout controller allows open redirects (#3948)
* fix: prevent open redirects on logout controller

* use clearer config key

* cast url as string, reinstate guest redirect

* clean up a little

* simplify

* return Uri

* resolve ternary always true

* simplify some more

* remove extra newline

* handle malformed uri

* chore: requested changes
2024-01-05 15:33:10 +00:00
Sami Mazouz
45a8b572e3 fix: package name require format 2024-01-04 14:14:45 +01:00
flarum-bot
5d14f96c32 Bundled output for commit 2299541e4d
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2023-12-18 12:50:33 +00:00
Sami Mazouz
2299541e4d feat: package manager improvements (#3943)
* chore: track
* Apply fixes from StyleCI
* chore: track
* Apply fixes from StyleCI
* fix: installing beta packages #3792
* chore: guess package not found error
* Apply fixes from StyleCI
* feat: queue improvements
* feat: queue improvements
* fix: issues with job failure and unique runs
* fix: enforce one composer action at a time
* feat: add cause to queued command output
* Apply fixes from StyleCI
* feat: add soft & hard extension update options
* chore: explain why an extension cannot be removed
* chore: remove test
* chore: simplify
* docs: readme
* Apply fixes from StyleCI
* fea: allow adding repositories and auth methods
* chore: prevent future issues when min stability is set
* chore: typings check
* fix: phpstan
* Apply fixes from StyleCI
* fix: bugs
2023-12-18 13:44:33 +01:00
Sami Mazouz
a131132654 chore: prepare 1.8.4 2023-12-14 14:56:10 +01:00
Sami Mazouz
7743a2bcd4 chore: apply textformatter constraint to monorepo as well 2023-12-14 14:51:46 +01:00
Sami Mazouz
62080303bf fix(1.x): textformatter 2.15 has breaking changes (#3946) 2023-12-14 14:44:30 +01:00
IanM
480093d023 chore(1.x): enable testing on PHP 8.3 (#3933) 2023-11-23 19:02:08 +01:00
Rafał Całka
1c421fc266 fix(1.x,approval): correct PostWasApproved event trigger condition (#3925) 2023-11-17 17:58:14 +01:00
Ian Morland
f07336e204 chore: prep 1.8.3 release 2023-10-18 19:47:50 +01:00
IanM
95061a2ed4 fix: console extender does not accept ::class (#3900) 2023-10-18 19:39:45 +01:00
IanM
c3fadbf6b1 [1.x] Conditional extender instantiation (#3898)
* chore: create tests to highlight the conditional instantiation problem

* Apply fixes from StyleCI

* add callback and invokable class + tests

* Apply fixes from StyleCI

* address stan issue on php 8.2

* Revert "address stan issue on php 8.2"

This reverts commit 1fc2c8801a.

* attempt to make stan happy

* Revert "attempt to make stan happy"

This reverts commit 1cc327bb3b.

* is it really that simple?

* Revert "is it really that simple?"

This reverts commit 2006755cf1.

* let's try this

* Update framework/core/src/Extend/Conditional.php

Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>

---------

Co-authored-by: StyleCI Bot <bot@styleci.io>
Co-authored-by: Sami Mazouz <sychocouldy@gmail.com>
2023-10-18 19:36:59 +01:00
Ian Morland
82e08e3fa5 chore: prep 1.8.2 release 2023-09-22 20:01:59 +01:00
flarum-bot
2c4a2b8d9e Bundled output for commit 00866fbba9
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2023-09-22 18:51:39 +00:00
Ian Morland
00866fbba9 chore: bump version 2023-09-22 19:46:39 +01:00
IanM
0d1d4d46d1 fix: missing compat exports (#3888) 2023-09-22 19:38:59 +01:00
Sami Mazouz
b1383a955f fix(1.x,suspend): suspended users can abuse avatar upload (#3890)
* fix(1.x,suspend): suspended users can abuse avatar upload

* test: works as expected

* Apply fixes from StyleCI

---------

Co-authored-by: StyleCI Bot <bot@styleci.io>
2023-09-22 19:38:33 +01:00
Sami Mazouz
daeab48ae8 chore: turn on frontend build on 1.x branch 2023-09-20 21:12:54 +01:00
Ian Morland
e03ca4406d chore: build js 2023-07-06 12:03:30 +01:00
StyleCI Bot
7894c6a69b Apply fixes from StyleCI 2023-07-05 09:31:05 +00:00
Sami Mazouz
102e31754a chore: not 1.8.2 2023-07-04 11:19:15 +01:00
Sami Mazouz
8538f9c8f6 chore: prepare v1.8.2 release 2023-07-04 11:12:55 +01:00
Sami Mazouz
5a4bb7ccf2 fix: missing slug from post mention links 2023-07-04 11:00:45 +01:00
Sami Mazouz
d2a6329689 fix(mentions): cannot use mentionables extender (#3849) 2023-07-04 10:56:52 +01:00
Rafael Horvat
2bc2899a1d fix(mentions): missed post mentions UI changes (#3832)
Co-authored-by: Ian Morland <ian@morland.me>
2023-07-01 17:44:59 +01:00
346 changed files with 4964 additions and 1257 deletions

View File

@@ -25,7 +25,7 @@ on:
description: Versions of PHP to test with. Should be array of strings encoded as JSON array
type: string
required: false
default: '["7.3", "7.4", "8.0", "8.1", "8.2"]'
default: '["7.3", "7.4", "8.0", "8.1", "8.2", "8.3"]'
php_extensions:
description: PHP extensions to install.
@@ -45,13 +45,25 @@ on:
required: false
default: error_reporting=E_ALL
runner_type:
description: The type of runner to use for the jobs. This should be one of the types supported by the `runs-on` keyword.
type: string
required: false
default: 'ubuntu-latest'
secrets:
composer_auth:
description: The Composer auth tokens to use for private packages.
required: false
env:
COMPOSER_ROOT_VERSION: dev-main
FLARUM_TEST_TMP_DIR_LOCAL: tests/integration/tmp
COMPOSER_AUTH: ${{ secrets.composer_auth }}
jobs:
test:
runs-on: ubuntu-latest
runs-on: ${{ inputs.runner_type }}
strategy:
matrix:
@@ -91,6 +103,10 @@ jobs:
# Include testing PHP 8.2 with deprecation warnings disabled.
- php: 8.2
php_ini_values: error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED
- php: 8.3
php_ini_values: error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED
# - php: 8.4
# php_ini_values: error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED
# To reduce number of actions, we exclude some PHP versions from running with some DB versions.
exclude:
@@ -158,11 +174,13 @@ jobs:
COMPOSER_PROCESS_TIMEOUT: 600
phpstan:
runs-on: ubuntu-latest
runs-on: ${{ inputs.runner_type }}
strategy:
matrix:
php: ${{ fromJSON(inputs.php_versions) }}
# exclude:
# - php: 8.4
name: 'PHPStan PHP ${{ matrix.php }}'

View File

@@ -74,7 +74,7 @@ on:
description: The node version to use for the workflow.
type: number
required: false
default: 16
default: 20
js_package_manager:
description: "Enable TypeScript?"
@@ -86,30 +86,41 @@ on:
type: string
required: false
runner_type:
description: The type of runner to use for the jobs. This should be one of the types supported by the `runs-on` keyword.
type: string
required: false
default: 'ubuntu-latest'
secrets:
bundlewatch_github_token:
description: The GitHub token to use for Bundlewatch.
required: false
composer_auth:
description: The Composer auth tokens to use for private packages.
required: false
env:
COMPOSER_ROOT_VERSION: dev-main
ci_script: ${{ inputs.js_package_manager == 'yarn' && 'yarn install --immutable' || 'npm ci' }}
cache_dependency_path: ${{ inputs.cache_dependency_path || format(inputs.js_package_manager == 'yarn' && '{0}/yarn.lock' || '{0}/package-lock.json', inputs.frontend_directory) }}
COMPOSER_AUTH: ${{ secrets.composer_auth }}
DISABLE_V8_COMPILE_CACHE: 1
jobs:
build:
name: Checks & Build
runs-on: ubuntu-latest
runs-on: ${{ inputs.runner_type }}
if: >-
((github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) || github.event_name != 'pull_request')
steps:
- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node_version }}
cache: ${{ inputs.js_package_manager }}
@@ -132,7 +143,7 @@ jobs:
working-directory: ${{ inputs.frontend_directory }}
- name: JS Checks & Production Build
uses: flarum/action-build@v3
uses: flarum/action-build@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
build_script: ${{ inputs.build_script }}

View File

@@ -1,4 +1,4 @@
name: Package Manager PHP
name: Extension Manager PHP
on: [workflow_dispatch, push, pull_request]

View File

@@ -10,7 +10,7 @@ jobs:
backend_directory: ./
js_package_manager: yarn
cache_dependency_path: ./yarn.lock
main_git_branch: main
main_git_branch: 1.x
enable_tests: true
# @TODO: fix bundlewatch
enable_bundlewatch: false

View File

@@ -1,10 +1,82 @@
# Changelog
## [v1.8.9](https://github.com/flarum/framework/compare/v1.8.8...v1.8.9)
### Fixed
* change condition when unread label is shown in Scrubber (https://github.com/flarum/framework/pull/4116)
* resolve a11y warnings in Admin Frontend (https://github.com/flarum/framework/pull/4114)
* return empty object if selected mail driver is unavailable (https://github.com/flarum/framework/pull/4113)
### Changed
* change private to protected, allowing extensibility (https://github.com/flarum/framework/pull/4119)
* change length of email field (https://github.com/flarum/framework/pull/4117)
### Added
* Implement Support for Translatable Validation Attribute Errors (https://github.com/flarum/framework/pull/4070)
* PHP 8.4 support (https://github.com/flarum/framework/pull/4105)
* conditional extend whenExtensionDisabled (https://github.com/flarum/framework/pull/4107)
## [v1.8.8](https://github.com/flarum/framework/compare/v1.8.7...v1.8.8)
### Fixed
* previously suspended admin users cannot remove their avatar after suspension (https://github.com/flarum/framework/pull/4071)
* new search term not being passed (https://github.com/flarum/framework/pull/4083)
* postfooter did not apply the empty subclass (https://github.com/flarum/framework/pull/4085)
## [v1.8.7](https://github.com/flarum/framework/compare/v1.8.6...v1.8.7)
### Fixed
* BasicsPage not viewable if only one language pack enabled, and/or `flarum/nicknames` not enabled (https://github.com/flarum/framework/pull/4062)
## [v1.8.6](https://github.com/flarum/framework/compare/v1.8.5...v1.8.6)
### Fixed
* reset admin page save button in catch handler (https://github.com/flarum/framework/pull/3963)
* suspended users can remove avatar (https://github.com/flarum/framework/pull/3998)
* return null if content left empty in formatter (https://github.com/flarum/framework/pull/4059)
### Changed
* allow DiscussionsSearchSource to be extended (https://github.com/flarum/framework/pull/4025)
* allow modifying the discussion title on PostsUserPage (https://github.com/flarum/framework/pull/4031)
* make it easier to modify AppearancePage, BasicsPage, MailPage (https://github.com/flarum/framework/pull/4037)
* point fontawesome links at v5 free (https://github.com/flarum/framework/pull/4038)
* make WelcomeHero extensible (https://github.com/flarum/framework/pull/4039)
* make PostMeta extensible (https://github.com/flarum/framework/pull/4040)
* extensible TagHero (https://github.com/flarum/framework/pull/4041)
* allow extending PostPreview content (https://github.com/flarum/framework/pull/4043)
* allow classes that extends AbstractJob to be placed on a specified queue (https://github.com/flarum/framework/pull/4026)
* use common component for ip address display (https://github.com/flarum/framework/pull/4042)
* make it easier to add content after the first post (https://github.com/flarum/framework/pull/4050)
* improve extensibility of IndexPage (https://github.com/flarum/framework/pull/4045)
* improve extensibility of DiscussionPage (https://github.com/flarum/framework/pull/4046)
* backport & improve extensibility of DiscussionListItem (https://github.com/flarum/framework/pull/4048)
* improve & use extensibility of CommentPost & Post (https://github.com/flarum/framework/pull/4047)
* allow labels of PostStreamScrubber to be customized (https://github.com/flarum/framework/pull/4049)
* allow to customize time formats through translations (https://github.com/flarum/framework/pull/4053)
### Added
* Export all missing modules in compat (https://github.com/flarum/framework/pull/4044)
* Add (some) missing shims (https://github.com/flarum/framework/pull/4027)
* provide an 'actions' dropdown for extensions to add their additional buttons to the admin UserListPage (https://github.com/flarum/framework/pull/4054)
## [v1.8.5](https://github.com/flarum/framework/compare/v1.8.4...v1.8.5)
### Fixed
* Logout controller allows open redirects [#3948]
## [v1.8.4](https://github.com/flarum/framework/compare/v1.8.3...v1.8.4)
### Fixed
* `s9e/textformatter` 2.15 has breaking changes [#3946]
## [v1.8.3](https://github.com/flarum/framework/compare/v1.8.2...v1.8.3)
### Fixed
* Console extender does not accept ::class [#3900]
* Conditional extender instantiation [#3898]
## [v1.8.2](https://github.com/flarum/framework/compare/v1.8.1...v1.8.2)
### Fixed
* suspended users can abuse avatar upload [#3890]
* missing compat exports [#3888]
## [v1.8.1](https://github.com/flarum/framework/compare/v1.8.0...v1.8.1)
### Fixed
* recover temporary solution for html entities in browser title (e72541e35de4f71f9d870bbd9bb46ddf586bdf1d)
* custom contrast color affected by parents (577890d89c593ae5b6cb96083fab69e2f1ae600c)
* reply placeholder wrong positioning (253a3d281dbf5ce3fa712b629b80587cf67e7dbe)
* (mentions) missed post mentions UI changes with lazy loading [#3832]
* (mentions) cannot use newly introduced mentionables extender [#3849]
* (mentions) missing slug from post mention links ([5a4bb7c](5a4bb7ccf226f66dd44816cb69b3d7cfe4ad7f7c))
## [v1.8.0](https://github.com/flarum/framework/compare/v1.7.1...v1.8.0)
### Fixed

View File

@@ -1,5 +1,5 @@
<p align="center">
<a href="https://flarum.org/"><img src="https://flarum.org/assets/img/logo.png"></a>
<a href="https://flarum.org/"><img src="https://flarum.org/images/flarum.svg"></a>
</p>
<p align="center">
@@ -7,7 +7,6 @@
<a href="https://packagist.org/packages/flarum/core"><img src="https://img.shields.io/packagist/dt/flarum/core" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/flarum/core"><img src="https://img.shields.io/github/v/release/flarum/core?sort=semver" alt="Latest Version"></a>
<a href="https://packagist.org/packages/flarum/core"><img src="https://img.shields.io/packagist/l/flarum/core" alt="License"></a>
<a href="https://huntr.dev/bounties/disclose/?target=https://github.com/flarum/core"><img src="https://cdn.huntr.dev/huntr_security_badge_mono.svg" alt="huntr"></a>
<a href="https://github.styleci.io/repos/28257573"><img src="https://github.styleci.io/repos/28257573/shield?style=flat" alt="StyleCI"></a>
</p>
@@ -38,3 +37,4 @@ If you discover a security vulnerability within Flarum, please send an e-mail to
## License
Flarum is open-source software licensed under the [MIT License](https://github.com/flarum/flarum/blob/master/LICENSE).

View File

@@ -46,7 +46,7 @@
"Flarum\\Lock\\": "extensions/lock/src",
"Flarum\\Mentions\\": "extensions/mentions/src",
"Flarum\\Nicknames\\": "extensions/nicknames/src",
"Flarum\\PackageManager\\": "extensions/package-manager/src",
"Flarum\\ExtensionManager\\": "extensions/package-manager/src",
"Flarum\\Pusher\\": "extensions/pusher/src",
"Flarum\\Statistics\\": "extensions/statistics/src",
"Flarum\\Sticky\\": "extensions/sticky/src",
@@ -74,7 +74,7 @@
"flarum/markdown": "self.version",
"flarum/mentions": "self.version",
"flarum/nicknames": "self.version",
"flarum/package-manager": "self.version",
"flarum/extension-manager": "self.version",
"flarum/pusher": "self.version",
"flarum/statistics": "self.version",
"flarum/sticky": "self.version",
@@ -112,9 +112,9 @@
"illuminate/view": "^8.0",
"intervention/image": "2.5.* || ^2.6.1",
"jenssegers/agent": "^2.6",
"laminas/laminas-diactoros": "^2.4.1",
"laminas/laminas-httphandlerrunner": "^1.2.0 || ^2.3.0",
"laminas/laminas-stratigility": "^3.2.2",
"laminas/laminas-diactoros": "^2.4.1 || ^3.0.0",
"laminas/laminas-httphandlerrunner": "^1.2.0 || ^2.3.0 || ^3.0.0",
"laminas/laminas-stratigility": "^3.2.2 || ^4.0.0",
"league/flysystem": "^1.0.11",
"matthiasmullie/minify": "^1.3",
"middlewares/base-path": "^2.0.1",
@@ -127,7 +127,7 @@
"psr/http-server-handler": "^1.0",
"psr/http-server-middleware": "^1.0",
"pusher/pusher-php-server": "^2.2",
"s9e/text-formatter": "^2.3.6",
"s9e/text-formatter": ">=2.3.6 <2.15",
"staudenmeir/eloquent-eager-limit": "^1.0",
"sycho/json-api": "^0.5.0",
"sycho/sourcemap": "^2.0.0",

View File

@@ -15,6 +15,7 @@
"declarationDir": "./dist-typings",
"paths": {
"flarum/*": ["../../../framework/core/js/dist-typings/*"],
"@flarum/core/*": ["../../../framework/core/js/dist-typings/*"],
"flarum/flags/*": ["../../flags/js/dist-typings/*"]
}
}

View File

@@ -50,7 +50,7 @@ class Akismet
$client = new Client();
return $client->request('POST', "$this->apiUrl/$type", [
'headers' => [
'headers' => [
'User-Agent' => "Flarum/$this->flarumVersion | Akismet/$this->extensionVersion",
],
'form_params' => $this->params,

View File

@@ -0,0 +1,15 @@
import 'flarum/common/models/Discussion';
import 'flarum/common/models/Post';
declare module 'flarum/common/models/Discussion' {
export default interface Discussion {
isApproved(): boolean;
}
}
declare module 'flarum/common/models/Post' {
export default interface Post {
isApproved(): boolean;
canApprove(): boolean;
}
}

View File

@@ -11,6 +11,7 @@ namespace Flarum\Approval\Listener;
use Flarum\Approval\Event\PostWasApproved;
use Flarum\Post\Event\Saving;
use Flarum\User\Exception\PermissionDeniedException;
use Illuminate\Contracts\Events\Dispatcher;
class ApproveContent
@@ -23,23 +24,42 @@ class ApproveContent
$events->listen(Saving::class, [$this, 'approvePost']);
}
/**
* @throws PermissionDeniedException
*/
public function approvePost(Saving $event)
{
$attributes = $event->data['attributes'];
$post = $event->post;
// Nothing to do if it is already approved.
if ($post->is_approved) {
return;
}
/*
* We approve a post in one of two cases:
* - The post was unapproved and the allowed action is approving it. We trigger an event.
* - The post was unapproved and the allowed actor is hiding or un-hiding it.
* We approve it silently if the action is unhiding.
*/
$approvingSilently = false;
if (isset($attributes['isApproved'])) {
$event->actor->assertCan('approve', $post);
$isApproved = (bool) $attributes['isApproved'];
} elseif (! empty($attributes['isHidden']) && $event->actor->can('approve', $post)) {
} elseif (isset($attributes['isHidden']) && $event->actor->can('approve', $post)) {
$isApproved = true;
$approvingSilently = $attributes['isHidden'];
}
if (! empty($isApproved)) {
$post->is_approved = true;
$post->raise(new PostWasApproved($post, $event->actor));
if (! $approvingSilently) {
$post->raise(new PostWasApproved($post, $event->actor));
}
}
}
}

2
extensions/emoji/js/dist/forum.js generated vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,7 @@
import AutocompleteDropdown from './fragments/AutocompleteDropdown';
import getEmojiIconCode from './helpers/getEmojiIconCode';
export default {
'emoji/fragments/AutocompleteDropdown': AutocompleteDropdown,
'emoji/helpers/getEmojiIconCode': getEmojiIconCode,
};

View File

@@ -11,3 +11,9 @@ app.initializers.add('flarum-emoji', () => {
// render emoji as image in Posts content and title.
renderEmoji();
});
// Expose compat API
import emojiCompat from './compat';
import { compat } from '@flarum/core/forum';
Object.assign(compat, emojiCompat);

View File

@@ -19,7 +19,7 @@
}
],
"require": {
"flarum/core": "^1.8"
"flarum/core": "^1.8.6"
},
"autoload": {
"psr-4": {

View File

@@ -1,3 +1,7 @@
import 'flarum/common/models/Post';
import 'flarum/forum/ForumApplication';
import 'flarum/forum/components/Post';
import Flag from '../forum/models/Flag';
import FlagListState from '../forum/states/FlagListState';
import Mithril from 'mithril';

View File

@@ -7,6 +7,7 @@ declare const _default: {
'flags/components/FlagPostModal': typeof FlagPostModal;
'flags/components/FlagsPage': typeof FlagsPage;
'flags/components/FlagsDropdown': typeof FlagsDropdown;
'flags/states/FlagListState': typeof FlagListState;
};
export default _default;
import addFlagsToPosts from "./addFlagsToPosts";
@@ -17,3 +18,4 @@ import FlagList from "./components/FlagList";
import FlagPostModal from "./components/FlagPostModal";
import FlagsPage from "./components/FlagsPage";
import FlagsDropdown from "./components/FlagsDropdown";
import FlagListState from "./states/FlagListState";

View File

@@ -1,2 +1,2 @@
declare const _default: (import("flarum/common/extenders/Model").default | import("flarum/common/extenders/Routes").default | import("flarum/common/extenders/Store").default)[];
declare const _default: (import("flarum/common/extenders/Routes").default | import("flarum/common/extenders/Store").default | import("flarum/common/extenders/Model").default)[];
export default _default;

2
extensions/flags/js/dist/forum.js generated vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,3 +1,7 @@
import 'flarum/common/models/Post';
import 'flarum/forum/ForumApplication';
import 'flarum/forum/components/Post';
import Flag from '../forum/models/Flag';
import FlagListState from '../forum/states/FlagListState';
import Mithril from 'mithril';

View File

@@ -75,7 +75,7 @@ export default function () {
return items;
};
extend(Post.prototype, 'content', function (vdom) {
extend(Post.prototype, 'viewItems', function (items) {
const post = this.attrs.post;
const flags = post.flags();
@@ -83,7 +83,8 @@ export default function () {
if (post.isHidden()) this.revealContent = true;
vdom.unshift(
items.add(
'flagged',
<div className="Post-flagged">
<div className="Post-flagged-flags">
{flags.map((flag) => (
@@ -91,7 +92,8 @@ export default function () {
))}
</div>
<div className="Post-flagged-actions">{this.flagActionItems().toArray()}</div>
</div>
</div>,
110
);
});

View File

@@ -6,6 +6,7 @@ import FlagList from './components/FlagList';
import FlagPostModal from './components/FlagPostModal';
import FlagsPage from './components/FlagsPage';
import FlagsDropdown from './components/FlagsDropdown';
import FlagListState from './states/FlagListState';
export default {
'flags/addFlagsToPosts': addFlagsToPosts,
@@ -16,4 +17,5 @@ export default {
'flags/components/FlagPostModal': FlagPostModal,
'flags/components/FlagsPage': FlagsPage,
'flags/components/FlagsDropdown': FlagsDropdown,
'flags/states/FlagListState': FlagListState,
};

View File

@@ -40,6 +40,7 @@ class AddCanFlagAttribute
// If $actor is the post author, check to see if the setting is enabled
return (bool) $this->settings->get('flarum-flags.can_flag_own');
}
// $actor is not the post author
return true;
}

View File

@@ -31,10 +31,10 @@ class FlagSerializer extends AbstractSerializer
}
return [
'type' => $flag->type,
'reason' => $flag->reason,
'type' => $flag->type,
'reason' => $flag->reason,
'reasonDetail' => $flag->reason_detail,
'createdAt' => $this->formatDate($flag->created_at),
'createdAt' => $this->formatDate($flag->created_at),
];
}

2
extensions/likes/js/dist/forum.js generated vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,9 +1,11 @@
import Post from 'flarum/common/models/Post';
import 'flarum/common/models/Post';
import User from 'flarum/common/models/User';
declare module 'flarum/common/models/Post' {
export default interface Post {
likes(): User[];
likesCount(): number;
canLike(): boolean;
}
}

View File

@@ -0,0 +1,11 @@
import LikesUserPage from './components/LikesUserPage';
import PostLikedNotification from './components/PostLikedNotification';
import PostLikesModal from './components/PostLikesModal';
import PostLikesModalState from './states/PostLikesModalState';
export default {
'likes/components/LikesUserPage': LikesUserPage,
'likes/components/PostLikedNotification': PostLikedNotification,
'likes/components/PostLikesModal': PostLikesModal,
'likes/states/PostLikesModalState': PostLikesModalState,
};

View File

@@ -24,3 +24,9 @@ app.initializers.add('flarum-likes', () => {
});
});
});
// Expose compat API
import likesCompat from './compat';
import { compat } from '@flarum/core/forum';
Object.assign(compat, likesCompat);

2
extensions/lock/js/dist/forum.js generated vendored
View File

@@ -1,2 +1,2 @@
(()=>{var o={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return o.d(n,{a:n}),n},d:(t,n)=>{for(var e in n)o.o(n,e)&&!o.o(t,e)&&Object.defineProperty(t,e,{enumerable:!0,get:n[e]})},o:(o,t)=>Object.prototype.hasOwnProperty.call(o,t),r:o=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(o,"__esModule",{value:!0})}},t={};(()=>{"use strict";o.r(t),o.d(t,{extend:()=>j});const n=flarum.core.compat["common/extend"],e=flarum.core.compat["forum/app"];var c=o.n(e);const r=flarum.core.compat["forum/components/NotificationGrid"];var s=o.n(r);function a(o,t){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(o,t){return o.__proto__=t,o},a(o,t)}function i(o,t){o.prototype=Object.create(t.prototype),o.prototype.constructor=o,a(o,t)}const u=flarum.core.compat["forum/components/Notification"];var f=function(o){function t(){return o.apply(this,arguments)||this}i(t,o);var n=t.prototype;return n.icon=function(){return"fas fa-lock"},n.href=function(){var o=this.attrs.notification;return c().route.discussion(o.subject(),o.content().postNumber)},n.content=function(){return c().translator.trans("flarum-lock.forum.notifications.discussion_locked_text",{user:this.attrs.notification.fromUser()})},t}(o.n(u)());const l=flarum.core.compat["common/models/Discussion"];var d=o.n(l);const p=flarum.core.compat["common/components/Badge"];var k=o.n(p);const y=flarum.core.compat["forum/utils/DiscussionControls"];var b=o.n(y);const _=flarum.core.compat["forum/components/DiscussionPage"];var v=o.n(_);const h=flarum.core.compat["common/components/Button"];var g=o.n(h);const L=flarum.core.compat["common/extenders"];var x=o.n(L);const O=flarum.core.compat["forum/components/EventPost"];var P=function(o){function t(){return o.apply(this,arguments)||this}i(t,o);var n=t.prototype;return n.icon=function(){return this.attrs.post.content().locked?"fas fa-lock":"fas fa-unlock"},n.descriptionKey=function(){return this.attrs.post.content().locked?"flarum-lock.forum.post_stream.discussion_locked_text":"flarum-lock.forum.post_stream.discussion_unlocked_text"},t}(o.n(O)());const j=[(new(x().PostTypes)).add("discussionLocked",P),new(x().Model)(d()).attribute("isLocked").attribute("canLock")];c().initializers.add("flarum-lock",(function(){c().notificationComponents.discussionLocked=f,(0,n.extend)(d().prototype,"badges",(function(o){this.isLocked()&&o.add("locked",m(k(),{type:"locked",label:c().translator.trans("flarum-lock.forum.badge.locked_tooltip"),icon:"fas fa-lock"}))})),(0,n.extend)(b(),"moderationControls",(function(o,t){t.canLock()&&o.add("lock",m(g(),{icon:"fas fa-lock",onclick:this.lockAction.bind(t)},c().translator.trans("flarum-lock.forum.discussion_controls."+(t.isLocked()?"unlock":"lock")+"_button")))})),b().lockAction=function(){this.save({isLocked:!this.isLocked()}).then((function(){c().current.matches(v())&&c().current.get("stream").update(),m.redraw()}))},(0,n.extend)(s().prototype,"notificationTypes",(function(o){o.add("discussionLocked",{name:"discussionLocked",icon:"fas fa-lock",label:c().translator.trans("flarum-lock.forum.settings.notify_discussion_locked_label")})}))}))})(),module.exports=t})();
(()=>{var o={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return o.d(n,{a:n}),n},d:(t,n)=>{for(var c in n)o.o(n,c)&&!o.o(t,c)&&Object.defineProperty(t,c,{enumerable:!0,get:n[c]})},o:(o,t)=>Object.prototype.hasOwnProperty.call(o,t),r:o=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(o,"__esModule",{value:!0})}},t={};(()=>{"use strict";o.r(t),o.d(t,{extend:()=>j});const n=flarum.core.compat["common/extend"],c=flarum.core.compat["forum/app"];var e=o.n(c);const r=flarum.core.compat["forum/components/NotificationGrid"];var s=o.n(r);function a(o,t){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(o,t){return o.__proto__=t,o},a(o,t)}function i(o,t){o.prototype=Object.create(t.prototype),o.prototype.constructor=o,a(o,t)}const u=flarum.core.compat["forum/components/Notification"];var l=function(o){function t(){return o.apply(this,arguments)||this}i(t,o);var n=t.prototype;return n.icon=function(){return"fas fa-lock"},n.href=function(){var o=this.attrs.notification;return e().route.discussion(o.subject(),o.content().postNumber)},n.content=function(){return e().translator.trans("flarum-lock.forum.notifications.discussion_locked_text",{user:this.attrs.notification.fromUser()})},t}(o.n(u)());const f=flarum.core.compat["common/models/Discussion"];var d=o.n(f);const p=flarum.core.compat["common/components/Badge"];var k=o.n(p);const y=flarum.core.compat["forum/utils/DiscussionControls"];var b=o.n(y);const _=flarum.core.compat["forum/components/DiscussionPage"];var v=o.n(_);const h=flarum.core.compat["common/components/Button"];var L=o.n(h);const g=flarum.core.compat["common/extenders"];var O=o.n(g);const x=flarum.core.compat["forum/components/EventPost"];var P=function(o){function t(){return o.apply(this,arguments)||this}i(t,o);var n=t.prototype;return n.icon=function(){return this.attrs.post.content().locked?"fas fa-lock":"fas fa-unlock"},n.descriptionKey=function(){return this.attrs.post.content().locked?"flarum-lock.forum.post_stream.discussion_locked_text":"flarum-lock.forum.post_stream.discussion_unlocked_text"},t}(o.n(x)());const j=[(new(O().PostTypes)).add("discussionLocked",P),new(O().Model)(d()).attribute("isLocked").attribute("canLock")],D={"lock/components/DiscussionLockedNotification":l,"lock/components/DiscussionLockedPost":P},S=flarum.core;e().initializers.add("flarum-lock",(function(){e().notificationComponents.discussionLocked=l,(0,n.extend)(d().prototype,"badges",(function(o){this.isLocked()&&o.add("locked",m(k(),{type:"locked",label:e().translator.trans("flarum-lock.forum.badge.locked_tooltip"),icon:"fas fa-lock"}))})),(0,n.extend)(b(),"moderationControls",(function(o,t){t.canLock()&&o.add("lock",m(L(),{icon:"fas fa-lock",onclick:this.lockAction.bind(t)},e().translator.trans("flarum-lock.forum.discussion_controls."+(t.isLocked()?"unlock":"lock")+"_button")))})),b().lockAction=function(){this.save({isLocked:!this.isLocked()}).then((function(){e().current.matches(v())&&e().current.get("stream").update(),m.redraw()}))},(0,n.extend)(s().prototype,"notificationTypes",(function(o){o.add("discussionLocked",{name:"discussionLocked",icon:"fas fa-lock",label:e().translator.trans("flarum-lock.forum.settings.notify_discussion_locked_label")})}))})),Object.assign(S.compat,D)})(),module.exports=t})();
//# sourceMappingURL=forum.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,8 @@
import 'flarum/common/models/Discussion';
declare module 'flarum/common/models/Discussion' {
export default interface Discussion {
isLocked(): boolean;
canLock(): boolean;
}
}

View File

@@ -0,0 +1,7 @@
import DiscussionLockedNotification from './components/DiscussionLockedNotification';
import DiscussionLockedPost from './components/DiscussionLockedPost';
export default {
'lock/components/DiscussionLockedNotification': DiscussionLockedNotification,
'lock/components/DiscussionLockedPost': DiscussionLockedPost,
};

View File

@@ -22,3 +22,9 @@ app.initializers.add('flarum-lock', () => {
});
});
});
// Expose compat API
import lockCompat from './compat';
import { compat } from '@flarum/core/forum';
Object.assign(compat, lockCompat);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,5 @@
import commonCompat from '../common/compat';
export default {
...commonCompat,
};

View File

@@ -2,3 +2,9 @@ import app from 'flarum/admin/app';
import { initialize } from '../common/index';
app.initializers.add('flarum-markdown', initialize);
// Expose compat API
import markdownCompat from './compat';
import { compat } from '@flarum/core/admin';
Object.assign(compat, markdownCompat);

View File

@@ -0,0 +1,7 @@
import MarkdownButton from './components/MarkdownButton';
import MarkdownToolbar from './components/MarkdownToolbar';
export default {
'markdown/components/MarkdownButton': MarkdownButton,
'markdown/components/MarkdownToolbar': MarkdownToolbar,
};

View File

@@ -0,0 +1,5 @@
import commonCompat from '../common/compat';
export default {
...commonCompat,
};

View File

@@ -2,3 +2,9 @@ import app from 'flarum/forum/app';
import { initialize } from '../common/index';
app.initializers.add('flarum-markdown', initialize);
// Expose compat API
import markdownCompat from './compat';
import { compat } from '@flarum/core/forum';
Object.assign(compat, markdownCompat);

View File

@@ -51,8 +51,7 @@ return [
->belongsToMany('mentionedBy', Post::class, 'post_mentions_post', 'mentions_post_id', 'post_id')
->belongsToMany('mentionsPosts', Post::class, 'post_mentions_post', 'post_id', 'mentions_post_id')
->belongsToMany('mentionsUsers', User::class, 'post_mentions_user', 'post_id', 'mentions_user_id')
->belongsToMany('mentionsGroups', Group::class, 'post_mentions_group', 'post_id', 'mentions_group_id')
->belongsToMany('mentionsUsers', User::class, 'post_mentions_user', 'post_id', 'mentions_user_id'),
->belongsToMany('mentionsGroups', Group::class, 'post_mentions_group', 'post_id', 'mentions_group_id'),
new Extend\Locales(__DIR__.'/locale'),
@@ -78,15 +77,17 @@ return [
->addInclude(['posts.mentionedBy', 'posts.mentionedBy.user', 'posts.mentionedBy.discussion'])
->load([
'posts.mentionsUsers', 'posts.mentionsPosts', 'posts.mentionsPosts.user',
'posts.mentionsGroups'
'posts.mentionsPosts.discussion', 'posts.mentionsGroups'
])
->loadWhere('posts.mentionedBy', [LoadMentionedByRelationship::class, 'mutateRelation'])
->prepareDataForSerialization([LoadMentionedByRelationship::class, 'countRelation']),
(new Extend\ApiController(Controller\ListDiscussionsController::class))
->load([
'firstPost.mentionsUsers', 'firstPost.mentionsPosts', 'firstPost.mentionsPosts.user', 'firstPost.mentionsGroups',
'lastPost.mentionsUsers', 'lastPost.mentionsPosts', 'lastPost.mentionsPosts.user', 'lastPost.mentionsGroups',
'firstPost.mentionsUsers', 'firstPost.mentionsPosts',
'firstPost.mentionsPosts.user', 'firstPost.mentionsPosts.discussion', 'firstPost.mentionsGroups',
'lastPost.mentionsUsers', 'lastPost.mentionsPosts',
'lastPost.mentionsPosts.user', 'lastPost.mentionsPosts.discussion', 'lastPost.mentionsGroups',
]),
(new Extend\ApiController(Controller\ShowPostController::class))
@@ -98,7 +99,7 @@ return [
(new Extend\ApiController(Controller\ListPostsController::class))
->addInclude(['mentionedBy', 'mentionedBy.user', 'mentionedBy.discussion'])
->load(['mentionsUsers', 'mentionsPosts', 'mentionsPosts.user', 'mentionsGroups'])
->load(['mentionsUsers', 'mentionsPosts', 'mentionsPosts.user', 'mentionsPosts.discussion', 'mentionsGroups'])
->loadWhere('mentionedBy', [LoadMentionedByRelationship::class, 'mutateRelation'])
->prepareDataForSerialization([LoadMentionedByRelationship::class, 'countRelation']),

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,3 +1,7 @@
import 'flarum/forum/ForumApplication';
import 'flarum/common/models/User';
import 'flarum/common/models/Post';
import MentionFormats from '../forum/mentionables/formats/MentionFormats';
import type BasePost from 'flarum/common/models/Post';

View File

@@ -5,12 +5,9 @@ import TextEditorButton from 'flarum/common/components/TextEditorButton';
import KeyboardNavigatable from 'flarum/common/utils/KeyboardNavigatable';
import AutocompleteDropdown from './fragments/AutocompleteDropdown';
import MentionFormats from './mentionables/formats/MentionFormats';
import MentionableModels from './mentionables/MentionableModels';
export default function addComposerAutocomplete() {
app.mentionFormats = new MentionFormats();
const $container = $('<div class="ComposerBody-mentionsDropdownContainer"></div>');
const dropdown = new AutocompleteDropdown();

View File

@@ -118,7 +118,7 @@ export default function addMentionedByList() {
});
const limit = 4;
const overLimit = repliers.length > limit;
const overLimit = post.mentionedByCount() > limit;
// Create a list of unique users who have replied. So even if a user has
// replied twice, they will only be in this array once.
@@ -136,7 +136,7 @@ export default function addMentionedByList() {
// others" name to the end of the list. Clicking on it will display a modal
// with a full list of names.
if (overLimit) {
const count = repliers.length - names.length;
const count = post.mentionedByCount() - names.length;
names.push(app.translator.trans('flarum-mentions.forum.post.others_text', { count }));
}

View File

@@ -1,4 +1,6 @@
import GroupMentionedNotification from './components/GroupMentionedNotification';
import MentionedByModal from './components/MentionedByModal';
import MentionsDropdownItem from './components/MentionsDropdownItem';
import MentionsUserPage from './components/MentionsUserPage';
import PostMentionedNotification from './components/PostMentionedNotification';
import UserMentionedNotification from './components/UserMentionedNotification';
@@ -9,13 +11,24 @@ import getMentionText from './utils/getMentionText';
import * as reply from './utils/reply';
import selectedText from './utils/selectedText';
import * as textFormatter from './utils/textFormatter';
import GroupMention from './mentionables/GroupMention';
import MentionableModel from './mentionables/MentionableModel';
import MentionableModels from './mentionables/MentionableModels';
import PostMention from './mentionables/PostMention';
import TagMention from './mentionables/TagMention';
import UserMention from './mentionables/UserMention';
import AtMentionFormat from './mentionables/formats/AtMentionFormat';
import HashMentionFormat from './mentionables/formats/HashMentionFormat';
import MentionFormat from './mentionables/formats/MentionFormat';
import MentionFormats from './mentionables/formats/MentionFormats';
import Mentionables from './extenders/Mentionables';
import MentionedByModalState from './state/MentionedByModalState';
export default {
'mentions/components/MentionsUserPage': MentionsUserPage,
'mentions/components/PostMentionedNotification': PostMentionedNotification,
'mentions/components/MentionedByModal': MentionedByModal,
'mentions/components/MentionsDropdownItem': MentionsDropdownItem,
'mentions/components/UserMentionedNotification': UserMentionedNotification,
'mentions/components/GroupMentionedNotification': GroupMentionedNotification,
'mentions/fragments/AutocompleteDropdown': AutocompleteDropdown,
@@ -25,7 +38,16 @@ export default {
'mentions/utils/reply': reply,
'mentions/utils/selectedText': selectedText,
'mentions/utils/textFormatter': textFormatter,
'mentions/mentionables/GroupMention': GroupMention,
'mentions/mentionables/MentionableModel': MentionableModel,
'mentions/mentionables/MentionableModels': MentionableModels,
'mentions/mentionables/PostMention': PostMention,
'mentions/mentionables/TagMention': TagMention,
'mentions/mentionables/UserMention': UserMention,
'mentions/mentionables/formats/AtMentionFormat': AtMentionFormat,
'mentions/mentionables/formats/HashMentionFormat': HashMentionFormat,
'mentions/mentionables/formats/MentionFormat': MentionFormat,
'mentions/mentionables/formats/MentionFormats': MentionFormats,
'mentions/extenders/Mentionables': Mentionables,
'mentions/state/MentionedByModalState': MentionedByModalState,
};

View File

@@ -5,7 +5,7 @@ import type MentionFormat from '../mentionables/formats/MentionFormat';
export default class Mentionables implements IExtender<ForumApplication> {
protected formats: (new () => MentionFormat)[] = [];
protected mentionables: Record<string, (new () => MentionableModel)[]> = {};
protected mentionables: Record<string, (new (...args: any[]) => MentionableModel)[]> = {};
/**
* Register a new mention format.
@@ -26,7 +26,7 @@ export default class Mentionables implements IExtender<ForumApplication> {
* @param mentionable The mentionable instance to register.
* Must extend MentionableModel.
*/
mentionable(symbol: string, mentionable: new () => MentionableModel): this {
mentionable(symbol: string, mentionable: new (...args: any[]) => MentionableModel): this {
if (!this.mentionables[symbol]) {
this.mentionables[symbol] = [];
}

View File

@@ -13,11 +13,14 @@ import addComposerAutocomplete from './addComposerAutocomplete';
import PostMentionedNotification from './components/PostMentionedNotification';
import UserMentionedNotification from './components/UserMentionedNotification';
import GroupMentionedNotification from './components/GroupMentionedNotification';
import MentionFormats from './mentionables/formats/MentionFormats';
import UserPage from 'flarum/forum/components/UserPage';
import LinkButton from 'flarum/common/components/LinkButton';
import User from 'flarum/common/models/User';
import Model from 'flarum/common/Model';
app.mentionFormats = new MentionFormats();
export { default as extend } from './extend';
app.initializers.add('flarum-mentions', function () {

View File

@@ -4,7 +4,7 @@ import TagMention from '../TagMention';
export default class HashMentionFormat extends MentionFormat {
public mentionables: (new (...args: any[]) => MentionableModel)[] = [TagMention];
protected extendable: boolean = false;
protected extendable: boolean = true;
public trigger(): string {
return '#';

View File

@@ -29,7 +29,7 @@ class LoadMentionedByRelationship
$actor = RequestUtil::getActor($request);
return $query
->with(['mentionsPosts', 'mentionsPosts.user', 'mentionsUsers'])
->with(['mentionsPosts', 'mentionsPosts.user', 'mentionsPosts.discussion', 'mentionsUsers'])
->whereVisibleTo($actor)
->oldest()
// Limiting a relationship results is only possible because
@@ -50,6 +50,16 @@ class LoadMentionedByRelationship
$loadable = $data->newCollection($data->posts)->filter(function ($post) {
return $post instanceof Post;
});
// firstPost and lastPost might have been included in the API response,
// so we have to make sure counts are also loaded for them.
if ($data->firstPost) {
$loadable->push($data->firstPost);
}
if ($data->lastPost) {
$loadable->push($data->lastPost);
}
} elseif ($data instanceof Collection) {
$loadable = $data;
} elseif ($data instanceof Post) {

View File

@@ -9,6 +9,9 @@
namespace Flarum\Mentions\Formatter;
use Flarum\Discussion\Discussion;
use Flarum\Http\SlugManager;
use Flarum\Post\Post;
use Psr\Http\Message\ServerRequestInterface as Request;
use s9e\TextFormatter\Renderer;
use s9e\TextFormatter\Utils;
@@ -21,9 +24,15 @@ class FormatPostMentions
*/
private $translator;
public function __construct(TranslatorInterface $translator)
/**
* @var SlugManager
*/
private $slugManager;
public function __construct(TranslatorInterface $translator, SlugManager $slugManager)
{
$this->translator = $translator;
$this->slugManager = $slugManager;
}
/**
@@ -31,16 +40,17 @@ class FormatPostMentions
*
* @param \s9e\TextFormatter\Renderer $renderer
* @param mixed $context
* @param string|null $xml
* @param \Psr\Http\Message\ServerRequestInterface $request
* @return string
* @param string $xml
* @param \Psr\Http\Message\ServerRequestInterface|null $request
* @return string $xml to be rendered
*/
public function __invoke(Renderer $renderer, $context, $xml, Request $request = null)
{
$post = $context;
return Utils::replaceAttributes($xml, 'POSTMENTION', function ($attributes) use ($context) {
$post = (($context && isset($context->getRelations()['mentionsPosts'])) || $context instanceof Post)
? $context->mentionsPosts->find($attributes['id'])
: Post::find($attributes['id']);
return Utils::replaceAttributes($xml, 'POSTMENTION', function ($attributes) use ($post) {
$post = $post->mentionsPosts->find($attributes['id']);
if ($post && $post->user) {
$attributes['displayname'] = $post->user->display_name;
}
@@ -56,6 +66,12 @@ class FormatPostMentions
$attributes['displayname'] = $this->translator->trans('core.lib.username.deleted_text');
}
if ($post) {
$attributes['discussionid'] = $this->slugManager
->forResource(Discussion::class)
->toSlug($post->discussion);
}
return $attributes;
});
}

View File

@@ -9,6 +9,7 @@
namespace Flarum\Mentions\Formatter;
use Flarum\Post\Post;
use s9e\TextFormatter\Utils;
use Symfony\Contracts\Translation\TranslatorInterface;
@@ -27,12 +28,16 @@ class UnparsePostMentions
/**
* Configure rendering for user mentions.
*
* @param string $xml
* @param string|null $xml
* @param mixed $context
* @return string $xml to be unparsed
* @return mixed $xml to be unparsed
*/
public function __invoke($context, string $xml)
public function __invoke($context, $xml)
{
if ($xml === null) {
return $xml;
}
$xml = $this->updatePostMentionTags($context, $xml);
$xml = $this->unparsePostMentionTags($xml);
@@ -50,8 +55,11 @@ class UnparsePostMentions
{
$post = $context;
return Utils::replaceAttributes($xml, 'POSTMENTION', function ($attributes) use ($post) {
$post = $post->mentionsPosts->find($attributes['id']);
return Utils::replaceAttributes($xml, 'POSTMENTION', function ($attributes) use ($context) {
$post = (($context && isset($context->getRelations()['mentionsPosts'])) || $context instanceof Post)
? $context->mentionsPosts->find($attributes['id'])
: Post::find($attributes['id']);
if ($post && $post->user) {
$attributes['displayname'] = $post->user->display_name;
}

View File

@@ -18,12 +18,16 @@ class UnparseTagMentions
/**
* Configure rendering for user mentions.
*
* @param string $xml
* @param string|null $xml
* @param mixed $context
* @return string $xml to be unparsed
* @return mixed $xml to be unparsed
*/
public function __invoke($context, string $xml)
public function __invoke($context, $xml)
{
if ($xml === null) {
return $xml;
}
$xml = $this->updateTagMentionTags($context, $xml);
$xml = $this->unparseTagMentionTags($xml);

View File

@@ -29,12 +29,16 @@ class UnparseUserMentions
/**
* Configure rendering for user mentions.
*
* @param string $xml
* @param string|null $xml
* @param mixed $context
* @return string $xml to be unparsed
* @return mixed $xml to be unparsed
*/
public function __invoke($context, string $xml)
public function __invoke($context, $xml)
{
if ($xml === null) {
return $xml;
}
$xml = $this->updateUserMentionTags($context, $xml);
$xml = $this->unparseUserMentionTags($xml);

View File

@@ -47,6 +47,8 @@ class SendMentionsNotificationsJob extends AbstractJob
public function __construct(CommentPost $post, array $userMentions, array $postMentions, array $groupMentions)
{
parent::__construct();
$this->post = $post;
$this->userMentions = $userMentions;
$this->postMentions = $postMentions;

View File

@@ -0,0 +1,137 @@
<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\Mentions\Tests\integration\api;
use Flarum\Extend;
use Flarum\Testing\integration\TestCase;
class CreateDiscussionTest extends TestCase
{
/**
* @inheritDoc
*/
protected function setUp(): void
{
parent::setUp();
$this->extension('flarum-mentions');
$this->extend(
(new Extend\Event())
->listen(\Flarum\Post\Event\Saving::class, function ($event) {
$event->post->content;
})
);
}
/**
* @test
*/
public function cannot_create_discussion_with_empty_string()
{
$response = $this->send(
$this->request('POST', '/api/discussions', [
'authenticatedAs' => 1,
'json' => [
'data' => [
'attributes' => [
'title' => 'Test post',
'content' => '',
],
],
],
])
);
$this->assertEquals(422, $response->getStatusCode());
$body = (string) $response->getBody();
$this->assertJson($body);
$this->assertEquals([
'errors' => [
[
'status' => '422',
'code' => 'validation_error',
'detail' => 'The content field is required.',
'source' => ['pointer' => '/data/attributes/content'],
],
],
], json_decode($body, true));
}
/**
* @test
*/
public function cannot_create_discussion_without_content_property()
{
$response = $this->send(
$this->request('POST', '/api/discussions', [
'authenticatedAs' => 1,
'json' => [
'data' => [
'attributes' => [
'title' => 'Test post',
],
],
],
])
);
$this->assertEquals(422, $response->getStatusCode());
$body = (string) $response->getBody();
$this->assertJson($body);
$this->assertEquals([
'errors' => [
[
'status' => '422',
'code' => 'validation_error',
'detail' => 'The content field is required.',
'source' => ['pointer' => '/data/attributes/content'],
],
],
], json_decode($body, true));
}
/**
* @test
*/
public function cannot_create_discussion_with_content_set_to_null()
{
$response = $this->send(
$this->request('POST', '/api/discussions', [
'authenticatedAs' => 1,
'json' => [
'data' => [
'attributes' => [
'title' => 'Test post',
'content' => null,
],
],
],
])
);
$this->assertEquals(422, $response->getStatusCode());
$body = (string) $response->getBody();
$this->assertJson($body);
$this->assertEquals([
'errors' => [
[
'status' => '422',
'code' => 'validation_error',
'detail' => 'The content field is required.',
'source' => ['pointer' => '/data/attributes/content'],
],
],
], json_decode($body, true));
}
}

View File

@@ -0,0 +1,110 @@
<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\Mentions\Tests\integration\api;
use Flarum\Extend;
use Flarum\Testing\integration\TestCase;
class EditPostTest extends TestCase
{
/**
* @inheritDoc
*/
protected function setUp(): void
{
parent::setUp();
$this->extension('flarum-mentions');
$this->prepareDatabase([
'discussions' => [
['id' => 1, 'title' => 'Discussion with post', 'user_id' => 1, 'first_post_id' => 1, 'comment_count' => 1],
],
'posts' => [
['id' => 1, 'discussion_id' => 1, 'user_id' => 1, 'type' => 'comment', 'content' => '<t><p>Text</p></t>'],
]
]);
$this->extend(
(new Extend\Event())
->listen(\Flarum\Post\Event\Saving::class, function ($event) {
$event->post->content;
})
);
}
/**
* @test
*/
public function cannot_update_post_with_empty_string()
{
$response = $this->send(
$this->request('PATCH', '/api/posts/1', [
'authenticatedAs' => 1,
'json' => [
'data' => [
'attributes' => [
'content' => '',
],
],
],
])
);
$this->assertEquals(422, $response->getStatusCode());
$body = (string) $response->getBody();
$this->assertJson($body);
$this->assertEquals([
'errors' => [
[
'status' => '422',
'code' => 'validation_error',
'detail' => 'The content field is required.',
'source' => ['pointer' => '/data/attributes/content'],
],
],
], json_decode($body, true));
}
/**
* @test
*/
public function cannot_update_post_with_invalid_content_type()
{
$response = $this->send(
$this->request('PATCH', '/api/posts/1', [
'authenticatedAs' => 1,
'json' => [
'data' => [
'attributes' => [
'content' => [],
],
],
],
])
);
$this->assertEquals(422, $response->getStatusCode());
$body = (string) $response->getBody();
$this->assertJson($body);
$this->assertEquals([
'errors' => [
[
'status' => '422',
'code' => 'validation_error',
'detail' => 'The content field is required.',
'source' => ['pointer' => '/data/attributes/content'],
],
],
], json_decode($body, true));
}
}

View File

@@ -11,7 +11,9 @@ namespace Flarum\Mentions\Tests\integration\api;
use Carbon\Carbon;
use Flarum\Extend;
use Flarum\Formatter\Formatter;
use Flarum\Post\CommentPost;
use Flarum\Post\Post;
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase;
use Flarum\User\DisplayName\DriverInterface;
@@ -538,6 +540,40 @@ class PostMentionsTest extends TestCase
$this->assertStringContainsString('PostMention', $response['data']['attributes']['contentHtml']);
$this->assertNotNull(CommentPost::find($response['data']['id'])->mentionsPosts->find(11));
}
/**
* @test
*/
public function rendering_post_mention_with_a_post_context_works()
{
/** @var Formatter $formatter */
$formatter = $this->app()->getContainer()->make(Formatter::class);
$post = Post::find(4);
$user = User::find(1);
$xml = $formatter->parse($post->content, $post, $user);
$renderedHtml = $formatter->render($xml, $post);
$this->assertStringContainsString('TOBY$', $renderedHtml);
}
/**
* @test
*/
public function rendering_post_mention_without_a_context_works()
{
/** @var Formatter $formatter */
$formatter = $this->app()->getContainer()->make(Formatter::class);
$post = Post::find(4);
$user = User::find(1);
$xml = $formatter->parse($post->content, null, $user);
$renderedHtml = $formatter->render($xml);
$this->assertStringContainsString('TOBY$', $renderedHtml);
}
}
class CustomOtherDisplayNameDriver implements DriverInterface

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,7 @@
import 'flarum/common/models/User';
declare module 'flarum/common/models/User' {
export default interface User {
canEditNickname(): boolean;
}
}

View File

@@ -0,0 +1,5 @@
import NicknameModal from './components/NicknameModal';
export default {
'nicknames/components/NicknameModal': NicknameModal,
};

View File

@@ -110,3 +110,9 @@ app.initializers.add('flarum/nicknames', () => {
}
});
});
// Expose compat API
import nicknamesCompat from './compat';
import { compat } from '@flarum/core/forum';
Object.assign(compat, nicknamesCompat);

View File

@@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) Sami Mazouz
Copyright (c) 2024 Stichting Flarum (Flarum Foundation)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,18 @@
# Package Manager
# Extension Manager
*An Experiment.*
The extension manager is a tool that allows you to easily install and manage extensions. It runs [composer](https://getcomposer.org/) under the hood.
Read: https://github.com/flarum/package-manager/wiki
## Security
If admin access is given to untrustworthy users, they can install malicious extensions. Please be careful.
This extension is optional and can be removed for those who prefer to manually manage installs and updates through the command line interface.
## Troubleshooting
If you have many extensions installed, you may run into memory issues when using the extension manager. If this happens, you can use an asynchronous queue that will run the extension manager in the background.
* Simple database queue guide: https://discuss.flarum.org/d/28151-database-queue-the-simplest-queue-even-for-shared-hosting
* (Advanced) Redis queue: https://discuss.flarum.org/d/21873-redis-sessions-cache-queues
You can find detailed logs on the extension manager operations in the `storage/logs/composer` directory. Please include the latest log file when reporting issues in the [Flarum support forum](https://discuss.flarum.org/t/support).

View File

@@ -1,6 +1,6 @@
{
"name": "flarum/package-manager",
"description": "A Flarum Package Manager.",
"name": "flarum/extension-manager",
"description": "An extension manager to install, update and remove extension packages from the interface (Wrapper around composer).",
"keywords": [
"extensions",
"composer",
@@ -18,12 +18,12 @@
}
],
"support": {
"issues": "https://github.com/flarum/package-manager/issues",
"source": "https://github.com/flarum/package-manager"
"issues": "https://github.com/flarum/framework/issues",
"source": "https://github.com/flarum/extension-manager"
},
"require": {
"flarum/core": "^1.8",
"composer/composer": "^2.3"
"composer/composer": "^2.7"
},
"require-dev": {
"flarum/testing": "^1.0.0",
@@ -31,7 +31,7 @@
},
"extra": {
"flarum-extension": {
"title": "Package Manager",
"title": "Extension Manager",
"icon": {
"name": "fas fa-box-open",
"backgroundColor": "#117187",
@@ -69,12 +69,12 @@
},
"autoload": {
"psr-4": {
"Flarum\\PackageManager\\": "src/"
"Flarum\\ExtensionManager\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Flarum\\PackageManager\\Tests\\": "tests/"
"Flarum\\ExtensionManager\\Tests\\": "tests/"
}
},
"scripts": {

View File

@@ -7,32 +7,26 @@
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\PackageManager;
namespace Flarum\ExtensionManager;
use Flarum\Extend;
use Flarum\Foundation\Paths;
use Flarum\Frontend\Document;
use Flarum\PackageManager\Exception\ComposerCommandFailedException;
use Flarum\PackageManager\Exception\ComposerRequireFailedException;
use Flarum\PackageManager\Exception\ComposerUpdateFailedException;
use Flarum\PackageManager\Exception\ExceptionHandler;
use Flarum\PackageManager\Exception\MajorUpdateFailedException;
use Flarum\PackageManager\Settings\LastUpdateCheck;
use Flarum\PackageManager\Settings\LastUpdateRun;
use Illuminate\Contracts\Queue\Queue;
use Illuminate\Queue\SyncQueue;
return [
(new Extend\Routes('api'))
->post('/package-manager/extensions', 'package-manager.extensions.require', Api\Controller\RequireExtensionController::class)
->patch('/package-manager/extensions/{id}', 'package-manager.extensions.update', Api\Controller\UpdateExtensionController::class)
->delete('/package-manager/extensions/{id}', 'package-manager.extensions.remove', Api\Controller\RemoveExtensionController::class)
->post('/package-manager/check-for-updates', 'package-manager.check-for-updates', Api\Controller\CheckForUpdatesController::class)
->post('/package-manager/why-not', 'package-manager.why-not', Api\Controller\WhyNotController::class)
->post('/package-manager/minor-update', 'package-manager.minor-update', Api\Controller\MinorUpdateController::class)
->post('/package-manager/major-update', 'package-manager.major-update', Api\Controller\MajorUpdateController::class)
->post('/package-manager/global-update', 'package-manager.global-update', Api\Controller\GlobalUpdateController::class)
->get('/package-manager-tasks', 'package-manager.tasks.index', Api\Controller\ListTasksController::class),
->post('/extension-manager/extensions', 'extension-manager.extensions.require', Api\Controller\RequireExtensionController::class)
->patch('/extension-manager/extensions/{id}', 'extension-manager.extensions.update', Api\Controller\UpdateExtensionController::class)
->delete('/extension-manager/extensions/{id}', 'extension-manager.extensions.remove', Api\Controller\RemoveExtensionController::class)
->post('/extension-manager/check-for-updates', 'extension-manager.check-for-updates', Api\Controller\CheckForUpdatesController::class)
->post('/extension-manager/why-not', 'extension-manager.why-not', Api\Controller\WhyNotController::class)
->post('/extension-manager/minor-update', 'extension-manager.minor-update', Api\Controller\MinorUpdateController::class)
->post('/extension-manager/major-update', 'extension-manager.major-update', Api\Controller\MajorUpdateController::class)
->post('/extension-manager/global-update', 'extension-manager.global-update', Api\Controller\GlobalUpdateController::class)
->get('/extension-manager-tasks', 'extension-manager.tasks.index', Api\Controller\ListTasksController::class)
->post('/extension-manager/composer', 'extension-manager.composer', Api\Controller\ConfigureComposerController::class),
(new Extend\Frontend('admin'))
->css(__DIR__.'/less/admin.less')
@@ -40,31 +34,34 @@ return [
->content(function (Document $document) {
$paths = resolve(Paths::class);
$document->payload['flarum-package-manager.writable_dirs'] = is_writable($paths->vendor)
$document->payload['flarum-extension-manager.writable_dirs'] = is_writable($paths->vendor)
&& is_writable($paths->storage)
&& (! file_exists($paths->storage.'/.composer') || is_writable($paths->storage.'/.composer'))
&& is_writable($paths->base.'/composer.json')
&& is_writable($paths->base.'/composer.lock');
$document->payload['flarum-package-manager.using_sync_queue'] = resolve(Queue::class) instanceof SyncQueue;
$document->payload['flarum-extension-manager.using_sync_queue'] = resolve(Queue::class) instanceof SyncQueue;
}),
new Extend\Locales(__DIR__.'/locale'),
(new Extend\Settings())
->default(LastUpdateCheck::key(), json_encode(LastUpdateCheck::default()))
->default(LastUpdateRun::key(), json_encode(LastUpdateRun::default()))
->default('flarum-package-manager.queue_jobs', false),
->default(Settings\LastUpdateCheck::key(), json_encode(Settings\LastUpdateCheck::default()))
->default(Settings\LastUpdateRun::key(), json_encode(Settings\LastUpdateRun::default()))
->default('flarum-extension-manager.queue_jobs', '0')
->default('flarum-extension-manager.minimum_stability', 'stable')
->default('flarum-extension-manager.task_retention_days', 7),
(new Extend\ServiceProvider)
->register(PackageManagerServiceProvider::class),
->register(ExtensionManagerServiceProvider::class),
(new Extend\ErrorHandling)
->handler(ComposerCommandFailedException::class, ExceptionHandler::class)
->handler(ComposerRequireFailedException::class, ExceptionHandler::class)
->handler(ComposerUpdateFailedException::class, ExceptionHandler::class)
->handler(MajorUpdateFailedException::class, ExceptionHandler::class)
->handler(Exception\ComposerCommandFailedException::class, Exception\ExceptionHandler::class)
->handler(Exception\ComposerRequireFailedException::class, Exception\ExceptionHandler::class)
->handler(Exception\ComposerUpdateFailedException::class, Exception\ExceptionHandler::class)
->handler(Exception\MajorUpdateFailedException::class, Exception\ExceptionHandler::class)
->status('extension_already_installed', 409)
->status('extension_not_installed', 409)
->status('no_new_major_version', 409),
->status('no_new_major_version', 409)
->status('extension_not_directly_dependency', 409),
];

49
extensions/package-manager/js/dist-typings/compat.d.ts generated vendored Normal file
View File

@@ -0,0 +1,49 @@
import AuthMethodModal from './components/AuthMethodModal';
import ConfigureAuth from './components/ConfigureAuth';
import ConfigureComposer from './components/ConfigureComposer';
import ConfigureJson from './components/ConfigureJson';
import ControlSection from './components/ControlSection';
import ExtensionItem from './components/ExtensionItem';
import Installer from './components/Installer';
import Label from './components/Label';
import MajorUpdater from './components/MajorUpdater';
import Pagination from './components/Pagination';
import QueueSection from './components/QueueSection';
import RepositoryModal from './components/RepositoryModal';
import SettingsPage from './components/SettingsPage';
import TaskOutputModal from './components/TaskOutputModal';
import Updater from './components/Updater';
import WhyNotModal from './components/WhyNotModal';
import Task from './models/Task';
import ControlSectionState from './states/ControlSectionState';
import ExtensionManagerState from './states/ExtensionManagerState';
import QueueState from './states/QueueState';
import errorHandler from './utils/errorHandler';
import humanDuration from './utils/humanDuration';
import jumpToQueue from './utils/jumpToQueue';
declare const _default: {
'extension-manager/components/AuthMethodModal': typeof AuthMethodModal;
'extension-manager/components/ConfigureAuth': typeof ConfigureAuth;
'extension-manager/components/ConfigureComposer': typeof ConfigureComposer;
'extension-manager/components/ConfigureJson': typeof ConfigureJson;
'extension-manager/components/ControlSection': typeof ControlSection;
'extension-manager/components/ExtensionItem': typeof ExtensionItem;
'extension-manager/components/Installer': typeof Installer;
'extension-manager/components/Label': typeof Label;
'extension-manager/components/MajorUpdater': typeof MajorUpdater;
'extension-manager/components/Pagination': typeof Pagination;
'extension-manager/components/QueueSection': typeof QueueSection;
'extension-manager/components/RepositoryModal': typeof RepositoryModal;
'extension-manager/components/SettingsPage': typeof SettingsPage;
'extension-manager/components/TaskOutputModal': typeof TaskOutputModal;
'extension-manager/components/Updater': typeof Updater;
'extension-manager/components/WhyNotModal': typeof WhyNotModal;
'extension-manager/models/Task': typeof Task;
'extension-manager/states/ControlSectionState': typeof ControlSectionState;
'extension-manager/states/ExtensionManagerState': typeof ExtensionManagerState;
'extension-manager/states/QueueState': typeof QueueState;
'extension-manager/utils/errorHandler': typeof errorHandler;
'extension-manager/utils/humanDuration': typeof humanDuration;
'extension-manager/utils/jumpToQueue': typeof jumpToQueue;
};
export default _default;

View File

@@ -0,0 +1,19 @@
import Modal, { IInternalModalAttrs } from 'flarum/common/components/Modal';
import Mithril from 'mithril';
import Stream from 'flarum/common/utils/Stream';
export interface IAuthMethodModalAttrs extends IInternalModalAttrs {
onsubmit: (type: string, host: string, token: string) => void;
type?: string;
host?: string;
token?: string;
}
export default class AuthMethodModal<CustomAttrs extends IAuthMethodModalAttrs = IAuthMethodModalAttrs> extends Modal<CustomAttrs> {
protected type: Stream<string>;
protected host: Stream<string>;
protected token: Stream<string>;
oninit(vnode: Mithril.Vnode<CustomAttrs, this>): void;
className(): string;
title(): Mithril.Children;
content(): Mithril.Children;
submit(): void;
}

View File

@@ -0,0 +1,10 @@
import type Mithril from 'mithril';
import ConfigureJson, { IConfigureJson } from './ConfigureJson';
export default class ConfigureAuth extends ConfigureJson<IConfigureJson> {
protected type: string;
title(): Mithril.Children;
className(): string;
content(): Mithril.Children;
submitButton(): Mithril.Children[];
onchange(oldHost: string | null, type: string, host: string, token: string): void;
}

View File

@@ -0,0 +1,14 @@
import type Mithril from 'mithril';
import ConfigureJson, { type IConfigureJson } from './ConfigureJson';
export declare type Repository = {
type: 'composer' | 'vcs' | 'path';
url: string;
};
export default class ConfigureComposer extends ConfigureJson<IConfigureJson> {
protected type: string;
title(): Mithril.Children;
className(): string;
content(): Mithril.Children;
submitButton(): Mithril.Children[];
onchange(repository: Repository, name: string): void;
}

View File

@@ -0,0 +1,24 @@
import type Mithril from 'mithril';
import Component, { type ComponentAttrs } from 'flarum/common/Component';
import { CommonSettingsItemOptions, type SettingsComponentOptions } from '@flarum/core/src/admin/components/AdminPage';
import type ItemList from 'flarum/common/utils/ItemList';
import Stream from 'flarum/common/utils/Stream';
export interface IConfigureJson extends ComponentAttrs {
buildSettingComponent: (entry: ((this: this) => Mithril.Children) | SettingsComponentOptions) => Mithril.Children;
}
export default abstract class ConfigureJson<CustomAttrs extends IConfigureJson = IConfigureJson> extends Component<CustomAttrs> {
protected settings: Record<string, Stream<any>>;
protected initialSettings: Record<string, any> | null;
protected loading: boolean;
oninit(vnode: Mithril.Vnode<CustomAttrs, this>): void;
protected abstract type: string;
abstract title(): Mithril.Children;
abstract content(): Mithril.Children;
className(): string;
view(): Mithril.Children;
submitButton(): Mithril.Children[];
customSettingComponents(): ItemList<(attributes: CommonSettingsItemOptions) => Mithril.Children>;
setting(key: string): Stream<any>;
submit(readOnly: boolean): void;
isDirty(): boolean;
}

View File

@@ -5,7 +5,10 @@ import { UpdatedPackage } from '../states/ControlSectionState';
export interface ExtensionItemAttrs extends ComponentAttrs {
extension: Extension;
updates: UpdatedPackage;
onClickUpdate: CallableFunction;
onClickUpdate: CallableFunction | {
soft: CallableFunction;
hard: CallableFunction;
};
whyNotWarning?: boolean;
isCore?: boolean;
updatable?: boolean;

View File

@@ -0,0 +1,18 @@
import Modal, { IInternalModalAttrs } from 'flarum/common/components/Modal';
import Mithril from 'mithril';
import Stream from 'flarum/common/utils/Stream';
import { type Repository } from './ConfigureComposer';
export interface IRepositoryModalAttrs extends IInternalModalAttrs {
onsubmit: (repository: Repository, key: string) => void;
name?: string;
repository?: Repository;
}
export default class RepositoryModal<CustomAttrs extends IRepositoryModalAttrs = IRepositoryModalAttrs> extends Modal<CustomAttrs> {
protected name: Stream<string>;
protected repository: Stream<Repository>;
oninit(vnode: Mithril.Vnode<CustomAttrs, this>): void;
className(): string;
title(): Mithril.Children;
content(): Mithril.Children;
submit(): void;
}

View File

@@ -2,5 +2,7 @@ import type Mithril from 'mithril';
import ExtensionPage, { ExtensionPageAttrs } from 'flarum/admin/components/ExtensionPage';
import ItemList from 'flarum/common/utils/ItemList';
export default class SettingsPage extends ExtensionPage {
content(): JSX.Element;
sections(vnode: Mithril.VnodeDOM<ExtensionPageAttrs, this>): ItemList<unknown>;
onsaved(): void;
}

View File

@@ -1,5 +1,5 @@
/// <reference types="mithril" />
/// <reference types="flarum/@types/translator-icu-rich" />
/// <reference types="@flarum/core/dist-typings/@types/translator-icu-rich" />
import Modal, { IInternalModalAttrs } from 'flarum/common/components/Modal';
import Task from '../models/Task';
interface TaskOutputModalAttrs extends IInternalModalAttrs {

View File

@@ -1,4 +1,4 @@
/// <reference types="flarum/@types/translator-icu-rich" />
/// <reference types="@flarum/core/dist-typings/@types/translator-icu-rich" />
import type Mithril from 'mithril';
import Modal, { IInternalModalAttrs } from 'flarum/common/components/Modal';
export interface WhyNotModalAttrs extends IInternalModalAttrs {

View File

@@ -1,11 +1,12 @@
import Model from 'flarum/common/Model';
export declare type TaskOperations = 'extension_install' | 'extension_remove' | 'extension_update' | 'update_global' | 'update_minor' | 'update_major' | 'update_check' | 'why_not';
export default class Task extends Model {
status(): "running" | "pending" | "success" | "failure";
status(): "pending" | "running" | "failure" | "success";
operation(): TaskOperations;
command(): string;
package(): string;
output(): string;
guessedCause(): string;
createdAt(): Date | null | undefined;
startedAt(): Date;
finishedAt(): Date;

View File

@@ -9,6 +9,8 @@ export declare type UpdatedPackage = {
'latest-minor': string | null;
'latest-major': string | null;
'latest-status': string;
'required-as': string;
'direct-dependency': boolean;
description: string;
};
export declare type ComposerUpdates = {
@@ -31,7 +33,7 @@ export declare type LastUpdateRun = {
} & {
limitedPackages: () => string[];
};
export declare type LoadingTypes = UpdaterLoadingTypes | InstallerLoadingTypes | MajorUpdaterLoadingTypes;
export declare type LoadingTypes = UpdaterLoadingTypes | InstallerLoadingTypes | MajorUpdaterLoadingTypes | 'queued-action';
export declare type CoreUpdate = {
package: UpdatedPackage;
extension: Extension;
@@ -45,13 +47,17 @@ export default class ControlSectionState {
get lastUpdateRun(): LastUpdateRun;
constructor();
isLoading(name?: LoadingTypes): boolean;
isLoadingOtherThan(name: LoadingTypes): boolean;
hasOperationRunning(): boolean;
setLoading(name: LoadingTypes): void;
requirePackage(data: any): void;
checkForUpdates(): void;
updateCoreMinor(): void;
updateExtension(extension: Extension): void;
updateExtension(extension: Extension, updateMode: 'soft' | 'hard'): void;
updateGlobally(): void;
formatExtensionUpdates(lastUpdateCheck: LastUpdateCheck): Extension[];
formatCoreUpdate(lastUpdateCheck: LastUpdateCheck): CoreUpdate | null;
majorUpdate({ dryRun }: {
dryRun: boolean;
}): void;
}
export {};

View File

@@ -1,6 +1,6 @@
import QueueState from './QueueState';
import ControlSectionState from './ControlSectionState';
export default class PackageManagerState {
export default class ExtensionManagerState {
queue: QueueState;
control: ControlSectionState;
}

View File

@@ -1,11 +1,12 @@
import Task from '../models/Task';
import { ApiQueryParamsPlural } from 'flarum/common/Store';
export default class QueueState {
private polling;
private tasks;
private limit;
private offset;
private total;
load(params?: ApiQueryParamsPlural): Promise<import("flarum/common/Store").ApiResponsePlural<Task>>;
load(params?: ApiQueryParamsPlural, actionTaken?: boolean): Promise<Task[]>;
getItems(): Task[] | null;
getTotalPages(): number;
pageNumber(): number;
@@ -13,4 +14,6 @@ export default class QueueState {
hasNext(): boolean;
prev(): void;
next(): void;
pollQueue(actionTaken?: boolean): void;
hasPending(): boolean;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,5 +1,5 @@
{
"name": "@flarum/package-manager",
"name": "@flarum/extension-manager",
"version": "0.0.0",
"private": true,
"prettier": "@flarum/prettier-config",

View File

@@ -0,0 +1,52 @@
import AuthMethodModal from './components/AuthMethodModal';
import ConfigureAuth from './components/ConfigureAuth';
import ConfigureComposer from './components/ConfigureComposer';
import ConfigureJson from './components/ConfigureJson';
import ControlSection from './components/ControlSection';
import ExtensionItem from './components/ExtensionItem';
import Installer from './components/Installer';
import Label from './components/Label';
import MajorUpdater from './components/MajorUpdater';
import Pagination from './components/Pagination';
import QueueSection from './components/QueueSection';
import RepositoryModal from './components/RepositoryModal';
import SettingsPage from './components/SettingsPage';
import TaskOutputModal from './components/TaskOutputModal';
import Updater from './components/Updater';
import WhyNotModal from './components/WhyNotModal';
import Task from './models/Task';
import ControlSectionState from './states/ControlSectionState';
import ExtensionManagerState from './states/ExtensionManagerState';
import QueueState from './states/QueueState';
import errorHandler from './utils/errorHandler';
import humanDuration from './utils/humanDuration';
import jumpToQueue from './utils/jumpToQueue';
export default {
'extension-manager/components/AuthMethodModal': AuthMethodModal,
'extension-manager/components/ConfigureAuth': ConfigureAuth,
'extension-manager/components/ConfigureComposer': ConfigureComposer,
'extension-manager/components/ConfigureJson': ConfigureJson,
'extension-manager/components/ControlSection': ControlSection,
'extension-manager/components/ExtensionItem': ExtensionItem,
'extension-manager/components/Installer': Installer,
'extension-manager/components/Label': Label,
'extension-manager/components/MajorUpdater': MajorUpdater,
'extension-manager/components/Pagination': Pagination,
'extension-manager/components/QueueSection': QueueSection,
'extension-manager/components/RepositoryModal': RepositoryModal,
'extension-manager/components/SettingsPage': SettingsPage,
'extension-manager/components/TaskOutputModal': TaskOutputModal,
'extension-manager/components/Updater': Updater,
'extension-manager/components/WhyNotModal': WhyNotModal,
'extension-manager/models/Task': Task,
'extension-manager/states/ControlSectionState': ControlSectionState,
'extension-manager/states/ExtensionManagerState': ExtensionManagerState,
'extension-manager/states/QueueState': QueueState,
'extension-manager/utils/errorHandler': errorHandler,
'extension-manager/utils/humanDuration': humanDuration,
'extension-manager/utils/jumpToQueue': jumpToQueue,
};

View File

@@ -0,0 +1,88 @@
import Modal, { IInternalModalAttrs } from 'flarum/common/components/Modal';
import Mithril from 'mithril';
import app from 'flarum/admin/app';
import Select from 'flarum/common/components/Select';
import Stream from 'flarum/common/utils/Stream';
import Button from 'flarum/common/components/Button';
import extractText from 'flarum/common/utils/extractText';
export interface IAuthMethodModalAttrs extends IInternalModalAttrs {
onsubmit: (type: string, host: string, token: string) => void;
type?: string;
host?: string;
token?: string;
}
export default class AuthMethodModal<CustomAttrs extends IAuthMethodModalAttrs = IAuthMethodModalAttrs> extends Modal<CustomAttrs> {
protected type!: Stream<string>;
protected host!: Stream<string>;
protected token!: Stream<string>;
oninit(vnode: Mithril.Vnode<CustomAttrs, this>) {
super.oninit(vnode);
this.type = Stream(this.attrs.type || 'bearer');
this.host = Stream(this.attrs.host || '');
this.token = Stream(this.attrs.token || '');
}
className(): string {
return 'AuthMethodModal Modal--small';
}
title(): Mithril.Children {
const context = this.attrs.host ? 'edit' : 'add';
return app.translator.trans(`flarum-extension-manager.admin.auth_config.${context}_label`);
}
content(): Mithril.Children {
const types = {
'github-oauth': app.translator.trans('flarum-extension-manager.admin.auth_config.types.github-oauth'),
'gitlab-oauth': app.translator.trans('flarum-extension-manager.admin.auth_config.types.gitlab-oauth'),
'gitlab-token': app.translator.trans('flarum-extension-manager.admin.auth_config.types.gitlab-token'),
bearer: app.translator.trans('flarum-extension-manager.admin.auth_config.types.bearer'),
};
return (
<div className="Modal-body">
<div className="Form-group">
<label>{app.translator.trans('flarum-extension-manager.admin.auth_config.add_modal.type_label')}</label>
<Select options={types} value={this.type()} onchange={this.type} />
</div>
<div className="Form-group">
<label>{app.translator.trans('flarum-extension-manager.admin.auth_config.add_modal.host_label')}</label>
<input
className="FormControl"
bidi={this.host}
placeholder={app.translator.trans('flarum-extension-manager.admin.auth_config.add_modal.host_placeholder')}
/>
</div>
<div className="Form-group">
<label>{app.translator.trans('flarum-extension-manager.admin.auth_config.add_modal.token_label')}</label>
<textarea
className="FormControl"
oninput={(e: InputEvent) => this.token((e.target as HTMLTextAreaElement).value)}
rows="6"
placeholder={
this.token().startsWith('unchanged:')
? extractText(app.translator.trans('flarum-extension-manager.admin.auth_config.add_modal.unchanged_token_placeholder'))
: ''
}
>
{this.token().startsWith('unchanged:') ? '' : this.token()}
</textarea>
</div>
<div className="Form-group">
<Button className="Button Button--primary" onclick={this.submit.bind(this)}>
{app.translator.trans('flarum-extension-manager.admin.auth_config.add_modal.submit_button')}
</Button>
</div>
</div>
);
}
submit() {
this.attrs.onsubmit(this.type(), this.host(), this.token());
this.hide();
}
}

View File

@@ -0,0 +1,120 @@
import app from 'flarum/admin/app';
import type Mithril from 'mithril';
import ConfigureJson, { IConfigureJson } from './ConfigureJson';
import Button from 'flarum/common/components/Button';
import AuthMethodModal from './AuthMethodModal';
import extractText from 'flarum/common/utils/extractText';
export default class ConfigureAuth extends ConfigureJson<IConfigureJson> {
protected type = 'auth';
title(): Mithril.Children {
return app.translator.trans('flarum-extension-manager.admin.auth_config.title');
}
className(): string {
return 'ConfigureAuth';
}
content(): Mithril.Children {
const authSettings = Object.keys(this.settings);
const hasAuthSettings =
authSettings.length &&
authSettings.every((type) => {
const data = this.settings[type]();
return Array.isArray(data) ? data.length : Object.keys(data).length;
});
return (
<div className="ExtensionManager-SettingsGroups-content">
{hasAuthSettings ? (
authSettings.map((type) => {
const hosts = this.settings[type]();
return (
<div className="Form-group">
<label>{app.translator.trans(`flarum-extension-manager.admin.auth_config.types.${type}`)}</label>
<div className="ConfigureAuth-hosts">
{Object.keys(hosts).map((host) => {
const data = hosts[host] as string | Record<string, string>;
return (
<div className="ButtonGroup ButtonGroup--full">
<Button
className="Button"
icon="fas fa-key"
onclick={() =>
app.modal.show(AuthMethodModal, {
type,
host,
token: data,
onsubmit: this.onchange.bind(this, host),
})
}
>
{host}
</Button>
<Button
className="Button Button--icon"
icon="fas fa-trash"
aria-label={app.translator.trans('flarum-extension-manager.admin.auth_config.delete_label')}
onclick={() => {
if (confirm(extractText(app.translator.trans('flarum-extension-manager.admin.auth_config.delete_confirmation')))) {
const newType = { ...this.setting(type)() };
delete newType[host];
if (Object.keys(newType).length) {
this.setting(type)(newType);
} else {
delete this.settings[type];
}
}
}}
/>
</div>
);
})}
</div>
</div>
);
})
) : (
<span className="helpText">{app.translator.trans('flarum-extension-manager.admin.auth_config.no_auth_methods_configured')}</span>
)}
</div>
);
}
submitButton(): Mithril.Children[] {
const items = super.submitButton();
items.push(
<Button
className="Button"
loading={this.loading}
onclick={() =>
app.modal.show(AuthMethodModal, {
onsubmit: this.onchange.bind(this, null),
})
}
>
{app.translator.trans('flarum-extension-manager.admin.auth_config.add_label')}
</Button>
);
return items;
}
onchange(oldHost: string | null, type: string, host: string, token: string) {
const data = { ...this.setting(type)() };
if (oldHost) {
delete data[oldHost];
}
data[host] = token;
this.setting(type)(data);
}
}

View File

@@ -0,0 +1,115 @@
import app from 'flarum/admin/app';
import type Mithril from 'mithril';
import ConfigureJson, { type IConfigureJson } from './ConfigureJson';
import Button from 'flarum/common/components/Button';
import extractText from 'flarum/common/utils/extractText';
import RepositoryModal from './RepositoryModal';
export type Repository = {
type: 'composer' | 'vcs' | 'path';
url: string;
};
export default class ConfigureComposer extends ConfigureJson<IConfigureJson> {
protected type = 'composer';
title(): Mithril.Children {
return app.translator.trans('flarum-extension-manager.admin.composer.title');
}
className(): string {
return 'ConfigureComposer';
}
content(): Mithril.Children {
return (
<div className="ExtensionManager-SettingsGroups-content">
{this.attrs.buildSettingComponent.call(this, {
setting: 'minimum-stability',
label: app.translator.trans('flarum-extension-manager.admin.composer.minimum_stability.label'),
help: app.translator.trans('flarum-extension-manager.admin.composer.minimum_stability.help'),
type: 'select',
options: {
stable: app.translator.trans('flarum-extension-manager.admin.composer.minimum_stability.options.stable'),
RC: app.translator.trans('flarum-extension-manager.admin.composer.minimum_stability.options.rc'),
beta: app.translator.trans('flarum-extension-manager.admin.composer.minimum_stability.options.beta'),
alpha: app.translator.trans('flarum-extension-manager.admin.composer.minimum_stability.options.alpha'),
dev: app.translator.trans('flarum-extension-manager.admin.composer.minimum_stability.options.dev'),
},
})}
<div className="Form-group">
<label>{app.translator.trans('flarum-extension-manager.admin.composer.repositories.label')}</label>
<div className="helpText">{app.translator.trans('flarum-extension-manager.admin.composer.repositories.help')}</div>
<div className="ConfigureComposer-repositories">
{Object.keys(this.setting('repositories')() || {}).map((name) => {
const repository = this.setting('repositories')()[name] as Repository;
return (
<div className="ButtonGroup ButtonGroup--full">
<Button
className="Button"
icon={
{
composer: 'fas fa-cubes',
vcs: 'fas fa-code-branch',
path: 'fas fa-folder',
}[repository.type]
}
onclick={() =>
app.modal.show(RepositoryModal, {
name,
repository,
onsubmit: (repository: Repository, newName: string) => {
const repositories = this.setting('repositories')();
delete repositories[name];
this.setting('repositories')(repositories);
this.onchange(repository, newName);
},
})
}
>
{name} ({repository.type})
</Button>
<Button
className="Button Button--icon"
icon="fas fa-trash"
aria-label={app.translator.trans('flarum-extension-manager.admin.composer.delete_repository_label')}
onclick={() => {
if (confirm(extractText(app.translator.trans('flarum-extension-manager.admin.composer.delete_repository_confirmation')))) {
const repositories = { ...this.setting('repositories')() };
delete repositories[name];
this.setting('repositories')(repositories);
}
}}
/>
</div>
);
})}
</div>
</div>
</div>
);
}
submitButton(): Mithril.Children[] {
const items = super.submitButton();
items.push(
<Button className="Button" onclick={() => app.modal.show(RepositoryModal, { onsubmit: this.onchange.bind(this) })}>
{app.translator.trans('flarum-extension-manager.admin.composer.add_repository_label')}
</Button>
);
return items;
}
onchange(repository: Repository, name: string) {
this.setting('repositories')({
...this.setting('repositories')(),
[name]: repository,
});
}
}

View File

@@ -0,0 +1,94 @@
import app from 'flarum/admin/app';
import type Mithril from 'mithril';
import Component, { type ComponentAttrs } from 'flarum/common/Component';
import { CommonSettingsItemOptions, type SettingsComponentOptions } from '@flarum/core/src/admin/components/AdminPage';
import AdminPage from 'flarum/admin/components/AdminPage';
import type ItemList from 'flarum/common/utils/ItemList';
import Stream from 'flarum/common/utils/Stream';
import Button from 'flarum/common/components/Button';
import classList from 'flarum/common/utils/classList';
export interface IConfigureJson extends ComponentAttrs {
buildSettingComponent: (entry: ((this: this) => Mithril.Children) | SettingsComponentOptions) => Mithril.Children;
}
export default abstract class ConfigureJson<CustomAttrs extends IConfigureJson = IConfigureJson> extends Component<CustomAttrs> {
protected settings: Record<string, Stream<any>> = {};
protected initialSettings: Record<string, any> | null = null;
protected loading: boolean = false;
oninit(vnode: Mithril.Vnode<CustomAttrs, this>) {
super.oninit(vnode);
this.submit(true);
}
protected abstract type: string;
abstract title(): Mithril.Children;
abstract content(): Mithril.Children;
className(): string {
return '';
}
view(): Mithril.Children {
return (
<div className={classList('Form', this.className())}>
<label>{this.title()}</label>
{this.content()}
<div className="Form-group Form--controls">{this.submitButton()}</div>
</div>
);
}
submitButton(): Mithril.Children[] {
return [
<Button className="Button Button--primary" loading={this.loading} onclick={() => this.submit(false)} disabled={!this.isDirty()}>
{app.translator.trans('core.admin.settings.submit_button')}
</Button>,
];
}
customSettingComponents(): ItemList<(attributes: CommonSettingsItemOptions) => Mithril.Children> {
return AdminPage.prototype.customSettingComponents();
}
setting(key: string) {
return this.settings[key] ?? (this.settings[key] = Stream());
}
submit(readOnly: boolean) {
this.loading = true;
const configuration: any = {};
Object.keys(this.settings).forEach((key) => {
configuration[key] = this.settings[key]();
});
app
.request({
method: 'POST',
url: app.forum.attribute('apiUrl') + '/extension-manager/composer',
body: {
type: this.type,
data: readOnly ? null : configuration,
},
})
.then(({ data }: any) => {
Object.keys(data).forEach((key) => {
this.settings[key] = Stream(data[key]);
});
this.initialSettings = Array.isArray(data) ? {} : data;
})
.finally(() => {
this.loading = false;
m.redraw();
});
}
isDirty() {
return JSON.stringify(this.initialSettings) !== JSON.stringify(this.settings);
}
}

View File

@@ -14,14 +14,14 @@ export default class ControlSection extends Component<ComponentAttrs> {
view() {
return (
<div className="ExtensionPage-permissions PackageManager-controlSection">
<div className="ExtensionPage-permissions ExtensionManager-controlSection">
<div className="ExtensionPage-permissions-header">
<div className="container">
<h2 className="ExtensionTitle">{app.translator.trans('flarum-package-manager.admin.sections.control.title')}</h2>
<h2 className="ExtensionTitle">{app.translator.trans('flarum-extension-manager.admin.sections.control.title')}</h2>
</div>
</div>
<div className="container">
{app.data['flarum-package-manager.writable_dirs'] ? (
{app.data['flarum-extension-manager.writable_dirs'] ? (
<>
<Installer />
<Updater />
@@ -29,7 +29,7 @@ export default class ControlSection extends Component<ComponentAttrs> {
) : (
<div className="Form-group">
<Alert type="warning" dismissible={false}>
{app.translator.trans('flarum-package-manager.admin.file_permissions')}
{app.translator.trans('flarum-extension-manager.admin.file_permissions')}
</Alert>
</div>
)}

View File

@@ -10,11 +10,17 @@ import { Extension } from 'flarum/admin/AdminApplication';
import { UpdatedPackage } from '../states/ControlSectionState';
import WhyNotModal from './WhyNotModal';
import Label from './Label';
import Dropdown from 'flarum/common/components/Dropdown';
export interface ExtensionItemAttrs extends ComponentAttrs {
extension: Extension;
updates: UpdatedPackage;
onClickUpdate: CallableFunction;
onClickUpdate:
| CallableFunction
| {
soft: CallableFunction;
hard: CallableFunction;
};
whyNotWarning?: boolean;
isCore?: boolean;
updatable?: boolean;
@@ -29,43 +35,56 @@ export default class ExtensionItem<Attrs extends ExtensionItemAttrs = ExtensionI
return (
<div
className={classList({
'PackageManager-extension': true,
'PackageManager-extension--core': isCore,
'PackageManager-extension--danger': isDanger,
'ExtensionManager-extension': true,
'ExtensionManager-extension--core': isCore,
'ExtensionManager-extension--danger': isDanger,
})}
>
<div className="PackageManager-extension-icon ExtensionIcon" style={extension.icon}>
<div className="ExtensionManager-extension-icon ExtensionIcon" style={extension.icon}>
{extension.icon ? icon(extension.icon.name) : ''}
</div>
<div className="PackageManager-extension-info">
<div className="PackageManager-extension-name">{extension.extra['flarum-extension'].title}</div>
<div className="PackageManager-extension-version">
<span className="PackageManager-extension-version-current">{this.version(updates['version'])}</span>
<div className="ExtensionManager-extension-info">
<div className="ExtensionManager-extension-name">{extension.extra['flarum-extension'].title}</div>
<div className="ExtensionManager-extension-version">
<span className="ExtensionManager-extension-version-current">{this.version(updates['version'])}</span>
{latestVersion ? (
<Label className="PackageManager-extension-version-latest" type={updates['latest-minor'] ? 'success' : 'warning'}>
<Label className="ExtensionManager-extension-version-latest" type={updates['latest-minor'] ? 'success' : 'warning'}>
{this.version(latestVersion)}
</Label>
) : null}
</div>
</div>
<div className="PackageManager-extension-controls">
{onClickUpdate ? (
<Tooltip text={app.translator.trans('flarum-package-manager.admin.extensions.update')}>
<div className="ExtensionManager-extension-controls">
{onClickUpdate && typeof onClickUpdate === 'function' ? (
<Tooltip text={app.translator.trans('flarum-extension-manager.admin.extensions.update')}>
<Button
icon="fas fa-arrow-alt-circle-up"
className="Button Button--icon Button--flat"
onclick={onClickUpdate}
aria-label={app.translator.trans('flarum-package-manager.admin.extensions.update')}
aria-label={app.translator.trans('flarum-extension-manager.admin.extensions.update')}
/>
</Tooltip>
) : onClickUpdate ? (
<Dropdown
buttonClassName="Button Button--icon Button--flat"
icon="fas fa-arrow-alt-circle-up"
label={app.translator.trans('flarum-extension-manager.admin.extensions.update')}
>
<Button icon="fas fa-arrow-alt-circle-up" className="Button" onclick={onClickUpdate.soft}>
{app.translator.trans('flarum-extension-manager.admin.extensions.update_soft_label')}
</Button>
<Button icon="fas fa-arrow-alt-circle-up" className="Button" onclick={onClickUpdate.hard} disabled={!updates['direct-dependency']}>
{app.translator.trans('flarum-extension-manager.admin.extensions.update_hard_label')}
</Button>
</Dropdown>
) : null}
{whyNotWarning ? (
<Tooltip text={app.translator.trans('flarum-package-manager.admin.extensions.check_why_it_failed_updating')}>
<Tooltip text={app.translator.trans('flarum-extension-manager.admin.extensions.check_why_it_failed_updating')}>
<Button
icon="fas fa-exclamation-circle"
className="Button Button--icon Button--flat Button--danger"
onclick={() => app.modal.show(WhyNotModal, { package: extension.name })}
aria-label={app.translator.trans('flarum-package-manager.admin.extensions.check_why_it_failed_updating')}
aria-label={app.translator.trans('flarum-extension-manager.admin.extensions.check_why_it_failed_updating')}
/>
</Tooltip>
) : null}
@@ -75,6 +94,6 @@ export default class ExtensionItem<Attrs extends ExtensionItemAttrs = ExtensionI
}
version(v: string): string {
return 'v' + v.replace('v', '');
return v.charAt(0) === 'v' ? v.substring(1) : v;
}
}

View File

@@ -3,11 +3,6 @@ import app from 'flarum/admin/app';
import Component, { ComponentAttrs } from 'flarum/common/Component';
import Button from 'flarum/common/components/Button';
import Stream from 'flarum/common/utils/Stream';
import LoadingModal from 'flarum/admin/components/LoadingModal';
import errorHandler from '../utils/errorHandler';
import jumpToQueue from '../utils/jumpToQueue';
import { AsyncBackendResponse } from '../shims';
export interface InstallerAttrs extends ComponentAttrs {}
@@ -24,11 +19,13 @@ export default class Installer extends Component<InstallerAttrs> {
view(): Mithril.Children {
return (
<div className="Form-group PackageManager-installer">
<label htmlFor="install-extension">{app.translator.trans('flarum-package-manager.admin.extensions.install')}</label>
<div className="Form-group ExtensionManager-installer">
<label htmlFor="install-extension">{app.translator.trans('flarum-extension-manager.admin.extensions.install')}</label>
<p className="helpText">
{app.translator.trans('flarum-package-manager.admin.extensions.install_help', {
{app.translator.trans('flarum-extension-manager.admin.extensions.install_help', {
extiverse: <a href="https://extiverse.com">extiverse.com</a>,
semantic_link: <a href="https://devhints.io/semver" />,
code: <code />,
})}
</p>
<div className="FormControl-container">
@@ -37,10 +34,10 @@ export default class Installer extends Component<InstallerAttrs> {
className="Button"
icon="fas fa-download"
onclick={this.onsubmit.bind(this)}
loading={app.packageManager.control.isLoading('extension-install')}
disabled={app.packageManager.control.isLoadingOtherThan('extension-install')}
loading={app.extensionManager.control.isLoading('extension-install')}
disabled={app.extensionManager.control.hasOperationRunning()}
>
{app.translator.trans('flarum-package-manager.admin.extensions.proceed')}
{app.translator.trans('flarum-extension-manager.admin.extensions.proceed')}
</Button>
</div>
</div>
@@ -54,35 +51,6 @@ export default class Installer extends Component<InstallerAttrs> {
}
onsubmit(): void {
app.packageManager.control.setLoading('extension-install');
app.modal.show(LoadingModal);
app
.request<AsyncBackendResponse & { id: number }>({
method: 'POST',
url: `${app.forum.attribute('apiUrl')}/package-manager/extensions`,
body: {
data: this.data(),
},
})
.then((response) => {
if (response.processing) {
jumpToQueue();
} else {
const extensionId = response.id;
app.alerts.show(
{ type: 'success' },
app.translator.trans('flarum-package-manager.admin.extensions.successful_install', { extension: extensionId })
);
window.location.href = `${app.forum.attribute('adminUrl')}#/extension/${extensionId}`;
window.location.reload();
}
})
.catch(errorHandler)
.finally(() => {
app.packageManager.control.setLoading(null);
app.modal.close();
m.redraw();
});
app.extensionManager.control.requirePackage(this.data());
}
}

View File

@@ -3,16 +3,12 @@ import app from 'flarum/admin/app';
import Component, { ComponentAttrs } from 'flarum/common/Component';
import Button from 'flarum/common/components/Button';
import Tooltip from 'flarum/common/components/Tooltip';
import LoadingModal from 'flarum/admin/components/LoadingModal';
import Alert from 'flarum/common/components/Alert';
import RequestError from 'flarum/common/utils/RequestError';
import { UpdatedPackage, UpdateState } from '../states/ControlSectionState';
import errorHandler from '../utils/errorHandler';
import WhyNotModal from './WhyNotModal';
import ExtensionItem from './ExtensionItem';
import { AsyncBackendResponse } from '../shims';
import jumpToQueue from '../utils/jumpToQueue';
import classList from 'flarum/common/utils/classList';
export interface MajorUpdaterAttrs extends ComponentAttrs {
coreUpdate: UpdatedPackage;
@@ -33,32 +29,39 @@ export default class MajorUpdater<T extends MajorUpdaterAttrs = MajorUpdaterAttr
view(): Mithril.Children {
// @todo move Form-group--danger class to core for reuse
return (
<div className="Form-group Form-group--danger PackageManager-majorUpdate">
<img alt="flarum logo" src={app.forum.attribute('baseUrl') + '/assets/extensions/flarum-package-manager/flarum.svg'} />
<label>{app.translator.trans('flarum-package-manager.admin.major_updater.title', { version: this.attrs.coreUpdate['latest-major'] })}</label>
<p className="helpText">{app.translator.trans('flarum-package-manager.admin.major_updater.description')}</p>
<div className="PackageManager-updaterControls">
<Tooltip text={app.translator.trans('flarum-package-manager.admin.major_updater.dry_run_help')}>
<div
className={classList('Form-group Form-group--danger ExtensionManager-majorUpdate', {
'ExtensionManager-majorUpdate--failed': this.updateState.status === 'failure',
'ExtensionManager-majorUpdate--incompatibleExtensions': this.updateState.incompatibleExtensions.length,
})}
>
<img alt="flarum logo" src={app.forum.attribute('baseUrl') + '/assets/extensions/flarum-extension-manager/flarum.svg'} />
<label>
{app.translator.trans('flarum-extension-manager.admin.major_updater.title', { version: this.attrs.coreUpdate['latest-major'] })}
</label>
<p className="helpText">{app.translator.trans('flarum-extension-manager.admin.major_updater.description')}</p>
<div className="ExtensionManager-updaterControls">
<Tooltip text={app.translator.trans('flarum-extension-manager.admin.major_updater.dry_run_help')}>
<Button
className="Button"
icon="fas fa-vial"
onclick={this.update.bind(this, true)}
disabled={app.packageManager.control.isLoadingOtherThan('major-update-dry-run')}
disabled={app.extensionManager.control.hasOperationRunning()}
>
{app.translator.trans('flarum-package-manager.admin.major_updater.dry_run')}
{app.translator.trans('flarum-extension-manager.admin.major_updater.dry_run')}
</Button>
</Tooltip>
<Button
className="Button Button--danger"
icon="fas fa-play"
onclick={this.update.bind(this, false)}
disabled={app.packageManager.control.isLoadingOtherThan('major-update')}
disabled={app.extensionManager.control.hasOperationRunning()}
>
{app.translator.trans('flarum-package-manager.admin.major_updater.update')}
{app.translator.trans('flarum-extension-manager.admin.major_updater.update')}
</Button>
</div>
{this.updateState.incompatibleExtensions.length ? (
<div className="PackageManager-majorUpdate-incompatibleExtensions PackageManager-extensions-grid">
<div className="ExtensionManager-majorUpdate-incompatibleExtensions ExtensionManager-extensions-grid">
{this.updateState.incompatibleExtensions.map((extension: string) => (
<ExtensionItem
extension={app.data.extensions[extension.replace('flarum-', '').replace('flarum-ext-', '').replace('/', '-')]}
@@ -72,20 +75,20 @@ export default class MajorUpdater<T extends MajorUpdaterAttrs = MajorUpdaterAttr
{this.updateState.status === 'failure' ? (
<Alert
type="error"
className="PackageManager-majorUpdate-failure"
className="ExtensionManager-majorUpdate-failure"
dismissible={false}
controls={[
<Button
className="Button Button--text PackageManager-majorUpdate-failure-details"
className="Button Button--text ExtensionManager-majorUpdate-failure-details"
icon="fas fa-question-circle"
onclick={() => app.modal.show(WhyNotModal, { package: 'flarum/core' })}
>
{app.translator.trans('flarum-package-manager.admin.major_updater.failure.why')}
{app.translator.trans('flarum-extension-manager.admin.major_updater.failure.why')}
</Button>,
]}
>
<p className="PackageManager-majorUpdate-failure-desc">
{app.translator.trans('flarum-package-manager.admin.major_updater.failure.desc')}
<p className="ExtensionManager-majorUpdate-failure-desc">
{app.translator.trans('flarum-extension-manager.admin.major_updater.failure.desc')}
</p>
</Alert>
) : null}
@@ -94,34 +97,6 @@ export default class MajorUpdater<T extends MajorUpdaterAttrs = MajorUpdaterAttr
}
update(dryRun: boolean) {
app.packageManager.control.setLoading(dryRun ? 'major-update-dry-run' : 'major-update');
app.modal.show(LoadingModal);
app
.request<AsyncBackendResponse | null>({
method: 'POST',
url: `${app.forum.attribute('apiUrl')}/package-manager/major-update`,
body: {
data: { dryRun },
},
})
.then((response) => {
if (response?.processing) {
jumpToQueue();
} else {
app.alerts.show({ type: 'success' }, app.translator.trans('flarum-package-manager.admin.update_successful'));
window.location.reload();
}
})
.catch(errorHandler)
.catch((e: RequestError) => {
app.modal.close();
this.updateState.status = 'failure';
this.updateState.incompatibleExtensions = e.response?.errors?.pop()?.incompatible_extensions as string[];
})
.finally(() => {
app.packageManager.control.setLoading(null);
m.redraw();
});
app.extensionManager.control.majorUpdate({ dryRun });
}
}

Some files were not shown because too many files have changed in this diff Show More