-
Notifications
You must be signed in to change notification settings - Fork 4
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
Ability to connect database multiple window #19
base: master
Are you sure you want to change the base?
Ability to connect database multiple window #19
Conversation
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.
I am a bit conflicted, at the moment, I want to keep only one main window at most database windows we can have multiple
But we have many code that can generate new windows and it is hard to control it in the future. At one point, we might make subtle mistake
export const mainWindow = new MainWindow();
app.whenReady(mainWindow.init)
We can expose several useful abstraction
// if main window is hidden, it will show and navigate to create connection
// if main window is destroyed, it will create window and navigate
mainWindow.navigate("/connection/mysql");
mainWindow.hide();
mainWindow.show();
mainWindow.getWindow(); // this will give reference to window or null
Then we can break down IPC code in separate file in the future
bindDockerIpc(mainWindow)
bindMenuIpc(mainWindow)
bindOtherIpcInTheFuture(mainWindow)
electron/menu/index.ts
Outdated
const connMenu: MenuItemConstructorOptions["submenu"] = connections.map( | ||
(conn) => { | ||
return { | ||
label: conn.name, | ||
click: () => { | ||
const existingWindow = windowMap.get(conn.id); | ||
if (existingWindow && !existingWindow.isDestroyed()) { | ||
existingWindow.focus(); | ||
} else { | ||
createDatabaseWindow({ win, conn }); | ||
win?.hide(); | ||
} | ||
}, | ||
}; | ||
}, | ||
); | ||
|
||
return connMenu; | ||
} |
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.
Make sure you slice the connection let say last 10, if there is more than 10, you can put "See more connections"
electron/menu/index.ts
Outdated
function handleClick() { | ||
createWindow(); | ||
} |
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.
We want to maintain only one main windows. We can have multiple database windows, but should only have one main window
electron/utils/index.ts
Outdated
show: false, | ||
width: 1024, | ||
height: 768, | ||
autoHideMenuBar: true, |
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.
autoHideMenuBar: false,
If it is true, Windows will never have menu
All updated |
No description provided.