github-issue-tower-defence-management 2.1.1 → 2.1.2

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.
Files changed (22) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/bin/adapter/entry-points/console/consoleOperationApi.js +6 -4
  3. package/bin/adapter/entry-points/console/consoleOperationApi.js.map +1 -1
  4. package/bin/adapter/entry-points/console/ui-dist/assets/{index-lT5OKx7e.js → index-BVyeR7xJ.js} +2 -2
  5. package/bin/adapter/entry-points/console/ui-dist/index.html +1 -1
  6. package/bin/adapter/entry-points/console/webServer.js +0 -4
  7. package/bin/adapter/entry-points/console/webServer.js.map +1 -1
  8. package/package.json +1 -1
  9. package/src/adapter/entry-points/console/consoleOperationApi.test.ts +60 -32
  10. package/src/adapter/entry-points/console/consoleOperationApi.ts +6 -7
  11. package/src/adapter/entry-points/console/ui/e2e/consoleTestHarness.ts +12 -17
  12. package/src/adapter/entry-points/console/ui/src/features/console/components/list/ConsoleStoryList.stories.tsx +1 -0
  13. package/src/adapter/entry-points/console/ui/src/features/console/components/list/ConsoleStoryList.test.tsx +85 -0
  14. package/src/adapter/entry-points/console/ui/src/features/console/components/list/ConsoleStoryList.tsx +73 -1
  15. package/src/adapter/entry-points/console/ui/src/features/console/pages/ConsolePage.tsx +53 -16
  16. package/src/adapter/entry-points/console/ui-dist/assets/{index-lT5OKx7e.js → index-BVyeR7xJ.js} +2 -2
  17. package/src/adapter/entry-points/console/ui-dist/index.html +1 -1
  18. package/src/adapter/entry-points/console/webServer.ts +0 -8
  19. package/types/adapter/entry-points/console/consoleOperationApi.d.ts +1 -2
  20. package/types/adapter/entry-points/console/consoleOperationApi.d.ts.map +1 -1
  21. package/types/adapter/entry-points/console/webServer.d.ts +0 -2
  22. package/types/adapter/entry-points/console/webServer.d.ts.map +1 -1
@@ -52,6 +52,7 @@ import type {
52
52
  ConsoleColor,
53
53
  ConsoleListItem,
54
54
  ConsoleOverlayStatus,
55
+ ConsoleStoryEntry,
55
56
  ConsoleTabName,
56
57
  } from '../logic/types';
57
58
  import { CONSOLE_TABS } from '../logic/types';
@@ -185,6 +186,11 @@ export const ConsolePage = () => {
185
186
  stories: typeof storyOptions;
186
187
  } | null>(null);
187
188
 
189
+ const [localStoryEntriesOverride, setLocalStoryEntriesOverride] = useState<{
190
+ generatedAt: string | undefined;
191
+ stories: ConsoleStoryEntry[];
192
+ } | null>(null);
193
+
188
194
  const triageStoryOptions =
189
195
  localStoryOptionsOverride !== null &&
190
196
  localStoryOptionsOverride.generatedAt === activeSnapshot?.generatedAt
@@ -347,7 +353,12 @@ export const ConsolePage = () => {
347
353
  }, []);
348
354
 
349
355
  const storiesSnapshot = snapshots.stories;
350
- const storyEntries = storiesSnapshot?.stories ?? [];
356
+ const rawStoryEntries = storiesSnapshot?.stories ?? [];
357
+ const storyEntries =
358
+ localStoryEntriesOverride !== null &&
359
+ localStoryEntriesOverride.generatedAt === storiesSnapshot?.generatedAt
360
+ ? localStoryEntriesOverride.stories
361
+ : rawStoryEntries;
351
362
  const defaultNameWithOwner = storiesSnapshot?.defaultNameWithOwner ?? null;
352
363
 
353
364
  const handleCreateIssue = useCallback(
@@ -374,24 +385,49 @@ export const ConsolePage = () => {
374
385
  throw new Error('No project specified in the URL path.');
375
386
  }
376
387
  await postConsoleReorderStory({ pjcode, storyOptionId, direction });
377
- const index = triageStoryOptions.findIndex((o) => o.id === storyOptionId);
378
- if (index === -1) {
379
- return;
388
+ const triageIndex = triageStoryOptions.findIndex(
389
+ (o) => o.id === storyOptionId,
390
+ );
391
+ if (triageIndex !== -1) {
392
+ const triageSwapIndex = triageIndex + (direction === 'up' ? -1 : 1);
393
+ if (
394
+ triageSwapIndex >= 0 &&
395
+ triageSwapIndex < triageStoryOptions.length
396
+ ) {
397
+ const nextTriage = [...triageStoryOptions];
398
+ const triageTemp = nextTriage[triageIndex];
399
+ nextTriage[triageIndex] = nextTriage[triageSwapIndex];
400
+ nextTriage[triageSwapIndex] = triageTemp;
401
+ setLocalStoryOptionsOverride({
402
+ generatedAt: activeSnapshot?.generatedAt,
403
+ stories: nextTriage,
404
+ });
405
+ }
380
406
  }
381
- const swapIndex = index + (direction === 'up' ? -1 : 1);
382
- if (swapIndex < 0 || swapIndex >= triageStoryOptions.length) {
383
- return;
407
+ const entryIndex = storyEntries.findIndex(
408
+ (e) => e.storyOptionId === storyOptionId,
409
+ );
410
+ if (entryIndex !== -1) {
411
+ const entrySwapIndex = entryIndex + (direction === 'up' ? -1 : 1);
412
+ if (entrySwapIndex >= 0 && entrySwapIndex < storyEntries.length) {
413
+ const nextEntries = [...storyEntries];
414
+ const entryTemp = nextEntries[entryIndex];
415
+ nextEntries[entryIndex] = nextEntries[entrySwapIndex];
416
+ nextEntries[entrySwapIndex] = entryTemp;
417
+ setLocalStoryEntriesOverride({
418
+ generatedAt: storiesSnapshot?.generatedAt,
419
+ stories: nextEntries,
420
+ });
421
+ }
384
422
  }
385
- const next = [...triageStoryOptions];
386
- const temp = next[index];
387
- next[index] = next[swapIndex];
388
- next[swapIndex] = temp;
389
- setLocalStoryOptionsOverride({
390
- generatedAt: activeSnapshot?.generatedAt,
391
- stories: next,
392
- });
393
423
  },
394
- [pjcode, triageStoryOptions, activeSnapshot?.generatedAt],
424
+ [
425
+ pjcode,
426
+ triageStoryOptions,
427
+ storyEntries,
428
+ activeSnapshot?.generatedAt,
429
+ storiesSnapshot?.generatedAt,
430
+ ],
395
431
  );
396
432
 
397
433
  const handleStoryAdd = useCallback(
@@ -523,6 +559,7 @@ export const ConsolePage = () => {
523
559
  onAddStory={handleStoryAdd}
524
560
  onSelectColor={handleSelectColor}
525
561
  onToggleGray={handleToggleGray}
562
+ onReorderStory={handleReorderStory}
526
563
  optimisticColors={storyOptimisticColors}
527
564
  colorChangeInFlight={storyColorChangeInFlight}
528
565
  colorErrors={storyColorErrors}