|
1 | 1 | "use client";
|
2 | 2 |
|
3 |
| -import { Command } from 'cmdk' |
4 |
| -import { useState, useEffect } from 'react'; |
5 |
| -import { useRouter } from 'next/navigation'; |
6 |
| -import { GitHubLogoIcon, FileTextIcon, TwitterLogoIcon } from '@radix-ui/react-icons' |
7 |
| - |
8 |
| -import '../styles/linear.scss'; |
| 3 | +import { Command } from "cmdk"; |
| 4 | +import { useState, useEffect } from "react"; |
| 5 | +import { useRouter } from "next/navigation"; |
| 6 | +import { |
| 7 | + GitHubLogoIcon, |
| 8 | + FileTextIcon, |
| 9 | + TwitterLogoIcon, |
| 10 | +} from "@radix-ui/react-icons"; |
| 11 | +import { |
| 12 | + GlobeAltIcon, |
| 13 | + UserGroupIcon, |
| 14 | + EnvelopeIcon, |
| 15 | + KeyIcon, |
| 16 | + BriefcaseIcon, |
| 17 | +} from "@heroicons/react/24/outline"; |
9 | 18 |
|
| 19 | +import "../styles/linear.scss"; |
10 | 20 |
|
11 | 21 | export function CMDK() {
|
12 |
| - const [open, setOpen] = useState(false) |
13 |
| - const router = useRouter(); |
| 22 | + const [open, setOpen] = useState(false); |
| 23 | + const router = useRouter(); |
14 | 24 |
|
15 | 25 | // Toggle the menu when ⌘K is pressed
|
16 | 26 | useEffect(() => {
|
17 | 27 | const down = (e: any) => {
|
18 |
| - if (e.key === 'k' && (e.metaKey || e.ctrlKey)) { |
19 |
| - e.preventDefault() |
20 |
| - setOpen((open) => !open) |
| 28 | + if (e.key === "k" && (e.metaKey || e.ctrlKey)) { |
| 29 | + e.preventDefault(); |
| 30 | + setOpen((open) => !open); |
21 | 31 | }
|
22 |
| - } |
| 32 | + }; |
23 | 33 |
|
24 |
| - document.addEventListener('keydown', down) |
25 |
| - return () => document.removeEventListener('keydown', down) |
26 |
| - }, []) |
| 34 | + document.addEventListener("keydown", down); |
| 35 | + return () => document.removeEventListener("keydown", down); |
| 36 | + }, []); |
27 | 37 | return (
|
28 | 38 | <div className="linear">
|
29 | 39 | <Command.Dialog open={open} onOpenChange={setOpen}>
|
30 | 40 | <div cmdk-linear-badge="">Keep Command Palette</div>
|
31 | 41 | <Command.Input autoFocus placeholder="Type a command or search..." />
|
32 | 42 | <Command.Group heading="Navigate">
|
33 |
| - <Command.List> |
| 43 | + <Command.List> |
34 | 44 | <Command.Empty>No results found.</Command.Empty>
|
35 | 45 | {navigationItems.map(({ icon, label, shortcut, navigate }) => {
|
36 |
| - return ( |
37 |
| - <Command.Item key={label} value={label} onSelect={() => { |
38 |
| - setOpen((open) => !open); |
39 |
| - router.push(navigate!); |
40 |
| - }}> |
41 |
| - {icon} |
42 |
| - {label} |
43 |
| - <div cmdk-linear-shortcuts=""> |
| 46 | + return ( |
| 47 | + <Command.Item |
| 48 | + key={label} |
| 49 | + value={label} |
| 50 | + onSelect={() => { |
| 51 | + setOpen((open) => !open); |
| 52 | + router.push(navigate!); |
| 53 | + }} |
| 54 | + > |
| 55 | + {icon} |
| 56 | + {label} |
| 57 | + <div cmdk-linear-shortcuts=""> |
44 | 58 | {shortcut.map((key) => {
|
45 |
| - return <kbd key={key}>{key}</kbd> |
| 59 | + return <kbd key={key}>{key}</kbd>; |
46 | 60 | })}
|
47 |
| - </div> |
| 61 | + </div> |
48 | 62 | </Command.Item>
|
49 |
| - ) |
| 63 | + ); |
50 | 64 | })}
|
51 |
| - </Command.List> |
| 65 | + </Command.List> |
52 | 66 | </Command.Group>
|
53 | 67 | <Command.Group heading="External sources">
|
54 |
| - <Command.List> |
| 68 | + <Command.List> |
55 | 69 | {externalItems.map(({ icon, label, shortcut, navigate }) => {
|
56 |
| - return ( |
57 |
| - <Command.Item key={label} value={label} onSelect={() => { |
58 |
| - setOpen((open) => !open); |
59 |
| - window.open(navigate, "_blank"); |
60 |
| - }}> |
61 |
| - {icon} |
62 |
| - {label} |
63 |
| - <div cmdk-linear-shortcuts=""> |
| 70 | + return ( |
| 71 | + <Command.Item |
| 72 | + key={label} |
| 73 | + value={label} |
| 74 | + onSelect={() => { |
| 75 | + setOpen((open) => !open); |
| 76 | + window.open(navigate, "_blank"); |
| 77 | + }} |
| 78 | + > |
| 79 | + {icon} |
| 80 | + {label} |
| 81 | + <div cmdk-linear-shortcuts=""> |
64 | 82 | {shortcut.map((key) => {
|
65 |
| - return <kbd key={key}>{key}</kbd> |
| 83 | + return <kbd key={key}>{key}</kbd>; |
66 | 84 | })}
|
67 |
| - </div> |
| 85 | + </div> |
68 | 86 | </Command.Item>
|
69 |
| - ) |
| 87 | + ); |
70 | 88 | })}
|
71 |
| - </Command.List> |
| 89 | + </Command.List> |
72 | 90 | </Command.Group>
|
73 | 91 | </Command.Dialog>
|
74 | 92 | </div>
|
75 |
| - ) |
| 93 | + ); |
76 | 94 | }
|
77 | 95 |
|
78 | 96 | const navigationItems = [
|
| 97 | + { |
| 98 | + icon: <ConnectIntegrationIcon />, |
| 99 | + label: "Go to the providers page", |
| 100 | + shortcut: ["p"], |
| 101 | + navigate: "/providers", |
| 102 | + }, |
79 | 103 | {
|
80 | 104 | icon: <GoToConsoleIcon />,
|
81 |
| - label: 'Go to alert console', |
82 |
| - shortcut: ['G'], |
83 |
| - navigate: '/alerts' |
| 105 | + label: "Go to alert console", |
| 106 | + shortcut: ["g"], |
| 107 | + navigate: "/alerts", |
84 | 108 | },
|
85 | 109 | {
|
86 |
| - icon: <ConnectIntegrationIcon />, |
87 |
| - label: 'Go to the providers page', |
88 |
| - shortcut: ['P'], |
89 |
| - navigate: '/providers' |
| 110 | + icon: <BriefcaseIcon />, |
| 111 | + label: "Go to the workflows page", |
| 112 | + shortcut: ["wf"], |
| 113 | + navigate: "/workflows", |
| 114 | + }, |
| 115 | + { |
| 116 | + icon: <UserGroupIcon />, |
| 117 | + label: "Go to users management", |
| 118 | + shortcut: ["u"], |
| 119 | + navigate: "/settings", |
| 120 | + }, |
| 121 | + { |
| 122 | + icon: <GlobeAltIcon />, |
| 123 | + label: "Go to generic webhook", |
| 124 | + shortcut: ["w"], |
| 125 | + navigate: "/settings?selectedTab=webhook", |
| 126 | + }, |
| 127 | + { |
| 128 | + icon: <EnvelopeIcon />, |
| 129 | + label: "Go to SMTP settings", |
| 130 | + shortcut: ["s"], |
| 131 | + navigate: "/settings?selectedTab=smtp", |
90 | 132 | },
|
91 | 133 | {
|
92 |
| - icon: <CreateAlertIcon />, |
93 |
| - label: 'Go to alert workflow builder', |
94 |
| - shortcut: ['D'], |
95 |
| - navigate: '/workflows/builder' |
96 |
| - } |
97 |
| -] |
| 134 | + icon: <KeyIcon />, |
| 135 | + label: "Go to API key", |
| 136 | + shortcut: ["a"], |
| 137 | + navigate: "/settings?selectedTab=api-key", |
| 138 | + }, |
| 139 | +]; |
98 | 140 |
|
99 | 141 | const externalItems = [
|
100 |
| - { |
101 |
| - icon: <FileTextIcon />, |
102 |
| - label: 'Keep Docs', |
103 |
| - shortcut: ['⇧', 'D'], |
104 |
| - navigate: 'https://docs.keephq.dev' |
105 |
| - }, |
106 |
| - { |
107 |
| - icon: <GitHubLogoIcon />, |
108 |
| - label: 'Keep Source code', |
109 |
| - shortcut: ['⇧', 'C'], |
110 |
| - navigate: 'https://github.com/keephq/keep' |
111 |
| - }, |
112 |
| - { |
113 |
| - icon: <TwitterLogoIcon />, |
114 |
| - label: 'Keep Twitter', |
115 |
| - shortcut: ['⇧', 'T'], |
116 |
| - navigate: 'https://twitter.com/keepalerting' |
117 |
| - } |
118 |
| -] |
| 142 | + { |
| 143 | + icon: <FileTextIcon />, |
| 144 | + label: "Keep Docs", |
| 145 | + shortcut: ["⇧", "D"], |
| 146 | + navigate: "https://docs.keephq.dev", |
| 147 | + }, |
| 148 | + { |
| 149 | + icon: <GitHubLogoIcon />, |
| 150 | + label: "Keep Source code", |
| 151 | + shortcut: ["⇧", "C"], |
| 152 | + navigate: "https://github.com/keephq/keep", |
| 153 | + }, |
| 154 | + { |
| 155 | + icon: <TwitterLogoIcon />, |
| 156 | + label: "Keep Twitter", |
| 157 | + shortcut: ["⇧", "T"], |
| 158 | + navigate: "https://twitter.com/keepalerting", |
| 159 | + }, |
| 160 | +]; |
119 | 161 |
|
120 | 162 | function ConnectIntegrationIcon() {
|
121 | 163 | return (
|
122 |
| - <svg fill="#000000" width="800px" height="800px" viewBox="0 0 1920 1920" xmlns="http://www.w3.org/2000/svg"> |
123 |
| - <path d="M1581.235 734.118c0 217.976-177.317 395.294-395.294 395.294H960.06c-217.977 0-395.294-177.318-395.294-395.294V564.706h1016.47v169.412Zm225.883-282.353h-338.824V0h-112.941v451.765H790.647V0H677.706v451.765H338.882v112.94h112.942v169.413c0 280.207 228.028 508.235 508.235 508.235h56.47v395.294c0 93.402-76.009 169.412-169.411 169.412-93.403 0-169.412-76.01-169.412-169.412 0-155.633-126.72-282.353-282.353-282.353S113 1482.014 113 1637.647V1920h112.941v-282.353c0-93.402 76.01-169.412 169.412-169.412s169.412 76.01 169.412 169.412c0 155.633 126.72 282.353 282.353 282.353 155.746 0 282.353-126.72 282.353-282.353v-395.294h56.47c280.207 0 508.235-228.028 508.235-508.235V564.706h112.942V451.765Z" fill-rule="evenodd"/> |
124 |
| -</svg> |
125 |
| - ) |
| 164 | + <svg |
| 165 | + fill="#000000" |
| 166 | + width="800px" |
| 167 | + height="800px" |
| 168 | + viewBox="0 0 1920 1920" |
| 169 | + xmlns="http://www.w3.org/2000/svg" |
| 170 | + > |
| 171 | + <path |
| 172 | + d="M1581.235 734.118c0 217.976-177.317 395.294-395.294 395.294H960.06c-217.977 0-395.294-177.318-395.294-395.294V564.706h1016.47v169.412Zm225.883-282.353h-338.824V0h-112.941v451.765H790.647V0H677.706v451.765H338.882v112.94h112.942v169.413c0 280.207 228.028 508.235 508.235 508.235h56.47v395.294c0 93.402-76.009 169.412-169.411 169.412-93.403 0-169.412-76.01-169.412-169.412 0-155.633-126.72-282.353-282.353-282.353S113 1482.014 113 1637.647V1920h112.941v-282.353c0-93.402 76.01-169.412 169.412-169.412s169.412 76.01 169.412 169.412c0 155.633 126.72 282.353 282.353 282.353 155.746 0 282.353-126.72 282.353-282.353v-395.294h56.47c280.207 0 508.235-228.028 508.235-508.235V564.706h112.942V451.765Z" |
| 173 | + fill-rule="evenodd" |
| 174 | + /> |
| 175 | + </svg> |
| 176 | + ); |
126 | 177 | }
|
127 | 178 |
|
128 | 179 | function GoToConsoleIcon() {
|
129 | 180 | return (
|
130 |
| - <svg width="800px" height="800px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M5 6l2.702 2.5L5 11zm0 12l2.702-2.5L5 13zm5-9h10V8H10zm0 7h7v-1h-7zM1 3h22v18H1zm1 17h20V4H2z"/><path fill="none" d="M0 0h24v24H0z"/></svg> |
131 |
| - ) |
| 181 | + <svg |
| 182 | + width="800px" |
| 183 | + height="800px" |
| 184 | + viewBox="0 0 24 24" |
| 185 | + xmlns="http://www.w3.org/2000/svg" |
| 186 | + > |
| 187 | + <path d="M5 6l2.702 2.5L5 11zm0 12l2.702-2.5L5 13zm5-9h10V8H10zm0 7h7v-1h-7zM1 3h22v18H1zm1 17h20V4H2z" /> |
| 188 | + <path fill="none" d="M0 0h24v24H0z" /> |
| 189 | + </svg> |
| 190 | + ); |
132 | 191 | }
|
133 | 192 |
|
134 | 193 | function CreateAlertIcon() {
|
135 | 194 | return (
|
136 |
| - <svg xmlns="http://www.w3.org/2000/svg" fill="#000000" width="800px" height="800px" viewBox="0 0 24 24"><path d="M10.01 21.01c0 1.1.89 1.99 1.99 1.99s1.99-.89 1.99-1.99h-3.98zm8.87-4.19V11c0-3.25-2.25-5.97-5.29-6.69v-.72C13.59 2.71 12.88 2 12 2s-1.59.71-1.59 1.59v.72C7.37 5.03 5.12 7.75 5.12 11v5.82L3 18.94V20h18v-1.06l-2.12-2.12zM16 13.01h-3v3h-2v-3H8V11h3V8h2v3h3v2.01z"/></svg> |
137 |
| - ) |
| 195 | + <svg |
| 196 | + xmlns="http://www.w3.org/2000/svg" |
| 197 | + fill="#000000" |
| 198 | + width="800px" |
| 199 | + height="800px" |
| 200 | + viewBox="0 0 24 24" |
| 201 | + > |
| 202 | + <path d="M10.01 21.01c0 1.1.89 1.99 1.99 1.99s1.99-.89 1.99-1.99h-3.98zm8.87-4.19V11c0-3.25-2.25-5.97-5.29-6.69v-.72C13.59 2.71 12.88 2 12 2s-1.59.71-1.59 1.59v.72C7.37 5.03 5.12 7.75 5.12 11v5.82L3 18.94V20h18v-1.06l-2.12-2.12zM16 13.01h-3v3h-2v-3H8V11h3V8h2v3h3v2.01z" /> |
| 203 | + </svg> |
| 204 | + ); |
138 | 205 | }
|
139 | 206 |
|
140 | 207 | function GoToDashboardIcon() {
|
141 | 208 | return (
|
142 |
| - <svg fill="#000000" width="800px" height="800px" viewBox="0 0 1920 1920" xmlns="http://www.w3.org/2000/svg"> |
143 |
| - <path d="M833.935 1063.327c28.913 170.315 64.038 348.198 83.464 384.79 27.557 51.84 92.047 71.944 144 44.387 51.84-27.558 71.717-92.273 44.16-144.113-19.426-36.593-146.937-165.46-271.624-285.064Zm-43.821-196.405c61.553 56.923 370.899 344.81 415.285 428.612 56.696 106.842 15.811 239.887-91.144 296.697-32.64 17.28-67.765 25.411-102.325 25.411-78.72 0-154.955-42.353-194.371-116.555-44.386-83.802-109.102-501.346-121.638-584.245-3.501-23.717 8.245-47.21 29.365-58.277 21.346-11.294 47.096-8.02 64.828 8.357ZM960.045 281.99c529.355 0 960 430.757 960 960 0 77.139-8.922 153.148-26.654 225.882l-10.39 43.144h-524.386v-112.942h434.258c9.487-50.71 14.231-103.115 14.231-156.084 0-467.125-380.047-847.06-847.059-847.06-467.125 0-847.059 379.935-847.059 847.06 0 52.97 4.744 105.374 14.118 156.084h487.454v112.942H36.977l-10.39-43.144C8.966 1395.137.044 1319.128.044 1241.99c0-529.243 430.645-960 960-960Zm542.547 390.686 79.85 79.85-112.716 112.715-79.85-79.85 112.716-112.715Zm-1085.184 0L530.123 785.39l-79.85 79.85L337.56 752.524l79.849-79.85Zm599.063-201.363v159.473H903.529V471.312h112.942Z" fill-rule="evenodd"/> |
| 209 | + <svg |
| 210 | + fill="#000000" |
| 211 | + width="800px" |
| 212 | + height="800px" |
| 213 | + viewBox="0 0 1920 1920" |
| 214 | + xmlns="http://www.w3.org/2000/svg" |
| 215 | + > |
| 216 | + <path |
| 217 | + d="M833.935 1063.327c28.913 170.315 64.038 348.198 83.464 384.79 27.557 51.84 92.047 71.944 144 44.387 51.84-27.558 71.717-92.273 44.16-144.113-19.426-36.593-146.937-165.46-271.624-285.064Zm-43.821-196.405c61.553 56.923 370.899 344.81 415.285 428.612 56.696 106.842 15.811 239.887-91.144 296.697-32.64 17.28-67.765 25.411-102.325 25.411-78.72 0-154.955-42.353-194.371-116.555-44.386-83.802-109.102-501.346-121.638-584.245-3.501-23.717 8.245-47.21 29.365-58.277 21.346-11.294 47.096-8.02 64.828 8.357ZM960.045 281.99c529.355 0 960 430.757 960 960 0 77.139-8.922 153.148-26.654 225.882l-10.39 43.144h-524.386v-112.942h434.258c9.487-50.71 14.231-103.115 14.231-156.084 0-467.125-380.047-847.06-847.059-847.06-467.125 0-847.059 379.935-847.059 847.06 0 52.97 4.744 105.374 14.118 156.084h487.454v112.942H36.977l-10.39-43.144C8.966 1395.137.044 1319.128.044 1241.99c0-529.243 430.645-960 960-960Zm542.547 390.686 79.85 79.85-112.716 112.715-79.85-79.85 112.716-112.715Zm-1085.184 0L530.123 785.39l-79.85 79.85L337.56 752.524l79.849-79.85Zm599.063-201.363v159.473H903.529V471.312h112.942Z" |
| 218 | + fill-rule="evenodd" |
| 219 | + /> |
144 | 220 | </svg>
|
145 |
| - ) |
| 221 | + ); |
146 | 222 | }
|
0 commit comments