forked from frappe/builder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainMenu.vue
More file actions
100 lines (96 loc) · 2.46 KB
/
MainMenu.vue
File metadata and controls
100 lines (96 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<template>
<Dropdown
:options="[
{
group: 'Builder',
hideLabel: true,
items: [
{ label: 'Back to Dashboard', onClick: () => $router.push({ name: 'home' }), icon: 'arrow-left' },
],
},
{
group: 'Page',
hideLabel: true,
items: [
{
label: 'New Page',
onClick: () => $router.push({ name: 'builder', params: { pageId: 'new' } }),
icon: 'plus',
},
{
label: 'Copy Page',
onClick: handleCopyPage,
icon: 'clipboard',
condition: () => Boolean(pageStore.activePage),
},
{
label: 'Duplicate Page',
onClick: () => pageStore.duplicatePage(pageStore.activePage as BuilderPage),
icon: 'copy',
},
{
label: `Toggle Theme`,
onClick: () => toggleDark(),
icon: isDark ? 'sun' : 'moon',
},
{ label: 'Settings', onClick: () => $emit('showSettings'), icon: 'settings' },
{
label: 'Help',
onClick: () => {
// @ts-ignore
window.open('https://t.me/frappebuilder');
},
icon: 'info',
},
],
},
{
group: 'Delete',
hideLabel: true,
items: [
{
label: 'Delete Page',
onClick: () => {
if (!pageStore.activePage) return;
pageStore.deletePage(pageStore.activePage).then(() => {
$router.push({ name: 'home' });
});
},
icon: 'trash-2',
},
],
},
]"
size="sm"
class="flex-1 [&>div>div>div]:w-full"
placement="right">
<template v-slot="{ open }">
<div class="flex cursor-pointer items-center gap-2">
<img src="/builder_logo.png" alt="logo" class="h-7" />
<FeatherIcon
:name="open ? 'chevron-up' : 'chevron-down'"
class="h-4 w-4 !text-gray-700 dark:!text-gray-200"></FeatherIcon>
</div>
</template>
</Dropdown>
</template>
<script setup lang="ts">
import useCanvasStore from "@/stores/canvasStore";
import usePageStore from "@/stores/pageStore";
import { BuilderPage } from "@/types/Builder/BuilderPage";
import { triggerCopyEvent } from "@/utils/helpers";
import { useDark, useToggle } from "@vueuse/core";
import { Dropdown } from "frappe-ui";
const pageStore = usePageStore();
const isDark = useDark({
attribute: "data-theme",
});
const toggleDark = useToggle(isDark);
const canvasStore = useCanvasStore();
const handleCopyPage = () => {
if (!pageStore.activePage) return;
canvasStore.copyEntirePage = true;
canvasStore.requiresConfirmationForCopyingEntirePage = false;
triggerCopyEvent();
};
</script>