Skip to content

feat: rework add cards dialog#149

Merged
gkrajniak merged 2 commits into
mainfrom
add-card-dialog
May 26, 2026
Merged

feat: rework add cards dialog#149
gkrajniak merged 2 commits into
mainfrom
add-card-dialog

Conversation

@Sobyt483
Copy link
Copy Markdown
Contributor

@Sobyt483 Sobyt483 commented May 26, 2026

image

Summary by CodeRabbit

  • New Features
    • Replaced the "Add Card" dialog with an "Edit Cards" dialog that supports adding and removing cards together and uses toggles for selection.
  • Documentation
    • Updated dashboard docs and default button label to "Edit Cards" with examples reflecting the new dialog.
  • Tests
    • Updated dashboard tests and added comprehensive tests for the new edit dialog; removed old add-dialog tests.
  • Examples
    • Storybook examples and card story configurations updated for the edit workflow and adjusted card display settings.

Review Change Stack

Signed-off-by: Sobyt483 <andrianingomel@gmail.com>
@Sobyt483 Sobyt483 requested review from a team as code owners May 26, 2026 11:53
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0c97293f-e381-4ccb-a0ce-c32cf8a7d5ca

📥 Commits

Reviewing files that changed from the base of the PR and between 9e74b0b and 32cda25.

📒 Files selected for processing (1)
  • projects/ngx/declarative-ui/dashboard/dashboard/dashboard.component.ts

📝 Walkthrough

Walkthrough

Replaces AddCardDialog with EditCardsDialog (add + remove). Dashboard uses the new dialog and onCardsEdited({ added, removed }) handler; tests, Storybook stories, exports, and docs updated. Minor Pods card story/config adjustments applied.

Changes

Dialog Implementation and Integration

Layer / File(s) Summary
EditCardsDialog component implementation
projects/ngx/declarative-ui/dashboard/edit-cards-dialog/edit-cards-dialog.component.ts, .../edit-cards-dialog.component.html, .../edit-cards-dialog.component.scss
New standalone component with signal inputs (availableCards, addedCardsIds, open), outputs (confirm, cancelled), selectedIds state, toggle() and confirmSave() logic; template renders list with switches and Save/Cancel footer; styles added.
EditCardsDialog test suite
projects/ngx/declarative-ui/dashboard/edit-cards-dialog/edit-cards-dialog.component.spec.ts
Comprehensive tests for empty state, initialization on open/reset, toggle semantics, confirmSave payloads covering added/removed combinations and edge-cases, cancel events, and template rendering.
Dashboard component integration
projects/ngx/declarative-ui/dashboard/dashboard/dashboard.component.ts, dashboard.component.html, dashboard.component.spec.ts
Dashboard imports EditCardsDialog, swaps mfp-add-card-dialogmfp-edit-cards-dialog, updates action text to "Edit Cards", and replaces onCardsAdded(cards) with onCardsEdited({added, removed}) that removes listed IDs then appends added cards; tests updated to cover no-change and removals.
Barrel export & Storybook
projects/ngx/declarative-ui/dashboard/index.ts, projects/ngx/declarative-ui/stories/edit-cards-dialog.stories.ts
Barrel export now re-exports EditCardsDialog; Storybook story switched to EditCardsDialogStory and updated to show added/removed messaging.
Documentation & pods story adjustments
docs/dashboard.md, projects/ngx/declarative-ui/stories/dashboard.cards.ts, projects/ngx/declarative-ui/stories/dashboard.stories.ts
Docs updated with EditCardsDialog section and changed default button text to "Edit Cards"; Pods table card height reduced and story inputs extended with header/headerTooltip.

Sequence Diagram

sequenceDiagram
  participant User
  participant Dashboard
  participant EditCardsDialog
  User->>Dashboard: click "Edit Cards"
  Dashboard->>EditCardsDialog: open(availableCards, addedCardsIds)
  EditCardsDialog->>EditCardsDialog: init selectedIds from addedCardsIds
  User->>EditCardsDialog: toggle selections and click Save
  EditCardsDialog->>Dashboard: emit confirm {added, removed}
  Dashboard->>Dashboard: remove IDs in removed and append added cards
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • gkrajniak

Poem

🐰 I hopped into dialogs, switches aglow,
I toggled the cards, letting some go.
I saved and emitted both add and remove,
A tiny rabbit, approving the move.
Cheers to the UI — flexible flow!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: rework add cards dialog' accurately reflects the main change: replacing the AddCardDialog component with a new EditCardsDialog component and updating related functionality throughout the codebase.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add-card-dialog

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Sobyt483 Sobyt483 self-assigned this May 26, 2026
@Sobyt483 Sobyt483 added the enhancement New feature or request label May 26, 2026
@Sobyt483 Sobyt483 moved this to In review in OpenMFP Development May 26, 2026
@Sobyt483 Sobyt483 linked an issue May 26, 2026 that may be closed by this pull request
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
projects/ngx/declarative-ui/dashboard/dashboard/dashboard.component.ts (1)

222-226: ⚡ Quick win

Preserve unique card IDs and clear stale positions in onCardsEdited.

Line 225 appends incoming cards blindly, and removed IDs are not purged from cardsPosition. A defensive merge avoids duplicate id keys and stale x/y reuse.

