Open maks-rafalko opened 4 years ago
The context menu method is not being used in the execution of your script, but it only gets called once when you open your project folder. So you can not see any output there. Also make sure not to dump anything in the context menu method as its execution needs to return valid json.
Did you import the label class use statement?
Yes I did, see the full code here https://github.com/tinkerwellapp/drivers/pull/7/files
I tried restart the app, reopen the folder but nothing helps, unfortunately. Is there any way to debug it?
I can confirm the same thing happening for me too. I logged to a file to make sure that contextMenu
gets called and below is a var_export
of what I'm returning from the method:
array (
0 =>
Tinkerwell\ContextMenu\Label::__set_state(array(
'label' => 'Detected Wordpress v',
)),
1 =>
Tinkerwell\ContextMenu\SetCode::__set_state(array(
'label' => 'Test',
'code' => 'Company::find( 302 )',
)),
)
Seems good to me, yet I get nothing in the context menu:
However, loading the default Laravel app, the context menu is populated correctly. So it has to be a problem in the project I'm working on perhaps. Any ideas as to what might be happening?
I think this was an issue with an older version of Tinkerwell. I can not reproduce the error - could you please verify that it still exists with the latest (2.1.1) version?
Installed 2.1.1 and same thing is still happening.
Are there any command line options I can pass to the binary to see some debugging information? Right now if I run tinkerwell from a terminal, I see a couple of lines of debug information(checking for updates and such), but nothing when I select a project directory or run commands.
@mpociot I can verify that i'm still having this issue in 2.2.0 as well
Still seeing this issue with 2.2.1.
Following up on this with one additional detail(aside from still having the same issue in 2.4.0) - some helper functions like dd
are undefined in my tinkerwell session for some reason(while they are available in general and in regular tinker). Not sure if that's helpful in any way or not.
In 2.7.0 (with a remote connection, if that makes any difference) I also do not see the context menu. My code in bootstrap
is executed, so it is using my custom driver.
I'm not sure if it helps for replication @mpociot but the contextMenu seems only to get called every once in a while but if you have multiple tabs open then it will hold the result of one of the tabs you had opened up when it gathered new data.
In other words I have 2 tabs 1 is a Laravel install and the other is a WordPress install. On boot my Laravel install was opened and I see the Laravel details but when I go to the WordPress install I still see the Laravel info.
I have this issue also on version 2.15.0 using a custom driver for Laravel.
I'm able to run Artisan commands but the context menu looks like the below
The contextMenu
method is as follows
public function contextMenu()
{
return [
Label::create('Detected Laravel v' . app()->version()),
Submenu::create('Artisan', collect(Artisan::all())->map(function ($command, $key) {
return SetCode::create($key, "Artisan::call('" . $key . "', []);\nArtisan::output();");
})->values()->toArray()),
OpenURL::create('Documentation', 'https://tinkerwell.app'),
];
}
Can confirm that this "bug" exists in version 2.18.1, extending LaravelTinkerwellDriver:
<?php
use Tinkerwell\ContextMenu\SetCode;
use Tinkerwell\ContextMenu\Label;
use Tinkerwell\ContextMenu\OpenURL;
use Tinkerwell\ContextMenu\Submenu;
class CompanyTinkerwellDriver extends LaravelTinkerwellDriver
{
public function canBootstrap($projectPath)
{
...
}
public function bootstrap($projectPath)
{
...
}
public function contextMenu(): array
{
return array_merge(parent::contextMenu(), [
Label::create('Detected Laravel v' . app()->version()),
Submenu::create('Snippets', [
SetCode::create('Perform Query', '\DB::table("example")->get();'),
]),
OpenURL::create('Documentation', 'https://tinkerwell.app'),
]);
}
}
The app bootstraps fine but the context menu remains unchanged.
Hope this can get fixed, or better documented since it would be a super useful feature for our team.
Not to bump issues without reason, but I've not tested it again in verion 3.10.0 - and still can't get custom context menus to work. Would be nice to know if there is a way to debug this - or if we are doing something wrong. I think getting this to function could really make the app twice as powerful.
With the following code:
when I run the empty script on Tinkerwell, it get:
So you can see that
contextMenu
is ignored and I don't see any new context menu items in the app.