@tuturuuu/ui 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +69 -0
- package/biome.json +1 -1
- package/package.json +74 -71
- package/src/components/ui/accordion.tsx +1 -1
- package/src/components/ui/breadcrumb.tsx +1 -1
- package/src/components/ui/calendar-app/calendar-page-shell.tsx +4 -0
- package/src/components/ui/calendar-app/components/calendar-connections-settings-content.tsx +239 -33
- package/src/components/ui/calendar-app/components/load-smart-scheduling-tasks.tsx +143 -0
- package/src/components/ui/calendar-app/components/priority-view.tsx +10 -3
- package/src/components/ui/calendar-app/components/tasks-sidebar.tsx +4 -116
- package/src/components/ui/calendar-app/components/use-calendar-connections-manager.ts +67 -2
- package/src/components/ui/calendar.tsx +1 -1
- package/src/components/ui/carousel.tsx +1 -1
- package/src/components/ui/chat/chat-agent-details-external-thread-panel.test.tsx +1 -1
- package/src/components/ui/chat/chat-agent-details-external-thread-panel.tsx +1 -1
- package/src/components/ui/chat/chat-agent-details-operations-panel.test.tsx +1 -1
- package/src/components/ui/chat/chat-agent-details-operations-panel.tsx +1 -1
- package/src/components/ui/chat/chat-agent-details-setup-panel.tsx +1 -1
- package/src/components/ui/chat/chat-agent-details-sidebar.test.tsx +1 -1
- package/src/components/ui/chat/chat-agent-details-sidebar.tsx +2 -2
- package/src/components/ui/chat/chat-agent-details-utils.test.ts +1 -1
- package/src/components/ui/chat/chat-agent-details-utils.tsx +1 -1
- package/src/components/ui/chat/chat-agent-details-zalo-personal-panel.tsx +2 -2
- package/src/components/ui/checkbox.tsx +1 -1
- package/src/components/ui/color-picker.tsx +1 -1
- package/src/components/ui/command.tsx +1 -1
- package/src/components/ui/context-menu.tsx +5 -1
- package/src/components/ui/custom/__tests__/settings-dialog-search.test.ts +78 -0
- package/src/components/ui/custom/__tests__/settings-dialog-shell-compile-graph.test.ts +76 -0
- package/src/components/ui/custom/__tests__/settings-dialog-shell.test.tsx +3 -0
- package/src/components/ui/custom/__tests__/workspace-select-helpers.test.ts +46 -1
- package/src/components/ui/custom/combobox.test.tsx +195 -0
- package/src/components/ui/custom/combobox.tsx +273 -156
- package/src/components/ui/custom/education/modules/youtube/delete-link-button.tsx +5 -13
- package/src/components/ui/custom/facebook-mockup/facebook-mockup.tsx +7 -1
- package/src/components/ui/custom/facebook-mockup/form.tsx +1 -1
- package/src/components/ui/custom/facebook-mockup/image-upload-field.tsx +1 -1
- package/src/components/ui/custom/facebook-mockup/preview.tsx +1 -1
- package/src/components/ui/custom/nav-link.test.tsx +165 -0
- package/src/components/ui/custom/nav-link.tsx +69 -11
- package/src/components/ui/custom/navigation.tsx +1 -0
- package/src/components/ui/custom/settings/task-settings.tsx +104 -0
- package/src/components/ui/custom/settings-dialog-search-loader.d.ts +5 -0
- package/src/components/ui/custom/settings-dialog-search-loader.js +3 -0
- package/src/components/ui/custom/settings-dialog-search.ts +75 -0
- package/src/components/ui/custom/settings-dialog-shell.tsx +65 -28
- package/src/components/ui/custom/theme-toggle.tsx +1 -1
- package/src/components/ui/custom/workspace-select-helpers.ts +23 -0
- package/src/components/ui/custom/workspace-select.tsx +25 -19
- package/src/components/ui/dialog.test.tsx +52 -0
- package/src/components/ui/dialog.tsx +6 -2
- package/src/components/ui/dropdown-menu.tsx +5 -1
- package/src/components/ui/finance/debts/debt-loan-form.tsx +12 -5
- package/src/components/ui/finance/debts/debt-loan-summary.tsx +3 -2
- package/src/components/ui/finance/debts/debts-page.test.tsx +54 -5
- package/src/components/ui/finance/debts/debts-page.tsx +15 -2
- package/src/components/ui/finance/invoices/components/subscription-group-selector.tsx +3 -5
- package/src/components/ui/finance/invoices/new-invoice-page.test.tsx +25 -5
- package/src/components/ui/finance/invoices/new-invoice-page.tsx +7 -2
- package/src/components/ui/finance/invoices/standard-invoice.tsx +4 -2
- package/src/components/ui/finance/invoices/subscription-invoice.tsx +4 -2
- package/src/components/ui/finance/invoices/utils.ts +3 -1
- package/src/components/ui/finance/transactions/form-content-dialog.tsx +3 -0
- package/src/components/ui/finance/transactions/form-types.ts +1 -0
- package/src/components/ui/finance/transactions/form.tsx +2 -0
- package/src/components/ui/finance/transactions/infinite-transactions-list.tsx +2 -0
- package/src/components/ui/finance/transactions/period-charts/category-breakdown-dialog.tsx +1 -1
- package/src/components/ui/finance/transactions/transaction-edit-dialog.tsx +1 -4
- package/src/components/ui/finance/transactions/transactions-create-summary.tsx +3 -0
- package/src/components/ui/finance/transactions/transactions-page.tsx +4 -1
- package/src/components/ui/finance/wallets/form.test.tsx +51 -3
- package/src/components/ui/finance/wallets/form.tsx +15 -4
- package/src/components/ui/finance/wallets/walletId/wallet-details-actions.tsx +4 -0
- package/src/components/ui/finance/wallets/walletId/wallet-details-page.tsx +4 -2
- package/src/components/ui/finance/wallets/wallets-data-table.tsx +1 -0
- package/src/components/ui/finance/wallets/wallets-page.tsx +5 -2
- package/src/components/ui/input-otp.tsx +1 -1
- package/src/components/ui/legacy/calendar/all-day-event-bar.tsx +28 -39
- package/src/components/ui/legacy/calendar/calendar-cell.tsx +2 -0
- package/src/components/ui/legacy/calendar/calendar-content.tsx +10 -6
- package/src/components/ui/legacy/calendar/calendar-header.tsx +23 -3
- package/src/components/ui/legacy/calendar/calendar-loading-skeleton.tsx +135 -0
- package/src/components/ui/legacy/calendar/calendar-matrix.tsx +175 -237
- package/src/components/ui/legacy/calendar/event-card.test.tsx +177 -0
- package/src/components/ui/legacy/calendar/event-card.tsx +220 -131
- package/src/components/ui/legacy/calendar/event-modal.tsx +17 -17
- package/src/components/ui/legacy/calendar/event-provider-display.tsx +69 -0
- package/src/components/ui/legacy/calendar/smart-calendar.test.tsx +86 -4
- package/src/components/ui/legacy/calendar/smart-calendar.tsx +32 -2
- package/src/components/ui/legacy/meet/create-plan-dialog.tsx +19 -10
- package/src/components/ui/navigation-menu.tsx +1 -1
- package/src/components/ui/pagination.tsx +1 -1
- package/src/components/ui/radio-group.tsx +1 -1
- package/src/components/ui/select.tsx +5 -1
- package/src/components/ui/sheet.tsx +1 -1
- package/src/components/ui/sidebar.tsx +1 -1
- package/src/components/ui/storefront/cart-popover.tsx +61 -0
- package/src/components/ui/storefront/cart-summary-parts.tsx +290 -0
- package/src/components/ui/storefront/cart-summary.tsx +93 -154
- package/src/components/ui/storefront/checkout-overlay.tsx +4 -5
- package/src/components/ui/storefront/listing-card.tsx +1 -1
- package/src/components/ui/storefront/merch-sections.tsx +70 -0
- package/src/components/ui/storefront/product-detail.tsx +1 -1
- package/src/components/ui/storefront/storefront-surface.test.tsx +106 -11
- package/src/components/ui/storefront/storefront-surface.tsx +101 -166
- package/src/components/ui/storefront/types.ts +4 -0
- package/src/components/ui/storefront/utils.ts +6 -0
- package/src/components/ui/text-editor/__tests__/extensions.test.ts +123 -0
- package/src/components/ui/text-editor/background-color-extension.ts +62 -0
- package/src/components/ui/text-editor/color-controls.tsx +284 -0
- package/src/components/ui/text-editor/editor.tsx +69 -14
- package/src/components/ui/text-editor/extensions.ts +8 -2
- package/src/components/ui/text-editor/highlight-extension.ts +22 -0
- package/src/components/ui/text-editor/tool-bar.tsx +9 -16
- package/src/components/ui/toast.tsx +1 -1
- package/src/components/ui/tu-do/boards/__tests__/board-share-dialog.test.tsx +286 -0
- package/src/components/ui/tu-do/boards/__tests__/task-board-form.test.tsx +12 -0
- package/src/components/ui/tu-do/boards/board-public-link-section.tsx +231 -0
- package/src/components/ui/tu-do/boards/board-share-dialog.tsx +15 -226
- package/src/components/ui/tu-do/boards/board-share-settings-panel.tsx +351 -0
- package/src/components/ui/tu-do/boards/boardId/board-column.tsx +121 -39
- package/src/components/ui/tu-do/boards/boardId/enhanced-task-list.tsx +7 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/bulk/bulk-mutations-clear-delete.ts +2 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/bulk/bulk-mutations-move.ts +5 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/bulk/bulk-mutations-updates.ts +3 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/bulk/bulk-operation-types.ts +3 -3
- package/src/components/ui/tu-do/boards/boardId/kanban/data/kanban-deadline-query.ts +50 -2
- package/src/components/ui/tu-do/boards/boardId/kanban/data/use-bulk-resources.ts +59 -5
- package/src/components/ui/tu-do/boards/boardId/kanban/dnd/__tests__/column-reorder.test.ts +17 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/dnd/column-reorder.ts +4 -1
- package/src/components/ui/tu-do/boards/boardId/kanban/dnd/drag-preview.tsx +20 -1
- package/src/components/ui/tu-do/boards/boardId/kanban/dnd/task-drag-cache.ts +38 -9
- package/src/components/ui/tu-do/boards/boardId/kanban/dnd/task-drag-order.ts +2 -8
- package/src/components/ui/tu-do/boards/boardId/kanban/dnd/task-sort-key.ts +47 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/dnd/use-kanban-dnd.ts +81 -30
- package/src/components/ui/tu-do/boards/boardId/kanban/planner/__tests__/kanban-planner-island.test.tsx +380 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/planner/kanban-planner-dialog.tsx +204 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/planner/planner-digest-panel.tsx +61 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/planner/planner-item-strip.tsx +54 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/planner/planner-plan-toolbar.tsx +251 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/planner/planner-scope-badge.tsx +27 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/planner/planner-section.tsx +58 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/planner/planner-share-dialog.tsx +238 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/planner/planner-target-controls.tsx +143 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/planner/planner-utils.ts +65 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/planner/use-kanban-planner-state.ts +234 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/rendering/kanban-columns.test.tsx +642 -5
- package/src/components/ui/tu-do/boards/boardId/kanban/rendering/kanban-columns.tsx +224 -15
- package/src/components/ui/tu-do/boards/boardId/kanban/rendering/kanban-deadline-panels.tsx +535 -53
- package/src/components/ui/tu-do/boards/boardId/kanban/rendering/kanban-skeleton.tsx +101 -33
- package/src/components/ui/tu-do/boards/boardId/kanban.tsx +235 -113
- package/src/components/ui/tu-do/boards/boardId/task-board-server-page.test.tsx +50 -5
- package/src/components/ui/tu-do/boards/boardId/task-board-server-page.tsx +12 -2
- package/src/components/ui/tu-do/boards/boardId/task-card/measured-task-card.tsx +10 -1
- package/src/components/ui/tu-do/boards/boardId/task-card/task-card-comparator.ts +3 -0
- package/src/components/ui/tu-do/boards/boardId/task-card/task-card-open-options.test.ts +20 -0
- package/src/components/ui/tu-do/boards/boardId/task-card/task-card-open-options.ts +10 -0
- package/src/components/ui/tu-do/boards/boardId/task-card/task-card.tsx +271 -36
- package/src/components/ui/tu-do/boards/boardId/task-filter.test.tsx +152 -0
- package/src/components/ui/tu-do/boards/boardId/task-filter.tsx +555 -545
- package/src/components/ui/tu-do/boards/boardId/task-list.tsx +22 -0
- package/src/components/ui/tu-do/boards/boardId/timeline/timeline-grid.tsx +9 -0
- package/src/components/ui/tu-do/boards/boardId/timeline/timeline-task-row.tsx +9 -0
- package/src/components/ui/tu-do/boards/boardId/timeline/timeline-toolbar.tsx +9 -0
- package/src/components/ui/tu-do/boards/boardId/timeline-board.tsx +35 -3
- package/src/components/ui/tu-do/boards/form.tsx +1 -1
- package/src/components/ui/tu-do/boards/share-section.tsx +100 -0
- package/src/components/ui/tu-do/drafts/draft-convert-dialog.tsx +10 -12
- package/src/components/ui/tu-do/drafts/drafts-page.tsx +33 -16
- package/src/components/ui/tu-do/hooks/__tests__/useTaskLabelManagement.test.tsx +48 -0
- package/src/components/ui/tu-do/hooks/__tests__/useTaskProjectManagement.test.tsx +144 -0
- package/src/components/ui/tu-do/hooks/useTaskDialog.ts +7 -0
- package/src/components/ui/tu-do/hooks/useTaskLabelManagement.ts +115 -106
- package/src/components/ui/tu-do/hooks/useTaskProjectManagement.ts +115 -122
- package/src/components/ui/tu-do/initiatives/task-initiatives-client.tsx +56 -88
- package/src/components/ui/tu-do/my-tasks/my-tasks-content.tsx +26 -2
- package/src/components/ui/tu-do/my-tasks/use-my-tasks-state.ts +55 -8
- package/src/components/ui/tu-do/notes/note-edit-dialog.tsx +1 -4
- package/src/components/ui/tu-do/progress/task-progress-import-panel.tsx +60 -0
- package/src/components/ui/tu-do/progress/task-progress-leaderboards-panel.tsx +156 -0
- package/src/components/ui/tu-do/progress/task-progress-page.tsx +348 -0
- package/src/components/ui/tu-do/progress/task-progress-panels.tsx +301 -0
- package/src/components/ui/tu-do/providers/task-dialog-provider.tsx +26 -0
- package/src/components/ui/tu-do/shared/__tests__/assignee-select.test.tsx +81 -10
- package/src/components/ui/tu-do/shared/__tests__/board-client.test.tsx +141 -1
- package/src/components/ui/tu-do/shared/__tests__/board-header.test.tsx +377 -36
- package/src/components/ui/tu-do/shared/__tests__/board-switcher.test.tsx +374 -0
- package/src/components/ui/tu-do/shared/__tests__/board-views.test.tsx +419 -5
- package/src/components/ui/tu-do/shared/__tests__/task-board-loading-state.test.tsx +38 -0
- package/src/components/ui/tu-do/shared/__tests__/task-cache-patches.test.ts +147 -0
- package/src/components/ui/tu-do/shared/__tests__/task-legacy-route-recovery.test.tsx +16 -0
- package/src/components/ui/tu-do/shared/__tests__/use-progressive-board-loader.test.tsx +3 -0
- package/src/components/ui/tu-do/shared/assignee-select.tsx +77 -26
- package/src/components/ui/tu-do/shared/board-client.tsx +15 -10
- package/src/components/ui/tu-do/shared/board-config-storage.ts +7 -1
- package/src/components/ui/tu-do/shared/board-header.tsx +471 -975
- package/src/components/ui/tu-do/shared/board-layout-settings.tsx +165 -136
- package/src/components/ui/tu-do/shared/board-switcher.tsx +244 -220
- package/src/components/ui/tu-do/shared/board-user-presence-avatars.tsx +18 -12
- package/src/components/ui/tu-do/shared/board-views.tsx +577 -85
- package/src/components/ui/tu-do/shared/list-view.tsx +246 -2
- package/src/components/ui/tu-do/shared/recycle-bin-panel.tsx +142 -94
- package/src/components/ui/tu-do/shared/special-task-list-pins.ts +51 -0
- package/src/components/ui/tu-do/shared/task-board-loading-state.tsx +28 -0
- package/src/components/ui/tu-do/shared/task-cache-patches.ts +394 -0
- package/src/components/ui/tu-do/shared/task-dialog-manager.tsx +21 -1
- package/src/components/ui/tu-do/shared/task-edit-dialog/components/quick-settings-popover.tsx +5 -1
- package/src/components/ui/tu-do/shared/task-edit-dialog/components/task-dialog-header.tsx +25 -2
- package/src/components/ui/tu-do/shared/task-edit-dialog/components/task-list-selector.tsx +7 -1
- package/src/components/ui/tu-do/shared/task-edit-dialog/field-diff-viewer.tsx +3 -2
- package/src/components/ui/tu-do/shared/task-edit-dialog/hooks/use-task-data.ts +79 -10
- package/src/components/ui/tu-do/shared/task-edit-dialog/hooks/use-task-mutations.ts +76 -77
- package/src/components/ui/tu-do/shared/task-edit-dialog/hooks/use-task-relationships.test.tsx +63 -0
- package/src/components/ui/tu-do/shared/task-edit-dialog/hooks/use-task-relationships.ts +78 -69
- package/src/components/ui/tu-do/shared/task-edit-dialog/personal-overrides-section.tsx +28 -8
- package/src/components/ui/tu-do/shared/task-edit-dialog/relationships/dependencies-section.tsx +14 -3
- package/src/components/ui/tu-do/shared/task-edit-dialog/relationships/parent-section.tsx +6 -1
- package/src/components/ui/tu-do/shared/task-edit-dialog/relationships/related-section.tsx +6 -1
- package/src/components/ui/tu-do/shared/task-edit-dialog/relationships/subtasks-section.tsx +6 -1
- package/src/components/ui/tu-do/shared/task-edit-dialog/relationships/types/task-relationships.types.ts +8 -0
- package/src/components/ui/tu-do/shared/task-edit-dialog/selective-revert-panel.test.tsx +91 -0
- package/src/components/ui/tu-do/shared/task-edit-dialog/selective-revert-panel.tsx +123 -78
- package/src/components/ui/tu-do/shared/task-edit-dialog/task-activity-section.tsx +7 -1
- package/src/components/ui/tu-do/shared/task-edit-dialog/task-dialog-actions.tsx +8 -1
- package/src/components/ui/tu-do/shared/task-edit-dialog/task-properties-section.test.tsx +150 -0
- package/src/components/ui/tu-do/shared/task-edit-dialog/task-properties-section.tsx +61 -35
- package/src/components/ui/tu-do/shared/task-edit-dialog/task-relationships-properties.tsx +44 -2
- package/src/components/ui/tu-do/shared/task-edit-dialog/task-snapshot-dialog.tsx +8 -3
- package/src/components/ui/tu-do/shared/task-edit-dialog.tsx +11 -1
- package/src/components/ui/tu-do/shared/task-legacy-route-recovery.tsx +2 -9
- package/src/components/ui/tu-do/shared/task-row-actions-menu.tsx +11 -0
- package/src/components/ui/tu-do/shared/use-progressive-board-loader.ts +2 -0
- package/src/declarations.d.ts +1 -0
- package/src/hooks/__tests__/use-calendar-readonly.test.tsx +322 -2
- package/src/hooks/__tests__/use-calendar-sync.test.tsx +446 -0
- package/src/hooks/__tests__/useBoardPresence.test.tsx +191 -0
- package/src/hooks/__tests__/useBoardRealtime.test.tsx +24 -144
- package/src/hooks/use-calendar-sync.tsx +247 -243
- package/src/hooks/use-calendar.tsx +323 -138
- package/src/hooks/use-task-actions.ts +24 -0
- package/src/hooks/use-user-workspace-config.ts +75 -0
- package/src/hooks/use-workspace-currency.ts +8 -3
- package/src/hooks/useBoardPresence.ts +364 -0
- package/src/hooks/useBoardRealtimeEventHandler.ts +45 -90
- package/src/lib/workspace-actions.ts +2 -6
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
2
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
3
|
+
import { fireEvent, render, screen } from '@testing-library/react';
|
|
4
|
+
import type { ComponentProps } from 'react';
|
|
5
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
6
|
+
import { NavLink } from './nav-link';
|
|
7
|
+
|
|
8
|
+
const navigationState = vi.hoisted(() => ({
|
|
9
|
+
pathname: '/personal/tasks',
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
vi.mock('next/navigation', () => ({
|
|
13
|
+
usePathname: () => navigationState.pathname,
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
vi.mock('next-intl', () => ({
|
|
17
|
+
useTranslations: () => (key: string) => key,
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
vi.mock('@tuturuuu/internal-api', () => ({
|
|
21
|
+
getWorkspaceConfigIdList: vi.fn(),
|
|
22
|
+
}));
|
|
23
|
+
|
|
24
|
+
function renderNavLink(
|
|
25
|
+
link: ComponentProps<typeof NavLink>['link'],
|
|
26
|
+
props: Partial<
|
|
27
|
+
Pick<ComponentProps<typeof NavLink>, 'onClick' | 'onSubMenuClick'>
|
|
28
|
+
> = {}
|
|
29
|
+
) {
|
|
30
|
+
const queryClient = new QueryClient({
|
|
31
|
+
defaultOptions: {
|
|
32
|
+
queries: {
|
|
33
|
+
retry: false,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
return render(
|
|
39
|
+
<QueryClientProvider client={queryClient}>
|
|
40
|
+
<NavLink
|
|
41
|
+
wsId="personal"
|
|
42
|
+
link={link}
|
|
43
|
+
isCollapsed={false}
|
|
44
|
+
onClick={props.onClick ?? vi.fn()}
|
|
45
|
+
onSubMenuClick={props.onSubMenuClick ?? vi.fn()}
|
|
46
|
+
/>
|
|
47
|
+
</QueryClientProvider>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
describe('NavLink', () => {
|
|
52
|
+
beforeEach(() => {
|
|
53
|
+
navigationState.pathname = '/personal/tasks';
|
|
54
|
+
vi.restoreAllMocks();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('matches wildcard aliases even when the primary route is exact', () => {
|
|
58
|
+
navigationState.pathname = '/personal/tasks/boards/board-1';
|
|
59
|
+
|
|
60
|
+
renderNavLink({
|
|
61
|
+
aliases: ['/personal/tasks/boards/*'],
|
|
62
|
+
href: '/personal/tasks',
|
|
63
|
+
matchExact: true,
|
|
64
|
+
title: 'Tasks',
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
expect(screen.getByRole('link', { name: 'Tasks' })).toHaveClass(
|
|
68
|
+
'bg-accent',
|
|
69
|
+
'text-accent-foreground'
|
|
70
|
+
);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('keeps exact primary routes from matching unrelated subroutes', () => {
|
|
74
|
+
navigationState.pathname = '/personal/tasks/progress';
|
|
75
|
+
|
|
76
|
+
renderNavLink({
|
|
77
|
+
aliases: ['/personal/tasks/boards/*'],
|
|
78
|
+
href: '/personal/tasks',
|
|
79
|
+
matchExact: true,
|
|
80
|
+
title: 'Tasks',
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
expect(screen.getByRole('link', { name: 'Tasks' })).not.toHaveClass(
|
|
84
|
+
'bg-accent'
|
|
85
|
+
);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('does not mark cross-origin links active just because the path matches', () => {
|
|
89
|
+
navigationState.pathname = '/personal';
|
|
90
|
+
|
|
91
|
+
renderNavLink({
|
|
92
|
+
href: 'https://mail.tuturuuu.com/personal',
|
|
93
|
+
title: 'Mail',
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
expect(screen.getByRole('link', { name: 'Mail' })).not.toHaveClass(
|
|
97
|
+
'bg-accent'
|
|
98
|
+
);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('navigates through the parent link instead of opening a single-child submenu', () => {
|
|
102
|
+
const onClick = vi.fn();
|
|
103
|
+
const onSubMenuClick = vi.fn();
|
|
104
|
+
|
|
105
|
+
renderNavLink(
|
|
106
|
+
{
|
|
107
|
+
children: [{ href: '/personal/tasks/boards', title: 'Boards' }],
|
|
108
|
+
href: '/personal/tasks',
|
|
109
|
+
title: 'Tasks',
|
|
110
|
+
},
|
|
111
|
+
{ onClick, onSubMenuClick }
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
const link = screen.getByRole('link', { name: 'Tasks' });
|
|
115
|
+
link.addEventListener('click', (event) => event.preventDefault());
|
|
116
|
+
fireEvent.click(link);
|
|
117
|
+
|
|
118
|
+
expect(onClick).toHaveBeenCalledTimes(1);
|
|
119
|
+
expect(onSubMenuClick).not.toHaveBeenCalled();
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it('dispatches the settings dialog open intent without navigating', () => {
|
|
123
|
+
const onClick = vi.fn();
|
|
124
|
+
const dispatchEvent = vi.spyOn(window, 'dispatchEvent');
|
|
125
|
+
|
|
126
|
+
renderNavLink(
|
|
127
|
+
{
|
|
128
|
+
openSettingsDialog: true,
|
|
129
|
+
title: 'Settings',
|
|
130
|
+
},
|
|
131
|
+
{ onClick }
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
fireEvent.click(screen.getByText('Settings'));
|
|
135
|
+
|
|
136
|
+
expect(onClick).toHaveBeenCalledTimes(1);
|
|
137
|
+
expect(dispatchEvent).toHaveBeenCalledWith(
|
|
138
|
+
expect.objectContaining({
|
|
139
|
+
type: 'tuturuuu:settings-dialog-open-intent',
|
|
140
|
+
})
|
|
141
|
+
);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('passes the requested tab when opening settings from navigation', () => {
|
|
145
|
+
const dispatchEvent = vi.spyOn(window, 'dispatchEvent');
|
|
146
|
+
|
|
147
|
+
renderNavLink({
|
|
148
|
+
openSettingsDialog: { tab: 'workspace_billing' },
|
|
149
|
+
title: 'Billing',
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
fireEvent.click(screen.getByText('Billing'));
|
|
153
|
+
|
|
154
|
+
const event = dispatchEvent.mock.calls.find(
|
|
155
|
+
([candidate]) =>
|
|
156
|
+
candidate instanceof CustomEvent &&
|
|
157
|
+
candidate.type === 'tuturuuu:settings-dialog-open-intent'
|
|
158
|
+
)?.[0];
|
|
159
|
+
|
|
160
|
+
expect(event).toBeInstanceOf(CustomEvent);
|
|
161
|
+
expect((event as CustomEvent).detail).toEqual({
|
|
162
|
+
settingsTab: 'workspace_billing',
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
});
|
|
@@ -38,20 +38,51 @@ function matchesPathPrefix(targetPath: string, pathPrefix: string) {
|
|
|
38
38
|
return targetPath === pathPrefix || targetPath.startsWith(`${pathPrefix}/`);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
function
|
|
41
|
+
function isAbsoluteHttpUrl(target: string) {
|
|
42
|
+
return /^https?:\/\//iu.test(target);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function getComparablePath(
|
|
46
|
+
target?: string,
|
|
47
|
+
options: { external?: boolean } = {}
|
|
48
|
+
) {
|
|
42
49
|
if (!target) return null;
|
|
50
|
+
if (options.external) return null;
|
|
43
51
|
|
|
44
52
|
try {
|
|
45
53
|
const base =
|
|
46
54
|
typeof window === 'undefined'
|
|
47
55
|
? 'https://tuturuuu.local'
|
|
48
56
|
: window.location.origin;
|
|
49
|
-
|
|
57
|
+
const url = isAbsoluteHttpUrl(target)
|
|
58
|
+
? new URL(target)
|
|
59
|
+
: new URL(target, base);
|
|
60
|
+
|
|
61
|
+
if (isAbsoluteHttpUrl(target) && url.origin !== base) return null;
|
|
62
|
+
|
|
63
|
+
return url.pathname;
|
|
50
64
|
} catch {
|
|
51
65
|
return target.split(/[?#]/u)[0] || target;
|
|
52
66
|
}
|
|
53
67
|
}
|
|
54
68
|
|
|
69
|
+
function matchesNavigationTarget(
|
|
70
|
+
pathname: string,
|
|
71
|
+
target: string,
|
|
72
|
+
matchExact = false
|
|
73
|
+
) {
|
|
74
|
+
const isWildcard = target.endsWith('/*');
|
|
75
|
+
const normalizedTarget = isWildcard
|
|
76
|
+
? target.slice(0, -2).replace(/\/+$/u, '') || '/'
|
|
77
|
+
: target;
|
|
78
|
+
|
|
79
|
+
if (isWildcard) return matchesPathPrefix(pathname, normalizedTarget);
|
|
80
|
+
|
|
81
|
+
return matchExact
|
|
82
|
+
? pathname === normalizedTarget
|
|
83
|
+
: matchesPathPrefix(pathname, normalizedTarget);
|
|
84
|
+
}
|
|
85
|
+
|
|
55
86
|
interface NavLinkProps {
|
|
56
87
|
wsId: string;
|
|
57
88
|
link: NavLinkType;
|
|
@@ -60,6 +91,9 @@ interface NavLinkProps {
|
|
|
60
91
|
onClick: () => void;
|
|
61
92
|
}
|
|
62
93
|
|
|
94
|
+
const SETTINGS_DIALOG_OPEN_INTENT_EVENT =
|
|
95
|
+
'tuturuuu:settings-dialog-open-intent';
|
|
96
|
+
|
|
63
97
|
export function NavLink({
|
|
64
98
|
wsId,
|
|
65
99
|
link,
|
|
@@ -69,8 +103,19 @@ export function NavLink({
|
|
|
69
103
|
}: NavLinkProps) {
|
|
70
104
|
const t = useTranslations();
|
|
71
105
|
const pathname = usePathname();
|
|
72
|
-
const {
|
|
73
|
-
|
|
106
|
+
const {
|
|
107
|
+
title,
|
|
108
|
+
icon,
|
|
109
|
+
href,
|
|
110
|
+
children,
|
|
111
|
+
newTab,
|
|
112
|
+
onClick: onLinkClick,
|
|
113
|
+
openSettingsDialog,
|
|
114
|
+
} = link;
|
|
115
|
+
const childLinks = children?.filter((child): child is NavLinkType =>
|
|
116
|
+
Boolean(child)
|
|
117
|
+
);
|
|
118
|
+
const hasSubMenu = (childLinks?.length ?? 0) > 1;
|
|
74
119
|
const [showUpgradeDialog, setShowUpgradeDialog] = useState(false);
|
|
75
120
|
|
|
76
121
|
// Recursive function to check if any nested child matches the pathname
|
|
@@ -78,10 +123,12 @@ export function NavLink({
|
|
|
78
123
|
return (
|
|
79
124
|
navLinks?.some((child) => {
|
|
80
125
|
const childTargets = [child?.href, ...(child?.aliases ?? [])]
|
|
81
|
-
.map(
|
|
126
|
+
.map((target) =>
|
|
127
|
+
getComparablePath(target, { external: child?.external })
|
|
128
|
+
)
|
|
82
129
|
.filter((target): target is string => Boolean(target));
|
|
83
130
|
const childMatches = childTargets.some((target) =>
|
|
84
|
-
|
|
131
|
+
matchesNavigationTarget(pathname, target, child?.matchExact)
|
|
85
132
|
);
|
|
86
133
|
|
|
87
134
|
if (childMatches) return true;
|
|
@@ -96,11 +143,11 @@ export function NavLink({
|
|
|
96
143
|
};
|
|
97
144
|
|
|
98
145
|
const activeTargets = [href, ...(link.aliases ?? [])]
|
|
99
|
-
.map(getComparablePath)
|
|
146
|
+
.map((target) => getComparablePath(target, { external: link.external }))
|
|
100
147
|
.filter((target): target is string => Boolean(target));
|
|
101
148
|
const isActive =
|
|
102
149
|
activeTargets.some((target) =>
|
|
103
|
-
|
|
150
|
+
matchesNavigationTarget(pathname, target, link.matchExact)
|
|
104
151
|
) ||
|
|
105
152
|
(children && hasActiveChild(children));
|
|
106
153
|
|
|
@@ -190,7 +237,7 @@ export function NavLink({
|
|
|
190
237
|
</Tooltip>
|
|
191
238
|
)}
|
|
192
239
|
|
|
193
|
-
{(
|
|
240
|
+
{(hasSubMenu || archivedItems.length > 0) &&
|
|
194
241
|
!preferenceArchiveAction &&
|
|
195
242
|
!preferenceQuickAction &&
|
|
196
243
|
!isDisabled && (
|
|
@@ -316,9 +363,20 @@ export function NavLink({
|
|
|
316
363
|
}
|
|
317
364
|
if (onLinkClick) {
|
|
318
365
|
onLinkClick();
|
|
319
|
-
} else if (
|
|
366
|
+
} else if (openSettingsDialog) {
|
|
367
|
+
event.preventDefault();
|
|
368
|
+
const detail =
|
|
369
|
+
typeof openSettingsDialog === 'object'
|
|
370
|
+
? { settingsTab: openSettingsDialog.tab }
|
|
371
|
+
: undefined;
|
|
372
|
+
|
|
373
|
+
window.dispatchEvent(
|
|
374
|
+
new CustomEvent(SETTINGS_DIALOG_OPEN_INTENT_EVENT, { detail })
|
|
375
|
+
);
|
|
376
|
+
onClick();
|
|
377
|
+
} else if (hasSubMenu) {
|
|
320
378
|
event.preventDefault();
|
|
321
|
-
onSubMenuClick(children, title);
|
|
379
|
+
onSubMenuClick(children ?? [], title);
|
|
322
380
|
} else if (href) {
|
|
323
381
|
if (shouldResolveQueryParamsFromConfig && !effectiveHref) {
|
|
324
382
|
event.preventDefault();
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
4
|
+
import {
|
|
5
|
+
TASK_NAVIGATION_GOALS_CONFIG_ID,
|
|
6
|
+
TASK_NAVIGATION_IMPORT_CONFIG_ID,
|
|
7
|
+
TASK_NAVIGATION_LEADERBOARDS_CONFIG_ID,
|
|
8
|
+
TASK_NAVIGATION_PROGRESS_CONFIG_ID,
|
|
9
|
+
TASK_NAVIGATION_STATS_CONFIG_ID,
|
|
10
|
+
} from '@tuturuuu/internal-api/users';
|
|
4
11
|
import type { Workspace } from '@tuturuuu/types';
|
|
5
12
|
import { SettingItemTab } from '@tuturuuu/ui/custom/settings-item-tab';
|
|
6
13
|
import {
|
|
@@ -85,6 +92,36 @@ export function TaskSettings({ workspace }: TaskSettingsProps) {
|
|
|
85
92
|
isLoading: showReviewDueDatesLoading,
|
|
86
93
|
isPending: showReviewDueDatesPending,
|
|
87
94
|
} = useUserBooleanConfig(TASKS_SHOW_REVIEW_DUE_DATES_CONFIG_ID, false);
|
|
95
|
+
const {
|
|
96
|
+
value: showTaskProgressNavigation,
|
|
97
|
+
setValue: setShowTaskProgressNavigation,
|
|
98
|
+
isLoading: showTaskProgressNavigationLoading,
|
|
99
|
+
isPending: showTaskProgressNavigationPending,
|
|
100
|
+
} = useUserBooleanConfig(TASK_NAVIGATION_PROGRESS_CONFIG_ID, false);
|
|
101
|
+
const {
|
|
102
|
+
value: showTaskGoalsNavigation,
|
|
103
|
+
setValue: setShowTaskGoalsNavigation,
|
|
104
|
+
isLoading: showTaskGoalsNavigationLoading,
|
|
105
|
+
isPending: showTaskGoalsNavigationPending,
|
|
106
|
+
} = useUserBooleanConfig(TASK_NAVIGATION_GOALS_CONFIG_ID, false);
|
|
107
|
+
const {
|
|
108
|
+
value: showTaskStatsNavigation,
|
|
109
|
+
setValue: setShowTaskStatsNavigation,
|
|
110
|
+
isLoading: showTaskStatsNavigationLoading,
|
|
111
|
+
isPending: showTaskStatsNavigationPending,
|
|
112
|
+
} = useUserBooleanConfig(TASK_NAVIGATION_STATS_CONFIG_ID, false);
|
|
113
|
+
const {
|
|
114
|
+
value: showTaskLeaderboardsNavigation,
|
|
115
|
+
setValue: setShowTaskLeaderboardsNavigation,
|
|
116
|
+
isLoading: showTaskLeaderboardsNavigationLoading,
|
|
117
|
+
isPending: showTaskLeaderboardsNavigationPending,
|
|
118
|
+
} = useUserBooleanConfig(TASK_NAVIGATION_LEADERBOARDS_CONFIG_ID, false);
|
|
119
|
+
const {
|
|
120
|
+
value: showTaskImportNavigation,
|
|
121
|
+
setValue: setShowTaskImportNavigation,
|
|
122
|
+
isLoading: showTaskImportNavigationLoading,
|
|
123
|
+
isPending: showTaskImportNavigationPending,
|
|
124
|
+
} = useUserBooleanConfig(TASK_NAVIGATION_IMPORT_CONFIG_ID, false);
|
|
88
125
|
const {
|
|
89
126
|
value: soundEffectsEnabled,
|
|
90
127
|
setValue: setSoundEffectsEnabled,
|
|
@@ -346,6 +383,73 @@ export function TaskSettings({ workspace }: TaskSettingsProps) {
|
|
|
346
383
|
/>
|
|
347
384
|
</SettingItemTab>
|
|
348
385
|
<Separator />
|
|
386
|
+
<SettingItemTab
|
|
387
|
+
title={t('navigation_progress')}
|
|
388
|
+
description={t('navigation_progress_description')}
|
|
389
|
+
>
|
|
390
|
+
<Switch
|
|
391
|
+
checked={showTaskProgressNavigation}
|
|
392
|
+
onCheckedChange={setShowTaskProgressNavigation}
|
|
393
|
+
disabled={
|
|
394
|
+
showTaskProgressNavigationLoading ||
|
|
395
|
+
showTaskProgressNavigationPending
|
|
396
|
+
}
|
|
397
|
+
/>
|
|
398
|
+
</SettingItemTab>
|
|
399
|
+
<Separator />
|
|
400
|
+
<SettingItemTab
|
|
401
|
+
title={t('navigation_goals')}
|
|
402
|
+
description={t('navigation_goals_description')}
|
|
403
|
+
>
|
|
404
|
+
<Switch
|
|
405
|
+
checked={showTaskGoalsNavigation}
|
|
406
|
+
onCheckedChange={setShowTaskGoalsNavigation}
|
|
407
|
+
disabled={
|
|
408
|
+
showTaskGoalsNavigationLoading || showTaskGoalsNavigationPending
|
|
409
|
+
}
|
|
410
|
+
/>
|
|
411
|
+
</SettingItemTab>
|
|
412
|
+
<Separator />
|
|
413
|
+
<SettingItemTab
|
|
414
|
+
title={t('navigation_stats')}
|
|
415
|
+
description={t('navigation_stats_description')}
|
|
416
|
+
>
|
|
417
|
+
<Switch
|
|
418
|
+
checked={showTaskStatsNavigation}
|
|
419
|
+
onCheckedChange={setShowTaskStatsNavigation}
|
|
420
|
+
disabled={
|
|
421
|
+
showTaskStatsNavigationLoading || showTaskStatsNavigationPending
|
|
422
|
+
}
|
|
423
|
+
/>
|
|
424
|
+
</SettingItemTab>
|
|
425
|
+
<Separator />
|
|
426
|
+
<SettingItemTab
|
|
427
|
+
title={t('navigation_leaderboards')}
|
|
428
|
+
description={t('navigation_leaderboards_description')}
|
|
429
|
+
>
|
|
430
|
+
<Switch
|
|
431
|
+
checked={showTaskLeaderboardsNavigation}
|
|
432
|
+
onCheckedChange={setShowTaskLeaderboardsNavigation}
|
|
433
|
+
disabled={
|
|
434
|
+
showTaskLeaderboardsNavigationLoading ||
|
|
435
|
+
showTaskLeaderboardsNavigationPending
|
|
436
|
+
}
|
|
437
|
+
/>
|
|
438
|
+
</SettingItemTab>
|
|
439
|
+
<Separator />
|
|
440
|
+
<SettingItemTab
|
|
441
|
+
title={t('navigation_import')}
|
|
442
|
+
description={t('navigation_import_description')}
|
|
443
|
+
>
|
|
444
|
+
<Switch
|
|
445
|
+
checked={showTaskImportNavigation}
|
|
446
|
+
onCheckedChange={setShowTaskImportNavigation}
|
|
447
|
+
disabled={
|
|
448
|
+
showTaskImportNavigationLoading || showTaskImportNavigationPending
|
|
449
|
+
}
|
|
450
|
+
/>
|
|
451
|
+
</SettingItemTab>
|
|
452
|
+
<Separator />
|
|
349
453
|
<SettingItemTab
|
|
350
454
|
title={t('submit_shortcut')}
|
|
351
455
|
description={t('submit_shortcut_description')}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { removeAccents } from '@tuturuuu/utils/text-helper';
|
|
2
|
+
import type {
|
|
3
|
+
SettingsNavGroup,
|
|
4
|
+
SettingsNavItem,
|
|
5
|
+
} from './settings-dialog-shell';
|
|
6
|
+
|
|
7
|
+
type IndexedSettingsNavItem = {
|
|
8
|
+
groupLabel: string;
|
|
9
|
+
item: SettingsNavItem;
|
|
10
|
+
normalizedSearchText: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
function normalizeSearchText(value: string) {
|
|
14
|
+
return removeAccents(value.toLowerCase());
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function getItemSearchText(groupLabel: string, item: SettingsNavItem) {
|
|
18
|
+
return [
|
|
19
|
+
groupLabel,
|
|
20
|
+
item.name,
|
|
21
|
+
item.label,
|
|
22
|
+
item.description,
|
|
23
|
+
...(item.keywords ?? []),
|
|
24
|
+
...(item.aliases ?? []),
|
|
25
|
+
...(item.searchLabels ?? []),
|
|
26
|
+
]
|
|
27
|
+
.filter(Boolean)
|
|
28
|
+
.join(' ');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function createSettingsSearchEngine(navItems: SettingsNavGroup[]) {
|
|
32
|
+
const indexedItems: IndexedSettingsNavItem[] = navItems.flatMap((group) =>
|
|
33
|
+
group.items.map((item) => ({
|
|
34
|
+
groupLabel: group.label,
|
|
35
|
+
item,
|
|
36
|
+
normalizedSearchText: normalizeSearchText(
|
|
37
|
+
getItemSearchText(group.label, item)
|
|
38
|
+
),
|
|
39
|
+
}))
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const allItems = indexedItems.map(({ item }) => item);
|
|
43
|
+
|
|
44
|
+
function search(query: string) {
|
|
45
|
+
const normalizedQuery = normalizeSearchText(query.trim());
|
|
46
|
+
if (!normalizedQuery) return navItems;
|
|
47
|
+
|
|
48
|
+
const matchesByName = new Set(
|
|
49
|
+
indexedItems
|
|
50
|
+
.filter(({ normalizedSearchText }) =>
|
|
51
|
+
normalizedSearchText.includes(normalizedQuery)
|
|
52
|
+
)
|
|
53
|
+
.map(({ item }) => item.name)
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
return navItems
|
|
57
|
+
.map((group) => ({
|
|
58
|
+
...group,
|
|
59
|
+
items: group.items.filter((item) => matchesByName.has(item.name)),
|
|
60
|
+
}))
|
|
61
|
+
.filter((group) => group.items.length > 0);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function getEnabledItems(query = '') {
|
|
65
|
+
return search(query)
|
|
66
|
+
.flatMap((group) => group.items)
|
|
67
|
+
.filter((item) => !item.disabled);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
allItems,
|
|
72
|
+
getEnabledItems,
|
|
73
|
+
search,
|
|
74
|
+
};
|
|
75
|
+
}
|