♻️ Proposed refactor
   onCardsEdited(event: { added: CardConfig[]; removed: string[] }): void {
+    const removedIds = new Set(event.removed);
+    removedIds.forEach((id) => this.cardsPosition.delete(id));
     this.cards.update((list) => {
-      const withoutRemoved = list.filter((c) => !event.removed.includes(c.id));
-      return [...withoutRemoved, ...event.added.map((ac) => ({ ...ac }))];
+      const next = list.filter((c) => !removedIds.has(c.id));
+      const nextIds = new Set(next.map((c) => c.id));
+      const uniqueAdded = event.added
+        .filter((ac) => !nextIds.has(ac.id))
+        .map((ac) => ({ ...ac }));
+      return [...next, ...uniqueAdded];
     });
     this.closeCardPanel();
   }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@projects/ngx/declarative-ui/dashboard/dashboard/dashboard.component.ts`
around lines 222 - 226, onCardsEdited currently appends incoming CardConfig
items blindly and never cleans up cardsPosition, causing duplicate ids and stale
x/y reuse; modify the cards.update callback to perform a defensive merge: build
a map of existing cards by id, remove any entries whose ids are in
event.removed, then upsert event.added items by replacing existing entries with
the same id (preserving other fields only when not overwritten) so no duplicates
remain; additionally, remove any keys from the cardsPosition store that match
removed ids and reset/clear positions for replaced ids so old x/y are not reused
(referencing onCardsEdited, cards.update, cardsPosition, CardConfig, id, x/y).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@projects/ngx/declarative-ui/dashboard/edit-cards-dialog/edit-cards-dialog.component.ts`:
- Around line 3-23: The component decorator for EditCardsDialog is missing
standalone mode and OnPush change detection; update the `@Component` to include
standalone: true and changeDetection: ChangeDetectionStrategy.OnPush, add an
import for ChangeDetectionStrategy from '`@angular/core`', and ensure the class
name EditCardsDialog (or the component class) remains unchanged; no other logic
changes needed.

---

Nitpick comments:
In `@projects/ngx/declarative-ui/dashboard/dashboard/dashboard.component.ts`:
- Around line 222-226: onCardsEdited currently appends incoming CardConfig items
blindly and never cleans up cardsPosition, causing duplicate ids and stale x/y
reuse; modify the cards.update callback to perform a defensive merge: build a
map of existing cards by id, remove any entries whose ids are in event.removed,
then upsert event.added items by replacing existing entries with the same id
(preserving other fields only when not overwritten) so no duplicates remain;
additionally, remove any keys from the cardsPosition store that match removed
ids and reset/clear positions for replaced ids so old x/y are not reused
(referencing onCardsEdited, cards.update, cardsPosition, CardConfig, id, x/y).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d50d88cd-b0b9-4335-a968-64857d81690f

📥 Commits

Reviewing files that changed from the base of the PR and between 2244ace and 9e74b0b.

📒 Files selected for processing (16)
  • docs/dashboard.md
  • projects/ngx/declarative-ui/dashboard/add-card-dialog/add-card-dialog.component.html
  • projects/ngx/declarative-ui/dashboard/add-card-dialog/add-card-dialog.component.scss
  • projects/ngx/declarative-ui/dashboard/add-card-dialog/add-card-dialog.component.spec.ts
  • projects/ngx/declarative-ui/dashboard/add-card-dialog/add-card-dialog.component.ts
  • projects/ngx/declarative-ui/dashboard/dashboard/dashboard.component.html
  • projects/ngx/declarative-ui/dashboard/dashboard/dashboard.component.spec.ts
  • projects/ngx/declarative-ui/dashboard/dashboard/dashboard.component.ts
  • projects/ngx/declarative-ui/dashboard/edit-cards-dialog/edit-cards-dialog.component.html
  • projects/ngx/declarative-ui/dashboard/edit-cards-dialog/edit-cards-dialog.component.scss
  • projects/ngx/declarative-ui/dashboard/edit-cards-dialog/edit-cards-dialog.component.spec.ts
  • projects/ngx/declarative-ui/dashboard/edit-cards-dialog/edit-cards-dialog.component.ts
  • projects/ngx/declarative-ui/dashboard/index.ts
  • projects/ngx/declarative-ui/stories/dashboard.cards.ts
  • projects/ngx/declarative-ui/stories/dashboard.stories.ts
  • projects/ngx/declarative-ui/stories/edit-cards-dialog.stories.ts
💤 Files with no reviewable changes (4)
  • projects/ngx/declarative-ui/dashboard/add-card-dialog/add-card-dialog.component.spec.ts
  • projects/ngx/declarative-ui/dashboard/add-card-dialog/add-card-dialog.component.html
  • projects/ngx/declarative-ui/dashboard/add-card-dialog/add-card-dialog.component.scss
  • projects/ngx/declarative-ui/dashboard/add-card-dialog/add-card-dialog.component.ts

@gkrajniak gkrajniak enabled auto-merge (squash) May 26, 2026 12:07
Signed-off-by: Sobyt483 <andrianingomel@gmail.com>
@gkrajniak gkrajniak merged commit 9130d77 into main May 26, 2026
8 of 9 checks passed
@gkrajniak gkrajniak deleted the add-card-dialog branch May 26, 2026 18:50
@github-project-automation github-project-automation Bot moved this from In review to Done in OpenMFP Development May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Rework the Add Cards dialog

2 participants