Skip to content
Snippets Groups Projects
This project is mirrored from https://github.com/metabase/metabase. Pull mirroring updated .
  1. May 02, 2023
  2. Apr 12, 2023
  3. Mar 29, 2023
    • Anton Kulyk's avatar
      Use metabase-lib v2 to manage query row limit (#29454) · 34d6f614
      Anton Kulyk authored
      * Add TypeScript wrapper for limit helpers
      
      * Use v2 limit in `StructuredQuery`
      
      * Add redux action for managing limit in QB
      
      * Switch `QuestionRowCount` to use ML v2
      
      * Add utils to convert v2 queries into v1
      
      * Use `toLegacyQuery`
      
      * Fix CLJS limit functions unavailable in Jest
      
      * Fix tests
      
      * Style tweaks
      
      * Fix type error
      
      * Use opaque type for ML `Query`
      
      * Use `Lib` instead of `MetabaseLib`
      
      * Drop v2 folder
      
      * Fix MBQL in unit tests
      
      * Don't import individual functions from MLv2
      
      * Export `limit` CLJC functions
      
      * Tweak CLJS imports
      Unverified
      34d6f614
  4. Mar 20, 2023
  5. Mar 14, 2023
  6. Mar 01, 2023
    • Braden Shepherdson's avatar
      Fix exclusion of CLJS devtools from release builds · 5e3c29cb
      Braden Shepherdson authored
      The new approach uses a dev-mode-only CLJC reader conditional
      `#?(:cljs-dev ...)` to make `metabase.util.devtools` empty
      except in dev builds.
      
      The previous approach for this relied on dead code elimination.
      But DCE relies on tracing function calls and `:require`s from the
      `:entries` list in shadow-cljs.edn. Top-level namespace code is
      handled differently; in particular a namespace listed in `:entries`
      like `metabase.util.devtools` will always have its top-level code
      in the build.
      5e3c29cb
  7. Feb 27, 2023
    • Braden Shepherdson's avatar
      [metabase-lib] Dev experience and CLJC infra improvements · 4580eab9
      Braden Shepherdson authored
      Dev experience:
      - CLJS now has source maps
      - Devtools extension renders CLJS data in Chrome (et al) Devtools
      - Use a debug build of CLJS in the tests
      - Fixed line numbers and breakpoints being off-by-one in Devtools
      
      CLJC infra:
      - More robust direct approach to JS<->CLJS conversions, powered by
        Malli transformers.
      - Powerful `define-getters-and-setters` macro to generate the accessors.
      4580eab9
  8. Feb 14, 2023
    • Braden Shepherdson's avatar
      [metabase-lib] PoC for wrapping JS objects with cljs-bean in CLJC · 4c15f80c
      Braden Shepherdson authored
      A `metabase.domain-entities.malli/defn` macro that (in CLJS) uses the
      schemas for the arguments to drive wrapping of vanilla JS objects for
      idiomatic use in CLJC code.
      
      See the first two functions in `metabase.domain-entities.queries.util`
      which get passed vanilla JS objects but can use them as CLJS maps.
      4c15f80c
  9. Feb 10, 2023
  10. Feb 08, 2023
  11. Feb 07, 2023
  12. Jan 13, 2023
    • Braden Shepherdson's avatar
      [metabase-lib] Port date and time parsing and formatting to CLJC (#27551) · 335d161f
      Braden Shepherdson authored
      This adds a cross-platform date/time formatting library in CLJC, with
      (nearly) identical output in both JVM and JS environments.
      
      The only known difference is week numbers.
      
      CLJS (through Moment.js) has ordinal numbers, and renders the week
      number as "34th". Neither the JVM nor Clojure has a handy library for
      this (I'm sure it's out there somewhere, but it seems like a silly
      dep to add) so it renders week numbers as simply "34".
      
      Both platforms have date formatters that use pattern strings (eg.
      `"YYYY-MM-dd"`) to turn date/time objects into strings. There's a strong
      resemblance in how these work and what letters stand for what parts of
      the date and time, but they are far from identical.
      
      Rather than try to hackily convert one set of strings to another with
      regexes or other manipulations, this PR defines a set of names for
      fragments of dates (eg. `:year`, `:day-of-week-full`, `:hour-24-dd`)
      and includes functions to transform a list of these keys into a
      platform-specific format function.
      
      This is portable and transparent, and can be written in Clojure or
      JS code:
      
      ```clj
      [:year "-" :month-dd "-" :day-of-month-dd]   ; 2022-04-08
      [:month-full " " :day-of-month-d ", " :year] ; April 8, 2022
      [:hour-12-dd ":" :minute-dd " " :am-pm]      ; 7:52 AM
      ```
      
      ```js
      [":year", "-", ":month-dd", "-", ":day-of-month-dd"]   ; 2022-04-08
      [":month-full", " ", ":day-of-month-d", ", ", ":year"] ; April 8, 2022
      [":hour-12-dd", ":", ":minute-dd", " ", ":am-pm"]      ; 7:52 AM
      ```
      
      Note that the original code allowed an unrecognized `:date-style` string
      to be used directly as the formatting string. With the move to
      formatting data structures that no longer works. Instead there is a
      fixed map of format strings to the above data structures, that contains
      all the currently used `:date-style` inputs.
      
      If some caller needs a new format someday, we can either: (a) add the
      style to the map; or (b) pass the data structure form directly to the
      `:date-format` option, which if provided is used as the format.
      
      It's tempting to go to all the call sites and replace these `:date-style`
      strings with the new format structures. However, the strings are still
      embedded in the `:visualization_settings` in user appDBs, so we still
      need to recognize them.
      
      Most of the existing functions in the TS library have the same API.
      
      The set of allowed `:date-style` and `:time-style` values is turned into
      a type using `keyof`, so that we get precise type-checking of these
      values rather than simply `string`.
      
      One function has been dropped from the API: `getDateFormatFromStyle`.
      There was no practical way to implement it using the new format data
      structures. The only caller was the date format column settings, and it
      has been rewritten to use the formatted string for its sample date as
      its key instead.
      Unverified
      335d161f
  13. Dec 21, 2022
    • Braden Shepherdson's avatar
      [metabase-lib] Port number formatting to CLJC; use it from JS (#27114) · 2537f3d0
      Braden Shepherdson authored
      This adds a cross-platform number formatting library in CLJC, which has
      (nearly) identical output in both JVM and JS environments.
      
      The only known differences are:
      - JVM Clojure has `BigDecimal` support, so isn't limited to a `double`'s
        range.
      - Exact spelling/capitalization of the full names of currencies differs.
          - JVM: "7.34 US Dollar"
          - JS: "7.34 US dollars"
      
      Some future work is required to fully land this. In particular, the
      `currency_in_header` logic should be moved to the table formatters, not
      implemented on the JS side of this change.
      Unverified
      2537f3d0
  14. Aug 05, 2022
    • Noah Moss's avatar
      Bump shadow-cljs to 2.19.6 (#24647) · dfd93579
      Noah Moss authored
      * Bump shadow-cljs
      
      This lets us use the template tag functionality
      
      ```
      add experimental support for creating js template strings
      
      used like str but emits native JS `` template
      
        (js-template "foo" (+ 1 2) "bar")
      
      emits the literal
      
        `foo${(1 + 2)}bar`
      ```
      
      But this required a few changes on our side as well.
      
      Required for this:
      
      -- LOGGING
      
      Bumped glogi
      ```diff
         ;; new stuff
      -  [lambdaisland/glogi "1.0.106"]]
      -
      +  [com.lambdaisland/glogi "1.1.144"]]
      ```
      Annoying because it had a group name change due to Clojars policy. This
      had the same error as us below. That's why I'm hopeful that it will
      actually just work.
      
      There were some changes with the Google Closure library with things not
      included or referenceable. So I just removed these imports and the
      typehints that used them. We'll need to verify that this still works but
      both compiling for dev and release (with advanced compilation)
      work. Still possible there will be some runtime errors but i'm hopeful
      there wont be. We can grab a jar from CI and poke around
      
      ```shell
      ❯ npx shadow-cljs compile app
      shadow-cljs - config: /Users/dan/projects/work/metabase/shadow-cljs.edn
      shadow-cljs - connected to server
      [:app] Compiling ...
      [:app] Build completed. (100 files, 0 compiled, 0 warnings, 1.65s)
      
      metabase on  nm-all-options-formatting [$!+?] via :coffee: v17.30 on :cloud:
      
        metabase-query took 2s
      ❯ npx shadow-cljs release app
      shadow-cljs - config: /Users/dan/projects/work/metabase/shadow-cljs.edn
      shadow-cljs - connected to server
      [:app] Compiling ...
      [:app] Build completed. (100 files, 30 compiled, 0 warnings, 28.04s)
      ```
      
      ```diff
                   [lambdaisland.glogi.console :as glogi-console])
      -  (:require-macros metabase.shared.util.log)
      -  (:import goog.debug.Logger
      -           goog.debug.Logger.Level))
      +  (:require-macros metabase.shared.util.log))
      ```
      
      ```diff
      @@ -37,4 +35,4 @@
       (defn is-loggable?
         "Part of the impl for [[metabase.shared.util.log/js-logp]] and [[metabase.shared.util.log/js-logf]]."
         [logger-name level]
      -  (.isLoggable ^Logger (log/logger logger-name) ^Level (log/levels level)))
      +  (.isLoggable (log/logger logger-name) (log/levels level)))
      ```
      
      -- WARNINGS ABOUT shadowing `abs`
      
      -  [medley "1.3.0"]
      +  [medley "1.4.0"]
      
      Similar to what we bumped for the backend. ClojureScript 1.11.x has an
      `abs` function.
      
      * use update-keys and update-vals in cljs
      
      * bump clj-kondo in CI
      
      Co-authored-by: default avatardan sutton <dan@dpsutton.com>
      Unverified
      dfd93579
  15. Jul 12, 2022
    • Noah Moss's avatar
      First pass at parameters in Markdown cards (#23641) · e136f430
      Noah Moss authored
      * first pass at parameters in text cards on FE
      
      * trying to get translations working
      
      * relative datetime formatting
      
      * copy changes and 'Text card' header
      
      * default text when no params
      
      * hide header for text cards with height of 1 with params when in param mapping mode
      
      * show UI text in mobile mode
      
      * minor fixes
      
      * enforce that a text card variable can only be mapped to one parameter
      
      * more value formatting
      
      * noop
      
      * fix backend tests
      
      * add back a couple pieces of frontend logic commented out
      
      * misc cleanup
      
      * attempt at adding a FE unit test
      
      * revert unit test, doesn't work
      
      * add a couple of basic cypress tests and fix a couple of bugs
      
      * basic unit tests for cljc
      
      * fix error
      
      * expanded unit tests
      
      * simplify ns
      
      * add cypress test for instance language translation
      
      * basic handling for a couple cases of :date/all-options
      
      * trs docstring clarification
      
      * whitespace tweaks
      
      * fix cypress test
      
      * minor refactor of tag-names
      
      * move cljc file from utils to new parameters dir
      
      * reorder functions
      
      * fix lint
      
      * add test assertion that locale is correctly reset back to english, and add a comment
      
      * fix bug where existing parameter mapping target was not being found
      
      * clojure logic tweaks
      
      * move text card header text to the Text component config
      
      * simplify header logic, and pull out isLoading into a function to reduce complexity
      
      * address alex's css feedback
      
      * fix trs comment
      Unverified
      e136f430
  16. Feb 03, 2022
  17. Aug 05, 2021
  18. Aug 04, 2021
  19. Jul 29, 2021
  20. Mar 23, 2021
  21. Mar 05, 2021
    • Cam Saul's avatar
      Shared CLJ/CLJS lib (#14980) · cca03d22
      Cam Saul authored
      * Shared CLJ/CLJS lib (PoC/WIP)
      
      * PoC 2.0
      
      * Fixes :wrench:
      
      * More test fixes :wrench:
      
      * Bump shadow-cljs version
      
      * Fix more stuff
      
      * Need to ^:export the exports
      
      * CI fixes :wrench:
      
      * Add eslintignore
      
      * Ignore cljs files for FE code coverage
      
      * Try prefixing CLJS -> JS import with goog:
      
      * Revert indentation change
      
      * No goog:
      
      * Add .prettierignore
      
      * Use advanced build for now for JS tests unit we can figure out how to make it work
      Unverified
      cca03d22
Loading