Skip to content

Commit 300137e

Browse files
add documentation URL option to setting modals
1 parent 3f297db commit 300137e

File tree

5 files changed

+47
-1
lines changed

5 files changed

+47
-1
lines changed

docs/src/content/docs/guides/creating-a-module.mdx

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,41 @@ class MyModule implements ModuleInterface
4141
return [];
4242
}
4343

44-
public function handle(array $data, Post $post, User $user)
44+
public function handle(Post $post, User $user)
4545
{
4646
// Do something with the data
4747
}
4848
}
49+
```
50+
51+
## Module Actions
52+
53+
### Flagging a Post
54+
55+
To flag a post within your module, use the `ModuleUtils` class:
56+
57+
```php
58+
// MyModule.php
59+
use OrdinaryJellyfish\Sentra\ModuleUtils;
60+
use OrdinaryJellyfish\Sentra\Modules\ModuleInterface;
61+
62+
class MyModule implements ModuleInterface
63+
{
64+
private ModuleUtils $utils;
65+
66+
public function __construct(ModuleUtils $utils)
67+
{
68+
$this->utils = $utils;
69+
}
70+
71+
public function getDependencies(): array
72+
{
73+
return [];
74+
}
75+
76+
public function handle(Post $post, User $user)
77+
{
78+
$this->utils->unapproveAndFlag($post, 'Short Reason', 'Optional Details');
79+
}
80+
}
4981
```

js/src/admin/components/ModuleModal.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import Switch from 'flarum/common/components/Switch';
2424
export default class ModuleModal extends SettingsModal {
2525
static isDismissible = true;
2626
key = '';
27+
docUrl: string | null = null;
2728

2829
className() {
2930
return 'Modal--large';
@@ -54,6 +55,11 @@ export default class ModuleModal extends SettingsModal {
5455
return (
5556
<div className="Modal-body">
5657
<p className="helpText">{this.helpText()}</p>
58+
{this.docUrl && (
59+
<a className="Button Button--primary" style="margin-bottom:10px" icon="fas fa-book" href={this.docUrl} external={true} target="_blank">
60+
{app.translator.trans('ordinaryjellyfish-sentra.admin.view_documentation')}
61+
</a>
62+
)}
5763
{requiredServices.length > 0 && (
5864
<p>
5965
{app.translator.trans('ordinaryjellyfish-sentra.admin.modules.requires', {

js/src/admin/components/PostShieldModal.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import Select from 'flarum/common/components/Select';
2222

2323
export default class PostShieldModal extends ModuleModal {
2424
key = 'post_shield';
25+
docUrl = 'https://sentra.ordinaryjellyfish.xyz';
2526

2627
dependencies() {
2728
return ['content_safety'];

js/src/admin/components/ServiceModal.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import Switch from 'flarum/common/components/Switch';
2323
export default class ServiceModal extends SettingsModal {
2424
static isDismissible = true;
2525
key = '';
26+
docUrl: string | null = null;
2627

2728
className() {
2829
return 'Modal--large';
@@ -43,6 +44,11 @@ export default class ServiceModal extends SettingsModal {
4344
return (
4445
<div className="Modal-body">
4546
<p className="helpText">{this.helpText()}</p>
47+
{this.docUrl && (
48+
<a className="Button Button--primary" style="margin-bottom:10px" icon="fas fa-book" href={this.docUrl} external={true} target="_blank">
49+
{app.translator.trans('ordinaryjellyfish-sentra.admin.view_documentation')}
50+
</a>
51+
)}
4652
<div className="Form">
4753
<div className="Form-group">
4854
<Switch state={!!value && value !== '0'} onchange={this.settings[setting]}>

locale/en.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ ordinaryjellyfish-sentra:
22
# For more details on the format
33
# Checkout https://docs.flarum.org/2.x/extend/i18n/#appendix-a-standard-key-format
44
admin:
5+
view_documentation: View Documentation
56
api_key: API Key
67
endpoint: Endpoint
78
enable: Enable

0 commit comments

Comments
 (0)