mirror of
https://github.com/zadam/trilium.git
synced 2025-12-13 10:54:25 +01:00
feat(global_menu): add an option to switch layouts
This commit is contained in:
parent
5a1d138f29
commit
ab1b4b37f4
@ -27,6 +27,18 @@ export function getEnabledExperimentalFeatureIds() {
|
|||||||
return getEnabledFeatures().values();
|
return getEnabledFeatures().values();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function toggleExperimentalFeature(featureId: ExperimentalFeatureId, enable: boolean) {
|
||||||
|
let features = Array.from(getEnabledFeatures());
|
||||||
|
if (enable) {
|
||||||
|
if (!features.includes(featureId)) {
|
||||||
|
features.push(featureId);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
features = features.filter(f => f !== featureId);
|
||||||
|
}
|
||||||
|
await options.save("experimentalFeatures", JSON.stringify(features));
|
||||||
|
}
|
||||||
|
|
||||||
function getEnabledFeatures() {
|
function getEnabledFeatures() {
|
||||||
if (!enabledFeatures) {
|
if (!enabledFeatures) {
|
||||||
let features: ExperimentalFeatureId[] = [];
|
let features: ExperimentalFeatureId[] = [];
|
||||||
|
|||||||
@ -10,7 +10,8 @@ import { KeyboardActionNames } from "@triliumnext/commons";
|
|||||||
import { ComponentChildren } from "preact";
|
import { ComponentChildren } from "preact";
|
||||||
import Component from "../../components/component";
|
import Component from "../../components/component";
|
||||||
import { ParentComponent } from "../react/react_utils";
|
import { ParentComponent } from "../react/react_utils";
|
||||||
import utils, { dynamicRequire, isElectron, isMobile } from "../../services/utils";
|
import utils, { dynamicRequire, isElectron, isMobile, reloadFrontendApp } from "../../services/utils";
|
||||||
|
import { isExperimentalFeatureEnabled, toggleExperimentalFeature } from "../../services/experimental_features";
|
||||||
|
|
||||||
interface MenuItemProps<T> {
|
interface MenuItemProps<T> {
|
||||||
icon: string,
|
icon: string,
|
||||||
@ -70,6 +71,7 @@ export default function GlobalMenu({ isHorizontalLayout }: { isHorizontalLayout:
|
|||||||
</>}
|
</>}
|
||||||
|
|
||||||
{!isElectron() && <BrowserOnlyOptions />}
|
{!isElectron() && <BrowserOnlyOptions />}
|
||||||
|
{glob.isDev && <DevelopmentOptions />}
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -99,6 +101,21 @@ function BrowserOnlyOptions() {
|
|||||||
</>;
|
</>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function DevelopmentOptions() {
|
||||||
|
const newLayoutEnabled = isExperimentalFeatureEnabled("new-layout");
|
||||||
|
|
||||||
|
return <>
|
||||||
|
<FormDropdownDivider />
|
||||||
|
<FormListItem
|
||||||
|
icon={newLayoutEnabled ? "bx bx-layout" : "bx bxs-layout"}
|
||||||
|
onClick={() => {
|
||||||
|
toggleExperimentalFeature("new-layout", !newLayoutEnabled);
|
||||||
|
reloadFrontendApp();
|
||||||
|
}}
|
||||||
|
>{!newLayoutEnabled ? "Switch to new layout" : "Switch to old layout"}</FormListItem>
|
||||||
|
</>;
|
||||||
|
}
|
||||||
|
|
||||||
function SwitchToOptions() {
|
function SwitchToOptions() {
|
||||||
if (isElectron()) {
|
if (isElectron()) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user