Skip to content

Resolve "ListRows/GetRow services need to check the trashed state of their table and database."

What is in this MR

This MR resolves two problems:

  1. When dispatching a ListRows / GetRow service, we raise ServiceImproperlyConfigured if:
    1. The table is trashed. This was technically handled already as table.get_model().objects.all() would have resulted in no rows, so any elements using the rows would have had no results, but now the element will display "No items have been found."
    2. The table's database is trashed. This is something Frederik discovered recently, if the table was untrashed but the database was trashed, we'd still show results in the table elements.
  2. In the frontend, when we fetch an element's content (i.e when a table element's content is dispatched), if the API responds with ERROR_DATA_SOURCE_IMPROPERLY_CONFIGURED we correctly handle it. Previously the 404 page would raise, whereas now we commit SET_CONTENT with an empty array so that the element is blank.

How to test this MR

  • Create a page with two tables.
  • On this page create two ListRows data sources:
    1. One of them to a new database, call it "Trashed database". Any table in that database will be fine.
    2. One of them to an existing database, but to a table called "Trashed table".
  • Connect your two tables to your two data sources.
  • Set up the tables so you see the rows properly.
  • Now trash "Trashed table" (via the sidebar "Delete table").
  • Reload the AB page (or navigate away and back), the table element connected to "Trashed table" should say "No items have been found.", and the API response code should be a 400 with a ERROR_DATA_SOURCE_IMPROPERLY_CONFIGURED error in the response data.
  • Now trash "Trashed database" (via the sidebar "Delete database").
  • Reload the AB page (or navigate away and back), the table element connected to "Trashed database" should say "No items have been found.", and the API response code should be a 400 with a ERROR_DATA_SOURCE_IMPROPERLY_CONFIGURED error in the response data.
  • A toast should appear only once per element using the failing data source.

Another test:

  • If you create a formula using a data source then delete the data source, you are not able to publish/duplicate/... the page.

Merge Request Checklist

  • changelog.md has been updated if required.
  • New/updated Premium/Enterprise features are separated correctly in the premium or enterprise folder
  • The latest Chrome and Firefox have been used to test any new frontend features
  • Documentation has been updated
  • Quality Standards are met
  • Performance: tables are still fast with 100k+ rows, 100+ field tables
  • The redoc API pages have been updated for any REST API changes
  • Our custom API docs are updated for changes to endpoints accessed via api tokens
  • The UI/UX has been updated following UI Style Guide

Closes #2362 (closed)

Edited by Jérémie Pardou

Merge request reports