refactor: replace keyboard events with command palette store (#2688)

This commit is contained in:
Aaryan Khandelwal 2023-11-08 13:51:55 +05:30 committed by GitHub
parent 53e7da08e4
commit 5a84ed279d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 219 additions and 344 deletions

View file

@ -1,8 +1,11 @@
import { FC } from "react";
// types
import { ICycle } from "types";
import { observer } from "mobx-react-lite";
// mobx store
import { useMobxStore } from "lib/mobx/store-provider";
// components
import { CyclePeekOverview, CyclesBoardCard } from "components/cycles";
// types
import { ICycle } from "types";
export interface ICyclesBoard {
cycles: ICycle[];
@ -12,9 +15,11 @@ export interface ICyclesBoard {
peekCycle: string;
}
export const CyclesBoard: FC<ICyclesBoard> = (props) => {
export const CyclesBoard: FC<ICyclesBoard> = observer((props) => {
const { cycles, filter, workspaceSlug, projectId, peekCycle } = props;
const { commandPalette: commandPaletteStore } = useMobxStore();
return (
<>
{cycles.length > 0 ? (
@ -53,12 +58,7 @@ export const CyclesBoard: FC<ICyclesBoard> = (props) => {
<button
type="button"
className="text-custom-primary-100 text-sm outline-none"
onClick={() => {
const e = new KeyboardEvent("keydown", {
key: "q",
});
document.dispatchEvent(e);
}}
onClick={() => commandPaletteStore.toggleCreateCycleModal(true)}
>
Create a new cycle
</button>
@ -67,4 +67,4 @@ export const CyclesBoard: FC<ICyclesBoard> = (props) => {
)}
</>
);
};
});