-
Notifications
You must be signed in to change notification settings - Fork 525
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#125 objects sql definitions #141
Conversation
Oh and by the way, execute default query is moved to context menu. This is because a single table click fetches columns/triggers, so double clicking on it was not a good UX. |
const scriptsNames = ['CREATE', 'SELECT', 'INSERT', 'UPDATE', 'DELETE']; | ||
|
||
this.contextMenu = new Menu(); | ||
if (dbObjectType === 'Tables' || dbObjectType === 'Views') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you avoid nested if and else statements. For instance this first if could be changed to leave the function. And the next if leave the function after appending the menu item.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, will do!
Since all sqlscripts has the same behavior I guess is good reason to gather them all. |
Alright then, I'll try to finish this tommorow :) |
Refactored code, added fetching functions/procedures SQL definitions and fixed behavior so it updates SQL editor when user selects script he selected earlier (so it's already fetched on front-end). There are two thing that should be changed in future, but I think they should be separate PR's:
Well, I guess this is it for this PR. @maxcnunes @krolow any thoughts? :) |
click: onExecuteDefaultQuery.bind(this, database, item) | ||
})); | ||
this.contextMenu.append(new MenuItem({ | ||
label: `CREATE script`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does not need to use template string
Related to your 2 suggestions. Please do that 👍 |
With last commit upgraded to newest sqlectron-core and changed the way of fetching routines SQL (create statement) definition. Also, removed those unnecessary template strings as @krolow suggested. Regarding second suggestion. Since adding |
Since Travis CI build failure is related to another change and not this PR, I'll merge it into master. |
PR resolving (partially - not yet for routines) issue #125 .
So here it is in short:
database-item.jsx
component because of context menu. I found this a cleanest solution, because context menu should be a property of database object (all links in menu are related exclusively to that object).actions/sqlscripts.js
) or make unique one (i.e. getScriptIfNeeded) and pass script type (I guess this would be a object, i.e.{ type: 'create', item: 'table' }
) as a parameter to single function (something like this getScriptIfNeeded (database, table, scriptNeeded) ). Then we would have if-else clause which would call on a database (sqlectron-core) API, depending on the parameter passed. I know this is probably anti-pattern, but it would be much less code than it is now, and only one event handler function would be passed to components (now we have like 7).