Skip to content

Commit

Permalink
Merge pull request #3387 from ever-co/fix/enable-edit-menu-server-web
Browse files Browse the repository at this point in the history
Fix/enable edit menu server web
  • Loading branch information
evereq authored Dec 4, 2024
2 parents b31cda6 + ebe2aee commit 8db23c8
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 14 deletions.
9 changes: 4 additions & 5 deletions apps/server-web/src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,7 @@ const createWindow = async (type: 'SETTING_WINDOW' | 'LOG_WINDOW' | 'SETUP_WINDO
url = resolveHtmlPath('index.html', 'setup');
setupWindow?.loadURL(url);
mainBindings(ipcMain, setupWindow, fs);
if (process.platform === 'darwin') {
Menu.setApplicationMenu(Menu.buildFromTemplate([]));
} else {
setupWindow.removeMenu();
}
Menu.setApplicationMenu(appMenu.buildDefaultTemplate(appMenu.initialMenu(), i18nextMainBackend));
setupWindow.on('closed', () => {
setupWindow = null;
})
Expand Down Expand Up @@ -270,6 +266,8 @@ const onInitApplication = () => {
trayMenuItems = trayMenuItems.length ? trayMenuItems : defaultTrayMenuItem(eventEmitter);
updateTrayMenu('none', {}, eventEmitter, tray, trayMenuItems, i18nextMainBackend);
Menu.setApplicationMenu(appMenu.buildDefaultTemplate(appMenuItems, i18nextMainBackend))
} else {
Menu.setApplicationMenu(appMenu.buildDefaultTemplate(appMenu.initialMenu(), i18nextMainBackend))
}
}, 250));

Expand Down Expand Up @@ -378,6 +376,7 @@ const onInitApplication = () => {
})
logWindow?.webContents.send('themeSignal', { type: SettingPageTypeMessage.themeChange, data });
settingWindow?.webContents.send('themeSignal', { type: SettingPageTypeMessage.themeChange, data });
setupWindow?.webContents.send('themeSignal', { type: SettingPageTypeMessage.themeChange, data });
})

