command pallet fixes and removing logs

This commit is contained in:
sriramveeraghanta 2023-08-10 16:30:41 +05:30
commit e325dc50ee
3 changed files with 49 additions and 41 deletions

View File

@ -23,8 +23,10 @@ import inboxService from "services/inbox.service";
import { INBOX_LIST, ISSUE_DETAILS } from "constants/fetch-keys"; import { INBOX_LIST, ISSUE_DETAILS } from "constants/fetch-keys";
// mobx store // mobx store
import { useMobxStore } from "lib/mobx/store-provider"; import { useMobxStore } from "lib/mobx/store-provider";
import { observable } from "mobx";
import { observer } from "mobx-react-lite";
export const CommandPalette: React.FC = () => { export const CommandPalette: React.FC = observer(() => {
const store: any = useMobxStore(); const store: any = useMobxStore();
const [isPaletteOpen, setIsPaletteOpen] = useState(false); const [isPaletteOpen, setIsPaletteOpen] = useState(false);
@ -76,45 +78,48 @@ export const CommandPalette: React.FC = () => {
(e: KeyboardEvent) => { (e: KeyboardEvent) => {
const { key, ctrlKey, metaKey, altKey, shiftKey } = e; const { key, ctrlKey, metaKey, altKey, shiftKey } = e;
if (!key) return; if (!key) return;
const keyPressed = key.toLowerCase(); const keyPressed = key.toLowerCase();
const cmdClicked = ctrlKey || metaKey; const cmdClicked = ctrlKey || metaKey;
// if on input, textarea or editor, don't do anything // if on input, textarea or editor, don't do anything
if ( if (
!(e.target instanceof HTMLTextAreaElement) && e.target instanceof HTMLTextAreaElement ||
!(e.target instanceof HTMLInputElement) && e.target instanceof HTMLInputElement ||
!(e.target as Element).classList?.contains("tiptap-editor-container") (e.target as Element).classList?.contains("ProseMirror")
) { )
if ((ctrlKey || metaKey) && keyPressed === "k") { return;
e.preventDefault();
setIsPaletteOpen(true); if (cmdClicked) {
} else if (keyPressed === "c" && altKey) { if (keyPressed === "k") {
e.preventDefault(); e.preventDefault();
copyIssueUrlToClipboard(); setIsPaletteOpen(true);
} else if (keyPressed === "b") { } else if (keyPressed === "c" && altKey) {
e.preventDefault(); e.preventDefault();
store.theme.setSidebarCollapsed(); copyIssueUrlToClipboard();
} else if (keyPressed === "backspace") { } else if (keyPressed === "b") {
console.log("KEYDOWN") e.preventDefault();
e.preventDefault(); store.theme.setSidebarCollapsed(!store?.theme?.sidebarCollapsed);
setIsBulkDeleteIssuesModalOpen(true); }
} else {
if (keyPressed === "c") {
setIsIssueModalOpen(true);
} else if (keyPressed === "p") {
setIsProjectModalOpen(true);
} else if (keyPressed === "v") {
setIsCreateViewModalOpen(true);
} else if (keyPressed === "d") {
setIsCreateUpdatePageModalOpen(true);
} else if (keyPressed === "h") {
setIsShortcutsModalOpen(true);
} else if (keyPressed === "q") {
setIsCreateCycleModalOpen(true);
} else if (keyPressed === "m") {
setIsCreateModuleModalOpen(true);
} else if (keyPressed === "backspace" || keyPressed === "delete") {
e.preventDefault();
setIsBulkDeleteIssuesModalOpen(true);
}
} }
} else {
if (keyPressed === "c") {
setIsIssueModalOpen(true);
} else if (keyPressed === "p") {
setIsProjectModalOpen(true);
} else if (keyPressed === "v") {
setIsCreateViewModalOpen(true);
} else if (keyPressed === "d") {
setIsCreateUpdatePageModalOpen(true);
} else if (keyPressed === "h") {
setIsShortcutsModalOpen(true);
} else if (keyPressed === "q") {
setIsCreateCycleModalOpen(true);
} else if (keyPressed === "m") {
setIsCreateModuleModalOpen(true);
}
}
}, },
[copyIssueUrlToClipboard] [copyIssueUrlToClipboard]
); );
@ -191,4 +196,4 @@ export const CommandPalette: React.FC = () => {
/> />
</> </>
); );
}; })

View File

@ -55,7 +55,7 @@ export const IssueDescriptionForm: FC<IssueDetailsProps> = ({
const handleDescriptionFormSubmit = useCallback( const handleDescriptionFormSubmit = useCallback(
async (formData: Partial<IIssue>) => { async (formData: Partial<IIssue>) => {
console.log("formdata", formData) // console.log("formdata", formData)
if (!formData?.name || formData?.name.length === 0 || formData?.name.length > 255) return; if (!formData?.name || formData?.name.length === 0 || formData?.name.length > 255) return;
await handleFormSubmit({ await handleFormSubmit({
@ -99,8 +99,9 @@ export const IssueDescriptionForm: FC<IssueDetailsProps> = ({
{characterLimit && ( {characterLimit && (
<div className="pointer-events-none absolute bottom-1 right-1 z-[2] rounded bg-custom-background-100 text-custom-text-200 p-0.5 text-xs"> <div className="pointer-events-none absolute bottom-1 right-1 z-[2] rounded bg-custom-background-100 text-custom-text-200 p-0.5 text-xs">
<span <span
className={`${watch("name").length === 0 || watch("name").length > 255 ? "text-red-500" : "" className={`${
}`} watch("name").length === 0 || watch("name").length > 255 ? "text-red-500" : ""
}`}
> >
{watch("name").length} {watch("name").length}
</span> </span>
@ -119,7 +120,9 @@ export const IssueDescriptionForm: FC<IssueDetailsProps> = ({
return ( return (
<Tiptap <Tiptap
value={ value={
!value || value === "" || (typeof value === "object" && Object.keys(value).length === 0) !value ||
value === "" ||
(typeof value === "object" && Object.keys(value).length === 0)
? watch("description_html") ? watch("description_html")
: value : value
} }

View File

@ -45,7 +45,7 @@ const defaultValues = {
const IssueDetailsPage: NextPage = () => { const IssueDetailsPage: NextPage = () => {
const router = useRouter(); const router = useRouter();
const { workspaceSlug, projectId, issueId } = router.query; const { workspaceSlug, projectId, issueId } = router.query;
console.log(workspaceSlug, "workspaceSlug") // console.log(workspaceSlug, "workspaceSlug")
const { user } = useUserAuth(); const { user } = useUserAuth();