Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Implementing a robust drafting feature for headline content management #80

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

Conversation

@fulleni
Copy link
Member

@fulleni fulleni commented Sep 22, 2025
edited
Loading

Status

READY

Description

This pull request introduces a comprehensive drafting system across headlines, topics, and sources, significantly enhancing content management flexibility. Users can now save content as drafts, manage them in dedicated draft sections, and then publish or permanently delete them. The changes involve substantial refactoring of content creation and editing BLoCs, the addition of new UI pages for draft management, seamless integration with a pending deletions service for a better user experience, and updates to localization and a reusable selection input widget.

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore

...feature
- Add Arabic translations for draft headlines, loading messages, buttons, and dialog text in app_ar.arb
- Add English translations for draft headlines, loading messages, buttons, and dialog text in app_en.arb
- Include translations for new concepts such as "publish", "save as draft", and "invalid form"
- Add new route for draft headlines in router.dart
- Define new constants for draft headlines route in routes.dart
- Import and use DraftHeadlinesPage from content_management package
- Add new fields for managing draft headlines:
 - draftsStatus
 - drafts
 - draftsCursor
 - draftsHasMore
- Update copyWith method to include new fields
- Update props list in Equatable to include new fields
...dlines
- Add Drafts tab to ContentManagementTab enum
- Implement LoadDraftHeadlinesRequested event handling in ContentManagementBloc
- Update initial data loading to include draft headlines
- Add logic to fetch paginated draft headlines from repository
- Handle success and failure states for draft headlines loading
...ties
- Implement _onSavedAsDraft method to handle saving headlines as drafts
- Implement _onPublished method to handle publishing headlines
- Add corresponding event handlers in the bloc initialization
- Add CreateHeadlineSavedAsDraft event to save the headline as a draft
- Add CreateHeadlinePublished event to publish the headline
- Implement _onSavedAsDraft method to handle saving headlines as drafts
- Implement _onPublished method to handle publishing headlines
- Add event handlers for EditHeadlineSavedAsDraft and EditHeadlinePublished events
- Update state management for draft saving and publishing processes
- Include error handling for HTTP exceptions and unknown errors
- Add EditHeadlineSavedAsDraft event to save the headline as a draft
- Add EditHeadlinePublished event to publish the headline
- Add publish and save as draft buttons
- Implement dialog for handling invalid form state
- Update UI to show these buttons conditionally based on form validity
- Modify existing save button to be an elevated button
- Add includeInactiveSelectedItem flag to searchable selection inputs
- Add DraftHeadlinesPage import and include it in the tab bar view
- Increase tab count from 3 to 4 to accommodate drafts tab
- Add new tab for drafts with appropriate localization and routing
- Update tab change listener to handle drafts case
- Allow creating new headlines from both headlines and drafts tabs
- Add options to save as draft and publish
- Implement dialog for invalid form confirmation
- Add discard functionality for unsaved changes
- Update UI to display new buttons and dialog
- Implement DraftHeadlinesPage for displaying and managing draft headlines
- Add _DraftHeadlinesView and _DraftHeadlinesDataSource classes
- Include functionality for loading, publishing, editing, and deleting draft headlines
- Implement pagination and snackbar notifications for pending deletions
- Update UI components for a tabular display of headlines with relevant actions
- Define DraftHeadlinesStatus enum for operation states
- Create DraftHeadlinesState class to manage draft headlines, pagination, and operations
- Include properties for status, headlines, cursor, hasMore, exception handling, and UI feedback
- Implement copyWith method for state immutability
- Define sealed class DraftHeadlinesEvent and its subclasses
- Implement events for loading, publishing, deleting, and undoing draft headlines
- Add event for clearing published headline from state
- Include event for handling updates from pending deletions service
- Add DraftHeadlinesBloc to manage the state of draft headlines
- Implement events for loading, publishing, and deleting draft headlines
- Add handling for temporary "undo" period for deletions
- Include pagination support for loading draft headlines
- Ensure proper disposal of deletion event subscription
- Modify `fetchItems` to include logic for adding the initial selected item
 when `includeInactiveSelectedItem` is true
- Implement this fix for both static items and repository-fetched items
- Refactor item fetching logic to consolidate common code paths
- Improve code readability and maintainability
- Introduce new parameter to always include the selected item in results
- Useful for edit pages where previously selected items should always be visible
- Affects both dynamic and static item scenarios
- Introduce new parameter to control the inclusion of inactive items
- Update class properties and constructor to include new parameter
- Modify props list to include the new parameter
- Remove unnecessary comments in ContentManagementPage
- Improve code readability in _ContentManagementPageState
- Add Arabic and English translations for new draft-related terms
- Introduce translations for:
 - draftsIconTooltip
 - draftHeadlines
 - draftTopics
 - draftSources
