chore(client/ts): port global_menu

This commit is contained in:
Elian Doran 2025-01-04 18:19:46 +02:00
parent 356cb2f12f
commit 874809254d
No known key found for this signature in database
3 changed files with 51 additions and 37 deletions

View File

@ -41,6 +41,7 @@ interface CustomGlobals {
assetPath: string;
instanceName: string;
appCssNoteIds: string[];
triliumVersion: string;
}
type RequireMethod = (moduleName: string) => any;

View File

@ -254,7 +254,16 @@ const TPL = `
`;
export default class GlobalMenuWidget extends BasicWidget {
constructor(isHorizontalLayout) {
private updateAvailableWidget: UpdateAvailableWidget;
private isHorizontalLayout: boolean;
private tooltip!: bootstrap.Tooltip;
private dropdown!: bootstrap.Dropdown;
private $updateToLatestVersionButton!: JQuery<HTMLElement>;
private $zoomState!: JQuery<HTMLElement>;
constructor(isHorizontalLayout: boolean) {
super();
this.updateAvailableWidget = new UpdateAvailableWidget();
@ -286,11 +295,15 @@ export default class GlobalMenuWidget extends BasicWidget {
<path class="st8" d="m66.3 52.2c15.3 12.8 23.3 33.6 26.1 48.9l-50.6-22 48.8 24.9c-12.2 6-29.6 11.8-46.5 10-19.8-16.4-40.2-46.4-42.6-61.5 12.4-6.5 41.5-5.8 64.8-0.3z"/>
</g>
</svg>`));
//TODO: Fix once bootstrap is imported via modules.
//@ts-ignore
this.tooltip = new bootstrap.Tooltip(this.$widget.find("[data-bs-toggle='tooltip']"), { trigger: "hover" });
} else {
$globalMenuButton.toggleClass("bx bx-menu");
}
//TODO: Fix once bootstrap is imported via modules.
//@ts-ignore
this.dropdown = bootstrap.Dropdown.getOrCreateInstance(this.$widget.find("[data-bs-toggle='dropdown']"), {
alignment: "bottom"
});

View File

@ -34,7 +34,7 @@ export default class UpdateAvailableWidget extends BasicWidget {
this.$widget = $(TPL);
}
updateVersionStatus(latestVersion) {
updateVersionStatus(latestVersion: string) {
this.$widget.toggle(utils.isUpdateAvailable(latestVersion, glob.triliumVersion));
}
}