canon

Reusable React environment and components for creating visualization engines.

GPL-3.0 License

Downloads
1.4K
Stars
27
Committers
19

Bot releases are hidden (Show)

canon - @datawheel/[email protected]

Published by davelandry about 4 years ago

This release of canon-core contains two substantial 🔥 BREAKING 🔥 changes related to redux and database connections. Please read these release notes to assist in upgrading from a previous version of canon-core.

Redux

All redux setup has been moved to a new location: app/store/index.js. This file is expected to have 3 named exports, and at it's minimum, should look like this:

/**
 * This object will be used to pre-populate the redux store with any
 * static values you may need.
 */
export const initialState = {};

/**
 * This array can contain redux middlewares that will be used in the
 * redux store. The loggerMiddleware is provided as an example.
 */
export const middleware = [];

/**
 * This object should contain reducers to be combined with the internal
 * default canon reducers.
 */
export const reducers = {};

Migration Steps

  1. Create a new app/store/index.js file with the contents from above.
  2. Move the default exported object from app/reducers/index.jsx to the reducers variable in this new file and delete the old app/reducers/index.jsx file.
  3. Move any custom reducers in app/reducers/ to new app/store/reducers/ folder and delete the old app/reducers/ folder.
  4. Move the default exported object from app/store.js to the initialState variable in this new app/store/index.js file and delete the old app/store.js file.
  5. Move any middleware from the ./canon.js file to the middleware Array in this new app/store/index.js file. In ./canon.js, the middleware was enabled with a function where the user had to add the middleware needed to a list of core middleware, and return applyMiddleware(...middlewares). The new way only needs an array of the user defined middleware; the internals will do the combination with the core middleware and the call to applyMiddleware.

Database Connections

This release of canon-core allows sites to connect to multiple separate databases, if desired (for example, hosting the users table in a completely different database than the CMS content tables). In order to do this, database connections now need to be defined explicitly in the ./canon.js file.

Migration Steps

In it's simplest form, if you have a custom database table on your site located at ./db/customTable.js, then your config in ./canon.js would look like this:

module.exports = {
  ...,
  db: [
    {
      host: process.env.CANON_DB_HOST,
      name: process.env.CANON_DB_NAME,
      user: process.env.CANON_DB_USER,
      pass: process.env.CANON_DB_PW,
      tables: [
        // using require.resolve enables canon-core to reload the models 
        // if the file is edited while the server is running on development mode
        require.resolve("./db/customTable.js") 
      ]
    }
  ]
};

Another new feature we are introducing is allowing connection strings for database connections, so instead of managing separate environment variables for host, name, user, and pass, you can construct a connection string and supply it to connection:

const {CANON_DB_USER, CANON_DB_PASS, CANON_DB_HOST, CANON_DB_NAME} = process.env;
const dbConnection = `postgresql://${CANON_DB_USER}:${CANON_DB_PASS}@${CANON_DB_HOST}:5432/${CANON_DB_NAME}`;

module.exports = {
  ...,
  db: [
    {
      connection: dbConnection
      tables: [
        require.resolve("./db/customTable.js") 
      ]
    }
  ]
};

Notice that the db value is an Array? This is what allows for multiple databases connections to be set up. Additionally, all canon plugins (like canon-cms) will now be exporting a models Object containing their internal tables that will need to be explicitly linked here as well. Let's say you have a database on a different server that you want to use to host the CMS tables, and you've stored the connection string in the environment as CANON_CMS_DB:

const {CANON_DB_USER, CANON_DB_PASS, CANON_DB_HOST, CANON_DB_NAME} = process.env;
const dbConnection = `postgresql://${CANON_DB_USER}:${CANON_DB_PASS}@${CANON_DB_HOST}:5432/${CANON_DB_NAME}`;

module.exports = {
  ...,
  db: [
    {
      connection: process.env.CANON_CMS_DB,
      tables: [
        require("@datawheel/canon-cms/models")
      ]
    }
    {
      connection: dbConnection
      tables: [
        require.resolve("./db/customTable.js") 
      ]
    }
  ]
};

This new setup method also allows additionally configuration to be performed on the Sequelize instance used to connect to the database. Full documentation can be found here.

Note: because the connections are explicitly defined, the environment variable names for databases can now be anything you want!


Full Changelog

  • adds documentation for new multi-db setup (74296655)
  • updates readme with changes to redux store (65b3143e)
  • fixes create-canon npx call (683c8a05)
  • patches calls to db.query on cms (207cec6d)
  • updates scaffold (f5520df3)
  • reconfigures config models to accept paths improves dbStep error handling (7f44c1c6)
  • enables multiple DB through canon.js file restructures app redux store file requirements moves redux middlewares to app/store (dc6c669d)
  • Update README.md (0551faa0)
