Merge branch 'develop'

This commit is contained in:
Jan Prochazka
2022-04-14 13:45:41 +02:00
12 changed files with 107 additions and 39 deletions

View File

@@ -11,8 +11,8 @@ jobs:
strategy: strategy:
matrix: matrix:
# os: [ubuntu-18.04, windows-2016] # os: [macOS-10.15, windows-2022, ubuntu-18.04]
os: [macOS-10.15, windows-2022, ubuntu-18.04] os: [macOS-10.15]
steps: steps:
- name: Context - name: Context
@@ -48,6 +48,8 @@ jobs:
GH_TOKEN: ${{ secrets.GH_TOKEN }} # token for electron publish GH_TOKEN: ${{ secrets.GH_TOKEN }} # token for electron publish
WIN_CSC_LINK: ${{ secrets.WINCERT_CERTIFICATE }} WIN_CSC_LINK: ${{ secrets.WINCERT_CERTIFICATE }}
WIN_CSC_KEY_PASSWORD: ${{ secrets.WINCERT_PASSWORD }} WIN_CSC_KEY_PASSWORD: ${{ secrets.WINCERT_PASSWORD }}
CSC_LINK: ${{ secrets.APPLECERT_CERTIFICATE }}
CSC_KEY_PASSWORD: ${{ secrets.APPLECERT_PASSWORD }}
- name: Save snap login - name: Save snap login
if: matrix.os == 'ubuntu-18.04' if: matrix.os == 'ubuntu-18.04'

View File

