Skip to content
Snippets Groups Projects
This project is mirrored from https://github.com/metabase/metabase. Pull mirroring updated .
  1. Feb 16, 2024
    • metabase-bot[bot]'s avatar
      Add per viz-type card template sizes in x-rays (#38836) (#38884) · aea2cb22
      metabase-bot[bot] authored
      * Add per viz-type card template sizes in x-rays
      
      Previously, any card without a size (width or height) set in their yaml definition was set to a default of `default-card-width` or `default-card-width`, respectively. This PR adds a map of default and min dimensions per viz type (the `:display`) key and fills that in for each template. The template is merged into this result, keeping anything that already existed in the yaml file.
      
      Before merging this we should consider if we want to use the min values and where this data should be stored. It is currently in `metabase.automagic-dashboards.dashboard-templates`, but was lifted from [sizes.ts](https://github.com/metabase/metabase/blob/master/frontend/src/metabase/visualizations/shared/utils/sizes.ts
      
      ).
      
      * Moving card sizing constants to cljc
      
      The default card sizes were found in `sizes.ts` and were duplicated into `metabase.automagic-dashboards.dashboard-templates`. This PR consolidates those changes into `metabase.shared.automagic-dashboards.constants`.
      
      Note that @kulyk and @JesseSDevaney might want to consider further consolidation of dashboard related constants into this namespace.
      
      * Incorporating Feedback
      
      Changes
      - Explicitly defined two constants in the shared file that are clj and js friendly
      - Set case to CARD_SIZE_DEFAULTS_JSON
      - Updated `metabase.automagic-dashboards.dashboard-templates/set-default-card-dimensions` to use a helper
      
      * Update src/metabase/shared/automagic_dashboards/constants.cljc
      
      
      
      * Updating ns name per Jesse
      
      ---------
      
      Co-authored-by: default avatarMark Bastian <markbastian@gmail.com>
      Co-authored-by: default avatarJesse Devaney <22608765+JesseSDevaney@users.noreply.github.com>
      Unverified
      aea2cb22
  2. Oct 02, 2023
    • Braden Shepherdson's avatar
      Enable ClojureScript REPL and hot reloading of CLJS code (#34007) · 8e298158
      Braden Shepherdson authored
      This also moves the CLJS output out of `frontend/src/cljs{,_release}` to
      `target/cljs_{dev,release}`. If that causes problems for FE tooling I
      don't know about, it could be moved back.
      
      Hot reloading:
      CLJS changes are hot-reloaded into the running app by Shadow CLJS - no
      action is needed. Note that the UI will not refresh; you usually have to
      click around so the updated MLv2 code gets executed.
      
      Usage of the CLJS REPL:
      - Open the browser (you should see `shadow-cljs: #N ready!` in console)
      - Connect to nrepl on 50655
      - "Select" the `:app` build;
          - https://shadow-cljs.github.io/docs/UsersGuide.html#_editor_integration
          - Conjure: `:ConjureShadowSelect app`
          - Plain REPL: Eval in CLJ mode `(shadow/repl :app)`
      - Consider running `yarn build-hot:cljs` and `yarn build-hot:js` in
        separate terminals; then when `yarn build-hot:js` crashes you don't
        have to reconnect your REPL.
      - The REPL works beautifully, even loading files outside the :entries
        of the shadow-cljs build like tests!
      
      "Stale" error in browser:
      - This can happen if the webpack bundle is created before the CLJS is
        done building.
      - If you ran `yarn build-hot:cljs` and `:js` separately, let `:cljs`
        finish compiling first.
      - If you see this otherwise: (a) contact Braden so it can be fixed; and
        (b) either restart `build-hot:js` or force webpack to rebuild by
        hitting http://localhost:8080/webpack-dev-server/invalidate
      
      Yarn commands:
      `dev`, `dev-ee`, `build-hot`, and `build-static-viz:watch` all now wait
      for the CLJS build to be complete by watching for files to be generated.
      They should work the same from a user's POV.
      
      (Since the webpack build no longer watches the CLJS output,
      it won't notice the changes and immediately rebuild after the first
      build. This avoids errors on the clean build, or "stale build" messages
      in the app from Shadow CLJS.)
      
      Fixes #32674.
      Unverified
      8e298158
  3. May 02, 2023
  4. Apr 12, 2023
  5. 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
  6. Mar 20, 2023
  7. Mar 14, 2023
  8. 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
  9. 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
  10. 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
  11. Feb 10, 2023
  12. Feb 08, 2023
  13. Feb 07, 2023
  14. 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
  15. 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
  16. 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
  17. 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
  18. Feb 03, 2022
  19. Aug 05, 2021
  20. Aug 04, 2021
  21. Jul 29, 2021
  22. Mar 23, 2021
  23. 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