canon - @datawheel/[email protected]

Published by davelandry about 4 years ago

  • fixes email validations for login (da44524d)
canon - @datawheel/[email protected]

Published by davelandry about 4 years ago

  • adds request duration to cms generators (398f26cd)
  • Includes title attribute into cp-hero-heading-dimension span (543a66e3)
  • Merge pull request #1064 from Datawheel/feature-local-varswap (04e74179)
  • removes phone home for logins, adds object.assign to buble (9aedb27b)
  • removes _rawProfile post, adds login to example app (cc095ffc)
  • unifies server/client-side profile preparation (c26c21a9)
  • cleans up unused vars, ports over group hiding (36410f77)
  • moves around how formatterFunctions work for reuse (01fe410b)
  • adds comments to help me understand my own code, updates sorting function (5b9d3a44)
  • cleans up some comments (4d9278f7)
  • handles updates without round trip (67134a33)
canon - @datawheel/[email protected]

Published by davelandry about 4 years ago

  • enables http headers on warming script (f3f7f2cf)
  • Merge pull request #1076 from Datawheel/lazy-load-images (224f9d93)
canon - @datawheel/[email protected]

Published by davelandry about 4 years ago

  • remove console.log (8ccfdf46)
  • add missing hash to anchor redirect fixed #1081 (1811424e)
canon - @datawheel/[email protected]

Published by davelandry about 4 years ago

  • fixes create-canon npx call (e24c523b)
canon - @datawheel/[email protected]

Published by davelandry about 4 years ago

  • adds support for new dataFormat full config return (0be4f337)
canon - @datawheel/[email protected]

Published by davelandry about 4 years ago

  • finally, for real, fixes Selector multis with no defaults (80c29ffd)
canon - @datawheel/[email protected]

Published by davelandry about 4 years ago

  • actually fixes the Selector check for multi-select (b7fb97db)
canon - @datawheel/[email protected]

Published by davelandry about 4 years ago

  • fixes bug with new Selector multi logic (06e88c7d)
canon - @datawheel/[email protected]

Published by davelandry about 4 years ago

  • added documentation on dataAttachments (52a73068)
  • dataAttachments prop is now checked for undefined, string (single file attachment), or array (multiple files). Files are pulled and attached to JSZip. (1e11ee0f)
  • Added dataAttachments prop (string) to propagate from Viz to Options (bf76a795)
  • fixes bug in multi-selectors that hid on no defaults (37f27f4d)
canon - @datawheel/[email protected]

Published by davelandry about 4 years ago

  • improves multi-cut behavior on same search hierarchy (4892b18d)
canon - @datawheel/[email protected]

Published by davelandry about 4 years ago

  • adds retry command (83327a05)
  • cms-warmup: adds file output of errors improves progress view minor bugfixes (b8a3351f)
  • cms-warmup: fixes auth parameters (e363d502)
canon - @datawheel/[email protected]

Published by davelandry over 4 years ago

  • fixes SubNav causing horizontal scroll (b72c3e45)
canon - @datawheel/[email protected]

Published by davelandry over 4 years ago

  • Merge pull request #1071 from Datawheel/search-special-chars (baed71e0)
  • add unaccent function to regular search query part of #1061 (497f576f)
canon - @datawheel/[email protected]

Published by davelandry over 4 years ago

  • updates README with warm script args (d3ea79f8)
  • makes warming script respect defined profile sort order (4a79f696)
canon - @datawheel/[email protected]

Published by davelandry over 4 years ago

  • feedback updates for warmup script (b5d3f630)
canon - @datawheel/[email protected]

Published by davelandry over 4 years ago

  • fixes package-lock (c64644a8)
  • updates d3plus dependencies (59b9d658)
canon - @datawheel/[email protected]

Published by davelandry over 4 years ago

  • adds initial Profile Caching to README (1653f330)
  • updates pnpm lock (3c2c74c2)
  • reverts cache warming script DB variables back to current state (1da76331)
  • Merge branch 'master' of https://github.com/datawheel/canon (fdd1065e)
  • adds beta warmup script (21fe4d7a)
  • includes sub-sections in SubNav component (1dc3d214)
  • removes deprecated vscode setting (def305ea)
canon - @datawheel/[email protected]

Published by davelandry over 4 years ago

  • updates to d3plus-common v0.7 (a9098a78)