mirror of
https://github.com/zadam/trilium.git
synced 2025-11-08 07:28:59 +01:00
chore(react/ribbon): port revisions button
This commit is contained in:
parent
d85746c1b9
commit
f91c1f4180
@ -1,14 +0,0 @@
|
|||||||
import { t } from "../../services/i18n.js";
|
|
||||||
import CommandButtonWidget from "./command_button.js";
|
|
||||||
|
|
||||||
export default class RevisionsButton extends CommandButtonWidget {
|
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
|
|
||||||
this.icon("bx-history").title(t("revisions_button.note_revisions")).command("showRevisions").titlePlacement("bottom").class("icon-action");
|
|
||||||
}
|
|
||||||
|
|
||||||
isEnabled() {
|
|
||||||
return super.isEnabled() && !["launcher", "doc"].includes(this.note?.type ?? "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,14 +1,19 @@
|
|||||||
|
import { CommandNames } from "../../components/app_context";
|
||||||
|
|
||||||
interface ActionButtonProps {
|
interface ActionButtonProps {
|
||||||
text: string;
|
text: string;
|
||||||
|
titlePosition?: "bottom"; // TODO: Use it
|
||||||
icon: string;
|
icon: string;
|
||||||
className?: string;
|
className?: string;
|
||||||
onClick?: (e: MouseEvent) => void;
|
onClick?: (e: MouseEvent) => void;
|
||||||
|
triggerCommand?: CommandNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function ActionButton({ text, icon, className, onClick }: ActionButtonProps) {
|
export default function ActionButton({ text, icon, className, onClick, triggerCommand }: ActionButtonProps) {
|
||||||
return <button
|
return <button
|
||||||
class={`icon-action ${icon} ${className ?? ""}`}
|
class={`icon-action ${icon} ${className ?? ""}`}
|
||||||
title={text}
|
title={text}
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
|
data-trigger-command={triggerCommand}
|
||||||
/>;
|
/>;
|
||||||
}
|
}
|
||||||
28
apps/client/src/widgets/ribbon/NoteActions.tsx
Normal file
28
apps/client/src/widgets/ribbon/NoteActions.tsx
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import FNote from "../../entities/fnote"
|
||||||
|
import { t } from "../../services/i18n"
|
||||||
|
import ActionButton from "../react/ActionButton"
|
||||||
|
|
||||||
|
interface NoteActionsProps {
|
||||||
|
note?: FNote;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function NoteActions(props: NoteActionsProps) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<RevisionsButton {...props} />
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function RevisionsButton({ note }: NoteActionsProps) {
|
||||||
|
const isEnabled = !["launcher", "doc"].includes(note?.type ?? "");
|
||||||
|
|
||||||
|
return (isEnabled &&
|
||||||
|
<ActionButton
|
||||||
|
icon="bx bx-history"
|
||||||
|
text={t("revisions_button.note_revisions")}
|
||||||
|
triggerCommand="showRevisions"
|
||||||
|
titlePosition="bottom"
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
@ -23,6 +23,7 @@ import OwnedAttributesTab from "./OwnedAttributesTab";
|
|||||||
import InheritedAttributesTab from "./InheritedAttributesTab";
|
import InheritedAttributesTab from "./InheritedAttributesTab";
|
||||||
import CollectionPropertiesTab from "./CollectionPropertiesTab";
|
import CollectionPropertiesTab from "./CollectionPropertiesTab";
|
||||||
import SearchDefinitionTab from "./SearchDefinitionTab";
|
import SearchDefinitionTab from "./SearchDefinitionTab";
|
||||||
|
import NoteActions from "./NoteActions";
|
||||||
|
|
||||||
interface TitleContext {
|
interface TitleContext {
|
||||||
note: FNote | null | undefined;
|
note: FNote | null | undefined;
|
||||||
@ -203,7 +204,9 @@ export default function Ribbon() {
|
|||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
<div className="ribbon-button-container"></div>
|
<div className="ribbon-button-container">
|
||||||
|
<NoteActions note={note} />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="ribbon-body-container">
|
<div className="ribbon-body-container">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user