Can't add meta data to custom tools
Closed this issue · 5 comments
- Laravel Version: 8.20.1
- Nova Version: 3.18.0
- PHP Version: 7.4.9
- Database Driver & Version: MariaDb 10.3
- Operating System and Version: Ubuntu 20.04
- Browser type and version: Chrome 87
Description:
You can't add extra (meta) data to a custom tool, like adding config settings to it. Possible dublicate of closed but never solved issue #761
Detailed steps to reproduce the issue on a fresh Nova installation:
Create a tool with the artisan command:
php artisan nova:tool acme/test-tool
In the Tool class (nova-components/TestTool/src/TestTool.php
) add a constructor and there some meta data:
class TestTool extends Tool
{
public function __construct($component = null) {
parent::__construct($component);
$this->withMeta([
'mytest' => 123
]);
}
...
In the Tool.vue
add some props (I have tried the card
, tool
and panel
props, since these are mentioned in other issues [for example #1270] for resource tools and cards) and console logs:
export default {
props: ['card', 'tool', 'panel', 'mytest'],
mounted() {
console.log(this.mytest);
console.log(this.card.mytest);
console.log(this.tool.mytest);
console.log(this.panel.mytest);
},
}
And now go to your tool and see that all logs are empty.
Unfortunately Laravel Nova never designed Tool
to work that way. It utilize Element
only to make use of AuthorisedToSee
, ProxiesCanSeeToGate
and Makeable
traits.
To make Metable
usable on Tool
, we need to setup an XHR request to pull jsonSerialize()
for each Tool, meaning:
- Every Tool would require something like
uriKey()
, which need to be unique. - Every Tool Vue components need to be updated to send the XHR request.
Marking this as "feature request" and something to consider for "next-series"
👋 Hi there! In order to keep this repository focused on bug reports, we auto-close feature requests and requests for help. Feel free to post your feature requests so others can discuss and add reactions. We'll keep an eye on them for later planning.
On the side note, issue #761 is about Resource Tool and not Tool. I personally used that before and doesn't seem to have any issue.
Thanks for your explanation and removing not working methods.
As a workaround, I can of course make an own call to a custom controller in the nova tool.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.