Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions frontend/src/pages/ApplicationsPage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { useMemo, useState, type FormEvent } from 'react';

import { useEffect, useMemo, useState } from 'react';
import { useNavigate } from 'react-router-dom';

import { ApplicationForm } from '@/components/forms/ApplicationForm';
Expand Down Expand Up @@ -43,6 +45,22 @@ export function ApplicationsPage() {
const [importUrl, setImportUrl] = useState('');
const [importError, setImportError] = useState<string | null>(null);

// Keyboard shortcut: press 'n' to open the add-application modal
// (only when no input/textarea is focused)
useEffect(() => {
const onKeyDown = (e: KeyboardEvent) => {
if (e.key !== 'n') return;
const el = document.activeElement;
if (el && (el.tagName === 'INPUT' || el.tagName === 'TEXTAREA' || (el as HTMLElement).isContentEditable)) {
return;
}
e.preventDefault();
setCreating(true);
};
window.addEventListener('keydown', onKeyDown);
return () => window.removeEventListener('keydown', onKeyDown);
}, []);

const { data, isLoading, isError, refetch } = useApplications({
q: debouncedSearch || undefined,
page_size: 100,
Expand Down