eventEmitter.on(EventLists.gotoAbout, async () => {
Expand Down
25 changes: 24 additions & 1 deletion apps/server-web/src/main/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default class MenuBuilder {
this.eventEmitter = eventEmitter
}

defaultMenu(): AppMenu[] {
initialMenu(): AppMenu[] {
const isDarwin = process.platform === 'darwin';
return [
{
Expand All @@ -41,6 +41,25 @@ export default class MenuBuilder {
},
],
},
{
id: 'MENU_APP_EDIT',
label: 'MENU_APP.APP_EDIT',
submenu: [
{ label: 'MENU_APP.APP_SUBMENU.APP_UNDO', accelerator: "CmdOrCtrl+Z", role: "undo" },
{ label: "MENU_APP.APP_SUBMENU.APP_REDO", accelerator: "Shift+CmdOrCtrl+Z", role: "redo" },
{ type: "separator" },
{ label: "MENU_APP.APP_SUBMENU.APP_CUT", accelerator: "CmdOrCtrl+X", role: "cut" },
{ label: "MENU_APP.APP_SUBMENU.APP_COPY", accelerator: "CmdOrCtrl+C", role: "copy" },
{ label: "MENU_APP.APP_SUBMENU.APP_PASTE", accelerator: "CmdOrCtrl+V", role: "paste" },
{ label: "MENU_APP.APP_SUBMENU.APP_SELECT_ALL", accelerator: "CmdOrCtrl+A", role: "selectAll" }
]
}
]
}

defaultMenu(): AppMenu[] {
return [
...this.initialMenu(),
{
id: 'MENU_APP_WINDOW',
label: 'MENU_APP.APP_WINDOW',
Expand Down Expand Up @@ -110,6 +129,10 @@ export default class MenuBuilder {
return Menu.buildFromTemplate(this.translateAppMenu(i18nextMainBackend, menuItems));
}

buildInitialTemplate(menuItems: any, i18nextMainBackend: typeof i18n) {
return Menu.buildFromTemplate(this.translateAppMenu(i18nextMainBackend, menuItems));
}

updateAppMenu(menuItem: string, context: { label?: string, enabled?: boolean}, contextMenuItems: any, i18nextMainBackend: typeof i18n) {
const menuIdx:number = contextMenuItems.findIndex((item: any) => item.id === menuItem);
if (menuIdx > -1) {
Expand Down
2 changes: 1 addition & 1 deletion apps/server-web/src/renderer/components/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const SelectComponent = ({
onValueChange={onValueChange}
>
<Select.Trigger
className="inline-flex items-center justify-center rounded-lg px-[15px] text-[13px] leading-none h-[35px] gap-[5px] bg-white dark:bg-[#25272D] text-violet11 dark:text-white shadow-[0_2px_10px] shadow-black/10 hover:bg-mauve3 focus:shadow-[0_0_0_2px] focus:shadow-black data-[placeholder]:text-violet9 outline-none"
className="inline-flex items-center justify-center rounded-lg px-[15px] text-[13px] leading-none h-[35px] gap-[5px] bg-white dark:bg-[#25272D] text-black dark:text-white shadow-[0_2px_10px] shadow-black/10 hover:bg-mauve3 focus:shadow-[0_0_0_2px] focus:shadow-black data-[placeholder]:text-violet9 outline-none"
aria-label="Food"
>
<Select.Value placeholder={title} />
Expand Down
4 changes: 2 additions & 2 deletions apps/server-web/src/renderer/components/Updater.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const UpdaterComponent = (props: IUpdaterComponent) => {
setToastShow(false);
};

const onSelectPeriode = (value: string) => {
const onSelectPeriod = (value: string) => {
props.changeAutoUpdate({
autoUpdate: props.data.autoUpdate,
updateCheckPeriod: value,
Expand Down Expand Up @@ -152,7 +152,7 @@ export const UpdaterComponent = (props: IUpdaterComponent) => {
value={props.data.updateCheckPeriod}
defaultValue={props.data.updateCheckPeriod}
disabled={!props.data.autoUpdate}
onValueChange={onSelectPeriode}
onValueChange={onSelectPeriod}
/>
</div>
</div>
Expand Down
14 changes: 12 additions & 2 deletions apps/server-web/src/renderer/pages/setup/Landing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { config } from '../../../configs/config';
import { useTranslation } from 'react-i18next';
import LanguageSelector from '../../components/LanguageSelector';
import { useEffect, useState } from 'react';
import { ThemeToggler } from '../../components/Toggler';
type props = {
nextAction: () => void;
};
Expand All @@ -25,8 +26,17 @@ const Landing = (props: props) => {
}, []);
return (
<div className="w-full">
<div className="mb-6 ml-10">
<LanguageSelector lang={defaultLang} />
<div className="flex w-full mb-6 ml-10">
<div className="flex flex-col w-6/12">
<div>
<LanguageSelector lang={defaultLang} />
</div>
</div>
<div className="flex w-6/12 flex-row-reverse mr-10">
<div className="flex flex-col w-2/8">
<ThemeToggler />
</div>
</div>
</div>

<div className="mb-8 w-full text-center">
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/interfaces/IRuntimeServerConfig.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface ServerRuntimeConfig {
export interface IServerRuntimeConfig {
GAUZY_API_SERVER_URL?: string;
NEXT_PUBLIC_GAUZY_API_SERVER_URL?: string;
[key: string]: any;
Expand Down
4 changes: 2 additions & 2 deletions apps/web/app/services/server/requests/desktop-source.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import getConfig from 'next/config';
import { ServerRuntimeConfig } from '@app/interfaces/IRuntimeServerConfig';
import { IServerRuntimeConfig } from '@app/interfaces/IRuntimeServerConfig';
import { GAUZY_API_SERVER_URL, GAUZY_API_BASE_SERVER_URL } from '@app/constants';

export function getDesktopConfig(): Partial<ServerRuntimeConfig> {
export function getDesktopConfig(): Partial<IServerRuntimeConfig> {
try {
const { serverRuntimeConfig } = getConfig();
return serverRuntimeConfig;
Expand Down

0 comments on commit 8db23c8

Please sign in to comment.