feat(modtools): UI refactoring and shared component library (Part 2/3)#2985
Conversation
c2f79bb to
0513b32
Compare
cece9f2 to
99f5d70
Compare
…, StatusMessage) Add reusable UI components for the modtools panel: - ModToolsSection: Collapsible section wrapper with consistent styling - HelpButton: Question mark icon that opens modal with documentation - StatusMessage: Type-based message display (success, error, warning, info) These components provide a consistent UI pattern for all modtools. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add comprehensive stylesheet (~1600 lines) for modtools components: - Styling for shared components (ModToolsSection, HelpButton, StatusMessage) - Form input styles with RTL support - Collapsible section animations - Modal overlay for help content 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Extract 6 tools from ModeratorToolsPanel.jsx to individual files: - BulkDownloadText, BulkUploadCSV, WorkflowyModeratorTool - UploadLinksFromCSV, DownloadLinks (renamed from GetLinks), RemoveLinksFromCsv Changes: - Create utils/stripHtmlTags.js for shared HTML sanitization - Main file reduced from ~681 to ~92 lines - Modernized BulkDownloadText and BulkUploadCSV to functional components - Updated modtools/index.js with new exports All existing functionality preserved, just reorganized for maintainability. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Move CSS loading from JavaScript import (Webpack bundled) to a static <link> tag in base.html. This ensures the CSS is collected by Django's collectstatic and served properly in CI environments. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Adjusted design system tokens and component styles: - Reduced spacing tokens by ~50% (xs: 2px, sm: 4px, md: 8px, lg: 12px, xl: 16px) - Reduced input padding from 12px 16px to 8px 12px - Reduced button padding from 12px 24px to 8px 16px - Reduced font sizes (inputs: 13px, labels: 13px, buttons: 13px) - Reduced input height from 48px to 36px - Reduced section title font size from 24px to 18px - Reduced page header font size from 28px to 22px - Reduced checkbox size from 18px to 14px - Made border radius smaller (sm instead of md for most elements) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Replace inline styles with design system classes (fieldGroup, hasError, fieldError) - Remove <br /> tags between form fields - Wrap form sections with fieldGroupSection class - Reduce gap spacing in legacy form CSS - Make fieldset and fieldGroupSection more compact Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1b541f8 to
0a61d4c
Compare
- Add IndexSelector component for card-based index selection grid - Add VERSION_FIELD_METADATA for BulkVersionEditor field definitions - Add INDEX_FIELD_METADATA for future BulkIndexEditor use 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add BulkVersionEditor for bulk editing Version metadata - Supports editing license, status, priority, notes, and other fields - Integration with IndexSelector for version selection - Export from modtools module and render in main panel 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add modtools_test.py for version bulk edit API testing - Add fieldMetadata.test.js for field metadata validation - Add stripHtmlTags.test.js for HTML utility function tests 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add MODTOOLS_GUIDE.md for quick reference and usage - Add COMPONENT_LOGIC.md for detailed implementation flows 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Note: These components are disabled and do not need review. Open tickets exist to reintroduce them: - BulkIndexEditor: Bulk edit index metadata - AutoLinkCommentaryTool: Auto-link commentaries to base texts - NodeTitleEditor: Edit node titles within Index schemas 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
static/css/modtools.css
Outdated
| * COLOR PALETTE | ||
| * Warm scholarly tones with clear semantic meaning | ||
| */ | ||
|
|
There was a problem hiding this comment.
We should be able to use Sefaria colors. I'm pretty sure we should have similar colors for almost all of these cases. Also, I don't think it's necessary to have a special file for modtools.css. It seems like static.css is appropriate
There was a problem hiding this comment.
But don't you think it would be good to have a separate file to work towards splitting things up?
There was a problem hiding this comment.
I updated the colors
There was a problem hiding this comment.
Really modtools are static pages so I think they should be in the static CSS file. I'm not sure if we should be splitting things up. But I would agree that the CSS of internal tools is not very important so I don't care too much either way.
There was a problem hiding this comment.
Although, precisely because the CSS here is not that important, it makes the case stronger not weaker for putting it into static.css.
There was a problem hiding this comment.
🤖 Claude Code: Fixed! I've moved all the modtools.css content into static.css and removed the separate file. Also removed the <link> tag from base.html.
There was a problem hiding this comment.
@stevekaplan123 although the modtools is a react page. Would it not be more correct to put it in S2?
There was a problem hiding this comment.
Yeah put it in s2.css thanks!
Replace custom color palette with Sefaria CSS variables from s2.css for consistency with the rest of the application. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace custom color palette with Sefaria CSS variables from s2.css for consistency with the rest of the application. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…omponent Replaces the inline ChevronIcon component with an img tag referencing the existing chevron-down.svg icon file, following the established pattern for icon usage in the codebase. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…omponent Replaces the inline ChevronIcon component with an img tag referencing the existing chevron-down.svg icon file, following the established pattern for icon usage in the codebase. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Remove code that is only used by disabled tool components: - check_index_dependencies_api from views.py (used by NodeTitleEditor) - URL route for check-index-dependencies from urls.py - TestCheckIndexDependenciesAPI from modtools_test.py - INDEX_FIELD_METADATA from fieldMetadata.js (used by BulkIndexEditor) - BASE_TEXT_MAPPING_OPTIONS from fieldMetadata.js (used by AutoLinkCommentaryTool) This code will be added to the appropriate feature branches: - sc-36477: NodeTitleEditor - sc-36473: BulkIndexEditor - sc-36476: AutoLinkCommentaryTool Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Resolved conflicts: - ModeratorToolsPanel.jsx: Keep pr2's UI refactor version - base.html: Keep modtools.css include from pr2
Resolved conflicts: - sefaria/urls.py: Took pr2's version (django-hosts structure with PR1 API routes)
🧪 CI InsightsHere's what we observed from your CI run for 0d01b7b. 🟢 All jobs passed!But CI Insights is watching 👀 |
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…static.css - Replace custom stripHtmlTags utility with existing String.prototype.stripHtml() from sefaria/util.js (addresses PR comment about duplicate code) - Move modtools.css content into static.css and remove separate file (addresses PR comment about CSS file organization) - Remove now-empty modtools/utils directory - Update base.html to remove modtools.css link tag Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Set renderStatic=True in the modtools view so that static.css (which now contains the modtools CSS) is loaded on the page. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
🤖 Claude Code: Added a fix — |
Move modtools CSS to s2.css instead of static.css because: - s2.css is the main React app CSS, always loaded for app pages - static.css is only loaded when renderStatic=True (for static Django pages) - modtools is a React component, not a static page, so s2.css is semantically correct This also reverts the renderStatic=True workaround in the modtools view. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove stripHtmlTags from shared/index.js (use String.prototype.stripHtml() instead) - Delete stripHtmlTags.test.js (testing built-in method not needed) - Update MODTOOLS_GUIDE.md to reference s2.css instead of modtools.css Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…36475/modtools-pr2-ui-refactor
…/sc-36475/modtools-pr3-bulk-version-editor
…36475/modtools-pr2-ui-refactor
…/sc-36475/modtools-pr3-bulk-version-editor
Clarify that versionTitle is a database identifier and cannot be bulk edited. Improve mark-for-deletion messaging to explain the two-step process: marking adds a note, then a developer completes the deletion. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…36475/modtools-pr2-ui-refactor
…/sc-36475/modtools-pr3-bulk-version-editor
…ulk-version-editor feat(modtools): BulkVersionEditor feature (Part 3/3)
1e3c289
into
feature/sc-36475/modtools-pr1-backend
Part 2 of 3: UI Refactoring
Related PRs:
Stacked PR chain: PR3 → PR2 → PR1 → master (merge in reverse order: PR1 first, then PR2, then PR3)
Summary
This PR refactors the ModeratorToolsPanel with:
s2.css(search for "ModTools Design System")ModeratorToolsPanel Refactoring (static/js/ModeratorToolsPanel.jsx)
The existing ModeratorToolsPanel was refactored in two phases:
Phase 1 - UI Integration:
ModToolsSectionfor consistent collapsible UIPhase 2 - Component Extraction:
Extracted 6 pre-existing tools into separate component files (~1373 → ~98 lines):
BulkDownloadText.jsxBulkUploadCSV.jsxWorkflowyModeratorTool.jsxUploadLinksFromCSV.jsxDownloadLinks.jsxRemoveLinksFromCsv.jsxLogic Preserved: All existing API calls and behavior unchanged.
Key patterns in new code:
Sefaria.apiRequestWithBodyinstead of jQuery/fetch (no jQuery dependency)String.prototype.stripHtml()for HTML sanitization (from sefaria/util.js)Shared Components (static/js/modtools/components/shared/)
Four reusable components extracted for consistency across modtools:
ModToolsSection.jsx (~137 lines)
helpContentproptitleandtitleHe)collapsedstate)HelpButton.jsx (~98 lines)
helpContentprop with JSX documentationStatusMessage.jsx (~51 lines)
MESSAGE_TYPESenum (SUCCESS, ERROR, WARNING, INFO){type, message}objectCSS Styles (in static/css/s2.css)
Modtools styles (~1650 lines) added to
s2.css(search for "ModTools Design System"):Note: CSS has not been thoroughly reviewed as this is internal tooling. Styling prioritizes functionality over polish.
Files Changed
Frontend (React/JS):
static/js/ModeratorToolsPanel.jsx- Refactored (now imports extracted components)static/js/modtools/components/BulkDownloadText.jsx- Extracted from ModeratorToolsPanelstatic/js/modtools/components/BulkUploadCSV.jsx- Extracted from ModeratorToolsPanelstatic/js/modtools/components/WorkflowyModeratorTool.jsx- Extracted from ModeratorToolsPanelstatic/js/modtools/components/UploadLinksFromCSV.jsx- Extracted from ModeratorToolsPanelstatic/js/modtools/components/DownloadLinks.jsx- Extracted from ModeratorToolsPanel (was GetLinks)static/js/modtools/components/RemoveLinksFromCsv.jsx- Extracted from ModeratorToolsPanelstatic/js/modtools/components/shared/ModToolsSection.jsx- Shared componentstatic/js/modtools/components/shared/HelpButton.jsx- Shared componentstatic/js/modtools/components/shared/StatusMessage.jsx- Shared componentstatic/js/modtools/components/shared/index.js- Exportsstatic/js/modtools/index.js- ExportsCSS:
static/css/s2.css- Added modtools styles (search for "ModTools Design System")🤖 Generated with Claude Code
Next PR
➡️ Part 3: #2986 - Merge after this PR is merged.