mirror of
https://github.com/zadam/trilium.git
synced 2025-12-11 09:54:23 +01:00
feat(client/server): basic support for experimental features
This commit is contained in:
parent
1ceed1b47b
commit
ae154212fe
13
apps/client/src/services/experimental_features.ts
Normal file
13
apps/client/src/services/experimental_features.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
interface ExperimentalFeature {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
description: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const experimentalFeatures: ExperimentalFeature[] = [
|
||||||
|
{
|
||||||
|
id: "newLayout",
|
||||||
|
name: "New Layout",
|
||||||
|
description: "Try out the new layout for a more modern look and improved usability.",
|
||||||
|
}
|
||||||
|
];
|
||||||
@ -7,6 +7,9 @@ import FormText from "../../react/FormText";
|
|||||||
import OptionsSection from "./components/OptionsSection"
|
import OptionsSection from "./components/OptionsSection"
|
||||||
import Column from "../../react/Column";
|
import Column from "../../react/Column";
|
||||||
import { useEffect, useState } from "preact/hooks";
|
import { useEffect, useState } from "preact/hooks";
|
||||||
|
import CheckboxList from "./components/CheckboxList";
|
||||||
|
import { experimentalFeatures } from "../../../services/experimental_features";
|
||||||
|
import { useTriliumOptionJson } from "../../react/hooks";
|
||||||
|
|
||||||
export default function AdvancedSettings() {
|
export default function AdvancedSettings() {
|
||||||
return <>
|
return <>
|
||||||
@ -14,6 +17,7 @@ export default function AdvancedSettings() {
|
|||||||
<DatabaseIntegrityOptions />
|
<DatabaseIntegrityOptions />
|
||||||
<DatabaseAnonymizationOptions />
|
<DatabaseAnonymizationOptions />
|
||||||
<VacuumDatabaseOptions />
|
<VacuumDatabaseOptions />
|
||||||
|
<ExperimentalOptions />
|
||||||
</>;
|
</>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,14 +48,14 @@ function DatabaseIntegrityOptions() {
|
|||||||
return (
|
return (
|
||||||
<OptionsSection title={t("database_integrity_check.title")}>
|
<OptionsSection title={t("database_integrity_check.title")}>
|
||||||
<FormText>{t("database_integrity_check.description")}</FormText>
|
<FormText>{t("database_integrity_check.description")}</FormText>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
text={t("database_integrity_check.check_button")}
|
text={t("database_integrity_check.check_button")}
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
toast.showMessage(t("database_integrity_check.checking_integrity"));
|
toast.showMessage(t("database_integrity_check.checking_integrity"));
|
||||||
|
|
||||||
const { results } = await server.get<DatabaseCheckIntegrityResponse>("database/check-integrity");
|
const { results } = await server.get<DatabaseCheckIntegrityResponse>("database/check-integrity");
|
||||||
|
|
||||||
if (results.length === 1 && results[0].integrity_check === "ok") {
|
if (results.length === 1 && results[0].integrity_check === "ok") {
|
||||||
toast.showMessage(t("database_integrity_check.integrity_check_succeeded"));
|
toast.showMessage(t("database_integrity_check.integrity_check_succeeded"));
|
||||||
} else {
|
} else {
|
||||||
@ -93,7 +97,7 @@ function DatabaseAnonymizationOptions() {
|
|||||||
buttonClick={async () => {
|
buttonClick={async () => {
|
||||||
toast.showMessage(t("database_anonymization.creating_fully_anonymized_database"));
|
toast.showMessage(t("database_anonymization.creating_fully_anonymized_database"));
|
||||||
const resp = await server.post<DatabaseAnonymizeResponse>("database/anonymize/full");
|
const resp = await server.post<DatabaseAnonymizeResponse>("database/anonymize/full");
|
||||||
|
|
||||||
if (!resp.success) {
|
if (!resp.success) {
|
||||||
toast.showError(t("database_anonymization.error_creating_anonymized_database"));
|
toast.showError(t("database_anonymization.error_creating_anonymized_database"));
|
||||||
} else {
|
} else {
|
||||||
@ -141,7 +145,7 @@ function ExistingAnonymizedDatabases({ databases }: { databases: AnonymizedDbRes
|
|||||||
return <FormText>{t("database_anonymization.no_anonymized_database_yet")}</FormText>
|
return <FormText>{t("database_anonymization.no_anonymized_database_yet")}</FormText>
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<table className="table table-stripped">
|
<table className="table table-stripped">
|
||||||
<thead>
|
<thead>
|
||||||
<th>{t("database_anonymization.existing_anonymized_databases")}</th>
|
<th>{t("database_anonymization.existing_anonymized_databases")}</th>
|
||||||
@ -172,4 +176,21 @@ function VacuumDatabaseOptions() {
|
|||||||
/>
|
/>
|
||||||
</OptionsSection>
|
</OptionsSection>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ExperimentalOptions() {
|
||||||
|
const [ enabledExperimentalFeatures, setEnabledExperimentalFeatures ] = useTriliumOptionJson<string[]>("experimentalFeatures");
|
||||||
|
|
||||||
|
return (
|
||||||
|
<OptionsSection title="Experimental Options">
|
||||||
|
<FormText>These options are experimental and may cause instability. Use with caution.</FormText>
|
||||||
|
|
||||||
|
<CheckboxList
|
||||||
|
values={experimentalFeatures}
|
||||||
|
keyProperty="id"
|
||||||
|
titleProperty="name"
|
||||||
|
currentValue={enabledExperimentalFeatures} onChange={setEnabledExperimentalFeatures}
|
||||||
|
/>
|
||||||
|
</OptionsSection>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
@ -99,6 +99,7 @@ const ALLOWED_OPTIONS = new Set<OptionNames>([
|
|||||||
"showLoginInShareTheme",
|
"showLoginInShareTheme",
|
||||||
"splitEditorOrientation",
|
"splitEditorOrientation",
|
||||||
"seenCallToActions",
|
"seenCallToActions",
|
||||||
|
"experimentalFeatures",
|
||||||
|
|
||||||
// AI/LLM integration options
|
// AI/LLM integration options
|
||||||
"aiEnabled",
|
"aiEnabled",
|
||||||
|
|||||||
@ -215,7 +215,8 @@ const defaultOptions: DefaultOption[] = [
|
|||||||
{ name: "aiSystemPrompt", value: "", isSynced: true },
|
{ name: "aiSystemPrompt", value: "", isSynced: true },
|
||||||
{ name: "aiSelectedProvider", value: "openai", isSynced: true },
|
{ name: "aiSelectedProvider", value: "openai", isSynced: true },
|
||||||
|
|
||||||
{ name: "seenCallToActions", value: "[]", isSynced: true }
|
{ name: "seenCallToActions", value: "[]", isSynced: true },
|
||||||
|
{ name: "experimentalFeatures", value: "[]", isSynced: true }
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -155,6 +155,7 @@ export interface OptionDefinitions extends KeyboardShortcutsOptions<KeyboardActi
|
|||||||
codeOpenAiModel: string;
|
codeOpenAiModel: string;
|
||||||
aiSelectedProvider: string;
|
aiSelectedProvider: string;
|
||||||
seenCallToActions: string;
|
seenCallToActions: string;
|
||||||
|
experimentalFeatures: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type OptionNames = keyof OptionDefinitions;
|
export type OptionNames = keyof OptionDefinitions;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user