Skip to content
Snippets Groups Projects
This project is mirrored from https://github.com/metabase/metabase. Pull mirroring updated .
  1. May 11, 2023
  2. May 04, 2023
    • Anton Kulyk's avatar
      Clean up metadata selectors (#30506) · c43e85f8
      Anton Kulyk authored
      * Add metrics and segments to entity store type
      
      * Add "sensitive" field visibility type
      
      * Add missing properties to MLv1 metadata classes
      
      * Handle metrics and segments in `createEntitiesState`
      
      * Convert metadata selector file to TypeScript
      
      * Fix type errors
      
      * Remove not used selectors
      
      * Don't export private selectors
      
      * Remove `getDatabases` selector
      
      * Remove `getFields` selectors
      
      * Fix types
      
      * Use normalized entity types in metadata selectors
      c43e85f8
  3. Apr 13, 2023
  4. Oct 26, 2022
  5. Sep 12, 2022
  6. Aug 30, 2022
  7. Mar 02, 2022
  8. Jan 20, 2022
    • Anton Kulyk's avatar
      Preserve metadata changes for models (via editor) (#19724) · 0b7435ee
      Anton Kulyk authored
      
      * RIP checksum
      
      Now that users can edit the metadata the checksum prevents that and
      would throw it away when edited. We'll treat the metadata as valid if it
      conforms. The UI isn't really expected to modify type information anyways.
      
      * Ns checker is a harsh disciplinarian
      
      * Extract `fields` variable in dataset editor
      
      * Allow extra onChange callback to form fields
      
      * Only show metadata sidebar when field is selected
      
      * Add onChange callback to semantic type picker
      
      * Add action for overwriting results metadata
      
      * Connect essential fields to form
      
      * display_name
      * description
      * semantic_type
      
      TBD: mapped database column for native datasets
      
      * Fix missing import
      
      * Fix sidebar inputs loosing focus while typing
      
      * Ensure focused field is in sync
      
      * Refactor FK and currency to be form fields
      
      * Use `field.settings` to keep formatting changes
      
      * Remove "display_as" from form definition
      
      * Connect remaining fields
      
      * Remove CurrencyPicker in favor of formatting input
      
      * Fix incomplete field metadata
      
      Results metadata doesn't contain everything we need for the editor.
      
      'Global' metadata is the most complete, though it shouldn't be muted while in the editor, only once a user saves the changes
      
      Now we only keep focused field ref in state and derive the metadata by merging global metadata and query's results metadata. Query results metadata is mutated by the editor, so merging them both will do the job
      
      * Fix ViewSidebar prop type
      
      * Fix prop type warnings
      
      * Add default values for some fields
      
      * Connect MappedFieldPicker
      
      * Fix MappedFieldPicker closes after loading fields
      
      Sidebar dependant on IDFields was rerendering once additional metadata was loaded, causing DataSelector to unmount
      
      Fixed by moving IDFields subscription to FKTargetPicker directly (the only component that actually needs them)
      
      * Hide metadata popovers in dataset editor
      
      * Disable saving invalid dataset editor changes
      
      Disables "Save changes" button if:
      * there is at least one field with empty display name
      * the underlying query is empty
      
      * Add `onChangeSetting` prop to ColumnSettings
      
      The existing `onChange` passes the whole settings object as an argument. On the other hand, `onChangeSetting` passes only the changed setting which is useful for storing metadata diff
      
      * Keep field metadata diff in redux
      
      * Ignore column width reset events in metadata editor
      
      * Preserve metadata diff between query edits
      
      * A few important changes:
      
      - ensure that we don't throw away metadata and return an empty channel
      in the card api if the query hasn't changed
      - ensure api/dataset uses `:metadata/dataset-metadata`
      - hydrate fields on api/table/card__id/query_metadata so that it has
      target and fk information
      - preserve id so this information can be recovered†
      
      †: When a user enters an id we preserve it, but it also gets confusing
      if that's the actual field's id or the user-identified id. This is
      important when we drill down (and probably lots of other places too if
      they start assuming an id means they know exactly what is going on).
      
      A situation based on the orders table:
      
      Suppose you make a native question
      
      ```sql
      SELECT "PUBLIC"."ORDERS"."ID" AS "ID",
        "PUBLIC"."ORDERS"."USER_ID" AS "user_id_bro",  -- note this is renamed
        "PUBLIC"."ORDERS"."PRODUCT_ID" AS "PRODUCT_ID",
        "PUBLIC"."ORDERS"."SUBTOTAL" AS "SUBTOTAL",
        "PUBLIC"."ORDERS"."TAX" AS "TAX",
        "PUBLIC"."ORDERS"."TOTAL" AS "TOTAL",
        "PUBLIC"."ORDERS"."DISCOUNT" AS "DISCOUNT",
        "PUBLIC"."ORDERS"."CREATED_AT" AS "CREATED_AT",
      "PUBLIC"."ORDERS"."QUANTITY" AS "QUANTITY"
      FROM "PUBLIC"."ORDERS"
      LIMIT 15
      ```
      
      In my db, the "USER_ID" column is field 3 and points at field 22. Our db
      knows that field 3 is called "USER_ID". But in the source query that
      column is actually called "user_id_bro". And lots of places assume that
      if there's a field's `:id` it knows what the name is. This is obviously
      incorrect here. It is a very important distinction that this column "is
      basically field 3 USER_ID" and this is literally the field "USER_ID".
      
      So if you do a drilldown based on this information, the FE will issue a
      query to "select field 3 from card__127" which expands to roughly
      "select USER_ID from (select ... USER_ID as user_id_bro ...)" and this
      query obviously will fail.
      
      * Don't put nil on a channel, clean ns
      
      i honestly don't know why the results-metadata and encrypt deps were
      there. I didn't add them but they just got caught in the linter for some
      reason. I don't understand it.
      
      * Update tests to include target and has_field_values
      
      * Correct final test
      
      * Select enough information for FK to work in UI
      
      * Pass mapped column's properties to BE
      
      * Qualify which semantic_type FK/PK we remove
      
      Previously always removed these semantic types. Now only remove when
      they do not have an id there. One thing I'm confused about though is
      that native fields should never have a semantic type anyways. There's no
      way for one to end up there, certainly not FK or PK right? So i want to
      delete this entire method because as I understand it it's not possible
      to trigger its conditions except for the new user-entered information,
      in which case we want to preserve it. But I have no idea why
      Mr. Chesterton built this function so I don't want to delete it.
      
      Bug reports and connecting them back to this change is so hard. Because
      it can be things like "native query with an aggregation named "blah"
      bucketed by month break when you drilldown into this column" and that's
      because it includes a semantic_type that breaks something. It's all very
      at-a-distance so hard to trace back to this.
      
      * Fix failed queries handling
      
      * Support custom column metadata editing
      
      * Hide empty sections in semantic type picker
      
      * Remove redundant import
      
      * Fetch database ID fields in FKTargetPicker
      
      * Allow aliasing EntityObjectLoader's entity prop
      
      * Reset DataSelector's state when ID props change
      
      * Fix MappedFieldPicker
      
      * Fixed saved question picker regression
      
      * Select description and settings when merging result_metadata
      
      Annotate columns allows for settings to be preserved from
      datasets. Example
      
      ```clojure
      ;; shows a little bar in the UI. quite nice
      :settings {:show_mini_bar true, :decimals 0},
      ```
      
      These settings were correctly preserved in annotate.clj but dropped in
      the final merging in result_metadata.clj. Fun times in metadata land
      
      * Let dataset revisions preserve metadata
      
      * Only wrap form fields with custom onChange handler
      
      This prevents form fields from extra re-renders
      
      * Fix summarize sidebar behavior
      
      * Fix e2e test
      
      * Update cypress expectations
      
      Previously expected really generic placeholder text in search boxes. But
      in `api/table/card__id/query_metadata` we hydrate native columns with
      `:has_field_values` so that when a user identifies an underlying field
      on datasets, we have extra information.
      
      This change comes about because the hydrate for `:has_field_values`
      doesn't hit the db and look for field values but uses a heuristic.  And
      this heuristic works for native fields and finds that they are
      searchable because when they are text or textlike and improves the
      search bar.
      
      Code from models/field.clj below
      
      ```clojure
      (defn- is-searchable?
        "Is this `field` a Field that you should be presented with a search widget for (to search its values)? If so, we can
        give it a `has_field_values` value of `search`."
        [{base-type :base_type}]
        ;; For the time being we will consider something to be "searchable" if it's a text Field since the `starts-with`
        ;; filter that powers the search queries (see `metabase.api.field/search-values`) doesn't work on anything else
        (or (isa? base-type :type/Text)
            (isa? base-type :type/TextLike)))
      
      (defn- infer-has-field-values
        "Determine the value of `has_field_values` we should return for a `Field` As of 0.29.1 this doesn't require any DB
        calls! :D"
        [{has-field-values :has_field_values, :as field}]
        (or
         ;; if `has_field_values` is set in the DB, use that value; but if it's `auto-list`, return the value as `list` to
         ;; avoid confusing FE code, which can remain blissfully unaware that `auto-list` is a thing
         (when has-field-values
           (if (= (keyword has-field-values) :auto-list)
             :list
             has-field-values))
         ;; otherwise if it does not have value set in DB we will infer it
         (if (is-searchable? field)
           :search
           :none)))
      
      (defn with-has-field-values
        "Infer what the value of the `has_field_values` should be for Fields where it's not set. See documentation for
        `has-field-values-options` above for a more detailed explanation of what these values mean."
        {:batched-hydrate :has_field_values}
        [fields]
        (for [field fields]
          (when field
            (assoc field :has_field_values (infer-has-field-values field)))))
      ```
      
      * Ignore `has_field_values` for field literals
      
      Field literals are field using a column title instead of a numeric ID. They're usually coming from native or nested queries.
      
      Metadata propagation changes introduced for data models, made the BE send a guessed `has_field_values` property for field literals too. But searching through possible field values isn't properly supported yet and it's difficult to prevent `has_field_values` being sent to the FE, so this makes the FE ignore it for field literals
      
      * Fix E2E test
      
      * Fix field literal check
      
      * Ensure `:has_field_values` only goes on fields with ids
      
      when a user selects an id to back a native field, we want to hydrate the
      field_value information and the target info. But _ONLY_ when they have
      ids. The hydration for `:has_field_values` works on a heuristic, not by
      hitting the db and seeing if we have field values and will give
      information about native fields that do not have backing field information.
      
      * Ensure no annotations on numeric field ids
      
      we put the vector id on each field when there's no numeric id field. I
      have no idea why and the comment `;; TODO -- what????` explains the
      thinking there. So only annotate where we have numeric ids (fields that
      we know how to identify fields in the db) and not when we have a made up
      vector id
      
      * Revert changes to FieldValuesWidget
      
      * Fix character case
      
      * Show `has_field_values` selector when ID is known
      
      * Undo the testing for indiscriminant hydration
      
      previously had put target and has_field_values on every native field
      which doesn't work well for the UI. Had to clean up the remaining tests
      to no longer expect it
      
      * Select `:dataset` when creating a new question
      
      when duplicating a question, we send over this info and need to select
      it from the existing question.
      
      * Ensure card is saved with boolean dataset info
      
      largely just for testing which does not send a `:dataset false` property
      in some cases. In regular usage there should always be an initial value
      
      * Remove dead code
      
      * Replace TODO with a meaningful comment
      
      * Type Field type
      
      * Select only what we need on the source card
      
      Co-authored-by: default avatardan sutton <dan@dpsutton.com>
      0b7435ee
  9. Dec 07, 2021
  10. Sep 10, 2021
  11. Aug 24, 2021
    • Ariya Hidayat's avatar
    • Alexander Lesnenko's avatar
      New Permissions Pages (#17328) · d012c89b
      Alexander Lesnenko authored
      * add PermissionSelect component
      
      * add PermissionSidebar component
      
      * add PermissionTable component
      
      * add PermissionEditor component
      
      * add useLeaveConfirmation hook
      
      * add selectors for the collections permissions page
      
      * add selectors for the data permissions pages
      
      * add confirmation creators to use in selectors
      
      * sandboxing permissions modal: redirect to parent route when closed
      
      * Add PermissionsPageLayout component
      
      * Adjust CollectionPermissionsModal to use new permissions UI
      
      * Add CollectionPermissionsPage
      
      * Add data permissions pages
      
      * Adjust collection permissions modal route
      
      * Adjust permissions routes according new pages structure
      
      * update permissions actions, reducers
      
      * adjust sandboxing
      
      * remove old permissions code
      
      * support admin colorScheme in Radio
      
      * support admin colorScheme in TextInput
      
      * support admin colorScheme in Tree
      
      * update permissions specs
      
      * fix data permissions url typo
      
      * fix sandboxing
      
      * add search debounce to permission pages
      
      * exclude schemas from search, make it flat
      
      * fix permissions for databases without schemas
      
      * fix copy for native queries permissions, show table display_name instead of raw name
      
      * fix before leave warning shown when change collections
      
      * permissions sidebar: make database name clickable
      
      * fix string groupIds lead to bugs in permissions editor
      
      * fix disabling table permissions shows all tables permission disabled
      
      * fix permissions copy
      
      * fix permissions disabled tooltips copy
      
      * fix, add specs
      
      * fix permissions edit bar button colors, fix breadcrumbs on schemaless dbs
      
      * fix official collection color, make sidebar tree scrollable
      
      * fix scroll in permissions modal
      
      * fix breadcrumbs
      
      * change table icon
      
      * create helpers for entity ids and permissions url creation
      
      * remove hardcoded colors
      
      * make confirmations an array
      
      * store confirmAction in state
      
      * add ModalRoute specs
      
      * fix propTypes, typo
      
      * build permission pages urls with helpers
      
      * revert switching from ref to state for confirm action function due to react invokes it on a render
      
      * move mapStateToProps to the top of the files
      
      * add visual specs
      
      * add more specs
      
      * fix edit sandbox access action
      
      * add cypress spec for sandboxing
      d012c89b
  12. Mar 04, 2021
    • Ariya Hidayat's avatar
      Remove type-checking with Flow (#14236) · f4d90f68
      Ariya Hidayat authored
      * yarn remove flow-bin eslint-plugin-flowtype
      
      * CI: remove fe-linter-flow
      
      * Remove Flow from ESLint config
      
      * Remove Flow type annotations and directives
      
      * Simplify Flow types for React elements and components
      
      * Import missing Flow types
      
      * Remove lint-flow from package.json
      f4d90f68
  13. Mar 04, 2020
  14. Feb 18, 2018
  15. May 30, 2017
  16. May 23, 2017
  17. May 16, 2017
Loading