Skip to content

Conversation

@DaxServer
Copy link
Owner

Addresses Task 26 of #66

@coderabbitai
Copy link

coderabbitai bot commented Aug 2, 2025

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Introduced real-time validation for drag-and-drop schema editing, providing immediate feedback on mapping validity.
    • Added new UI integration for schema validation, displaying validation status, error/warning counts, and visual feedback in the interface.
  • Bug Fixes

    • Updated error message formatting in validation feedback for consistency.
  • Tests

    • Added comprehensive test suites for real-time validation, schema validation UI, and their integration with drag-and-drop functionality.
  • Chores

    • Updated auto-import configurations to recognize new validation composables as globally available.

Walkthrough

This change introduces a comprehensive real-time validation system for drag-and-drop schema editing in the frontend. It adds two new composables—useRealTimeValidation and useSchemaValidationUI—along with their global auto-imports and type declarations. The drag-and-drop context is refactored to delegate validation to the new real-time system. Extensive test suites are added for the new composables and their integration, and documentation is updated to mark the real-time validation task as complete.

Changes

Cohort / File(s) Change Summary
Real-Time Validation Composables (New)
frontend/src/composables/useRealTimeValidation.ts, frontend/src/composables/useSchemaValidationUI.ts
Introduced new composables for real-time validation logic and UI integration, providing reactive validation state, feedback, and control methods for schema editing.
Drag-and-Drop Context Integration
frontend/src/composables/useDragDropContext.ts
Refactored to use the new real-time validation composable for drop validation and feedback, removing previous manual validation logic.
Global Auto-Imports and Type Declarations
frontend/.eslintrc-auto-import.json, frontend/auto-imports.d.ts
Registered useRealTimeValidation and useSchemaValidationUI as global auto-imports and updated type declarations for global usage in the codebase.
New and Updated Test Suites
frontend/src/composables/__tests__/useRealTimeValidation.test.ts, frontend/src/composables/__tests__/useSchemaValidationUI.test.ts, frontend/src/composables/__tests__/useDragDropValidationIntegration.test.ts, frontend/src/composables/__tests__/useDragDropContext.test.ts
Added comprehensive tests for the new composables, their integration, and updated an existing test for validation error message consistency.
Documentation / Task Tracking
.kiro/specs/wikibase-schema-editor/tasks.md
Marked the "Implement real-time validation" task as completed.

Sequence Diagram(s)

Real-Time Drag-and-Drop Validation Flow

sequenceDiagram
    participant User
    participant UI
    participant useDragDropContext
    participant useRealTimeValidation
    participant ValidationStore

    User->>UI: Drag column over drop target
    UI->>useDragDropContext: enterDropZone(column, target)
    useDragDropContext->>useRealTimeValidation: validateDragOperation(column, target)
    useRealTimeValidation->>ValidationStore: (optional) Add validation error
    useRealTimeValidation-->>useDragDropContext: Validation result / feedback
    useDragDropContext-->>UI: Update drop feedback in UI
    User->>UI: Drop column
    UI->>useDragDropContext: drop(column, target)
    useDragDropContext->>useRealTimeValidation: validateDragOperation(column, target)
    alt Valid
        useDragDropContext-->>UI: Accept drop
    else Invalid
        useDragDropContext-->>UI: Reject drop, show error
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch wikibase-editor-task26

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@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: 3

🧹 Nitpick comments (1)
frontend/src/composables/useDragDropContext.ts (1)

5-5: Consider using auto-import for consistency.

Since useRealTimeValidation is configured for auto-import in both ESLint and TypeScript declaration files, the explicit import might be redundant. Consider removing this import line to leverage the auto-import feature consistently across the codebase.

-import { useRealTimeValidation } from '@frontend/composables/useRealTimeValidation'
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 37b454b and 0a1d7f8.

📒 Files selected for processing (10)
  • .kiro/specs/wikibase-schema-editor/tasks.md (1 hunks)
  • frontend/.eslintrc-auto-import.json (2 hunks)
  • frontend/auto-imports.d.ts (4 hunks)
  • frontend/src/composables/__tests__/useDragDropContext.test.ts (1 hunks)
  • frontend/src/composables/__tests__/useDragDropValidationIntegration.test.ts (1 hunks)
  • frontend/src/composables/__tests__/useRealTimeValidation.test.ts (1 hunks)
  • frontend/src/composables/__tests__/useSchemaValidationUI.test.ts (1 hunks)
  • frontend/src/composables/useDragDropContext.ts (4 hunks)
  • frontend/src/composables/useRealTimeValidation.ts (1 hunks)
  • frontend/src/composables/useSchemaValidationUI.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit Inference Engine (.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc)

**/*.{ts,tsx,js,jsx}: Use bun <file> instead of node <file> or ts-node <file> for running TypeScript or JavaScript files
Do not use dotenv; Bun automatically loads .env files
Use Bun.serve() for HTTP servers and WebSockets instead of express
Use bun:sqlite for SQLite instead of better-sqlite3
Use Bun.redis for Redis instead of ioredis
Use Bun.sql for Postgres instead of pg or postgres.js
Use built-in WebSocket instead of ws
Prefer Bun.file over node:fs's readFile/writeFile
Use Bun.$ (e.g., Bun.$ls``) instead of execa for running shell commands

Files:

  • frontend/src/composables/__tests__/useDragDropContext.test.ts
  • frontend/src/composables/__tests__/useSchemaValidationUI.test.ts
  • frontend/src/composables/useSchemaValidationUI.ts
  • frontend/src/composables/__tests__/useRealTimeValidation.test.ts
  • frontend/src/composables/useDragDropContext.ts
  • frontend/auto-imports.d.ts
  • frontend/src/composables/useRealTimeValidation.ts
  • frontend/src/composables/__tests__/useDragDropValidationIntegration.test.ts
**/*.test.{ts,tsx,js,jsx}

📄 CodeRabbit Inference Engine (.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc)

Use bun test instead of jest for running tests

Files:

  • frontend/src/composables/__tests__/useDragDropContext.test.ts
  • frontend/src/composables/__tests__/useSchemaValidationUI.test.ts
  • frontend/src/composables/__tests__/useRealTimeValidation.test.ts
  • frontend/src/composables/__tests__/useDragDropValidationIntegration.test.ts
**/*.{html,ts,tsx,css}

📄 CodeRabbit Inference Engine (.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc)

Use bun build <file.html|file.ts|file.css> instead of webpack or esbuild for building HTML, TypeScript, or CSS files

Files:

  • frontend/src/composables/__tests__/useDragDropContext.test.ts
  • frontend/src/composables/__tests__/useSchemaValidationUI.test.ts
  • frontend/src/composables/useSchemaValidationUI.ts
  • frontend/src/composables/__tests__/useRealTimeValidation.test.ts
  • frontend/src/composables/useDragDropContext.ts
  • frontend/auto-imports.d.ts
  • frontend/src/composables/useRealTimeValidation.ts
  • frontend/src/composables/__tests__/useDragDropValidationIntegration.test.ts
🧠 Learnings (21)
📓 Common learnings
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/frontend-setup.rule.md:0-0
Timestamp: 2025-07-20T14:13:24.706Z
Learning: Applies to src/composables/**/*.ts : Use composables for logic that is not global state
📚 Learning: applies to src/**/*.vue : use auto-imports for vue, pinia, composables, and utilities...
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/frontend-setup.rule.md:0-0
Timestamp: 2025-07-20T14:13:24.706Z
Learning: Applies to src/**/*.vue : Use auto-imports for Vue, Pinia, composables, and utilities

Applied to files:

  • frontend/.eslintrc-auto-import.json
  • frontend/auto-imports.d.ts
📚 Learning: applies to src/**/*.{vue,ts} : use useapi composable (elysia eden) for all api calls...
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/frontend-setup.rule.md:0-0
Timestamp: 2025-07-20T14:13:24.706Z
Learning: Applies to src/**/*.{vue,ts} : Use useApi composable (Elysia Eden) for all API calls

Applied to files:

  • frontend/.eslintrc-auto-import.json
  • frontend/src/composables/__tests__/useSchemaValidationUI.test.ts
  • frontend/src/composables/useSchemaValidationUI.ts
  • frontend/src/composables/__tests__/useRealTimeValidation.test.ts
  • frontend/src/composables/useDragDropContext.ts
  • frontend/auto-imports.d.ts
  • frontend/src/composables/useRealTimeValidation.ts
📚 Learning: applies to **/*.{html,tsx,jsx,js,css} : use html imports with `bun.serve()` instead of `vite` for fr...
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-07-20T14:13:40.153Z
Learning: Applies to **/*.{html,tsx,jsx,js,css} : Use HTML imports with `Bun.serve()` instead of `vite` for frontend development

Applied to files:

  • frontend/.eslintrc-auto-import.json
  • frontend/auto-imports.d.ts
📚 Learning: applies to src/**/*.{vue,ts} : always use backend-inferred types for api data...
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/frontend-setup.rule.md:0-0
Timestamp: 2025-07-20T14:13:24.706Z
Learning: Applies to src/**/*.{vue,ts} : Always use backend-inferred types for API data

Applied to files:

  • frontend/.eslintrc-auto-import.json
  • frontend/auto-imports.d.ts
📚 Learning: applies to **/*.{tsx,jsx,js} : import .css files directly in .tsx, .jsx, or .js files and bun will h...
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc:0-0
Timestamp: 2025-07-20T14:13:40.153Z
Learning: Applies to **/*.{tsx,jsx,js} : Import .css files directly in .tsx, .jsx, or .js files and Bun will handle them

Applied to files:

  • frontend/.eslintrc-auto-import.json
📚 Learning: applies to src/composables/**/*.ts : use composables for logic that is not global state...
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/frontend-setup.rule.md:0-0
Timestamp: 2025-07-20T14:13:24.706Z
Learning: Applies to src/composables/**/*.ts : Use composables for logic that is not global state

Applied to files:

  • frontend/src/composables/__tests__/useSchemaValidationUI.test.ts
  • frontend/src/composables/useSchemaValidationUI.ts
  • frontend/src/composables/__tests__/useRealTimeValidation.test.ts
  • frontend/src/composables/useDragDropContext.ts
  • frontend/auto-imports.d.ts
  • frontend/src/composables/useRealTimeValidation.ts
  • frontend/src/composables/__tests__/useDragDropValidationIntegration.test.ts
📚 Learning: applies to src/**/*.vue : use vue 3 with composition api and <script setup lang="ts"> in all vue com...
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/frontend-setup.rule.md:0-0
Timestamp: 2025-07-20T14:13:24.706Z
Learning: Applies to src/**/*.vue : Use Vue 3 with Composition API and <script setup lang="ts"> in all Vue components

Applied to files:

  • frontend/src/composables/__tests__/useSchemaValidationUI.test.ts
  • frontend/src/composables/useSchemaValidationUI.ts
  • frontend/src/composables/__tests__/useRealTimeValidation.test.ts
  • frontend/auto-imports.d.ts
  • frontend/src/composables/useRealTimeValidation.ts
📚 Learning: applies to src/composables/**/*.ts : do not proxy or export pinia store state/actions from composabl...
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/frontend-setup.rule.md:0-0
Timestamp: 2025-07-20T14:13:24.706Z
Learning: Applies to src/composables/**/*.ts : Do not proxy or export Pinia store state/actions from composables

Applied to files:

  • frontend/src/composables/__tests__/useSchemaValidationUI.test.ts
  • frontend/src/composables/useSchemaValidationUI.ts
  • frontend/src/composables/__tests__/useRealTimeValidation.test.ts
  • frontend/src/composables/__tests__/useDragDropValidationIntegration.test.ts
📚 Learning: applies to src/**/*.{vue,ts} : use pinia stores for global state...
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/frontend-setup.rule.md:0-0
Timestamp: 2025-07-20T14:13:24.706Z
Learning: Applies to src/**/*.{vue,ts} : Use Pinia stores for global state

Applied to files:

  • frontend/src/composables/__tests__/useSchemaValidationUI.test.ts
  • frontend/src/composables/__tests__/useRealTimeValidation.test.ts
  • frontend/auto-imports.d.ts
  • frontend/src/composables/__tests__/useDragDropValidationIntegration.test.ts
📚 Learning: applies to src/composables/**/*.ts : place composables in the composables/ directory...
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/frontend-setup.rule.md:0-0
Timestamp: 2025-07-20T14:13:24.706Z
Learning: Applies to src/composables/**/*.ts : Place composables in the composables/ directory

Applied to files:

  • frontend/src/composables/__tests__/useSchemaValidationUI.test.ts
  • frontend/src/composables/useSchemaValidationUI.ts
  • frontend/src/composables/__tests__/useRealTimeValidation.test.ts
📚 Learning: applies to src/composables/**/*.ts : do not export store state from composables...
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/frontend-setup.rule.md:0-0
Timestamp: 2025-07-20T14:13:24.706Z
Learning: Applies to src/composables/**/*.ts : Do not export store state from composables

Applied to files:

  • frontend/src/composables/useSchemaValidationUI.ts
  • frontend/src/composables/useDragDropContext.ts
  • frontend/auto-imports.d.ts
  • frontend/src/composables/useRealTimeValidation.ts
📚 Learning: applies to src/**/*.vue : use reactive objects for form state and errors...
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/frontend-setup.rule.md:0-0
Timestamp: 2025-07-20T14:13:24.706Z
Learning: Applies to src/**/*.vue : Use reactive objects for form state and errors

Applied to files:

  • frontend/src/composables/useSchemaValidationUI.ts
  • frontend/auto-imports.d.ts
  • frontend/src/composables/useRealTimeValidation.ts
📚 Learning: applies to src/**/*.vue : prefer composables over methods in vue components...
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/frontend-setup.rule.md:0-0
Timestamp: 2025-07-20T14:13:24.706Z
Learning: Applies to src/**/*.vue : Prefer composables over methods in Vue components

Applied to files:

  • frontend/src/composables/useSchemaValidationUI.ts
  • frontend/auto-imports.d.ts
📚 Learning: applies to src/**/*.vue : props and emits must use explicit typescript interfaces...
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/frontend-setup.rule.md:0-0
Timestamp: 2025-07-20T14:13:24.706Z
Learning: Applies to src/**/*.vue : Props and emits must use explicit TypeScript interfaces

Applied to files:

  • frontend/src/composables/useSchemaValidationUI.ts
  • frontend/auto-imports.d.ts
📚 Learning: applies to src/**/*.{ts,vue} : type safety everywhere...
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/frontend-setup.rule.md:0-0
Timestamp: 2025-07-20T14:13:24.706Z
Learning: Applies to src/**/*.{ts,vue} : Type safety everywhere

Applied to files:

  • frontend/src/composables/useSchemaValidationUI.ts
  • frontend/auto-imports.d.ts
📚 Learning: applies to src/**/*.{vue,ts} : use readonly and shallowreactive for large or expensive data...
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/frontend-setup.rule.md:0-0
Timestamp: 2025-07-20T14:13:24.706Z
Learning: Applies to src/**/*.{vue,ts} : Use readonly and shallowReactive for large or expensive data

Applied to files:

  • frontend/auto-imports.d.ts
📚 Learning: applies to src/**/*.vue : use storetorefs for state in components...
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/frontend-setup.rule.md:0-0
Timestamp: 2025-07-20T14:13:24.706Z
Learning: Applies to src/**/*.vue : Use storeToRefs for state in components

Applied to files:

  • frontend/auto-imports.d.ts
📚 Learning: applies to src/**/*.vue : use v-memo, shallowref, markraw, and suspense for performance optimization...
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/frontend-setup.rule.md:0-0
Timestamp: 2025-07-20T14:13:24.706Z
Learning: Applies to src/**/*.vue : Use v-memo, shallowRef, markRaw, and Suspense for performance optimization

Applied to files:

  • frontend/auto-imports.d.ts
📚 Learning: applies to src/**/*.vue : use primevue as the ui library in all vue components...
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/frontend-setup.rule.md:0-0
Timestamp: 2025-07-20T14:13:24.706Z
Learning: Applies to src/**/*.vue : Use PrimeVue as the UI library in all Vue components

Applied to files:

  • frontend/auto-imports.d.ts