- Update existing 'drafts' translation with more detailed description
- Remove ContentManagementTab.drafts enum value
- Remove LoadDraftHeadlinesRequested event handler
- Remove _onLoadDraftHeadlinesRequested method
- Remove draft-related state fields and logic
- Update imports to remove unused packages
...ntentManagementState
- Remove draftStatus, drafts, draftsCursor, and draftsHasMore properties
- Update constructor, copyWith method, and props list to reflect removal of draft properties
- This change simplifies the state management by removing unnecessary draft-related data
- Remove separate Drafts tab in ContentManagementPage
- Add IconButton for navigating to draft pages based on the active tab
- Update archived items navigation to reflect the removal of the Drafts tab
- Adjust create item navigation for headlines and topics
- Remove DraftHeadlinesPage from the tabs list
...tefulWidget
- Remove _DraftHeadlinesView widget
- Move BlocProvider and related logic into DraftHeadlinesPage
- Add AppBar to the scaffold
- Update tooltip text for edit button
- Create a new stateless widget for displaying draft sources
- Add basic layout with app bar and centered text
- Implement localization using context.l10n
- Create a new Dart file for the Draft Topics page
- Implement a basic StatelessWidget with an app bar and centered text
- Use localization for page title and content
- Add path and name constants for draft topics page
- Add path and name constants for draft sources page
- Import DraftSourcesPage and DraftTopicsPage
- Add GoRoutes for draft sources and topics
- Update router to include new routes
...eState
- Removed contentStatus property from CreateHeadlineState class
- Updated constructor, copyWith method, and props list to reflect the removal
- This change simplifies the state object by removing unnecessary content status information
- Remove CreateHeadlineStatusChanged and CreateHeadlineSubmitted events
- These events are no longer needed as the publish flow is now managed
 directly through the content module
- Add DraftTopicsBloc to handle draft topic operations
- Implement event handlers for loading, publishing, and deleting draft topics
- Integrate with PendingDeletionsService for temporary deletions with undo capability
- Manage state transitions and error handling
- Remove placeholder comments for Draft Topics and Draft Sources pages
- Keep the existing navigation logic intact
- Add DraftSourcesPage widget to display and manage draft sources
- Implement pagination and sorting for the sources table
- Add functionality to publish, edit, and delete draft sources
- Include snackbar notifications for deleted sources with undo option
- Handle loading and error states for the data table
- Add BlocProvider and BlocListener for DraftTopicsBloc
- Implement loading, failure, and empty states
- Create paginated data table to display draft topics
- Add actions to publish, edit, and delete draft topics
- Implement snackbar for deleted topics with undo functionality
- Update imports and add necessary packages
- Removed form validity checks from CreateHeadlineSavedAsDraft and CreateHeadlinePublished event handlers
- These checks are redundant as the buttons for saving or publishing are disabled when the form is not valid
- Remove isFormValid checks from CreateSourceSavedAsDraft and CreateSourcePublished event handlers
- Directly emit submitting status without validating form state
...ng or publishing topic
- Remove isFormValid checks from handleCreateTopicSavedAsDraft and handleCreateTopicPublished event handlers
- These checks are unnecessary as the form submit button should be disabled if the form is not valid
- Remove form validity checks from EditHeadlineSavedAsDraft and EditHeadlinePublished event handlers
- These checks are redundant because the buttons for saving and publishing are disabled when the form is invalid
...ng or publishing source
- Removed validity checks from both EditSourceSavedAsDraft and EditSourcePublished event handlers
- This change allows saving and publishing of sources regardless of their validity
- May be related to ongoing work on allowing draft saving of incomplete forms
...ng or publishing topic
- Removed isFormValid checks from EditTopicSavedAsDraft and EditTopicPublished event handlers
- These validations are already performed in the UI, making these checks redundant
...utton logic
- Remove unused _showInvalidFormDialog function
- Enable/disable save button based on form validity
- Simplify save button onPressed logic
- Improve code readability and reduce nesting
...n logic
- Remove _showInvalidFormDialog function as it's no longer needed
- Simplify save button onPressed logic:
 - Enable button only if form is valid
 - Directly show save options dialog when form is valid
 - Add context.mounted check before bloc events
- Remove unnecessary TODO comment in FailureStateWidget
...button logic
- Remove _showInvalidFormDialog function as it's no longer needed
- Simplify save button onPressed logic:
 - Enable button only when form is valid
 - Directly show save options dialog without form validation check
- Update comments and code formatting for better readability
...ompts
- Remove invalid form and save options dialogs
- Directly save the headline without prompts on edit page
- Maintain the original status (draft/active) unless changed
- Enable/disable save button based on form validity
- Remove _showInvalidFormDialog and _showSaveOptionsDialog functions
- Directly save the source without additional prompts
- Maintain the original content status (draft/active) on save
- Enable/disable save button based on form validity
- Remove _showInvalidFormDialog and _showSaveOptionsDialog functions
- Directly save the topic without additional prompts
- Maintain the original status (draft/active) on save
- Enable/disable save button based on form validity
- Reduce state information string length limit from 250 to 150 characters
- Remove status property check and related logic
- Simplify variable declarations using final instead of var
- Add 'Draft' option to headlines, topics, and sources
- Emphasize centralized system for accuracy and consistency
- Highlight management of draft/active content
Copy link

