Fix priority auto (#470)
* Make none as default priority for tasks and projects * fixup! Make none as default priority for tasks and projects
This commit is contained in:
parent
00eda4b936
commit
9807a4eea2
10 changed files with 315 additions and 31 deletions
2
.github/pull_request_template.md
vendored
2
.github/pull_request_template.md
vendored
|
|
@ -45,7 +45,7 @@ Fixes #
|
||||||
|
|
||||||
## Checklist
|
## Checklist
|
||||||
|
|
||||||
- [ ] This is not an AI slop crap0'/|, I know what I am doing
|
- [ ] This is not an AI slop crap, I know what I am doing
|
||||||
- [ ] Code follows project style guidelines
|
- [ ] Code follows project style guidelines
|
||||||
- [ ] Self-reviewed my own code
|
- [ ] Self-reviewed my own code
|
||||||
- [ ] Added/updated tests (if applicable)
|
- [ ] Added/updated tests (if applicable)
|
||||||
|
|
|
||||||
|
|
@ -1560,7 +1560,7 @@ router.post('/task', async (req, res) => {
|
||||||
? typeof priority === 'string'
|
? typeof priority === 'string'
|
||||||
? Task.getPriorityValue(priority)
|
? Task.getPriorityValue(priority)
|
||||||
: priority
|
: priority
|
||||||
: Task.PRIORITY.LOW,
|
: null,
|
||||||
due_date: processDueDateForStorage(
|
due_date: processDueDateForStorage(
|
||||||
due_date,
|
due_date,
|
||||||
getSafeTimezone(req.currentUser.timezone)
|
getSafeTimezone(req.currentUser.timezone)
|
||||||
|
|
|
||||||
261
e2e/tests/priority-defaults.spec.ts
Normal file
261
e2e/tests/priority-defaults.spec.ts
Normal file
|
|
@ -0,0 +1,261 @@
|
||||||
|
import { test, expect, Page } from '@playwright/test';
|
||||||
|
import {
|
||||||
|
login,
|
||||||
|
navigateAndWait,
|
||||||
|
waitForElement,
|
||||||
|
hoverAndWaitForVisible,
|
||||||
|
createUniqueEntity,
|
||||||
|
waitForNetworkIdle
|
||||||
|
} from '../helpers/testHelpers';
|
||||||
|
|
||||||
|
// Helper to create a task
|
||||||
|
async function createTask(page: Page, taskName: string) {
|
||||||
|
const taskInput = page.locator('[data-testid="new-task-input"]');
|
||||||
|
await taskInput.fill(taskName);
|
||||||
|
await taskInput.press('Enter');
|
||||||
|
await waitForNetworkIdle(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper to open task edit modal
|
||||||
|
async function openTaskEditModal(page: Page, taskName: string) {
|
||||||
|
const taskContainer = page.locator('[data-testid*="task-item"]').filter({ hasText: taskName });
|
||||||
|
await expect(taskContainer).toBeVisible({ timeout: 15000 });
|
||||||
|
|
||||||
|
const editButton = taskContainer.locator('[data-testid*="task-edit"]');
|
||||||
|
await hoverAndWaitForVisible(taskContainer, editButton);
|
||||||
|
|
||||||
|
await editButton.click();
|
||||||
|
|
||||||
|
const taskNameInput = page.locator('[data-testid="task-name-input"]');
|
||||||
|
await waitForElement(taskNameInput, { timeout: 15000 });
|
||||||
|
|
||||||
|
return taskNameInput;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper to create a project
|
||||||
|
async function createProject(page: Page, projectName: string) {
|
||||||
|
// Find the "Add Project" button in the sidebar
|
||||||
|
const addProjectButton = page.locator('button[aria-label="Add Project"]');
|
||||||
|
await expect(addProjectButton).toBeVisible();
|
||||||
|
|
||||||
|
// Click the Add Project button
|
||||||
|
await addProjectButton.click();
|
||||||
|
|
||||||
|
// Wait for the Project Modal to appear
|
||||||
|
await expect(page.locator('input[name="name"]')).toBeVisible({ timeout: 10000 });
|
||||||
|
|
||||||
|
// Fill in the project name
|
||||||
|
const nameInput = page.locator('[data-testid="project-name-input"]');
|
||||||
|
await nameInput.click();
|
||||||
|
await nameInput.clear();
|
||||||
|
await nameInput.fill(projectName);
|
||||||
|
|
||||||
|
// Verify the field has the expected value
|
||||||
|
await expect(nameInput).toHaveValue(projectName, { timeout: 2000 });
|
||||||
|
|
||||||
|
// Wait for the save button to be enabled
|
||||||
|
const saveButton = page.locator('[data-testid="project-save-button"]');
|
||||||
|
await expect(saveButton).toBeEnabled();
|
||||||
|
|
||||||
|
// Save the project
|
||||||
|
await saveButton.click();
|
||||||
|
|
||||||
|
// Wait for modal to close
|
||||||
|
await expect(page.locator('[data-testid="project-modal"]')).not.toBeVisible({ timeout: 15000 });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper to open project edit modal
|
||||||
|
async function openProjectEditModal(page: Page, projectName: string) {
|
||||||
|
// Click on the project in the projects list
|
||||||
|
const projectCard = page.locator('[data-testid*="project-card"]').filter({ hasText: projectName });
|
||||||
|
await expect(projectCard).toBeVisible({ timeout: 15000 });
|
||||||
|
|
||||||
|
// Click the edit button
|
||||||
|
const editButton = projectCard.locator('[data-testid*="project-edit"]');
|
||||||
|
await expect(editButton).toBeVisible();
|
||||||
|
await editButton.click();
|
||||||
|
|
||||||
|
// Wait for modal to open
|
||||||
|
const nameInput = page.locator('[data-testid="project-name-input"]');
|
||||||
|
await waitForElement(nameInput, { timeout: 15000 });
|
||||||
|
|
||||||
|
return nameInput;
|
||||||
|
}
|
||||||
|
|
||||||
|
test('task created without priority selection defaults to None', async ({ page, baseURL }) => {
|
||||||
|
const appUrl = await login(page, baseURL);
|
||||||
|
|
||||||
|
await navigateAndWait(page, appUrl + '/tasks');
|
||||||
|
|
||||||
|
// Create a task without setting any priority
|
||||||
|
const taskName = createUniqueEntity('Default Priority Task');
|
||||||
|
await createTask(page, taskName);
|
||||||
|
|
||||||
|
// Open the task edit modal
|
||||||
|
await openTaskEditModal(page, taskName);
|
||||||
|
|
||||||
|
// Wait for modal to be in idle state
|
||||||
|
await expect(page.locator('[data-testid="task-modal"][data-state="idle"]')).toBeVisible();
|
||||||
|
|
||||||
|
// Click the priority section icon to expand the priority section
|
||||||
|
const prioritySectionButton = page.locator('button[title*="Priority"]').filter({ has: page.locator('svg') });
|
||||||
|
await prioritySectionButton.click();
|
||||||
|
|
||||||
|
// Wait for priority section to be expanded
|
||||||
|
await expect(page.locator('[data-testid="priority-section"][data-state="expanded"]')).toBeVisible();
|
||||||
|
|
||||||
|
// Check that the priority dropdown shows "None"
|
||||||
|
const priorityDropdown = page.locator('[data-testid="priority-dropdown"]');
|
||||||
|
await expect(priorityDropdown).toBeVisible();
|
||||||
|
|
||||||
|
// The dropdown should contain "None" text
|
||||||
|
await expect(priorityDropdown).toContainText(/none/i);
|
||||||
|
|
||||||
|
// Close modal without saving
|
||||||
|
await page.keyboard.press('Escape');
|
||||||
|
await expect(page.locator('[data-testid="task-modal"]')).not.toBeVisible({ timeout: 5000 });
|
||||||
|
});
|
||||||
|
|
||||||
|
test('project created without priority selection defaults to None', async ({ page, baseURL }) => {
|
||||||
|
const appUrl = await login(page, baseURL);
|
||||||
|
|
||||||
|
await navigateAndWait(page, appUrl + '/projects');
|
||||||
|
|
||||||
|
// Click the "Add Project" button
|
||||||
|
const addProjectButton = page.locator('button[aria-label="Add Project"]');
|
||||||
|
await expect(addProjectButton).toBeVisible();
|
||||||
|
await addProjectButton.click();
|
||||||
|
|
||||||
|
// Wait for the Project Modal to appear
|
||||||
|
await expect(page.locator('[data-testid="project-modal"]')).toBeVisible({ timeout: 10000 });
|
||||||
|
|
||||||
|
// Fill in the project name
|
||||||
|
const projectName = createUniqueEntity('Default Priority Project');
|
||||||
|
const nameInput = page.locator('[data-testid="project-name-input"]');
|
||||||
|
await nameInput.fill(projectName);
|
||||||
|
|
||||||
|
// Click the priority section icon to expand the priority section
|
||||||
|
const prioritySectionButton = page.locator('button[title*="Priority"]').filter({ has: page.locator('svg') });
|
||||||
|
await expect(prioritySectionButton).toBeVisible();
|
||||||
|
await prioritySectionButton.click();
|
||||||
|
|
||||||
|
// Wait for priority section to be expanded
|
||||||
|
await page.waitForTimeout(300);
|
||||||
|
|
||||||
|
// Check that the priority dropdown shows "None"
|
||||||
|
const priorityDropdown = page.locator('[data-testid="priority-dropdown"]');
|
||||||
|
await expect(priorityDropdown).toBeVisible();
|
||||||
|
|
||||||
|
// The dropdown should contain "None" text
|
||||||
|
await expect(priorityDropdown).toContainText(/none/i);
|
||||||
|
|
||||||
|
// Close modal without saving
|
||||||
|
await page.keyboard.press('Escape');
|
||||||
|
await expect(page.locator('[data-testid="project-modal"]')).not.toBeVisible({ timeout: 5000 });
|
||||||
|
});
|
||||||
|
|
||||||
|
test('task priority can be set to None after being set to High', async ({ page, baseURL }) => {
|
||||||
|
const appUrl = await login(page, baseURL);
|
||||||
|
|
||||||
|
await navigateAndWait(page, appUrl + '/tasks');
|
||||||
|
|
||||||
|
// Create a task
|
||||||
|
const taskName = createUniqueEntity('Priority Clear Task');
|
||||||
|
await createTask(page, taskName);
|
||||||
|
|
||||||
|
// Open the task edit modal
|
||||||
|
await openTaskEditModal(page, taskName);
|
||||||
|
|
||||||
|
// Wait for modal to be in idle state
|
||||||
|
await expect(page.locator('[data-testid="task-modal"][data-state="idle"]')).toBeVisible();
|
||||||
|
|
||||||
|
// Expand priority section
|
||||||
|
const prioritySectionButton = page.locator('button[title*="Priority"]').filter({ has: page.locator('svg') });
|
||||||
|
await prioritySectionButton.click();
|
||||||
|
await expect(page.locator('[data-testid="priority-section"][data-state="expanded"]')).toBeVisible();
|
||||||
|
|
||||||
|
// Set priority to High
|
||||||
|
const priorityDropdown = page.locator('[data-testid="priority-dropdown"]');
|
||||||
|
await priorityDropdown.click();
|
||||||
|
await expect(page.locator('[data-testid="priority-dropdown"][data-state="open"]')).toBeVisible();
|
||||||
|
|
||||||
|
const highPriorityOption = page.locator('[data-testid="priority-option-high"]');
|
||||||
|
await expect(highPriorityOption).toBeVisible();
|
||||||
|
await highPriorityOption.click();
|
||||||
|
|
||||||
|
await expect(page.locator('[data-testid="priority-dropdown"][data-state="closed"]')).toBeVisible();
|
||||||
|
|
||||||
|
// Verify High is selected
|
||||||
|
await expect(priorityDropdown).toContainText(/high/i);
|
||||||
|
|
||||||
|
// Now clear the priority by selecting None
|
||||||
|
await priorityDropdown.click();
|
||||||
|
await expect(page.locator('[data-testid="priority-dropdown"][data-state="open"]')).toBeVisible();
|
||||||
|
|
||||||
|
const nonePriorityOption = page.locator('[data-testid="priority-option-none"]');
|
||||||
|
await expect(nonePriorityOption).toBeVisible();
|
||||||
|
await nonePriorityOption.click();
|
||||||
|
|
||||||
|
await expect(page.locator('[data-testid="priority-dropdown"][data-state="closed"]')).toBeVisible();
|
||||||
|
|
||||||
|
// Verify None is now selected
|
||||||
|
await expect(priorityDropdown).toContainText(/none/i);
|
||||||
|
|
||||||
|
// Close modal without saving
|
||||||
|
await page.keyboard.press('Escape');
|
||||||
|
await expect(page.locator('[data-testid="task-modal"]')).not.toBeVisible({ timeout: 5000 });
|
||||||
|
});
|
||||||
|
|
||||||
|
test('project priority can be set to None after being set to Medium', async ({ page, baseURL }) => {
|
||||||
|
const appUrl = await login(page, baseURL);
|
||||||
|
|
||||||
|
await navigateAndWait(page, appUrl + '/projects');
|
||||||
|
|
||||||
|
// Click the "Add Project" button
|
||||||
|
const addProjectButton = page.locator('button[aria-label="Add Project"]');
|
||||||
|
await expect(addProjectButton).toBeVisible();
|
||||||
|
await addProjectButton.click();
|
||||||
|
|
||||||
|
// Wait for the Project Modal to appear
|
||||||
|
await expect(page.locator('[data-testid="project-modal"]')).toBeVisible({ timeout: 10000 });
|
||||||
|
|
||||||
|
// Fill in the project name
|
||||||
|
const projectName = createUniqueEntity('Priority Clear Project');
|
||||||
|
const nameInput = page.locator('[data-testid="project-name-input"]');
|
||||||
|
await nameInput.fill(projectName);
|
||||||
|
|
||||||
|
// Expand priority section
|
||||||
|
const prioritySectionButton = page.locator('button[title*="Priority"]').filter({ has: page.locator('svg') });
|
||||||
|
await expect(prioritySectionButton).toBeVisible();
|
||||||
|
await prioritySectionButton.click();
|
||||||
|
await page.waitForTimeout(300);
|
||||||
|
|
||||||
|
// Set priority to Medium
|
||||||
|
const priorityDropdown = page.locator('[data-testid="priority-dropdown"]');
|
||||||
|
await priorityDropdown.click();
|
||||||
|
await page.waitForTimeout(200);
|
||||||
|
|
||||||
|
const mediumPriorityOption = page.locator('[data-testid="priority-option-medium"]');
|
||||||
|
await expect(mediumPriorityOption).toBeVisible();
|
||||||
|
await mediumPriorityOption.click();
|
||||||
|
await page.waitForTimeout(200);
|
||||||
|
|
||||||
|
// Verify Medium is selected
|
||||||
|
await expect(priorityDropdown).toContainText(/medium/i);
|
||||||
|
|
||||||
|
// Now clear the priority by selecting None
|
||||||
|
await priorityDropdown.click();
|
||||||
|
await page.waitForTimeout(200);
|
||||||
|
|
||||||
|
const nonePriorityOption = page.locator('[data-testid="priority-option-none"]');
|
||||||
|
await expect(nonePriorityOption).toBeVisible();
|
||||||
|
await nonePriorityOption.click();
|
||||||
|
await page.waitForTimeout(200);
|
||||||
|
|
||||||
|
// Verify None is now selected
|
||||||
|
await expect(priorityDropdown).toContainText(/none/i);
|
||||||
|
|
||||||
|
// Close modal without saving
|
||||||
|
await page.keyboard.press('Escape');
|
||||||
|
await expect(page.locator('[data-testid="project-modal"]')).not.toBeVisible({ timeout: 5000 });
|
||||||
|
});
|
||||||
|
|
@ -55,7 +55,7 @@ test('user can set task priority to high', async ({ page, baseURL }) => {
|
||||||
await expect(page.locator('[data-testid="priority-section"][data-state="expanded"]')).toBeVisible();
|
await expect(page.locator('[data-testid="priority-section"][data-state="expanded"]')).toBeVisible();
|
||||||
|
|
||||||
// Wait for priority dropdown to be ready, then click it
|
// Wait for priority dropdown to be ready, then click it
|
||||||
const priorityDropdown = page.locator('.inline-flex.justify-between').filter({ hasText: /low|medium|high/i }).first();
|
const priorityDropdown = page.locator('[data-testid="priority-dropdown"]');
|
||||||
await expect(priorityDropdown).toBeVisible();
|
await expect(priorityDropdown).toBeVisible();
|
||||||
await priorityDropdown.click();
|
await priorityDropdown.click();
|
||||||
|
|
||||||
|
|
@ -63,7 +63,7 @@ test('user can set task priority to high', async ({ page, baseURL }) => {
|
||||||
await expect(page.locator('[data-testid="priority-dropdown"][data-state="open"]')).toBeVisible();
|
await expect(page.locator('[data-testid="priority-dropdown"][data-state="open"]')).toBeVisible();
|
||||||
|
|
||||||
// Select "High" priority from the portal dropdown
|
// Select "High" priority from the portal dropdown
|
||||||
const highPriorityOption = page.locator('button').filter({ hasText: /high/i }).first();
|
const highPriorityOption = page.locator('[data-testid="priority-option-high"]');
|
||||||
await expect(highPriorityOption).toBeVisible();
|
await expect(highPriorityOption).toBeVisible();
|
||||||
await highPriorityOption.click();
|
await highPriorityOption.click();
|
||||||
|
|
||||||
|
|
@ -103,12 +103,12 @@ test('user can set task priority to medium and low', async ({ page, baseURL }) =
|
||||||
await expect(page.locator('[data-testid="priority-section"][data-state="expanded"]')).toBeVisible();
|
await expect(page.locator('[data-testid="priority-section"][data-state="expanded"]')).toBeVisible();
|
||||||
|
|
||||||
// Set to medium priority
|
// Set to medium priority
|
||||||
const priorityDropdown = page.locator('.inline-flex.justify-between').filter({ hasText: /low|medium|high/i }).first();
|
const priorityDropdown = page.locator('[data-testid="priority-dropdown"]');
|
||||||
await expect(priorityDropdown).toBeVisible();
|
await expect(priorityDropdown).toBeVisible();
|
||||||
await priorityDropdown.click();
|
await priorityDropdown.click();
|
||||||
await expect(page.locator('[data-testid="priority-dropdown"][data-state="open"]')).toBeVisible();
|
await expect(page.locator('[data-testid="priority-dropdown"][data-state="open"]')).toBeVisible();
|
||||||
|
|
||||||
const mediumPriorityOption = page.locator('button').filter({ hasText: /medium/i }).first();
|
const mediumPriorityOption = page.locator('[data-testid="priority-option-medium"]');
|
||||||
await expect(mediumPriorityOption).toBeVisible();
|
await expect(mediumPriorityOption).toBeVisible();
|
||||||
await mediumPriorityOption.click();
|
await mediumPriorityOption.click();
|
||||||
await expect(page.locator('[data-testid="priority-dropdown"][data-state="closed"]')).toBeVisible();
|
await expect(page.locator('[data-testid="priority-dropdown"][data-state="closed"]')).toBeVisible();
|
||||||
|
|
@ -127,7 +127,7 @@ test('user can set task priority to medium and low', async ({ page, baseURL }) =
|
||||||
await expect(page.locator('[data-testid="task-modal"][data-state="idle"]')).toBeVisible();
|
await expect(page.locator('[data-testid="task-modal"][data-state="idle"]')).toBeVisible();
|
||||||
|
|
||||||
// Check if priority section is already expanded (it should be for non-default priority)
|
// Check if priority section is already expanded (it should be for non-default priority)
|
||||||
const priorityDropdown2 = page.locator('.inline-flex.justify-between').filter({ hasText: /low|medium|high/i }).first();
|
const priorityDropdown2 = page.locator('[data-testid="priority-dropdown"]');
|
||||||
const isAlreadyExpanded = await priorityDropdown2.isVisible().catch(() => false);
|
const isAlreadyExpanded = await priorityDropdown2.isVisible().catch(() => false);
|
||||||
|
|
||||||
if (!isAlreadyExpanded) {
|
if (!isAlreadyExpanded) {
|
||||||
|
|
@ -140,7 +140,7 @@ test('user can set task priority to medium and low', async ({ page, baseURL }) =
|
||||||
await priorityDropdown2.click();
|
await priorityDropdown2.click();
|
||||||
await expect(page.locator('[data-testid="priority-dropdown"][data-state="open"]')).toBeVisible();
|
await expect(page.locator('[data-testid="priority-dropdown"][data-state="open"]')).toBeVisible();
|
||||||
|
|
||||||
const lowPriorityOption = page.locator('button').filter({ hasText: /low/i }).first();
|
const lowPriorityOption = page.locator('[data-testid="priority-option-low"]');
|
||||||
await expect(lowPriorityOption).toBeVisible();
|
await expect(lowPriorityOption).toBeVisible();
|
||||||
await lowPriorityOption.click();
|
await lowPriorityOption.click();
|
||||||
await expect(page.locator('[data-testid="priority-dropdown"][data-state="closed"]')).toBeVisible();
|
await expect(page.locator('[data-testid="priority-dropdown"][data-state="closed"]')).toBeVisible();
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ const ProjectModal: React.FC<ProjectModalProps> = ({
|
||||||
area_id: null,
|
area_id: null,
|
||||||
state: 'idea',
|
state: 'idea',
|
||||||
tags: [],
|
tags: [],
|
||||||
priority: 'low',
|
priority: null,
|
||||||
due_date_at: null,
|
due_date_at: null,
|
||||||
image_url: '',
|
image_url: '',
|
||||||
}
|
}
|
||||||
|
|
@ -139,7 +139,7 @@ const ProjectModal: React.FC<ProjectModalProps> = ({
|
||||||
area_id: null,
|
area_id: null,
|
||||||
state: 'idea',
|
state: 'idea',
|
||||||
tags: [],
|
tags: [],
|
||||||
priority: 'low',
|
priority: null,
|
||||||
due_date_at: null,
|
due_date_at: null,
|
||||||
image_url: '',
|
image_url: '',
|
||||||
});
|
});
|
||||||
|
|
@ -688,8 +688,8 @@ const ProjectModal: React.FC<ProjectModalProps> = ({
|
||||||
</h3>
|
</h3>
|
||||||
<PriorityDropdown
|
<PriorityDropdown
|
||||||
value={
|
value={
|
||||||
formData.priority ||
|
formData.priority ??
|
||||||
'medium'
|
null
|
||||||
}
|
}
|
||||||
onChange={(
|
onChange={(
|
||||||
value: PriorityType
|
value: PriorityType
|
||||||
|
|
@ -836,7 +836,7 @@ const ProjectModal: React.FC<ProjectModalProps> = ({
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<ExclamationTriangleIcon className="h-5 w-5" />
|
<ExclamationTriangleIcon className="h-5 w-5" />
|
||||||
{formData.priority !== 'medium' && (
|
{formData.priority != null && (
|
||||||
<span className="absolute -top-1 -right-1 w-3 h-3 bg-green-500 rounded-full"></span>
|
<span className="absolute -top-1 -right-1 w-3 h-3 bg-green-500 rounded-full"></span>
|
||||||
)}
|
)}
|
||||||
</button>
|
</button>
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import {
|
||||||
ArrowDownIcon,
|
ArrowDownIcon,
|
||||||
ArrowUpIcon,
|
ArrowUpIcon,
|
||||||
FireIcon,
|
FireIcon,
|
||||||
|
XMarkIcon,
|
||||||
} from '@heroicons/react/24/outline';
|
} from '@heroicons/react/24/outline';
|
||||||
import { PriorityType } from '../../entities/Task';
|
import { PriorityType } from '../../entities/Task';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
@ -21,6 +22,13 @@ const PriorityDropdown: React.FC<PriorityDropdownProps> = ({
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const priorities = [
|
const priorities = [
|
||||||
|
{
|
||||||
|
value: null,
|
||||||
|
label: t('priority.none', 'None'),
|
||||||
|
icon: (
|
||||||
|
<XMarkIcon className="w-5 h-5 text-gray-400 dark:text-gray-500" />
|
||||||
|
),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
value: 'low',
|
value: 'low',
|
||||||
label: t('priority.low', 'Low'),
|
label: t('priority.low', 'Low'),
|
||||||
|
|
@ -102,13 +110,14 @@ const PriorityDropdown: React.FC<PriorityDropdownProps> = ({
|
||||||
}, [isOpen]);
|
}, [isOpen]);
|
||||||
|
|
||||||
// Convert numeric priority to string if needed
|
// Convert numeric priority to string if needed
|
||||||
|
// Don't default to any value - allow null/undefined
|
||||||
const normalizedValue =
|
const normalizedValue =
|
||||||
typeof value === 'number'
|
typeof value === 'number'
|
||||||
? ['low', 'medium', 'high'][value] || 'medium'
|
? (['low', 'medium', 'high'][value] as PriorityType)
|
||||||
: value;
|
: value;
|
||||||
|
|
||||||
const selectedPriority = priorities.find(
|
const selectedPriority = priorities.find(
|
||||||
(p) => p.value === normalizedValue
|
(p) => p.value === (normalizedValue || null)
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -152,6 +161,7 @@ const PriorityDropdown: React.FC<PriorityDropdownProps> = ({
|
||||||
handleSelect(priority.value as PriorityType)
|
handleSelect(priority.value as PriorityType)
|
||||||
}
|
}
|
||||||
className="flex items-center justify-between px-4 py-2 text-sm text-gray-900 dark:text-gray-100 hover:bg-gray-100 dark:hover:bg-gray-600 w-full first:rounded-t-md last:rounded-b-md"
|
className="flex items-center justify-between px-4 py-2 text-sm text-gray-900 dark:text-gray-100 hover:bg-gray-100 dark:hover:bg-gray-600 w-full first:rounded-t-md last:rounded-b-md"
|
||||||
|
data-testid={`priority-option-${priority.value || 'none'}`}
|
||||||
>
|
>
|
||||||
<span className="flex items-center space-x-2">
|
<span className="flex items-center space-x-2">
|
||||||
{priority.icon}{' '}
|
{priority.icon}{' '}
|
||||||
|
|
|
||||||
|
|
@ -270,10 +270,14 @@ const TaskModal: React.FC<TaskModalProps> = ({
|
||||||
priority: PriorityType | number | undefined
|
priority: PriorityType | number | undefined
|
||||||
): PriorityType => {
|
): PriorityType => {
|
||||||
if (typeof priority === 'number') {
|
if (typeof priority === 'number') {
|
||||||
const priorityNames: PriorityType[] = ['low', 'medium', 'high'];
|
const priorityNames: ('low' | 'medium' | 'high')[] = [
|
||||||
return priorityNames[priority] || 'low';
|
'low',
|
||||||
|
'medium',
|
||||||
|
'high',
|
||||||
|
];
|
||||||
|
return priorityNames[priority] || null;
|
||||||
}
|
}
|
||||||
return priority || 'low';
|
return priority ?? null;
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleChange = (
|
const handleChange = (
|
||||||
|
|
@ -820,9 +824,7 @@ const TaskModal: React.FC<TaskModalProps> = ({
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<ExclamationTriangleIcon className="h-5 w-5" />
|
<ExclamationTriangleIcon className="h-5 w-5" />
|
||||||
{getPriorityString(
|
{formData.priority != null && (
|
||||||
formData.priority
|
|
||||||
) !== 'medium' && (
|
|
||||||
<span className="absolute -top-1 -right-1 w-3 h-3 bg-green-500 rounded-full"></span>
|
<span className="absolute -top-1 -right-1 w-3 h-3 bg-green-500 rounded-full"></span>
|
||||||
)}
|
)}
|
||||||
</button>
|
</button>
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ const TaskPriorityIcon: React.FC<TaskPriorityIconProps> = ({
|
||||||
let priorityStr = priority;
|
let priorityStr = priority;
|
||||||
if (typeof priority === 'number') {
|
if (typeof priority === 'number') {
|
||||||
const priorityNames = ['low', 'medium', 'high'];
|
const priorityNames = ['low', 'medium', 'high'];
|
||||||
priorityStr = priorityNames[priority] || 'low';
|
priorityStr = priorityNames[priority];
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (priorityStr) {
|
switch (priorityStr) {
|
||||||
|
|
@ -31,8 +31,13 @@ const TaskPriorityIcon: React.FC<TaskPriorityIconProps> = ({
|
||||||
return 'Medium priority';
|
return 'Medium priority';
|
||||||
case 'low':
|
case 'low':
|
||||||
case 0:
|
case 0:
|
||||||
default:
|
|
||||||
return 'Low priority';
|
return 'Low priority';
|
||||||
|
case null:
|
||||||
|
case undefined:
|
||||||
|
case '':
|
||||||
|
return ''; // No priority set
|
||||||
|
default:
|
||||||
|
return ''; // Default to no priority text
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -49,7 +54,7 @@ const TaskPriorityIcon: React.FC<TaskPriorityIconProps> = ({
|
||||||
let priorityStr = priority;
|
let priorityStr = priority;
|
||||||
if (typeof priority === 'number') {
|
if (typeof priority === 'number') {
|
||||||
const priorityNames = ['low', 'medium', 'high'];
|
const priorityNames = ['low', 'medium', 'high'];
|
||||||
priorityStr = priorityNames[priority] || 'low';
|
priorityStr = priorityNames[priority];
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (priorityStr) {
|
switch (priorityStr) {
|
||||||
|
|
@ -61,12 +66,17 @@ const TaskPriorityIcon: React.FC<TaskPriorityIconProps> = ({
|
||||||
return 'text-yellow-500';
|
return 'text-yellow-500';
|
||||||
case 'low':
|
case 'low':
|
||||||
case 0:
|
case 0:
|
||||||
default:
|
|
||||||
return 'text-gray-300';
|
return 'text-gray-300';
|
||||||
|
case null:
|
||||||
|
case undefined:
|
||||||
|
case '':
|
||||||
|
default:
|
||||||
|
return 'text-gray-300'; // No priority - use gray
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const colorClass = getIconColor();
|
const colorClass = getIconColor();
|
||||||
|
const priorityText = getPriorityText();
|
||||||
|
|
||||||
const handleClick = (e: React.MouseEvent) => {
|
const handleClick = (e: React.MouseEvent) => {
|
||||||
e.stopPropagation(); // Prevent triggering TaskHeader onClick
|
e.stopPropagation(); // Prevent triggering TaskHeader onClick
|
||||||
|
|
@ -89,7 +99,7 @@ const TaskPriorityIcon: React.FC<TaskPriorityIconProps> = ({
|
||||||
marginRight: '-2px',
|
marginRight: '-2px',
|
||||||
}}
|
}}
|
||||||
onClick={handleClick}
|
onClick={handleClick}
|
||||||
title={getPriorityText()}
|
{...(priorityText && { title: priorityText })}
|
||||||
role="checkbox"
|
role="checkbox"
|
||||||
aria-checked="true"
|
aria-checked="true"
|
||||||
data-testid={`task-completion-checkbox${testIdSuffix}`}
|
data-testid={`task-completion-checkbox${testIdSuffix}`}
|
||||||
|
|
@ -100,7 +110,7 @@ const TaskPriorityIcon: React.FC<TaskPriorityIconProps> = ({
|
||||||
<div
|
<div
|
||||||
className={`${colorClass} cursor-pointer border-2 border-current rounded-full flex-shrink-0 transition-all duration-300 ease-in-out hover:border-green-500 hover:bg-green-50 dark:hover:bg-green-900/20 w-5 h-5 md:w-4 md:h-4`}
|
className={`${colorClass} cursor-pointer border-2 border-current rounded-full flex-shrink-0 transition-all duration-300 ease-in-out hover:border-green-500 hover:bg-green-50 dark:hover:bg-green-900/20 w-5 h-5 md:w-4 md:h-4`}
|
||||||
onClick={handleClick}
|
onClick={handleClick}
|
||||||
title={getPriorityText()}
|
{...(priorityText && { title: priorityText })}
|
||||||
role="checkbox"
|
role="checkbox"
|
||||||
aria-checked="false"
|
aria-checked="false"
|
||||||
data-testid={`task-completion-checkbox${testIdSuffix}`}
|
data-testid={`task-completion-checkbox${testIdSuffix}`}
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ export type StatusType =
|
||||||
| 'done'
|
| 'done'
|
||||||
| 'archived'
|
| 'archived'
|
||||||
| 'waiting';
|
| 'waiting';
|
||||||
export type PriorityType = 'low' | 'medium' | 'high';
|
export type PriorityType = 'low' | 'medium' | 'high' | null | undefined;
|
||||||
export type RecurrenceType =
|
export type RecurrenceType =
|
||||||
| 'none'
|
| 'none'
|
||||||
| 'daily'
|
| 'daily'
|
||||||
|
|
|
||||||
|
|
@ -469,9 +469,10 @@
|
||||||
"created_at": "Created At"
|
"created_at": "Created At"
|
||||||
},
|
},
|
||||||
"priority": {
|
"priority": {
|
||||||
"low": "low",
|
"none": "None",
|
||||||
"medium": "medium",
|
"low": "Low",
|
||||||
"high": "high"
|
"medium": "Medium",
|
||||||
|
"high": "High"
|
||||||
},
|
},
|
||||||
"status": {
|
"status": {
|
||||||
"notStarted": "Not Started",
|
"notStarted": "Not Started",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue