Skip to content

refactor: api, tables, and ui cleanup and refactor code, add e2e tests #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 47 commits into from
May 5, 2025

Conversation

kmendell
Copy link
Member

@kmendell kmendell commented May 1, 2025

Fixes: #95
Fixes: #80
Fixes: #65

TODO:

  • Remove all form actions and use API Routes
  • Use handleApiReponse wrapper for all Api calls
  • Cleanup Code and Svelte components
  • Use Api endpoints for Stack and Container Creation
  • Update action-buttons to use handleApiReponse
  • Make Get Handlers for API
  • Refactor Volumes Table and API
  • Refactor Network Table and API
  • Refactor Users Table and API
  • Update Dashboard Tables
  • Refactor Settings API Calls
  • Fix Autoupdate Switch on Compose Edit Page
  • Stacks Not able to be updated and saved
  • Loading Indicators not showing up on containers and stacks page (buttons and popups)
  • Add playwright e2e tests (This will be a ongoing effort)
  • Prepare for 0.4.0 release

Summary by CodeRabbit

  • New Features

    • Added centralized API service classes for managing containers, images, networks, stacks, users, system, and volumes, enabling more consistent and robust API interactions.
    • Introduced unified confirmation dialog and enhanced toast notifications for destructive actions across the app.
    • Added Playwright end-to-end testing setup, including authentication and test suites for images and networks.
    • User management, network, volume, and stack management pages now support improved bulk actions and feedback.
  • Improvements

    • Refactored state management throughout the app for better organization and maintainability.
    • Enhanced tables and action menus for containers, images, networks, volumes, stacks, and users with inline action dropdowns, status badges, and improved feedback.
    • Streamlined and unified error handling, loading indicators, and API response management.
    • Improved onboarding, authentication, and session management for a smoother user experience.
  • Bug Fixes

    • Fixed issues with default role selection and role dropdowns in user forms.
    • Prevented deletion of default Docker networks and in-use volumes/images.
  • Documentation

    • Major updates to user-facing documentation, including new guides for user management, volume, and network features, and expanded troubleshooting.
    • Outdated or redundant documentation pages were removed or rewritten for clarity.
  • Chores

    • Updated development and test dependencies, improved .gitignore, and added VS Code settings for Copilot.
    • Optimized Vite and Dockerfile configurations for better compatibility and performance.
  • Style

    • Added test IDs to dialogs for improved automated testing.
  • Tests

    • Introduced comprehensive Playwright test coverage for key features and user flows.

Copy link
Contributor

coderabbitai bot commented May 1, 2025

Caution

Review failed

Failed to post review comments.

Walkthrough

This pull request introduces a comprehensive refactor and enhancement of the Arcane application, affecting UI components, state management, API service abstractions, testing, and documentation. Major changes include the replacement of legacy table cell and action components with inline declarative table definitions, centralized confirmation dialog handling, and the introduction of dedicated API service classes for containers, images, stacks, networks, volumes, and users. State management is consolidated into grouped objects, and all resource lifecycle actions now use consistent async flows with utility functions for error handling and toasts. Extensive end-to-end Playwright tests and supporting test infrastructure are added. Documentation is overhauled, with new user guides and the removal of outdated or redundant files.

Changes

Files / Groups Change Summary
src/lib/components/table-cells/*, src/routes/*/columns.ts, src/routes/*/components/*.svelte, src/routes/columns.ts Deleted legacy table cell, action, and column definition components for users, containers, images, stacks, volumes, and networks.
src/lib/components/action-buttons.svelte, src/routes/*/+page.svelte, src/routes/settings/tabs/user-management.svelte Refactored to use centralized confirmation dialog utility, grouped state management, and dedicated API service classes for all resource actions.
src/lib/components/confirm-dialog/*, src/lib/components/universal-table.svelte, src/lib/types/loading-states.type.ts, src/lib/types/actions.type.ts, src/lib/services/api/*, src/lib/utils/try-catch.ts, src/lib/utils/api.util.ts, src/lib/utils/string.utils.ts Added new confirm dialog component and store, extended universal table for row customization, introduced API service abstractions, new utility types and functions for async error handling and string manipulation.
src/routes/containers/*, src/routes/images/*, src/routes/networks/*, src/routes/volumes/*, src/routes/stacks/* Refactored all resource management pages to use new API services, inline table definitions, grouped state, and improved UI feedback; removed legacy form-based actions and replaced with programmatic API calls and confirmation dialogs.
src/lib/services/paths-service.ts, src/lib/constants.ts Updated to support test environment data paths and environment detection.
src/lib/services/session-service.ts Increased default session timeout and improved session refresh behavior.
src/app.d.ts Expanded the global error interface with message and status.
src/routes/+layout.svelte Integrated the new confirm dialog globally and improved navigation/loading state handling.
package.json, playwright.config.ts, scripts/init-test-env.ts, tests/* Added Playwright E2E test infrastructure, test environment setup script, and comprehensive tests for images and networks features.
docs/docs/features/*, docs/docs/getting-started/user-management.md, docs/docs/guides/troubleshooting.md Overhauled and expanded documentation, adding new user and troubleshooting guides, updating feature overviews, and removing outdated guides.
.gitignore, .vscode/settings.json, Dockerfile, README.md, vite.config.ts Updated configuration, documentation, and environment files for improved developer experience and compatibility.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UIComponent
    participant ConfirmDialog
    participant APIService
    participant Backend

    User->>UIComponent: Clicks resource action (start/stop/remove/etc.)
    UIComponent->>ConfirmDialog: openConfirmDialog({action, message, callback})
    ConfirmDialog->>User: Shows confirmation dialog
    User->>ConfirmDialog: Confirms action
    ConfirmDialog->>APIService: Calls API method (e.g., remove(id))
    APIService->>Backend: Sends HTTP request
    Backend-->>APIService: Returns API response
    APIService->>ConfirmDialog: Resolves callback with result
    ConfirmDialog->>UIComponent: Closes dialog, triggers UI update
    UIComponent->>User: Shows toast/feedback, updates state
Loading

Assessment against linked issues

Objective Addressed Explanation
Refactor: Create Universal Table Cell Svelte Components (#95) Legacy table cell components were deleted, but no new universal table cell Svelte components were introduced; instead, inline row rendering is used.
Clean up UI Elements and Cleanup/Refactor Code (#80)
Docs: Add Documentation (#65)
Tests: Create E2E Playwright Tests and Vitest Unit Tests (#23)

Possibly related PRs

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

playwright.config.ts

Oops! Something went wrong! :(

ESLint: 9.25.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@sveltejs/adapter-node' imported from /svelte.config.js
at packageResolve (node:internal/modules/esm/resolve:839:9)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)
(node:1389) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
(Use node --trace-warnings ... to show where the warning was created)

scripts/init-test-env.ts

Oops! Something went wrong! :(

ESLint: 9.25.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@sveltejs/adapter-node' imported from /svelte.config.js
at packageResolve (node:internal/modules/esm/resolve:839:9)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)
(node:1390) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
(Use node --trace-warnings ... to show where the warning was created)

src/app.d.ts

Oops! Something went wrong! :(

ESLint: 9.25.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@sveltejs/adapter-node' imported from /svelte.config.js
at packageResolve (node:internal/modules/esm/resolve:839:9)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)
(node:1391) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
(Use node --trace-warnings ... to show where the warning was created)

  • 57 others
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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 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.

@kmendell kmendell changed the title refactor: container table refactor refactor: api, tables, and ui cleanup and refactor May 1, 2025
@kmendell kmendell changed the title refactor: api, tables, and ui cleanup and refactor refactor: api, tables, and ui cleanup and refactor code May 2, 2025
@@ -49,7 +64,7 @@
},
columns,
getRowId: idKey
? (originalRow: TData, index: number, parent?: RowData) => {
? (originalRow: TData, _index: number, _parent?: RowData) => {

Check failure

Code scanning / ESLint

Disallow unused variables Error

'_index' is defined but never used.

Copilot Autofix

AI 3 months ago

Copilot could not generate an autofix suggestion

Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.

@kmendell kmendell changed the title refactor: api, tables, and ui cleanup and refactor code refactor: api, tables, and ui cleanup and refactor code, add e22e tests May 3, 2025
@kmendell kmendell changed the title refactor: api, tables, and ui cleanup and refactor code, add e22e tests refactor: api, tables, and ui cleanup and refactor code, add e2e tests May 3, 2025
@kmendell kmendell added this to the 0.4.0 milestone May 3, 2025
@@ -12,15 +11,15 @@
let {
open = $bindable(false),
userToEdit = $bindable<User | null>(null),
roles = []
roles = [],
onSubmit = $bindable((_data: { user: Partial<User> & { password?: string }; isEditMode: boolean; userId?: string }) => {})

Check failure

Code scanning / ESLint

Disallow unused variables Error

'_data' is defined but never used.

Copilot Autofix

AI 3 months ago

Copilot could not generate an autofix suggestion

Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.

import { Button } from '$lib/components/ui/button/index.js';
import { Download, AlertCircle, RefreshCw, HardDrive, Trash2, Loader2, ChevronDown, CopyX } from '@lucide/svelte';
import { Download, AlertCircle, HardDrive, Trash2, Loader2, ChevronDown, CopyX, Ellipsis, ScanSearch, Plus } from '@lucide/svelte';

Check failure

Code scanning / ESLint

Disallow unused variables Error

'Plus' is defined but never used.

Copilot Autofix

AI 3 months ago

Copilot could not generate an autofix suggestion

Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.

@@ -2,65 +2,135 @@
import type { PageData } from './$types';
import * as Card from '$lib/components/ui/card/index.js';
import { Button } from '$lib/components/ui/button/index.js';
import { Plus, AlertCircle, Layers, RefreshCw, Upload, FileStack } from '@lucide/svelte';
import { Plus, AlertCircle, Layers, Upload, FileStack, Loader2, Play, RotateCcw, StopCircle, Trash2, Ellipsis, Pen, Import } from '@lucide/svelte';

Check failure

Code scanning / ESLint

Disallow unused variables Error

'Upload' is defined but never used.

Copilot Autofix

AI 3 months ago

Copilot could not generate an autofix suggestion

Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.

@kmendell kmendell marked this pull request as ready for review May 5, 2025 04:20
@kmendell kmendell merged commit eec7fd2 into main May 5, 2025
6 of 7 checks passed
@kmendell kmendell deleted the refactor/table-fixes branch May 5, 2025 04:27
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.

Refactor: Create Universal Table Cell Svelte Components Clean up UI Elements and Cleanup/Refactor Code Docs: Add Documentation
1 participant