📚 Learning: applies to src/**/*.vue : build reusable, well-structured components...
Learnt from: CR
PR: DaxServer/dataforge#0
File: .cursor/rules/frontend-setup.rule.md:0-0
Timestamp: 2025-07-20T14:13:24.706Z
Learning: Applies to src/**/*.vue : Build reusable, well-structured components

Applied to files:

  • frontend/auto-imports.d.ts
🧬 Code Graph Analysis (5)
frontend/src/composables/useSchemaValidationUI.ts (4)
frontend/src/composables/useRealTimeValidation.ts (1)
  • useRealTimeValidation (33-437)
frontend/src/stores/drag-drop.store.ts (1)
  • useDragDropStore (10-174)
frontend/src/stores/validation.store.ts (1)
  • useValidationStore (9-128)
frontend/auto-imports.d.ts (2)
  • ColumnInfo (382-382)
  • DropTarget (376-376)
frontend/src/composables/__tests__/useRealTimeValidation.test.ts (4)
frontend/auto-imports.d.ts (3)
  • ColumnInfo (382-382)
  • DropTarget (376-376)
  • WikibaseDataType (382-382)
frontend/src/stores/drag-drop.store.ts (1)
  • useDragDropStore (10-174)
frontend/src/stores/validation.store.ts (1)
  • useValidationStore (9-128)
frontend/src/composables/useRealTimeValidation.ts (1)
  • useRealTimeValidation (33-437)
frontend/src/composables/useDragDropContext.ts (3)
frontend/src/stores/drag-drop.store.ts (1)
  • useDragDropStore (10-174)
frontend/src/composables/useDataTypeCompatibility.ts (1)
  • useDataTypeCompatibility (8-44)
frontend/src/composables/useRealTimeValidation.ts (1)
  • useRealTimeValidation (33-437)
frontend/auto-imports.d.ts (2)
frontend/src/composables/useRealTimeValidation.ts (1)
  • useRealTimeValidation (33-437)
frontend/src/composables/useSchemaValidationUI.ts (1)
  • useSchemaValidationUI (12-190)
frontend/src/composables/__tests__/useDragDropValidationIntegration.test.ts (4)
frontend/src/stores/drag-drop.store.ts (1)
  • useDragDropStore (10-174)
frontend/src/stores/validation.store.ts (1)
  • useValidationStore (9-128)
frontend/src/composables/useDragDropContext.ts (1)
  • useDragDropContext (41-270)
frontend/src/composables/useRealTimeValidation.ts (1)
  • useRealTimeValidation (33-437)
🔇 Additional comments (11)
.kiro/specs/wikibase-schema-editor/tasks.md (1)

154-154: Documentation update is appropriate.

The task completion aligns with the PR's implementation of real-time validation functionality.

frontend/src/composables/__tests__/useDragDropContext.test.ts (1)

168-168: Test expectation correctly updated.

The validation message format change aligns with the new real-time validation system's message conventions.

frontend/.eslintrc-auto-import.json (1)

322-322: ESLint configuration properly updated.

The new composables are correctly added as global identifiers and maintain alphabetical ordering.

Also applies to: 334-334

frontend/auto-imports.d.ts (1)

1-6: Verify auto-generation process for type declarations.

The new composable declarations are correctly added and maintain alphabetical ordering. However, since this file is marked as auto-generated, please confirm these changes were made through the proper auto-generation process rather than manual edits.

Also applies to: 263-263, 275-275, 644-644, 656-656

frontend/src/composables/useDragDropContext.ts (2)

123-139: Validation refactoring is well-implemented.

The delegation to realTimeValidation.validateDragOperation successfully centralizes validation logic while maintaining the original interface. The error handling with fallback message ensures robustness.


107-115: Feedback delegation properly implemented.

The use of realTimeValidation.getValidationFeedback ensures consistent validation feedback across the application.

frontend/src/composables/__tests__/useRealTimeValidation.test.ts (1)

37-134: Well-structured validation tests.

The real-time drag validation tests comprehensively cover various validation scenarios including data type compatibility, nullable constraints, property requirements, and length constraints. Good use of reactive property testing.

frontend/src/composables/__tests__/useSchemaValidationUI.test.ts (2)

