mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-02-07 00:12:21 +01:00
merge main
This commit is contained in:
commit
106975b1f0
@ -76,12 +76,5 @@ export default defineConfig({
|
||||
targets: [{ src: "node_modules/monaco-editor/min/vs/*", dest: "monaco" }],
|
||||
}),
|
||||
],
|
||||
css: {
|
||||
preprocessorOptions: {
|
||||
scss: {
|
||||
api: "modern-compiler", // or "modern"
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
@ -43,6 +43,9 @@ function setPlatform(platform: NodeJS.Platform) {
|
||||
PLATFORM = platform;
|
||||
}
|
||||
|
||||
// Used to override the tab id when switching tabs to prevent flicker in the tab bar.
|
||||
const overrideStaticTabAtom = atom(null) as PrimitiveAtom<string>;
|
||||
|
||||
function initGlobalAtoms(initOpts: GlobalInitOptions) {
|
||||
const windowIdAtom = atom(initOpts.windowId) as PrimitiveAtom<string>;
|
||||
const clientIdAtom = atom(initOpts.clientId) as PrimitiveAtom<string>;
|
||||
@ -100,9 +103,8 @@ function initGlobalAtoms(initOpts: GlobalInitOptions) {
|
||||
const tabAtom: Atom<Tab> = atom((get) => {
|
||||
return WOS.getObjectValue(WOS.makeORef("tab", initOpts.tabId), get);
|
||||
});
|
||||
const staticTabIdAtom: Atom<string> = atom((get) => {
|
||||
return initOpts.tabId;
|
||||
});
|
||||
// This atom is used to determine the tab id to use for the static tab. It is set to the overrideStaticTabAtom value if it is not null, otherwise it is set to the initOpts.tabId value.
|
||||
const staticTabIdAtom: Atom<string> = atom((get) => get(overrideStaticTabAtom) ?? initOpts.tabId);
|
||||
const controlShiftDelayAtom = atom(false);
|
||||
const updaterStatusAtom = atom<UpdaterStatus>("up-to-date") as PrimitiveAtom<UpdaterStatus>;
|
||||
try {
|
||||
@ -627,7 +629,9 @@ function createTab() {
|
||||
}
|
||||
|
||||
function setActiveTab(tabId: string) {
|
||||
// We use this hack to prevent a flicker in the tab bar when switching to a new tab. This class is unset in reinitWave in wave.ts. See tab.scss for where this class is used.
|
||||
// We use this hack to prevent a flicker of the previously-hovered tab when this view was last active. This class is set in setActiveTab in global.ts. See tab.scss for where this class is used.
|
||||
// Also overrides the staticTabAtom to the new tab id so that the active tab is set correctly.
|
||||
globalStore.set(overrideStaticTabAtom, tabId);
|
||||
document.body.classList.add("nohover");
|
||||
getApi().setActiveTab(tabId);
|
||||
}
|
||||
@ -655,6 +659,7 @@ export {
|
||||
isDev,
|
||||
loadConnStatus,
|
||||
openLink,
|
||||
overrideStaticTabAtom,
|
||||
PLATFORM,
|
||||
pushFlashError,
|
||||
pushNotification,
|
||||
|
@ -100,6 +100,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Only apply hover effects when not in nohover mode. This prevents the previously-hovered tab from remaining hovered while a tab view is not mounted.
|
||||
body:not(.nohover) .tab:hover {
|
||||
& + .tab::after,
|
||||
&::after {
|
||||
@ -118,6 +119,11 @@ body:not(.nohover) .tab:hover {
|
||||
}
|
||||
}
|
||||
|
||||
// When in nohover mode, always show the close button on the active tab. This prevents the close button of the active tab from flickering when nohover is toggled.
|
||||
body.nohover .tab.active .close {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
@keyframes expandWidthAndFadeIn {
|
||||
from {
|
||||
width: var(--initial-tab-width);
|
||||
|
@ -155,47 +155,50 @@ const Tab = memo(
|
||||
event.stopPropagation();
|
||||
};
|
||||
|
||||
function handleContextMenu(e: React.MouseEvent<HTMLDivElement, MouseEvent>) {
|
||||
e.preventDefault();
|
||||
let menu: ContextMenuItem[] = [
|
||||
{ label: isPinned ? "Unpin Tab" : "Pin Tab", click: onPinChange },
|
||||
{ label: "Rename Tab", click: () => handleRenameTab(null) },
|
||||
{ label: "Copy TabId", click: () => navigator.clipboard.writeText(id) },
|
||||
{ type: "separator" },
|
||||
];
|
||||
const fullConfig = globalStore.get(atoms.fullConfigAtom);
|
||||
const bgPresets: string[] = [];
|
||||
for (const key in fullConfig?.presets ?? {}) {
|
||||
if (key.startsWith("bg@")) {
|
||||
bgPresets.push(key);
|
||||
}
|
||||
}
|
||||
bgPresets.sort((a, b) => {
|
||||
const aOrder = fullConfig.presets[a]["display:order"] ?? 0;
|
||||
const bOrder = fullConfig.presets[b]["display:order"] ?? 0;
|
||||
return aOrder - bOrder;
|
||||
});
|
||||
if (bgPresets.length > 0) {
|
||||
const submenu: ContextMenuItem[] = [];
|
||||
const oref = makeORef("tab", id);
|
||||
for (const presetName of bgPresets) {
|
||||
const preset = fullConfig.presets[presetName];
|
||||
if (preset == null) {
|
||||
continue;
|
||||
const handleContextMenu = useCallback(
|
||||
(e: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
|
||||
e.preventDefault();
|
||||
let menu: ContextMenuItem[] = [
|
||||
{ label: isPinned ? "Unpin Tab" : "Pin Tab", click: () => onPinChange() },
|
||||
{ label: "Rename Tab", click: () => handleRenameTab(null) },
|
||||
{ label: "Copy TabId", click: () => navigator.clipboard.writeText(id) },
|
||||
{ type: "separator" },
|
||||
];
|
||||
const fullConfig = globalStore.get(atoms.fullConfigAtom);
|
||||
const bgPresets: string[] = [];
|
||||
for (const key in fullConfig?.presets ?? {}) {
|
||||
if (key.startsWith("bg@")) {
|
||||
bgPresets.push(key);
|
||||
}
|
||||
submenu.push({
|
||||
label: preset["display:name"] ?? presetName,
|
||||
click: () => {
|
||||
ObjectService.UpdateObjectMeta(oref, preset);
|
||||
RpcApi.ActivityCommand(TabRpcClient, { settabtheme: 1 });
|
||||
},
|
||||
});
|
||||
}
|
||||
menu.push({ label: "Backgrounds", type: "submenu", submenu }, { type: "separator" });
|
||||
}
|
||||
menu.push({ label: "Close Tab", click: () => onClose(null) });
|
||||
ContextMenuModel.showContextMenu(menu, e);
|
||||
}
|
||||
bgPresets.sort((a, b) => {
|
||||
const aOrder = fullConfig.presets[a]["display:order"] ?? 0;
|
||||
const bOrder = fullConfig.presets[b]["display:order"] ?? 0;
|
||||
return aOrder - bOrder;
|
||||
});
|
||||
if (bgPresets.length > 0) {
|
||||
const submenu: ContextMenuItem[] = [];
|
||||
const oref = makeORef("tab", id);
|
||||
for (const presetName of bgPresets) {
|
||||
const preset = fullConfig.presets[presetName];
|
||||
if (preset == null) {
|
||||
continue;
|
||||
}
|
||||
submenu.push({
|
||||
label: preset["display:name"] ?? presetName,
|
||||
click: () => {
|
||||
ObjectService.UpdateObjectMeta(oref, preset);
|
||||
RpcApi.ActivityCommand(TabRpcClient, { settabtheme: 1 });
|
||||
},
|
||||
});
|
||||
}
|
||||
menu.push({ label: "Backgrounds", type: "submenu", submenu }, { type: "separator" });
|
||||
}
|
||||
menu.push({ label: "Close Tab", click: () => onClose(null) });
|
||||
ContextMenuModel.showContextMenu(menu, e);
|
||||
},
|
||||
[onPinChange, handleRenameTab, id, onClose, isPinned]
|
||||
);
|
||||
|
||||
const showSeparator = useCallback(
|
||||
(id) => {
|
||||
|
@ -589,12 +589,15 @@ const TabBar = memo(({ workspace }: TabBarProps) => {
|
||||
deleteLayoutModelForTab(tabId);
|
||||
};
|
||||
|
||||
const handlePinChange = (tabId: string, pinned: boolean) => {
|
||||
console.log("handlePinChange", tabId, pinned);
|
||||
fireAndForget(async () => {
|
||||
await WorkspaceService.ChangeTabPinning(workspace.oid, tabId, pinned);
|
||||
});
|
||||
};
|
||||
const handlePinChange = useCallback(
|
||||
(tabId: string, pinned: boolean) => {
|
||||
console.log("handlePinChange", tabId, pinned);
|
||||
fireAndForget(async () => {
|
||||
await WorkspaceService.ChangeTabPinning(workspace.oid, tabId, pinned);
|
||||
});
|
||||
},
|
||||
[workspace]
|
||||
);
|
||||
|
||||
const handleTabLoaded = useCallback((tabId: string) => {
|
||||
setTabsLoaded((prev) => {
|
||||
|
@ -22,6 +22,7 @@ import {
|
||||
initGlobal,
|
||||
initGlobalWaveEventSubs,
|
||||
loadConnStatus,
|
||||
overrideStaticTabAtom,
|
||||
pushFlashError,
|
||||
pushNotification,
|
||||
removeNotificationById,
|
||||
@ -88,12 +89,12 @@ async function reinitWave() {
|
||||
console.log("Reinit Wave");
|
||||
getApi().sendLog("Reinit Wave");
|
||||
|
||||
// We use this hack to prevent a flicker in the tab bar when switching to a new tab. This class is set in setActiveTab in global.ts. See tab.scss for where this class is used.
|
||||
requestAnimationFrame(() => {
|
||||
setTimeout(() => {
|
||||
document.body.classList.remove("nohover");
|
||||
}, 100);
|
||||
});
|
||||
// We use this hack to prevent a flicker of the previously-hovered tab when this view was last active. This class is set in setActiveTab in global.ts. See tab.scss for where this class is used.
|
||||
// Also overrides the staticTabAtom to the new tab id so that the active tab is set correctly.
|
||||
globalStore.set(overrideStaticTabAtom, savedInitOpts.tabId);
|
||||
setTimeout(() => {
|
||||
document.body.classList.remove("nohover");
|
||||
}, 100);
|
||||
|
||||
const client = await WOS.reloadWaveObject<Client>(WOS.makeORef("client", savedInitOpts.clientId));
|
||||
const waveWindow = await WOS.reloadWaveObject<WaveWindow>(WOS.makeORef("window", savedInitOpts.windowId));
|
||||
|
Loading…
Reference in New Issue
Block a user