Skip to content
Snippets Groups Projects
  • Mahatthana (Kelvin) Nomsawadi's avatar
    715174d3
    [M1] Metabase illustration settings (#40219) · 715174d3
    Mahatthana (Kelvin) Nomsawadi authored
    
    * Add login page illustration (#39299)
    
    * Move Metabot setting to a new place
    
    * Add setting for login page illustration
    
    * fix UI styling
    
    * Fix not able to upload the same file twice
    
    * Update the admin > appearance > conceal metabase copy
    
    * Prepare the component for tests
    
    * Add some unit tests
    
    * Prevent settings not saved sometimes
    
    After setting the value to/from `custom` one of the setting could be
    failed to save, I suspect this happens because the race condition from
    trying to save the setting values relatively at the same time.
    
    * Make unit tests easier to read
    
    * Add all unit test test cases
    
    * Add basic E2E test
    
    * Show fallback icon for broken images
    
    * Make use of the proper component
    
    * Update the comment to affect the reality
    
    * Add an error message when file size is over 2MB
    
    * Show an error message when the file size > 2MB
    
    * Add the error message tests
    
    * Preserve the preview image aspect-ratio
    
    * Detect corrupted images
    
    * Fix failing unit tests
    
    * Address feedback: Type
    
    * Feedback: Create meaningful variables
    
    * Feedback: Make selector API more sensible
    
    * Prevent race condition
    
    Makes sure we save the settings completely before making other actions
    that also change settings otherwise, there could be race conditions.
    
    * Feedback: tighten up a type
    
    * Feedback: Fix inconsistency callback calls
    
    * 2. Add the rest 3 illustration settings (#40487)
    
    * Add the rest 3 illustration settings
    
    * Don't make the X icon feel lonely
    
    * Fix illustration widget saving
    
    * Fix type error
    
    * 3. Update the select UX to match new design (#40491)
    
    * Update the select UX to match new design
    
    * Move info dot next to file upload button
    
    * Simplify IllustrationWidget API
    
    * Update setting title copy
    
    * Clean up test comments
    
    * Feedback: Clarify `any` type
    
    * Feedback: Use shorthand object creation
    
    Co-authored-by: default avatarDenis Berezin <denis.berezin@metabase.com>
    
    * Feedback: Use global CSS glass instead of inlining values
    
    Co-authored-by: default avatarDenis Berezin <denis.berezin@metabase.com>
    
    * Feedback: Remove unnecessary curly brackets in JSX
    
    Co-authored-by: default avatarDenis Berezin <denis.berezin@metabase.com>
    
    ---------
    
    Co-authored-by: default avatarDenis Berezin <denis.berezin@metabase.com>
    
    * 4. Connect illustrations to new setting values (#40139)
    
    * Wire landing page illustration to the setting value
    
    * Wire the unsubscribe page to the setting value
    
    * Prepare no rows error to be wired to the setting value
    
    * Wire no question results illustration to the setting value
    
    * Wire no search results illustration to setting value
    
    * Fix error from fixing conflict
    
    * Fix required unnecsseary prop on Image
    
    * Use Image component
    
    * Link dashboard card no results image to the setting value
    
    * Move the no data results to more a generic directory
    
    * Link collection picker no results image to the setting value
    
    * Make illustrations more accessible
    
    * Fix failed tests
    
    * Test unscribe page illustration + test no illustration
    
    * Add landing page tests
    
    * Simplify Cypress selectors
    
    * Refactor: Rename settings to match the new requirements
    
    No question data -> No Data
    No search results -> No object
    
    These changes are made so, these 2 settings are generic enough to
    include other illustrations later on.
    
    * Add no data illustration test
    
    * Add no object illustration tests
    
    * Fix unsubscribe page background style
    
    * Fix not able to build static viz
    
    * 5. Follow-up on milestone 1 (#40710)
    
    * Update custom background illustration scale behavior
    
    * Remove the need to put an SVG file in static folder
    
    * Fix test from rebasing off master with @testing-library/user-event upgrade
    
    ---------
    
    Co-authored-by: default avatarDenis Berezin <denis.berezin@metabase.com>
    [M1] Metabase illustration settings (#40219)
    Mahatthana (Kelvin) Nomsawadi authored
    
    * Add login page illustration (#39299)
    
    * Move Metabot setting to a new place
    
    * Add setting for login page illustration
    
    * fix UI styling
    
    * Fix not able to upload the same file twice
    
    * Update the admin > appearance > conceal metabase copy
    
    * Prepare the component for tests
    
    * Add some unit tests
    
    * Prevent settings not saved sometimes
    
    After setting the value to/from `custom` one of the setting could be
    failed to save, I suspect this happens because the race condition from
    trying to save the setting values relatively at the same time.
    
    * Make unit tests easier to read
    
    * Add all unit test test cases
    
    * Add basic E2E test
    
    * Show fallback icon for broken images
    
    * Make use of the proper component
    
    * Update the comment to affect the reality
    
    * Add an error message when file size is over 2MB
    
    * Show an error message when the file size > 2MB
    
    * Add the error message tests
    
    * Preserve the preview image aspect-ratio
    
    * Detect corrupted images
    
    * Fix failing unit tests
    
    * Address feedback: Type
    
    * Feedback: Create meaningful variables
    
    * Feedback: Make selector API more sensible
    
    * Prevent race condition
    
    Makes sure we save the settings completely before making other actions
    that also change settings otherwise, there could be race conditions.
    
    * Feedback: tighten up a type
    
    * Feedback: Fix inconsistency callback calls
    
    * 2. Add the rest 3 illustration settings (#40487)
    
    * Add the rest 3 illustration settings
    
    * Don't make the X icon feel lonely
    
    * Fix illustration widget saving
    
    * Fix type error
    
    * 3. Update the select UX to match new design (#40491)
    
    * Update the select UX to match new design
    
    * Move info dot next to file upload button
    
    * Simplify IllustrationWidget API
    
    * Update setting title copy
    
    * Clean up test comments
    
    * Feedback: Clarify `any` type
    
    * Feedback: Use shorthand object creation
    
    Co-authored-by: default avatarDenis Berezin <denis.berezin@metabase.com>
    
    * Feedback: Use global CSS glass instead of inlining values
    
    Co-authored-by: default avatarDenis Berezin <denis.berezin@metabase.com>
    
    * Feedback: Remove unnecessary curly brackets in JSX
    
    Co-authored-by: default avatarDenis Berezin <denis.berezin@metabase.com>
    
    ---------
    
    Co-authored-by: default avatarDenis Berezin <denis.berezin@metabase.com>
    
    * 4. Connect illustrations to new setting values (#40139)
    
    * Wire landing page illustration to the setting value
    
    * Wire the unsubscribe page to the setting value
    
    * Prepare no rows error to be wired to the setting value
    
    * Wire no question results illustration to the setting value
    
    * Wire no search results illustration to setting value
    
    * Fix error from fixing conflict
    
    * Fix required unnecsseary prop on Image
    
    * Use Image component
    
    * Link dashboard card no results image to the setting value
    
    * Move the no data results to more a generic directory
    
    * Link collection picker no results image to the setting value
    
    * Make illustrations more accessible
    
    * Fix failed tests
    
    * Test unscribe page illustration + test no illustration
    
    * Add landing page tests
    
    * Simplify Cypress selectors
    
    * Refactor: Rename settings to match the new requirements
    
    No question data -> No Data
    No search results -> No object
    
    These changes are made so, these 2 settings are generic enough to
    include other illustrations later on.
    
    * Add no data illustration test
    
    * Add no object illustration tests
    
    * Fix unsubscribe page background style
    
    * Fix not able to build static viz
    
    * 5. Follow-up on milestone 1 (#40710)
    
    * Update custom background illustration scale behavior
    
    * Remove the need to put an SVG file in static folder
    
    * Fix test from rebasing off master with @testing-library/user-event upgrade
    
    ---------
    
    Co-authored-by: default avatarDenis Berezin <denis.berezin@metabase.com>
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
webpack.static-viz.config.js 3.32 KiB
const YAML = require("json-to-pretty-yaml");
const TerserPlugin = require("terser-webpack-plugin");
const { StatsWriterPlugin } = require("webpack-stats-plugin");
const { IgnorePlugin } = require("webpack");

const ASSETS_PATH = __dirname + "/resources/frontend_client/app/assets";
const SRC_PATH = __dirname + "/frontend/src/metabase";
const BUILD_PATH = __dirname + "/resources/frontend_client";
const CLJS_SRC_PATH = __dirname + "/target/cljs_release";
const CLJS_SRC_PATH_DEV = __dirname + "/target/cljs_dev";
const LIB_SRC_PATH = __dirname + "/frontend/src/metabase-lib";
const TYPES_SRC_PATH = __dirname + "/frontend/src/metabase-types";

const BABEL_CONFIG = {
  cacheDirectory: process.env.BABEL_DISABLE_CACHE ? null : ".babel_cache",
};

const WEBPACK_BUNDLE = process.env.WEBPACK_BUNDLE || "development";
const devMode = WEBPACK_BUNDLE !== "production";

module.exports = env => {
  const shouldDisableMinimization = env.WEBPACK_WATCH === true;

  return {
    mode: "production",
    context: SRC_PATH,

    performance: {
      hints: false,
    },

    entry: {
      "lib-static-viz": {
        import: "./static-viz/index.js",
        library: {
          name: "StaticViz",
          type: "var",
        },
      },
    },

    output: {
      path: BUILD_PATH + "/app/dist",
      filename: "[name].bundle.js",
      publicPath: "/app/dist",
      globalObject: "{}",
    },

    module: {
      rules: [
        {
          test: /\.css$/i,
          use: "null-loader",
        },
        {
          test: /\.(tsx?|jsx?)$/,
          exclude: /node_modules|cljs/,
          use: [{ loader: "babel-loader", options: BABEL_CONFIG }],
        },
        {
          test: /\.svg/,
          type: "asset/source",
          resourceQuery: /source/, // *.svg?source
        },
        {
          test: /\.svg$/i,
          issuer: /\.[jt]sx?$/,
          resourceQuery: /component/, // *.svg?component
          use: [
            {
              loader: "@svgr/webpack",
              options: {
                ref: true,
              },
            },
          ],
        },
        {
          test: /\.svg$/i,
          use: "null-loader",
        },
      ],
    },
    resolve: {
      extensions: [".webpack.js", ".web.js", ".js", ".jsx", ".ts", ".tsx"],
      alias: {
        assets: ASSETS_PATH,
        metabase: SRC_PATH,
        cljs: devMode ? CLJS_SRC_PATH_DEV : CLJS_SRC_PATH,
        "metabase-lib": LIB_SRC_PATH,
        "metabase-types": TYPES_SRC_PATH,
      },
    },
    optimization: {
      minimize: !shouldDisableMinimization,
      minimizer: [
        new TerserPlugin({
          minify: TerserPlugin.swcMinify,
        }),
      ],
    },
    plugins: [
      new StatsWriterPlugin({
        stats: {
          modules: true,
          assets: false,
          nestedModules: false,
          reasons: false,
          excludeModules: [/node_modules/],
        },
        filename: "../../../../.github/static-viz-sources.yaml",
        transform: stats =>
          YAML.stringify({
            static_viz: stats.modules
              .filter(
                module =>
                  module.type !== "hidden modules" &&
                  module.moduleType !== "runtime",
              )
              .map(module =>
                module.nameForCondition.replace(`${__dirname}/`, ""),
              ),
          }),
      }),
    ],
  };
};