Add isTest to settings and ability to redirect to test env. Add rome/imex specific builds.
This commit is contained in:
@@ -3,6 +3,7 @@ import log from "electron-log/main";
|
||||
import { GraphQLClient, RequestMiddleware } from "graphql-request";
|
||||
import errorTypeCheck from "../../util/errorTypeCheck.js";
|
||||
import ipcTypes from "../../util/ipcTypes.json";
|
||||
import store from "../store/store.js";
|
||||
|
||||
const requestMiddleware: RequestMiddleware = async (request) => {
|
||||
const token = await getTokenFromRenderer();
|
||||
@@ -20,7 +21,9 @@ const requestMiddleware: RequestMiddleware = async (request) => {
|
||||
};
|
||||
|
||||
const client: GraphQLClient = new GraphQLClient(
|
||||
import.meta.env.VITE_GRAPHQL_ENDPOINT,
|
||||
store.get("app.isTest") || false
|
||||
? import.meta.env.VITE_GRAPHQL_ENDPOINT_TEST
|
||||
: import.meta.env.VITE_GRAPHQL_ENDPOINT,
|
||||
{
|
||||
requestMiddleware,
|
||||
},
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
import { electronApp, is, optimizer } from "@electron-toolkit/utils";
|
||||
import Sentry from "@sentry/electron/main";
|
||||
import { app, BrowserWindow, Menu, nativeImage, shell, Tray } from "electron";
|
||||
import {
|
||||
app,
|
||||
BrowserWindow,
|
||||
globalShortcut,
|
||||
Menu,
|
||||
nativeImage,
|
||||
shell,
|
||||
Tray,
|
||||
} from "electron";
|
||||
import log from "electron-log/main";
|
||||
import { autoUpdater } from "electron-updater";
|
||||
import path, { join } from "path";
|
||||
@@ -138,6 +146,20 @@ function createWindow(): void {
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "Connect to Test",
|
||||
checked: store.get("app.isTest") as boolean,
|
||||
visible: false,
|
||||
type: "checkbox",
|
||||
id: "toggleTest",
|
||||
click: (): void => {
|
||||
const currentSetting = store.get("app.isTest") as boolean;
|
||||
store.set("app.isTest", !currentSetting);
|
||||
log.info("Setting isTest to: ", !currentSetting);
|
||||
app.relaunch(); // Relaunch the app
|
||||
app.exit(0); // Exit the current instance
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
// { role: 'windowMenu' }
|
||||
@@ -219,6 +241,23 @@ function createWindow(): void {
|
||||
const menu: Electron.Menu = Menu.buildFromTemplate(template);
|
||||
Menu.setApplicationMenu(menu);
|
||||
|
||||
// Register a global shortcut to show the hidden item
|
||||
globalShortcut.register("CommandOrControl+Shift+T", () => {
|
||||
console.log("Shortcut pressed! Revealing hidden item.");
|
||||
|
||||
// Update the menu to make the hidden item visible
|
||||
// Find the menu item dynamically by its id
|
||||
const fileMenu = template.find((item) => item.label === "Application");
|
||||
const hiddenItem = fileMenu?.submenu?.find(
|
||||
(item) => item.id === "toggleTest",
|
||||
);
|
||||
if (hiddenItem) {
|
||||
hiddenItem.visible = true; // Update the visibility dynamically
|
||||
const menu: Electron.Menu = Menu.buildFromTemplate(template);
|
||||
Menu.setApplicationMenu(menu);
|
||||
}
|
||||
});
|
||||
|
||||
// Store window properties for later
|
||||
const storeWindowState = (): void => {
|
||||
const [width, height] = mainWindow.getSize();
|
||||
@@ -388,7 +427,7 @@ app.on("before-quit", () => {
|
||||
openAtLogin: !currentSetting,
|
||||
});
|
||||
}
|
||||
|
||||
globalShortcut.unregisterAll();
|
||||
isAppQuitting = true;
|
||||
});
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ const store = new Store({
|
||||
y: undefined,
|
||||
},
|
||||
user: null,
|
||||
isTest: false,
|
||||
bodyshop: {},
|
||||
masterdata: {
|
||||
opcodes: null,
|
||||
|
||||
Reference in New Issue
Block a user