@@ -15,8 +15,9 @@
"url": "https://github.com/dbgate/dbgate.git" "url": "https://github.com/dbgate/dbgate.git"
}, },
"build": { "build": {
"artifactName": "${productName}-${version}-${os}_${arch}.${ext}", "artifactName": "dbgate-${version}-${os}_${arch}.${ext}",
"appId": "org.dbgate", "appId": "org.dbgate",
"productName": "DbGate",
"mac": { "mac": {
"category": "database", "category": "database",
"icon": "icon512.png", "icon": "icon512.png",
@@ -26,8 +27,7 @@
"target": { "target": {
"target": "default", "target": "default",
"arch": [ "arch": [
"arm64", "universal"
"x64"
] ]
} }
}, },

View File

@@ -20,6 +20,9 @@ const { settings } = require('cluster');
const configRootPath = path.join(app.getPath('userData'), 'config-root.json'); const configRootPath = path.join(app.getPath('userData'), 'config-root.json');
let initialConfig = {}; let initialConfig = {};
let apiLoaded = false;
const isMac = () => os.platform() == 'darwin';
try { try {
initialConfig = JSON.parse(fs.readFileSync(configRootPath, { encoding: 'utf-8' })); initialConfig = JSON.parse(fs.readFileSync(configRootPath, { encoding: 'utf-8' }));
@@ -41,6 +44,7 @@ try {
// be closed automatically when the JavaScript object is garbage collected. // be closed automatically when the JavaScript object is garbage collected.
let mainWindow; let mainWindow;
let mainMenu; let mainMenu;
let runCommandOnLoad = null;
log.transports.file.level = 'debug'; log.transports.file.level = 'debug';
autoUpdater.logger = log; autoUpdater.logger = log;
@@ -59,30 +63,62 @@ function formatKeyText(keyText) {
return keyText.replace('CtrlOrCommand+', 'Ctrl+'); return keyText.replace('CtrlOrCommand+', 'Ctrl+');
} }
function commandItem(id) { function commandItem(item) {
const id = item.command;
const command = commands[id]; const command = commands[id];
if (item.skipInApp) {
return { skip: true };
}
return { return {
id, id,
label: command ? command.menuName || command.toolbarName || command.name : id, label: command ? command.menuName || command.toolbarName || command.name : id,
accelerator: formatKeyText(command ? command.keyText : undefined), accelerator: formatKeyText(command ? command.keyText : undefined),
enabled: command ? command.enabled : false, enabled: command ? command.enabled : false,
click() { click() {
if (mainWindow) {
mainWindow.webContents.send('run-command', id); mainWindow.webContents.send('run-command', id);
} else {
runCommandOnLoad = id;
createWindow();
}
}, },
}; };
} }
function buildMenu() { function buildMenu() {
const template = _cloneDeepWith(mainMenuDefinition, item => { let template = _cloneDeepWith(mainMenuDefinition, item => {
if (item.divider) { if (item.divider) {
return { type: 'separator' }; return { type: 'separator' };
} }
if (item.command) { if (item.command) {
return commandItem(item.command); return commandItem(item);
} }
}); });
template = _cloneDeepWith(template, item => {
if (Array.isArray(item) && item.find(x => x.skip)) {
return item.filter(x => x && !x.skip);
}
});
if (isMac()) {
template = [
{
label: 'DbGate',
submenu: [
commandItem({ command: 'about.show' }),
{ role: 'services' },
{ role: 'hide' },
{ role: 'hideOthers' },
{ role: 'unhide' },
{ role: 'quit' },
],
},
...template,
];
}
return Menu.buildFromTemplate(template); return Menu.buildFromTemplate(template);
} }
@@ -105,8 +141,12 @@ ipcMain.on('update-commands', async (event, arg) => {
menu.enabled = command.enabled; menu.enabled = command.enabled;
} }
}); });
ipcMain.on('close-window', async (event, arg) => { ipcMain.on('quit-app', async (event, arg) => {
if (isMac()) {
app.quit();
} else {
mainWindow.close(); mainWindow.close();
}
}); });
ipcMain.on('set-title', async (event, arg) => { ipcMain.on('set-title', async (event, arg) => {
mainWindow.setTitle(arg); mainWindow.setTitle(arg);
@@ -117,6 +157,12 @@ ipcMain.on('open-link', async (event, arg) => {
ipcMain.on('open-dev-tools', () => { ipcMain.on('open-dev-tools', () => {
mainWindow.webContents.openDevTools(); mainWindow.webContents.openDevTools();
}); });
ipcMain.on('app-started', async (event, arg) => {
if (runCommandOnLoad) {
mainWindow.webContents.send('run-command', runCommandOnLoad);
runCommandOnLoad = null;
}
});
ipcMain.on('window-action', async (event, arg) => { ipcMain.on('window-action', async (event, arg) => {
switch (arg) { switch (arg) {
case 'minimize': case 'minimize':
@@ -252,6 +298,7 @@ function createWindow() {
// mainWindow.webContents.toggleDevTools(); // mainWindow.webContents.toggleDevTools();
} }
if (!apiLoaded) {
const apiPackage = path.join( const apiPackage = path.join(
__dirname, __dirname,
process.env.DEVMODE ? '../../packages/api/src/index' : '../packages/api/dist/bundle.js' process.env.DEVMODE ? '../../packages/api/src/index' : '../packages/api/dist/bundle.js'
@@ -271,6 +318,8 @@ function createWindow() {
const main = api.getMainModule(); const main = api.getMainModule();
main.initializeElectronSender(mainWindow.webContents); main.initializeElectronSender(mainWindow.webContents);
main.useAllControllers(null, electron); main.useAllControllers(null, electron);
apiLoaded = true;
}
loadMainWindow(); loadMainWindow();
@@ -299,7 +348,7 @@ app.on('ready', onAppReady);
app.on('window-all-closed', function () { app.on('window-all-closed', function () {
// On OS X it is common for applications and their menu bar // On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q // to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') { if (!isMac()) {
app.quit(); app.quit();
} }
}); });

View File

@@ -17,7 +17,7 @@ module.exports = [
{ command: 'group.saveAs', hideDisabled: true }, { command: 'group.saveAs', hideDisabled: true },
{ divider: true }, { divider: true },
{ command: 'file.exit', hideDisabled: true }, { command: 'file.exit', hideDisabled: true },
{ command: 'app.logout', hideDisabled: true }, { command: 'app.logout', hideDisabled: true, skipInApp: true },
], ],
}, },
{ {

View File

@@ -1,6 +1,6 @@
{ {
"private": true, "private": true,
"version": "4.8.4-beta.2", "version": "4.8.4-beta.6",
"name": "dbgate-all", "name": "dbgate-all",
"workspaces": [ "workspaces": [
"packages/*", "packages/*",

View File

@@ -17,6 +17,7 @@
import { apiCall } from './utility/api'; import { apiCall } from './utility/api';
import { getConfig, getSettings, getUsedApps } from './utility/metadataLoaders'; import { getConfig, getSettings, getUsedApps } from './utility/metadataLoaders';
import AppTitleProvider from './utility/AppTitleProvider.svelte'; import AppTitleProvider from './utility/AppTitleProvider.svelte';
import getElectron from './utility/getElectron';
let loadedApi = false; let loadedApi = false;
let loadedPlugins = false; let loadedPlugins = false;
@@ -63,6 +64,7 @@
if (loadedApi && $loadingPluginStore?.loaded) { if (loadedApi && $loadingPluginStore?.loaded) {
setAppLoaded(); setAppLoaded();
loadedPlugins = true; loadedPlugins = true;
getElectron()?.send('app-started');
} }
} }
</script> </script>

View File

@@ -29,6 +29,7 @@ import { apiCall } from '../utility/api';
import runCommand from './runCommand'; import runCommand from './runCommand';
import { openWebLink } from '../utility/exportFileTools'; import { openWebLink } from '../utility/exportFileTools';
import { getSettings } from '../utility/metadataLoaders'; import { getSettings } from '../utility/metadataLoaders';
import { isMac } from '../utility/common';
// function themeCommand(theme: ThemeDefinition) { // function themeCommand(theme: ThemeDefinition) {
// return { // return {
@@ -97,7 +98,7 @@ registerCommand({
toolbarOrder: 2, toolbarOrder: 2,
name: 'Query', name: 'Query',
toolbarName: 'New query', toolbarName: 'New query',
keyText: 'CtrlOrCommand+Q', keyText: 'CtrlOrCommand+T',
onClick: () => newQuery(), onClick: () => newQuery(),
}); });
@@ -457,9 +458,10 @@ if (hasPermission('settings/change')) {
registerCommand({ registerCommand({
id: 'file.exit', id: 'file.exit',
category: 'File', category: 'File',
name: 'Exit', name: isMac() ? 'Quit' : 'Exit',
// keyText: isMac() ? 'Command+Q' : null,
testEnabled: () => getElectron() != null, testEnabled: () => getElectron() != null,
onClick: () => getElectron().send('close-window'), onClick: () => getElectron().send('quit-app'),
}); });
registerCommand({ registerCommand({

View File

@@ -306,6 +306,7 @@
import EditJsonModal from '../modals/EditJsonModal.svelte'; import EditJsonModal from '../modals/EditJsonModal.svelte';
import { apiCall } from '../utility/api'; import { apiCall } from '../utility/api';
import getElectron from '../utility/getElectron'; import getElectron from '../utility/getElectron';
import { isCtrlOrCommandKey } from '../utility/common';
export let onLoadNextData = undefined; export let onLoadNextData = undefined;
export let grider = undefined; export let grider = undefined;
@@ -976,7 +977,7 @@
const oldCurrentCell = currentCell; const oldCurrentCell = currentCell;
currentCell = cell; currentCell = cell;
if (event.ctrlKey) { if (isCtrlOrCommandKey(event)) {
if (isRegularCell(cell)) { if (isRegularCell(cell)) {
if (selectedCells.find(x => x[0] == cell[0] && x[1] == cell[1])) { if (selectedCells.find(x => x[0] == cell[0] && x[1] == cell[1])) {
selectedCells = selectedCells.filter(x => x[0] != cell[0] || x[1] != cell[1]); selectedCells = selectedCells.filter(x => x[0] != cell[0] || x[1] != cell[1]);
@@ -1116,6 +1117,7 @@
if ( if (
!event.ctrlKey && !event.ctrlKey &&
!event.altKey && !event.altKey &&
!event.metaKey &&
((event.keyCode >= keycodes.a && event.keyCode <= keycodes.z) || ((event.keyCode >= keycodes.a && event.keyCode <= keycodes.z) ||
(event.keyCode >= keycodes.n0 && event.keyCode <= keycodes.n9) || (event.keyCode >= keycodes.n0 && event.keyCode <= keycodes.n9) ||
(event.keyCode >= keycodes.numPad0 && event.keyCode <= keycodes.numPad9) || (event.keyCode >= keycodes.numPad0 && event.keyCode <= keycodes.numPad9) ||
@@ -1150,7 +1152,7 @@
function handleCursorMove(event) { function handleCursorMove(event) {
if (!isRegularCell(currentCell)) return null; if (!isRegularCell(currentCell)) return null;
let rowCount = grider.rowCount; let rowCount = grider.rowCount;
if (event.ctrlKey) { if (isCtrlOrCommandKey(event)) {
switch (event.keyCode) { switch (event.keyCode) {
case keycodes.upArrow: case keycodes.upArrow:
case keycodes.pageUp: case keycodes.pageUp:

View File

@@ -13,6 +13,7 @@
import createRef from '../utility/createRef'; import createRef from '../utility/createRef';
import _ from 'lodash'; import _ from 'lodash';
import { arrayToHexString, parseCellValue, stringifyCellValue } from 'dbgate-tools'; import { arrayToHexString, parseCellValue, stringifyCellValue } from 'dbgate-tools';
import { isCtrlOrCommandKey } from '../utility/common';
export let inplaceEditorState; export let inplaceEditorState;
export let dispatchInsplaceEditor; export let dispatchInsplaceEditor;
@@ -43,7 +44,7 @@
dispatchInsplaceEditor({ type: 'close', mode: 'enter' }); dispatchInsplaceEditor({ type: 'close', mode: 'enter' });
break; break;
case keycodes.s: case keycodes.s:
if (event.ctrlKey) { if (isCtrlOrCommandKey(event)) {
if (isChangedRef.get()) { if (isChangedRef.get()) {
onSetValue(parseCellValue(domEditor.value)); onSetValue(parseCellValue(domEditor.value));
// grider.setCellValue(rowIndex, uniqueName, editor.value); // grider.setCellValue(rowIndex, uniqueName, editor.value);

View File

@@ -10,6 +10,7 @@
import { showModal } from '../modals/modalTools'; import { showModal } from '../modals/modalTools';
import { currentThemeDefinition } from '../stores'; import { currentThemeDefinition } from '../stores';
import VirtualForeignKeyEditorModal from '../tableeditor/VirtualForeignKeyEditorModal.svelte'; import VirtualForeignKeyEditorModal from '../tableeditor/VirtualForeignKeyEditorModal.svelte';
import { isCtrlOrCommandKey } from '../utility/common';
import contextMenu from '../utility/contextMenu'; import contextMenu from '../utility/contextMenu';
import moveDrag from '../utility/moveDrag'; import moveDrag from '../utility/moveDrag';
import ColumnLine from './ColumnLine.svelte'; import ColumnLine from './ColumnLine.svelte';
@@ -217,7 +218,7 @@
e.stopPropagation(); e.stopPropagation();
onBringToFront(table); onBringToFront(table);
if (settings?.canSelectTables && !table?.isSelectedTable) { if (settings?.canSelectTables && !table?.isSelectedTable) {
onSelectTable(table, e.ctrlKey); onSelectTable(table, isCtrlOrCommandKey(e));
} }
} }
}} }}

View File

@@ -177,6 +177,7 @@
import { apiCall } from '../utility/api'; import { apiCall } from '../utility/api';
import { copyTextToClipboard, extractRowCopiedValue } from '../utility/clipboard'; import { copyTextToClipboard, extractRowCopiedValue } from '../utility/clipboard';
import { isCtrlOrCommandKey } from '../utility/common';
import contextMenu, { getContextMenu, registerMenu } from '../utility/contextMenu'; import contextMenu, { getContextMenu, registerMenu } from '../utility/contextMenu';
import createActivator, { getActiveComponent } from '../utility/createActivator'; import createActivator, { getActiveComponent } from '../utility/createActivator';
import createReducer from '../utility/createReducer'; import createReducer from '../utility/createReducer';
@@ -383,6 +384,7 @@
if ( if (
!event.ctrlKey && !event.ctrlKey &&
!event.metaKey &&
!event.altKey && !event.altKey &&
((event.keyCode >= keycodes.a && event.keyCode <= keycodes.z) || ((event.keyCode >= keycodes.a && event.keyCode <= keycodes.z) ||
(event.keyCode >= keycodes.n0 && event.keyCode <= keycodes.n9) || (event.keyCode >= keycodes.n0 && event.keyCode <= keycodes.n9) ||
@@ -472,7 +474,7 @@
return moveCurrentCell(columnIndex % formDisplay.columns.length, Math.floor(columnIndex / rowCount) * 2); return moveCurrentCell(columnIndex % formDisplay.columns.length, Math.floor(columnIndex / rowCount) * 2);
}; };
if (event.ctrlKey) { if (isCtrlOrCommandKey(event)) {
switch (event.keyCode) { switch (event.keyCode) {
case keycodes.leftArrow: case keycodes.leftArrow:
return moveCurrentCell(currentCell[0], 0); return moveCurrentCell(currentCell[0], 0);

View File

@@ -64,3 +64,10 @@ export function resolveKeyText(keyText: string): string {
} }
return keyText.replace('CtrlOrCommand+', 'Ctrl+'); return keyText.replace('CtrlOrCommand+', 'Ctrl+');
} }
export function isCtrlOrCommandKey(event) {
if (isMac()) {
return event.metaKey;
}
return event.ctrlKey;
}