Summary of Changes

Hello @fulleni, I'm Gemini Code Assist1 ! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a comprehensive drafting system across headlines, topics, and sources, significantly enhancing content management flexibility. Users can now save content as drafts, manage them in dedicated draft sections, and then publish or permanently delete them. The changes involve substantial refactoring of content creation and editing BLoCs, the addition of new UI pages for draft management, seamless integration with a pending deletions service for a better user experience, and updates to localization and a reusable selection input widget.

Highlights

  • Robust Drafting Feature: Implemented a comprehensive drafting feature for headlines, topics, and sources, allowing users to save content as drafts before publishing them.
  • Refactored Content Creation and Editing: The BLoCs responsible for creating and editing headlines, topics, and sources have been refactored to explicitly support 'save as draft' and 'publish' actions, replacing the previous generic 'submit' and 'status changed' events.
  • Dedicated Draft Management Pages: New UI pages (DraftHeadlinesPage, DraftSourcesPage, DraftTopicsPage) have been added, providing a centralized location to view, manage, publish, and permanently delete draft content.
  • Pending Deletions Service Integration: The new draft management BLoCs integrate with a PendingDeletionsService to offer an optimistic deletion experience with an 'undo' option, similar to archived items.
  • UI Enhancements and Localization: The main content management page now includes a 'Drafts' icon button for quick navigation. Create/Edit forms have updated save logic, and numerous new localization strings have been added to support the new drafting terminology.
  • Searchable Selection Input Improvement: The SearchableSelectionInput widget now includes an includeInactiveSelectedItem flag, ensuring that previously selected inactive items are visible in edit forms, improving usability.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a robust drafting feature, which is a great addition to the content management capabilities. The implementation is extensive, touching many parts of the BLoC and UI layers, and introducing new pages for managing drafts. The code is generally well-structured. My review focuses on several areas for improvement:

  • Refactoring Duplication: There's significant code duplication in the new _onSavedAsDraft and _onPublished handlers across several BLoCs. I've suggested refactoring these into helper methods to improve maintainability.
  • Bug Fixes: I've identified a few bugs, including a critical issue with the optimistic UI update logic that fails to roll back correctly on error, and a potential issue in copyWith methods that could lead to unintended state loss.
  • Performance: There's a performance issue in the edit pages where data is fetched twice, once in the UI and again in the BLoC. I've proposed a solution to eliminate the redundant fetch.
  • UI Consistency: I've noted an inconsistency in error handling on one of the create pages and suggested aligning it with the others for a better user experience.

Overall, this is a solid implementation of a complex feature. Addressing these points will enhance the code's robustness, performance, and maintainability.

- Replace edit_note icon with drafts_outlined for Drafts button
- Replace inventory_2_outlined icon with archive_outlined for Archived Items button
- Replace plain add icon with add_outlined for Add New Item button
...Bloc
- Use state.headlines directly instead of creating a new List
- Create a new List for updatedHeadlines to avoid modifying the original list
- Remove unnecessary line breaks and improve code readability
- Improve efficiency by directly using state.sources instead of creating a new List
- Ensure immutability by creating a new List for updatedSources
- Remove unnecessary step of checking for -1 index, as it's already handled earlier in the code
- Replace unnecessary list copying with direct assignment
- Use list spread operator for efficient element removal
- Improve code readability and performance in DraftTopicsBloc
- Update DraftHeadlinesState.copyWith to preserve lastPendingDeletionId and snackbarHeadlineTitle when new values are null
- This prevents potential null reference errors and maintains state consistency
- Update DraftSourcesState.copyWith constructor to handle null values
- Ensure lastPendingDeletionId and snackbarSourceTitle retain their current
 values if null is passed
- Update DraftTopicsState.copyWith to maintain lastPendingDeletionId and snackbarTopicTitle when they are null
- This prevents loss of snackbar data when updating other state properties
...r for error handling
- Remove FailureStateWidget usage for displaying errors
- Implement SnackBar to show friendly error messages
- Improve user experience by providing inline feedback
@fulleni fulleni merged commit 4e0aa71 into main Sep 22, 2025
1 check failed
@fulleni fulleni deleted the Implementing-a-Robust-Drafting-Feature-for-Headline-Content-Management branch September 22, 2025 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer

@gemini-code-assist gemini-code-assist[bot] gemini-code-assist[bot] left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

AltStyle によって変換されたページ (->オリジナル) /