Skip to content
Snippets Groups Projects
This project is mirrored from https://github.com/metabase/metabase. Pull mirroring updated .
  1. Jun 21, 2024
  2. Jun 20, 2024
  3. Jun 19, 2024
  4. Jun 18, 2024
  5. Jun 17, 2024
  6. Jun 14, 2024
  7. Jun 13, 2024
  8. Jun 12, 2024
  9. Jun 11, 2024
    • bryan's avatar
      Make recents understand context (#43478) · 7b849da3
      bryan authored
      
      * adds the endpoint and a test
      
      * add recents endpoint, todo: tests
      
      * add post recents endpoint
      
      * return recent views for both lists, but make the endpoint work
      
      * Make recent-views context aware
      
      - pruning is context aware, only checks for the recently-inserted
        context
      - Adds endpoints:
          - POST to create selection recents,
          - GET activity/recents
            - requres context query param to be one of:
            - all, views, selections
      
      - Adds context arg to update-users-recent-views!
      - Cleans up arg schema for update-users-recent-views
      
      * impl GET api/activity/recents
      
      - return recent-selections and recent-views from
      - send context == collection from pinned card reads
      
      * update callsites of recent-views/update-users-recent-views!
      
      - to use :view param where necessary
      
      * fixes models/recent-view tests
      
      * adds more activity/recent-view tests
      
      * wip
      
      - fix whitespace linter
      
      * Fix command palette e2e test
      
      - reuse util snake-keys
      
      * updates fe to use new recents endpoints
      
      * fixes fe type issue
      
      * snake-keys -> deep-snake-keys
      
      - I've been betrayed by lsp rename
      
      * snake-keys -> deep-snake-keys
      
      - I've been betrayed by lsp rename
      
      * log selection events for created collections
      
      * mysql doesn't allow default values for TEXT types
      
      * log a recent view on data-picker selection
      
      * decouple view-log context from card-event view context
      
      * fix a doc typo
      
      * stop double logging recent-views on POST
      
      * maybe fixes some tests
      
      * some e2e fixes
      
      * fix mysterious divide by zero during score search
      
      * fix divide by zero possibilities everywhere in score-items
      
      metabase.api.activity/score-items used to throw when there weren't any
      items being scored (even though there's a `(when (seq items) ...)` check)
      
      * more test fixes
      
      * fix more e2e tests, + rename endpoint in tests
      
      * fix oopsie
      
      * fixes a few more tests
      
      * address review comments/questions
      
      * allow for a comma delimited list in qps like ?context=views,selections
      
      returns all recent view items with those contexts, most recent first
      under the `:recents` key.
      
      * refactors FE around new endpoint
      
      * fixes for unit tests
      
      * use ms/QueryVectorOf for context
      
      * fix models/recent_views tests
      
      * use multiple query params instead of comma delimited value on FE
      
      * ignore timestamp when deduping recents
      
      * review comments + test fixing
      
      * update docstring
      
      * fix api/activity_test s
      
      * actually dedupe
      
      * add test for deduping by context
      
      * e2e fix: shows up-to-date list of recently viewed items after another page is visited
      
      * e2e fix: should undo the question replace action
      
      * e2e fix: should replace a dashboard card question (metabase#36984)
      
      * e2e fix: should preselect the most recently visited dashboard
      
      * fix 6 more e2e tests
      
      * fixes fe type check and unit failure
      
      * renames unit test mocking function
      
      * fix a flaky e2e test
      
      * widen Item to accept str or kw where sensible
      
      - allow strings or keywords for moderated_status, and authority_level
      
      * simplify impl + add test
      
      * add view-log to events schema
      
      * add collection context to view log
      
      * fix the final 2 failing e2e tests
      
      * click dashboard tab when the user has can-read? on recent entities
      
      ---------
      
      Co-authored-by: default avatarSloan Sparger <sloansparger@gmail.com>
      7b849da3
    • John Swanson's avatar
      Improve the Trash data model (#42845) · 7374e61e
      John Swanson authored
      
      * Improve the Trash
      
      Ok, so I had a realization at the PERFECT time, immediately after the RC
      cutoff. Great job, brain!
      
      Here's the realization. For the Trash, we need to keep track of two
      things:
      
      - where the item actually is located in the hierarchy, and
      
      - what collection we should look at to see what permissions apply to the
      item.
      
      For example, a Card might be in the Trash, but we need to look at
      Collection 1234 to see that a user has permission to Write that card.
      
      My implementation of this was to add a column,
      `trashed_from_collection_id`, so that we could move a Card or a
      Dashboard to a new `collection_id`, but keep track of the permissions we
      actually needed to check.
      
      So:
      
      - `collection_id` was where the item was located in the collection
      hierarchy, and
      
      - `trashed_from_collection_id` was where we needed to look to check
      permissions.
      
      Today I had the realization that it's much, much more important to get
      PERMISSIONS right than to get collection hierarchy right. Like if we
      mess up and show something as in the Trash when it's not in the Trash,
      or show something in the wrong Collection - that's not great, sure. But
      if we mess up and show a Card when we shouldn't, or show a Dashboard
      when we shouldn't, that's Super Duper Bad.
      
      So the problem with my initial implementation was that we needed to
      change everywhere that checked permissions, to make sure they checked
      BOTH `trashed_from_collection_id` and `collection_id` as appropriate.
      
      So... there's a much better solution. Instead of adding a column to
      represent the *permissions* that we should apply to the dashboard or
      card, add a column to represent the *location in the hierarchy* that
      should apply to the dashboard or the card.
      
      We can simplify further: the *only time* we want to display something in
      a different place in the hierarchy than usual is when it was put
      directly into the trash. If you trash a dashboard as a part of a
      collection, then we should display it in that collection just like
      normal.
      
      So, we can do the following:
      
      - add a `trashed_directly` column to Cards and Dashboards, representing
      whether they should be displayed in the Trash instead of their actual
      parent collection
      
      - use the `collection_id` column of Cards and Dashboards without
      modification to represent permissions.
      
      There's one main downside of this approach. If you trash a dashboard,
      and then delete the collection that the dashboard was originally in,
      what do we do with `dashboard.collection_id`?
      
      - we have to change it, because it's a foreign key
      
      - we can't set it to null, because that represents the root collection
      
      In this initial implementation, I've just cascaded the delete: if you
      delete a dashboard and then delete a collection, the dashboard will be
      deleted. This is not ideal. I'm not totally sure what we should do in
      this situation.
      
      * Rip out all the `trashed_from_collection_id`
      
      * Migration to delete trashed_from_collection_id
      
      * fixes
      
      * don't move collections
      
      And don't allow deleting collections
      
      * only show cards/dashboards with write perms
      
      * Show the correct archived/unarchived branch
      
      * some cleanup
      
      * add a todo for tomorrow
      
      * Fix for yesterday's TODO
      
      * more wip
      
      * refactor
      
      * memoize collection info
      
      * move around memoization a bit
      
      * fix schema migration test
      
      * oops, delete server.middleware.memo
      
      * Use a migration script (postgres only for now)
      
      * Fix some tests
      
      * remove n+1 queries in `collection-can-restore`
      
      * fix test
      
      * fix more tests, and x-db migration script
      
      * fix h2 rollback
      
      * fix mysql/mariadb migration
      
      * lint
      
      * fix some mariadb/mysql tests
      
      * fix h2 rollback
      
      * Fix mysql rollback
      
      * Fix Postgres migration
      
      * "Real" `trash_operation_id` UUIDs from migration
      
      * fix mariadb migration
      
      * Separate MySQL/MariaDB migrations
      
      * trashed directly bit->boolean
      
      * Remove `trashed_from_*` from migrations
      
      * Rename `api/updates-with-trashed-directly`
      
      Previously named `move-on-archive-or-unarchive`, which was no longer
      accurate since we're not moving anything!
      
      * Add `can_delete`
      
      * Delete test of deleted code
      
      * Can't move anything to the Trash
      
      The Trash exists as a real collection so that we can list items in and
      such without needing special cases. But we don't want anything to
      _actually_ get moved to it.
      
      * integrates can_delete flag on FE
      
      * Update src/metabase/models/collection.clj
      
      Co-authored-by: default avatarNoah Moss <32746338+noahmoss@users.noreply.github.com>
      
      * Update src/metabase/search/impl.clj
      
      Co-authored-by: default avatarNoah Moss <32746338+noahmoss@users.noreply.github.com>
      
      * Better name for `fix-collection-id`
      
      Also consolidated it into a single function. It takes the
      trash-collection-id as an argument to prevent a circular dependency.
      
      * s/trashed/archived/ on the backend
      
      In the product, we want to move to "trashed" as the descriptor for
      things that are currently-known-as-archived.
      
      It'd be nice to switch to that on the backend as well, but that'll
      require quite a lot of churn on the frontend as we'd need to change the
      API (or have an awkward translation layer, where we call it `trashed` on
      the backend, turn it into `archived` when sending data out via the API,
      and then the FE turns around and called it "trashed" again).
      
      For now, let's just be consistent on the backend and call it `archived`
      everywhere. So:
      
      - `archived_directly` instead of `trashed_directly`, and
      - `archive_operation_id` instead of `trash_operation_id`
      
      * Fix up a couple docstrings
      
      * Rename `visible-collection-ids` args
      
      for `collection/permissions-set->visible-collection-ids`:
      
      - `:include-archived` => `:include-archived-items`
      
      - `:include-trash?` => `:include-trash-collection`
      
      * select affected-collection-ids in the tx
      
      * Stop dealing with `:all` visible collection ids
      
      This used to be a possible return value for
      `permissions-set->visible-collection-ids` indicating that the user could
      view all collections. Now that function always returns a set of
      collection IDs (possibly including "root" for the root collection) so we
      don't need to deal with that anymore.
      
      * Don't use separate hydration keys for collections
      
      Dispatch on the model of each item (but still keep them in batches for
      efficiency.)
      
      * vars for collectable/archived-directly models
      
      * Round up loose `trashed_directly`s
      
      * Fix a test
      
      * Use `clojure.core.memoize` instead of handrolled
      
      It's slightly different (TTL instead of exactly per-request) but that
      should be fine.
      
      * FE lint fixes
      
      * :sob:
      
       e2e test fix
      
      ---------
      
      Co-authored-by: default avatarSloan Sparger <sloansparger@gmail.com>
      Co-authored-by: default avatarNoah Moss <32746338+noahmoss@users.noreply.github.com>
      7374e61e
    • Phoomparin Mano's avatar
      feat(sdk): theme option to customize the dashboard card border (#43963) · a742b340
      Phoomparin Mano authored
      
      * add option to customize dashcard border
      
      * use the shadow CSS variable
      
      Co-authored-by: default avatarDenis Berezin <denis.berezin@metabase.com>
      
      * make the shadow and border decoration call more explicit
      
      Co-authored-by: default avatarDenis Berezin <denis.berezin@metabase.com>
      
      * pass in theme as argument
      
      ---------
      
      Co-authored-by: default avatarDenis Berezin <denis.berezin@metabase.com>
      a742b340
Loading