Skip to content
Snippets Groups Projects
This project is mirrored from https://github.com/metabase/metabase. Pull mirroring updated .
  1. Jul 02, 2024
  2. Jun 27, 2024
  3. Jun 26, 2024
  4. Jun 20, 2024
    • Phoomparin Mano's avatar
      fix(sdk): font size, color and padding in viz (#44283) · dab2d852
      Phoomparin Mano authored
      * funnel start color should be text-dark
      
      * change pivot table font size unit to em for scaling
      
      * change funnel and legend item unit to em
      
      * change funnel font size to em
      
      * change object detail font size to em
      
      * change gauge font size to em
      
      * add cartesian chart padding config
      
      * update docs
      
      * remove isEmbeddingSdk prop
      
      * simulate the 0.875em base font size
      
      * chart padding override should apply in query builder
      
      * add cartesian padding to stories
      
      * update readme docs
      
      * fix collection browser option in readme docs
      
      * fix pivot table font size scaling
      
      * update loki
      
      * update loki
      
      * use em for smart scalar
      
      * update chart default padding
      
      * revert smart scalar font size scaling due to measurement
      
      * dynamic font family and font size as defaults
      
      * pivot table
      
      * add more properties to sdk docs
      
      * make FONT_SIZES constant local
      
      * link to discussion on query builder extra spacing
      
      * enforce that font is passed to getLeftHeaderWidths
      dab2d852
  5. Jun 19, 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
  10. Jun 06, 2024
  11. Jun 04, 2024
  12. May 31, 2024
    • Case Nelson's avatar
      Single metadata endpoint for cards (#43405) · 68435f90
      Case Nelson authored
      68435f90
    • Nick Fitzpatrick's avatar
      React 18 (#41975) · ead905b1
      Nick Fitzpatrick authored
      
      * initial commit with most types sorted
      
      * admin, binning, collections, custom-column and dashboard-cards suites
      
      * Filters, Joins, Metrics, Models, Native and Native filters suites
      
      * rest of e2e specs
      
      * filters, actions, onboarding and custom column will hopfully be green?
      
      * fixing static viz, brush filtering, login redirecting, and a few other tests
      
      * types green
      
      * linter green
      
      * hopefully fixes filter tests
      
      * I don't often cry, but when I do it's because of filter-types
      
      * hopfully sorted the last test that's failing CI
      
      * PR Feedback
      
      * yarn prettier
      
      * React 18 Upgrade - Unit Tests (#41577)
      
      * fixes for most unit tests to work with react 18 + upgraded rtl to v15
      
      * fixes all unit tests locally
      
      * fixes from rebasing
      
      * linter shames me
      
      * fix flake in maps.cy.spec.js
      
      ---------
      
      Co-authored-by: default avatarSloan Sparger <sloansparger@users.noreply.github.com>
      Co-authored-by: default avatarSloan Sparger <sloansparger@gmail.com>
      ead905b1
    • Uladzimir Havenchyk's avatar
      862ca7ea
  13. May 30, 2024
  14. May 29, 2024
  15. May 28, 2024
    • Phoomparin Mano's avatar
      feat(sdk): expose color and typography options for smart scalar in embedding SDK (#42915) · 8fc52d22
      Phoomparin Mano authored
      
      * feat(sdk): allow overriding positive and negative values
      
      * docs(sdk): add positive and negative colors to docs
      
      * feat(sdk): add smart scalar font size
      
      * feat(sdk): add smart scalar line height settings
      
      * feat(sdk): get rid of custom embedding mantine theme type
      
      * wip: setup storybook and loki for smart scalar
      
      * fix missing state for rendering visualizations
      
      * docs(sdk): add scalar customizations to readme
      
      * test(sdk): add test cases to loki
      
      * add smart scalar reference image
      
      * use css variables for brand
      
      * make embedding theme options partial
      
      * fix scalar value wrapper line height
      
      * update loki snapshot
      
      ---------
      
      Co-authored-by: default avatarAleksandr Lesnenko <alxnddr@gmail.com>
      8fc52d22
  16. May 20, 2024
  17. May 17, 2024
    • Nemanja Glumac's avatar
    • Sloan Sparger's avatar
      [Feature branch] Make Trash Usable (#42339) · 7460cad8
      Sloan Sparger authored
      * Migration to add `trashed_from_*` (#41529)
      
      We want to record where things were trashed *from* for two purposes:
      
      - first, we want to be able to put things back if they're "untrashed".
      
      - second, we want to be able to enforce permissions *as if* something is
      still in its previous location. That is, if we trash a card or a
      dashboard from Collection A, the permissions of Collection A should
      continue to apply to the card or dashboard (e.g. in terms of who can
      view it).
      
      To achieve this, collections get a `trashed_from_location` (paralleling
      their `location`) and dashboards/cards get a
      `trashed_from_collection_id` (paralleling their `collection_id`).
      
      * Create the trash collection on startup (#41535)
      
      * Create the trash collection on startup
      
      The trash collection (and its descendants) can't have its permissions
      modified.
      
      Note that right now, it's possible to move the Trash collection. I'll
      fix this when I implement the API for moving things to the Trash.
      
      * s/TRASH_COLLECTION_ID/trash-collection-id/g
      
      * Add a comment to explain null comparison
      
      * Move archived items to the trash (#41543)
      
      This PR is probably too big. Hopefully documenting all the changes made here will make it easier to review and digest. So:
      
      Tables with a `collection_id` had `ON DELETE SET NULL` on the foreign key. Since we only deleted collections in testing and development, this didn't really affect anything. But now that we are actually deleting collections in production, it's important that nothing accidentally get moved to the root collection, which is what `SET NULL` actually does.
      
      When we get an API request to update the `archived` flag on a card, collection, or dashboard, we either move the item *to* the trash (if `archived` is `true`) or *from* the trash (if `archived` is `false`). We set the `trashed_from_collection_id` flag as appropriate, and use it when restoring an item if possible.
      
      Because moving something to the trash by itself would have permissions implications (since permissions are based on the parent collection) we need to change the way permissions are enforced for trashed items.
      
      First, we change the definition of `perms-objects-set-for-parent-collection` so that it returns the permission set for the collection the object was *trashed from*, if it is archived.
      
      Second, when listing objects inside the Trash itself, we need to check permissions to make sure the user can actually read the object - usually, of course, if you can read a collection you can read the contents, but this is not true for the trash so we need to check each one. In this case we're actually a little extra restrictive and only return objects the user can *write*. The reasoning here is that you only really want to browse the Trash to see things you could "act on" - unarchive or permanently delete. So there's no reason to show you things you only have read permissions on.
      
      Because previously the Collections API expected archived collections to live anywhere, not just in a single tree based in the Trash, I needed to make some changes to some API endpoints.
      
      This endpoint still takes an `exclude-archived` parameter, which defaults to `false`. When it's `false`, we return the entire tree including the Trash collection and archived children. When it's `true`, we exclude the Trash collection (and its subtree) from the results.
      
      Previously, this endpoint took an `archived` parameter, which defaulted to `false`. Thus it would only return non-archived results. This is a problem, because we want the frontend to be able to ask for the contents of the Trash or an archived subcollection without explicitly asking for archived results. We just want to treat these like normal collections.
      
      The change made to support this was to just default `archived` to the `archived` status of the collection itself. If you're asking for the items in an archived collection, you'll only get archived results. If you're asking for the items in a non-archived collection, you'll only get unarchived results.
      
      This is, for normal collections, the same thing as just returning all results. But see the section on namespaced collections for details on why we needed this slightly awkward default.
      
      No change - this endpoint still takes an `archived` parameter. When `archived=true`, we return the Trash collection, as it is in the root collection. Otherwise, we don't.
      
      * Make Trash Usable - UI (#41666)
      
      * Remove Archive Page + Add `/trash` routing (#42226)
      
      * removes archive page and related resources, adds new /trash route for trash collection, adds redirects to ensure consistent /trash routing instead of collection path
      
      * fixes unit + e2e tests, corrects links generated for trash collection to use /trash over /collect/:trashId route
      
      * updates comment
      
      * Serialize trash correctly (#42345)
      
      Also, create the Trash in a migration rather than on startup. Don't set a specific trash collection.id, instead just select based on the `type` when necessary.
      
      * Fix collection data for trashed items (#42284)
      
      * Fix collection IDs for trashed items
      
      When something is in the trash, we need to check permissions on the
      `trashed_from_collection_id` rather than the `collection_id`. We were
      doing this. However, we want the actual collection data on the search
      result to represent the actual collection it's in (the trash). I added
      the code to do this, a test to make sure it works as intended, and a
      comment to explain what we're doing here and why.
      
      * Refactor permission for trashed_from_collection_id
      
      Noah pointed out that the logic of "what collection do I check for
      permissions" was getting sprinkled into numerous places, and it felt a
      little scary. In fact, there was a bug in the previous implementation.
      If you selected a collection with `(t2/select [:model/Collection ...])`,
      selecting a subset of columns, and *didn't* include the
      `trashed_from_collection_id` in that set of columns, then called
      `mi/can-write?` on the result, you'd get erroneous results.
      Specifically, we'd return `nil` (representing the root collection).
      
      I think this is a reasonable fix, though I'm pretty new to using fancy
      multimethods with `derive` and such. But basically, I wanted a way to
      annotate a model to say "check these permissions using
      `:trashed_from_collection_id` if the item is archived." And in this
      case, we'll throw an exception if `:trashed_from_collection_id` is not
      present, just like we currently throw an exception if `:collection_id`
      is not present when checking permissions the normal way.
      
      * Move existing archived items to the trash (#42241)
      
      Move everything that's archived directly to the trash. It's not ideal
      because we're wiping out the existing collection structure, but the
      existing Archive page also has no collection structure.
      
      * lint fixes from rebase
      
      * Fix backend tests (#42506)
      
      `can_write` on collection items was wrong because we didn't have a
      `trashed_from_collection_id` - the refactor to ensure we didn't make
      that mistake worked! :tada:
      
      
      
      * Add an /api/collections/trash endpoint (#42476)
      
      This fetches the Trash in exactly the same way as if we'd fetched it
      with `/api/collection/:id` with the Trash ID. I hadn't realized that the
      frontend was doing this with the previously hardcoded Trash ID.
      
      * Make Trash Usable - Dynamic Trash Collection Id (#42532)
      
      * wip
      
      * fixes hardcoded reference to trash id in sidebar
      
      * remove TRAHS_COLLECTION
      
      * fixes line and e2e tests
      
      * fix invert logic mistake and fixes lint
      
      * Make Trash Usable - Search Filter UI (#42402)
      
      * adds filtering for archived items on the search page
      
      * fix typing mistake
      
      * Make Trash Usable - Bug Bash 1 (#42541)
      
      * disables reordering columns in archived questions, disables modifying archived question name in question header, collection picker no longer defaults to archived item, keeps trashed collection from appearing collection picker search results, shops showing empty area in trashed dashboard info sidebar, disables uploading csvs to trashed collections
      
      * impls pr feedback
      
      * fix e2e failure
      
      * Localize the name of the Trash (#42514)
      
      There are at least two spots where we can't just rely on the
      after-select hook, and select the collection name directly from the
      database: the Search and Collection API.
      
      In these cases we need to call `collection/maybe-localize-trash-name`,
      which will localize the name if the passed Collection is the Trash
      collection.
      
      * Update migration IDs
      
      Migration IDs need to be in order.
      
      * Fix failing mariadb:latest test (#42608)
      
      Hooooly cow. Glad to finally track this down. The issue was that
      booleans come back from MariaDB as NON BOOLEANS, and clojure says 0 is
      truthy, and together that makes for FUN TIMES.
      
      We need to turn MariaDB's bits to booleans before we can work with them.
      
      * Make Trash Usable: Add `can_restore` to API endpoints (#42654)
      
      Rather than having two separate implementations of the `can_restore`
      hydration for cards and dashboards, I set up automagic hydration for the
      `trashed_from_collection_id`. Then the hydration method for
      `can_restore` can just first hydrate `trashed_from_collection` and then
      operate based on that.
      
      * fix can_restore for collections trashed from root
      
      * Fix `trashed_from_location` for trashed subcols
      
      We were setting `trashed_from_location` on subcollections to the
      `trashed_from_location` of the ancestor that was trashed - which is
      wrong.
      
      This would have caused bugs where collections would be restored to the
      root collection, regardless of where they were originally trashed from.
      
      ---------
      
      Co-authored-by: default avatarSloan Sparger <sloansparger@gmail.com>
      
      * Fix Trash rollbacks (#42710)
      
      * Fix Trash rollbacks
      
      There were a few errors in my initial implementation.
      
      First, we can't simply assume that `trashed_from_location` and
      `trashed_from_collection_id` are set for anything in the archive. They
      should be set for things *directly* trashed, but not for things trashed
      as part of a collection.
      
      Therefore, we need to set `location` and `collection_id` to something
      like "if the item is in the trash, then the `trashed_from` - otherwise,
      don't modify it".
      
      Second, because `trashed_from_collection_id` is not a foreign key but
      `collection_id` is, we have a potential problem. If someone upgrades,
      Trashes a dashboard, then Trashes and permanently deletes the collection
      that dashboard _was_ in, then downgrades, how do we move the dashboard
      "back"? What do we set the dashboard's `collection_id` to?
      
      The solution here is that when we downgrade, we don't actually move
      dashboards, collections, or cards out of the Trash collection. Instead
      we just make Trash a normal collection and leave everything in it.
      
      * Make Trash Usable - Bug Bash 2 (#42787)
      
      * wip
      
      * fixes access to property on null value
      
      * pr clean up
      
      * more clean up
      
      * Fix up tests
      
      - permissions will check the archived from location. So recents need to
      select :report_card.trashed_from_collection_id and
      :dash.trashed_from_collection_id to satisfy mi/can-read?
      - some commented out code with `(def wtf (mt/user-http-request
      ...))`. Restore tests.
      - probably commented out because the recent views come back in an order
      but we don't care about the order. And it was asserting against an
      ordered collection. Just go from [{:id <id> :model <model>} ...] to a
      map of {<id> <model>} and then our comparison works fine and is not
      sensitive to order.
      
      * put try/finally around read-only-mode
      
      ensure the setting read-only-mode! to false happens in a finally
      block. Also, set read-only-mode to false in
      
      ```clojure
      (deftest read-only-login-test
        (try
          (cloud-migration/read-only-mode! true)
          (mt/client :post 200 "session" (mt/user->credentials :rasta))
          (finally
            (cloud-migration/read-only-mode! false))))
      ```
      
      But worryingly, I think we have a lurking problem that I'm not sure why
      we haven't hit yet. We run tests in parallel and then put all of the
      non-parallel tests on the same main thread. And when one of these puts
      the app in read-only-mode, the parallel tests will fail. HOPEFULLY since
      they are parallel they won't be hitting the app-db necessarily, but
      there could be lots of silly things that break.
      
      ---------
      
      Co-authored-by: default avatarJohn Swanson <john.swanson@metabase.com>
      Co-authored-by: default avatardan sutton <dan@dpsutton.com>
      7460cad8
  18. May 16, 2024
  19. May 14, 2024
  20. May 13, 2024
    • bryan's avatar
      New Recents API Format (#42239) · 2b91354f
      bryan authored
      
      * wip
      
      * adds more collection-touch events
      
      * remove sneaky dep that slipped in
      
      * cleaning up, and adding tests
      
      * respond to review comments + mini bug reports
      
      * make it official
      
      * double official
      
      * cleanup + return recent-views/Item for `GET activity/popular_items`
      
      * get popular_items returning the proper shape
      
      * compare doesn't what I thought
      
      * add display_name to tables
      
      * table.database.name should be the db name, not the table name
      
      * add table.database.initial_sync_status
      
      * improve call to toucan2
      
      * light renaming + many text fixes
      
      * include moderated_status in cards and datasets
      
      * look up Dashboard permissions for Dashboards
      
      * stop double-querying for `can-write?` checks
      
      - also include some debug logging
      
      * fix card <-> model dispatching
      
      also gets tests passing locally
      
      * let the test runner run the tests
      
      * fix gc test
      
      * adds description
      
      * description can be null
      
      * better tests
      
      no more nils passed through the app
      
      * debugging test
      
      * fix tests and skip archived
      
      * mysql finesse
      
      * ellide inactive tables
      
      * wip
      
      * adds more collection-touch events
      
      * remove sneaky dep that slipped in
      
      * cleaning up, and adding tests
      
      * respond to review comments + mini bug reports
      
      * make it official
      
      * double official
      
      * cleanup + return recent-views/Item for `GET activity/popular_items`
      
      * get popular_items returning the proper shape
      
      * compare doesn't what I thought
      
      * add display_name to tables
      
      * table.database.name should be the db name, not the table name
      
      * add table.database.initial_sync_status
      
      * improve call to toucan2
      
      * light renaming + many text fixes
      
      * include moderated_status in cards and datasets
      
      * look up Dashboard permissions for Dashboards
      
      * stop double-querying for `can-write?` checks
      
      - also include some debug logging
      
      * fix card <-> model dispatching
      
      also gets tests passing locally
      
      * let the test runner run the tests
      
      * fix gc test
      
      * adds description
      
      * description can be null
      
      * better tests
      
      no more nils passed through the app
      
      * debugging test
      
      * fix tests and skip archived
      
      * mysql finesse
      
      * New Recents + Popular API Format - Frontend (#42305)
      
      * fix tests
      
      * new API payload format for recents and populars
      
      * update url generation
      
      * update recents components
      
      * update tests
      
      * only show 5 recents in command palette
      
      * remove unused types
      
      * update tests
      
      * obey the linter
      
      * type updates
      
      * fix unit test
      
      * change where we filter recents
      
      ---------
      
      Co-authored-by: default avatarBryan Maass <bryan.maass@gmail.com>
      
      * fix modelToUrl types
      
      * respond to review comments
      
      * post merge test fix
      
      ---------
      
      Co-authored-by: default avatarRyan Laurie <30528226+iethree@users.noreply.github.com>
      Co-authored-by: default avatarRyan Laurie <iethree@gmail.com>
      2b91354f
  21. May 10, 2024
  22. May 09, 2024
    • Ryan Laurie's avatar
      Allow Admins to clean up uploaded tables in bulk (#42183) · 06cd458d
      Ryan Laurie authored
      
      * add upload management API
      
      * add upload management interface
      
      * remove trailing slash
      
      * add e2e upload management test
      
      * add upload management to token_features
      
      * jsdoc cleanup
      
      * fixes tests
      
      - include :upload_management in session_test
      - fix list-url in upload management
      - ensure local tests have upload management disabled
        (causes tests locally to 422 instead of 402: it has sufficient
        permissions from a local token to try to delete the table but the
        table is not an upload table, so you get a 422)
      
      * add card archive param
      
      * update tests
      
      * use common component
      
      * add success/error toasts
      
      * test success/error notifications
      
      * update e2e tests
      
      * address review comments
      
      * make sure we have fresh data
      
      ---------
      
      Co-authored-by: default avatardan sutton <dan@dpsutton.com>
      06cd458d
  23. May 07, 2024
  24. May 02, 2024
  25. Apr 30, 2024
  26. Apr 29, 2024
    • Cam Saul's avatar
      Add `Offset()` expression (BE + FE) (Part 1) (#41346) · dd0f14a5
      Cam Saul authored
      * Fix add-alias-info matching for nominal field literal refs
      
      * Minor cleanup
      
      * Minimize diff
      
      * A bit more cleanup
      
      * Cumulative aggregations w/ multiple breakouts should reset counts (#2862)
      
      * Update dox
      
      * Do the nesting FIRST before adding alias info.
      
      * Remove unused
      
      * FE for Offset()
      
      * Cleanup stray code
      
      * Prettier
      
      * Kondo
      
      * Test fixes :wrench:
      
      * Better error message when no breakout
      
      * Support offset as an expression with no breakouts. Still require an ORDER BY tho.
      
      * Fix most stuff
      
      * Hack city??????
      
      * Revert nest-query changes and disable the offset-no-breakout test for now.
      
      * Appease TypeScript
      
      * Test fix :wrench:
      
      * Oracle & MySQL test fixes
      
      * Test fixes :wrench:
      
      * Remove maxWorkers for FE unit tests
      dd0f14a5
    • Nemanja Glumac's avatar
  27. Apr 26, 2024
  28. Apr 25, 2024
  29. Apr 19, 2024
Loading