Open Yahud100 opened 5 months ago
Hi,
Can you share a little bit about what you are trying to do or customize ?
There are a lot of commands, and most of them are called in response to specific user actions (clicking on items in the tree, or executing sql code).
If we can understand what you are trying to customize we might be able to point you to the appropriate commands, or suggest a better way to do it.
Thanks for reply , For example I want to connect with my data base , there is a command called dbcode.connection.add but I need to pass parameters in executeCommand('dbcode.connection.add',args) what's args or parameters should I need to pass to make it successfully work , in which formate do I need to pass ? This is one commandId , I need to explore More commandIds using my code , so I need almost each commandId information and parameters need to be passed .
You should not need to call those commands directly, the UI the extension adds to VS Code has all the elements needed to run the commands.
For example, to connect, click the database icon in the activity panel (usually on the left) and then click the add connection button.. it will then open the window to enter the connection details.
We are working on some docs around doing this, but here is a quick video showing it...
Thank you , I am trying to connect my application through command IDs to dbcode extension , here my main goal is to use my own frontend to access all the features given by dbcode extension . I am using theia application , it's just like vs code , I am creating my own frontend screens to access my data base without writing any database code , by just accessing all your dbcode features Please tell me is this possible using command IDs ?
I don't think it will be.
Just looking at the connection command, it's argument is the treeitem element.. we don't control that, it's based on VSCode and how the tree works.
So to use our connect command as it's currently written you would have to replicate the tree elements exactly as we do.. or we would have to change that command (and lots of others) and place functions before them to unwrap vscode elements to get the data and just pass that through to our command... but that's not a small amount of work, or if it makes sense for us to enable a different front end we don't control ?
Ok thank you
Hi, I'm the developer of https://github.com/ddev/vscode-ddev-manager and I’m also interested in this feature. A major issue with extensions like this is that users have to manually configure everything. It would be fantastic if other extensions could easily configure new databases.
I don’t think the necessary changes would be overly complex (though I’m just speculating without knowing your code). You mentioned that “its argument is the treeitem element… we don’t control that.” However, you could consider creating a new command that other developers can call.
vscode.commands.registerCommand('newCommandBydevs', (config: IConfig) => {
vscode.commands.executeCommand('yourOriginalCommand', config);
});
As you mentioned, your original command receives a treeitem element when the user interacts with the sidebar, but it can accept any parameter if the command is executed from a different context.
vscode.commands.registerCommand('yourOriginalCommand', (item: TreeItem|IConfig) => {
...
});
If that's not possible maybe allow using a json file for config?
Anyway, it was just an idea. I recently discovered this extension, and so far, it hasn’t been able to connect to the database. Other extensions, however, connect without any issues.
That’s a very nice looking extension you have built! I was not previously aware of DDEV.
Agree it’s a pain to have to add configs to get started, we try to minimize that where we can with the zero config feature and discovering connection strings in env files etc, will look into seeing if we can do that for DDEV environments to save the need to manually add them.
Your suggestion for wrapping is one we considered, and I guess if there is more interest we can look at that.
The configurations are actually stored in the settings.json file that vscode uses… and the spec for an individual connection is unlikely to change at this point as it would break users existing configs. So you could in theory just write directly to that setting (dbcode.connections).
If you open the settings.json in vscode it will give you the schema validation for a connection in that setting, I will look to get it added to this repo as well.
We don’t recommend storing passwords in settings.json in plain text as the setting can be synced. So you can use the savePassword option to control how passwords are handled. Let me know if you have any questions about the spec or how you could add a connection via that method.
Would you mind opening a new issue with some details about the connection type that’s not working (type, error you get, etc) so we can look into it and get it resolved ?
Hi @mikeburgh, thanks for your response. I’ve checked the settings.json file, and that should work for now. Storing the password there is completely perfect since DDEV is only for local development and uses “db” for both the database name and password.
I’ll open a new issue with more details about the connection error. I’m eager to test your extension as it looks really promising.
We just pushed an update that includes ddev as a source for zero config. If the extension finds a .ddev folder, it will attempt to resolve the DB config and add it if it can.
The only catch at the moment is ddev needs to be running, as that seems to be the only way to find the containers published port, do you know another solution for that ?
This repo also now has a copy of the package.json file, which contains the full spec for the dbcode.connections object, so you can see all the keys and their purpose if you write your own connections in (the extension watches the setting, so it should refresh the tree if you do).
Hi, I just tested the update and can see the connection—it’s working perfectly. I’m excited to spend some time playing with it because it looks great.
The only catch at the moment is ddev needs to be running, as that seems to be the only way to find the containers published port, do you know another solution for that ?
No, the project needs to be running to retrieve the port, and there’s no workaround for that. Also, the port changes frequently, so if you want to integrate this directly into your extension, it would require listening for when the project starts, restarts, or any other event that causes the container port to change and there's no easy way to do that.
The DDEV extension already manages all those cases by checking if the port has changed and it can update the database configuration accordingly. However, with the new change you implemented, this won’t be possible since the connection is not saved in the settings.json file. It would be great if the settings could be saved in the workspace’s settings.json file, or perhaps you could add an option allowing users to choose where to store the connection when adding a new connection (global/workspace)?
Thank's for all your work.
Thanks for confirming that.. I think I will need to refactor zero config, to make it support a "dynamic" config that it can fetch at connection time to deal with when DDEV is not running.. or if the port changes. Agreed watching it for changes is a lot of work and outside the scope.
I believe if you add the connection to a workspace settings, vscode will merge them, so that probably works, but I have not tried it..
When I refactor it, I will also make it so that if a connection exists in settings, it wont be added from the zero config/discovered side.. and to check that when new connections are added.
Yes, adding the connection to the workspace settings works, but currently, when I add a connection manually, it’s saved to the global settings.json file. I have to manually remove it from there and add it to the workspace settings file. It would be great to have an option to choose where to store the connection when creating a new connection.
When I refactor it, I will also make it so that if a connection exists in settings, it wont be added from the zero config/discovered side.. and to check that when new connections are added.
That sounds great.
Yeah, we thought about that option awhile ago, it complicates things a bit as those files tend to get get picked up in Git repo's so we want to be careful about password storage..
I think the other changes might negate the need for now.. will see how it looks once those are in place.
You have given some command IDs to use and customize our requirements , but can I know what parameters do I need to send in method executecommand() Along dbcode commandId? There are different command IDs., i just need to know for every commandId what could be the way to find the parameters