Skip to content

Commit 830d834

Browse files
committed
🚑 STDOUT error
✨ help can be set from API ✨ button will quiet commands automatically closes #100 Signed-off-by: bnomei <[email protected]>
1 parent dfc8e50 commit 830d834

File tree

7 files changed

+21
-9
lines changed

7 files changed

+21
-9
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ The button you create with the `field: janitor` in your blueprint can be configu
154154
- `command`, command like you would enter it in terminal, with [query language support](https://getkirby.com/docs/guide/blueprints/query-language) and page/file/user/site/data arguments
155155
- `cooldown`, time in milliseconds the message is flashed on the button (default: 2000)
156156
- `error`, set message to show on all **non-200**-status returns with query language support
157+
- `help`, set help of the button
157158
- `icon`, set the [icon](https://getkirby.com/docs/reference/panel/icons) of the button
158159
- `intab`, if `true` then use in combination with the `open`-option to open an URL in a new tab
159160
- `label`, set label of the button
@@ -168,6 +169,7 @@ In either the command or the callback you will be setting/returning data to the
168169
- `clipboard`, string to copy to clipboard
169170
- `download`, URL to start downloading
170171
- `error`, see `error`-field option
172+
- `help`, see `help`-field option
171173
- `icon`, see `icon`-field option
172174
- `label`, see `label`-field option
173175
- `message`, see `message`-field option
@@ -232,6 +234,8 @@ janitor_thumbssite:
232234
233235
If you want you can also call any of [the core shipping with the CLI](https://github.com/getkirby/cli#available-core-commands) like `clear:cache`.
234236

237+
Keep in mind that the Janitor panel button will append the `--quiet` option on all commands automatically to silence outputs to the non-existing CLI.
238+
235239
### Smartly delaying resolution of a command argument
236240

237241
In some cases you do not want to resolve the query language of a commands argument(s) **every time** when the button is shown in the panel but delay that until the api call is received by Janitor. Janitor will then resolve it **once** and forward the updated argument(s) to your command. This is useful for process-intensive calls or when the string of the data would be very long, like when the data is HTML.

classes/Janitor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ final class Janitor
5050
],
5151
];
5252

53-
private static array $data;
53+
private static array $data = [];
5454

5555
public function data(string $command, ?array $data = null): ?array
5656
{

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "bnomei/kirby3-janitor",
33
"type": "kirby-plugin",
4-
"version": "3.3.0",
4+
"version": "3.4.0",
55
"license": "MIT",
66
"description": "Kirby 3 Plugin for running commands like cleaning the cache from within the Panel, PHP code or a cronjob",
77
"authors": [

index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@
5151
}
5252
$command .= ' --model '. $this->model()->uuid()->toString() ??
5353
($this->model() instanceof \Kirby\Cms\Site ? 'site://' : $this->model()->id());
54+
55+
$command .= ' --quiet'; // no STDOUT on frontend PHP
56+
5457
return $command;
5558
},
5659
'confirm' => function ($confirm = '') {

src/components/fields/Janitor.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
>
1111
{{ button.label || label }}
1212
</k-button>
13-
<k-text v-if="help" theme="help" class="k-field-help" :html="help" />
13+
<k-text v-if="button.help || help" theme="help" class="k-field-help" :html="button.help || help" />
1414
<a
1515
v-show="downloadRequest"
1616
ref="downloadAnchor"
@@ -54,6 +54,7 @@ export default {
5454
button: {
5555
label: null,
5656
state: null,
57+
help: null,
5758
},
5859
clipboardRequest: null,
5960
downloadRequest: null,
@@ -152,7 +153,7 @@ export default {
152153
this.button.label = this.progress ?? `${this.label}`;
153154
this.button.state = "is-running";
154155
155-
const { label, message, status, reload, open, download, clipboard, success, error, icon } =
156+
const { label, message, status, reload, open, download, clipboard, success, error, icon, help } =
156157
await this.$api.post(path, data);
157158
158159
if (status === 200) {
@@ -169,6 +170,10 @@ export default {
169170
this.button.label = message;
170171
}
171172
173+
if (help) {
174+
this.button.help = help;
175+
}
176+
172177
if (icon) {
173178
this.icon = icon;
174179
}

vendor/composer/installed.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php return array(
22
'root' => array(
33
'name' => 'bnomei/kirby3-janitor',
4-
'pretty_version' => '3.3.0',
5-
'version' => '3.3.0.0',
4+
'pretty_version' => '3.4.0',
5+
'version' => '3.4.0.0',
66
'reference' => NULL,
77
'type' => 'kirby-plugin',
88
'install_path' => __DIR__ . '/../../',
@@ -11,8 +11,8 @@
1111
),
1212
'versions' => array(
1313
'bnomei/kirby3-janitor' => array(
14-
'pretty_version' => '3.3.0',
15-
'version' => '3.3.0.0',
14+
'pretty_version' => '3.4.0',
15+
'version' => '3.4.0.0',
1616
'reference' => NULL,
1717
'type' => 'kirby-plugin',
1818
'install_path' => __DIR__ . '/../../',

0 commit comments

Comments
 (0)