Fixes For Translation Editor: Public Sharing & Privacy

by Lucas 55 views

Introduction

Hey everyone, this is an RFC (Request for Comments) about some pesky issues we've got with the Translation Editor. Specifically, we're tackling the problems of shared documents not loading for public users and the privacy toggle not working as it should. These bugs are really cramping our style, because they're hindering collaboration and making it tough to control who sees what. Let's dive into what's going on and how we can fix it, guys.

The Core Problems: Broken Sharing and Privacy

So, here's the deal: When you share a translation publicly, the text doesn't load for those public viewers. It's like throwing a party and forgetting to unlock the door! Also, the privacy toggle, which is supposed to let you switch between public and private access, isn't working properly. This means you might think something's private when it's not, or vice versa. It's a serious issue because it breaks the fundamental idea of the Translation Editor: to enable smooth collaboration while allowing users to maintain control over their work. The current situation directly impacts the OpenPecha project, and specifically, the pecha-tool-translation-editor. We need to ensure that users can confidently share their translations and manage their privacy settings without any hiccups. Fixing these issues is crucial for a functional and trustworthy translation environment.

Steps to Resolve the Issues

We've got a plan to fix these problems, breaking it down into backend and frontend tasks. Let's break it down. The backend folks will be focusing on ensuring the correct text is served for public links, and that the privacy toggle functions as intended. The frontend crew will focus on making sure the editor requests the correct data and provides clear feedback to the user.

Backend Fixes

  1. Auditing Endpoints: The first step is to carefully audit the backend endpoints responsible for fetching the translation text when a public link is accessed. We need to make sure these endpoints are correctly configured to serve the data. This will involve checking that the correct data is being retrieved and that it's being returned in the right format. The audit should thoroughly examine how the data is being accessed. This step helps ensure that we understand the current state of these endpoints.
  2. Public Access and Privacy: We'll need to guarantee that public access bypasses authentication correctly, yet it still respects the privacy settings. This means that when a user clicks a public link, they shouldn't be prompted to log in. However, the system needs to check if the translation is set to 'public.' This involves implementing access controls that accurately reflect the sharing settings. This will ensure that we are providing the right level of access, and not allowing unauthorized access to data. This is a critical step in upholding the privacy of the users.
  3. Database Updates for Toggling: The next thing is, we will add checks to make sure the database updates happen when the sharing state is toggled. We want to ensure the sharing status gets saved correctly when a user switches between public and private. This means verifying that the database records reflect the toggle action. Proper database updates are essential for the correct functioning of the sharing mechanism. These checks will help prevent data discrepancies and data inconsistencies.
  4. Success/Error Responses: We'll implement explicit success/error responses for toggle actions. This way, the frontend knows whether the toggle was successful or not. If there's an error, the frontend can provide the user with feedback. This will involve setting up error handling so the frontend knows if something went wrong with the toggle and can inform the user about it. Detailed responses improve the user experience by confirming actions.
  5. Caching and Permissions: Implement caching to improve performance and manage permissions effectively. Invalidate any cached permissions whenever the sharing state is updated. This ensures that users always see the correct access state. The caches need to be cleared when the sharing state changes, which ensures that the latest privacy settings apply immediately. Doing this makes sure the user is always seeing the correct version.
  6. Middleware Checks: Introduce middleware checks to avoid serving outdated access states. These checks will ensure that users always have the most recent information regarding the access status of a translation. This helps prevent users from seeing outdated or incorrect information. The use of middleware is a key factor in improving the overall security and integrity of the system.

Frontend Fixes

  1. Loading State Improvements: We need to make sure the editor uses the correct API endpoint when opened via a public link. This means the frontend must be able to make requests to the right place to fetch the data for shared translations. The editor needs to know where to get the data for public views. We'll want to add error handling and a fallback UI if the text fails to load. This includes providing a user-friendly message and a way to deal with the issue when it arises. This helps the user see the data they need, and handles error cases gracefully.
  2. Toggle UX Enhancements: We're making the toggle UX (User Experience) better. The key here is that we need to give users feedback about their actions. This will make things a lot clearer. So, we'll provide a confirmation toast/snackbar on successful toggles. This will let the user know that their privacy settings have been successfully updated. We will also show error messages if the toggle action fails. Instead of silently failing, the user will see an error message, helping them understand what went wrong and why the toggle didn't work. These enhancements will make it easy for users to understand the actions they are taking.

Review Process

  • Reviewer: @Karma-Tsering will be the reviewer for this RFC. We will make sure we have proper testing in place to prevent the errors from reoccurring.

Conclusion

By addressing these issues, we're ensuring that the Translation Editor is reliable and user-friendly, improving the overall experience for everyone involved. Fixing these problems directly benefits the OpenPecha project, creating a more functional and trustworthy environment for everyone. Let's get these fixes implemented so our community can keep on translating and sharing with ease, guys!