213-213: Update tests after removing unused acceptedTypes parameter.

These test calls need to be updated once the acceptedTypes parameter is removed from getDropZoneClasses method as suggested in the implementation review.

-      const classes = ui.getDropZoneClasses('item.terms.labels.en', ['string'])
+      const classes = ui.getDropZoneClasses('item.terms.labels.en')

Apply similar changes to lines 241, 269, and 275.

Also applies to: 241-241, 269-269, 275-275


380-392: Remove tests for direct store access.

Since direct store access should be removed from the composable as per coding guidelines, these tests should be updated accordingly.

   describe('Direct Access', () => {
     it('should provide direct access to underlying composables', () => {
       const ui = useSchemaValidationUI()

       expect(ui.realTimeValidation).toBeDefined()
-      expect(ui.dragDropStore).toBeDefined()
-      expect(ui.validationStore).toBeDefined()
-
-      // Should be the same instances
-      expect(ui.dragDropStore).toBe(dragDropStore)
-      expect(ui.validationStore).toBe(validationStore)
     })
   })
frontend/src/composables/__tests__/useDragDropValidationIntegration.test.ts (1)

115-269: Excellent store integration test coverage.

The store integration tests thoroughly verify error synchronization, clearing behavior, and multiple path handling. The drag store integration tests properly validate target computation and state changes.

frontend/src/composables/useRealTimeValidation.ts (1)

286-348: Well-implemented real-time validation lifecycle management.

The implementation properly manages watchers with cleanup, handles all relevant state changes, and provides immediate feedback. Good use of Vue's reactivity system.

Comment on lines +25 to +51
const currentDragValidation = computed(() => {
if (!dragDropStore.draggedColumn || !dragDropStore.hoveredTarget) {
return null
}

const target = dragDropStore.availableTargets.find(
(t) => t.path === dragDropStore.hoveredTarget,
)
if (!target) return null

return realTimeValidation.validateDragOperation(dragDropStore.draggedColumn, target)
})

// UI feedback for current drag operation
const currentDragFeedback = computed(() => {
if (!dragDropStore.draggedColumn || !dragDropStore.hoveredTarget) {
return null
}

const target = dragDropStore.availableTargets.find(
(t) => t.path === dragDropStore.hoveredTarget,
)
if (!target) return null

return realTimeValidation.getValidationFeedback(dragDropStore.draggedColumn, target)
})

Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Refactor duplicated target lookup logic.

The target lookup logic is duplicated between currentDragValidation and currentDragFeedback computed properties. This violates the DRY principle.

Consider extracting the target lookup logic into a helper computed property:

+  // Helper computed property for current hovered target
+  const currentHoveredTarget = computed(() => {
+    if (!dragDropStore.hoveredTarget) return null
+    return dragDropStore.availableTargets.find(
+      (t) => t.path === dragDropStore.hoveredTarget,
+    )
+  })
+
   // Current drag validation state
   const currentDragValidation = computed(() => {
     if (!dragDropStore.draggedColumn || !dragDropStore.hoveredTarget) {
       return null
     }

-    const target = dragDropStore.availableTargets.find(
-      (t) => t.path === dragDropStore.hoveredTarget,
-    )
+    const target = currentHoveredTarget.value
     if (!target) return null

     return realTimeValidation.validateDragOperation(dragDropStore.draggedColumn, target)
   })

   // UI feedback for current drag operation
   const currentDragFeedback = computed(() => {
     if (!dragDropStore.draggedColumn || !dragDropStore.hoveredTarget) {
       return null
     }

-    const target = dragDropStore.availableTargets.find(
-      (t) => t.path === dragDropStore.hoveredTarget,
-    )
+    const target = currentHoveredTarget.value
     if (!target) return null

     return realTimeValidation.getValidationFeedback(dragDropStore.draggedColumn, target)
   })
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const currentDragValidation = computed(() => {
if (!dragDropStore.draggedColumn || !dragDropStore.hoveredTarget) {
return null
}
const target = dragDropStore.availableTargets.find(
(t) => t.path === dragDropStore.hoveredTarget,
)
if (!target) return null
return realTimeValidation.validateDragOperation(dragDropStore.draggedColumn, target)
})
// UI feedback for current drag operation
const currentDragFeedback = computed(() => {
if (!dragDropStore.draggedColumn || !dragDropStore.hoveredTarget) {
return null
}
const target = dragDropStore.availableTargets.find(
(t) => t.path === dragDropStore.hoveredTarget,
)
if (!target) return null
return realTimeValidation.getValidationFeedback(dragDropStore.draggedColumn, target)
})
// Helper computed property for current hovered target
const currentHoveredTarget = computed(() => {
if (!dragDropStore.hoveredTarget) return null
return dragDropStore.availableTargets.find(
(t) => t.path === dragDropStore.hoveredTarget,
)
})
const currentDragValidation = computed(() => {
if (!dragDropStore.draggedColumn || !dragDropStore.hoveredTarget) {
return null
}
const target = currentHoveredTarget.value
if (!target) return null
return realTimeValidation.validateDragOperation(dragDropStore.draggedColumn, target)
})
// UI feedback for current drag operation
const currentDragFeedback = computed(() => {
if (!dragDropStore.draggedColumn || !dragDropStore.hoveredTarget) {
return null
}
const target = currentHoveredTarget.value
if (!target) return null
return realTimeValidation.getValidationFeedback(dragDropStore.draggedColumn, target)
})
🤖 Prompt for AI Agents
In frontend/src/composables/useSchemaValidationUI.ts between lines 25 and 51,
the logic to find the target from dragDropStore.availableTargets based on
dragDropStore.hoveredTarget is duplicated in both currentDragValidation and
currentDragFeedback computed properties. Extract this target lookup into a
separate computed property, for example named currentDragTarget, that returns
the found target or null. Then update currentDragValidation and
currentDragFeedback to use this new computed property instead of repeating the
lookup logic.

}

// Get drop zone classes based on current drag state
const getDropZoneClasses = (targetPath: string, acceptedTypes: string[]) => {
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove unused parameter acceptedTypes.

The acceptedTypes parameter is not used within the getDropZoneClasses method.

-  const getDropZoneClasses = (targetPath: string, acceptedTypes: string[]) => {
+  const getDropZoneClasses = (targetPath: string) => {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const getDropZoneClasses = (targetPath: string, acceptedTypes: string[]) => {
const getDropZoneClasses = (targetPath: string) => {
🤖 Prompt for AI Agents
In frontend/src/composables/useSchemaValidationUI.ts at line 103, the function
getDropZoneClasses has an unused parameter acceptedTypes. Remove the
acceptedTypes parameter from the function signature to clean up the code and
avoid confusion.

Comment on lines +185 to +189
// Direct access to underlying composables
realTimeValidation,
dragDropStore,
validationStore,
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Do not export store instances from composables.

According to the coding guidelines, composables should not export Pinia store state or actions. Directly exposing dragDropStore and validationStore violates this principle.

Remove the direct store exports from the return statement:

     // Control methods
     enableRealTimeValidation,
     disableRealTimeValidation,
     clearAllValidation,
     clearPathValidation,

-    // Direct access to underlying composables
-    realTimeValidation,
-    dragDropStore,
-    validationStore,
+    // Direct access to underlying composable only
+    realTimeValidation,
   }

If components need to access store state, they should import the stores directly rather than accessing them through this composable.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Direct access to underlying composables
realTimeValidation,
dragDropStore,
validationStore,
}
return {
// Control methods
enableRealTimeValidation,
disableRealTimeValidation,
clearAllValidation,
clearPathValidation,
// Direct access to underlying composable only
realTimeValidation,
}
🤖 Prompt for AI Agents
In frontend/src/composables/useSchemaValidationUI.ts around lines 185 to 189,
remove the direct exports of the Pinia store instances dragDropStore and
validationStore from the return statement of the composable. Instead, only
export non-store composables or functions. Components that need access to these
stores should import them directly rather than accessing them through this
composable.

@DaxServer DaxServer merged commit ab5f174 into main Aug 2, 2025
6 checks passed
@DaxServer DaxServer deleted the wikibase-editor-task26 branch August 2, 2025 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant