Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@amsterdam/bmi-dms-upload

Amsterdam3.1kMPL-2.02.0.4TypeScript support: included

A document upload flow that can be implemented in any BMI React application. Documents are stored in DMS. Metadata can be added in the flow.

dms, upload, bmi, asc, react, component, material-ui

readme

DMS Upload

A document upload flow that can be implemented in any BMI React application. Documents are stored in DMS. Metadata can be added in the flow.

Installation

npm install --save @amsterdam/bmi-dms-upload

Implementation

`typescript jsx import { AddDocumentButton } from '@amsterdam/bmi-dms-upload';

function MyComponent() { return ( <AddDocumentButton<MetadataExample> // Dynamically construct the URL for the file upload POST getPostUrl={(file) => Promise.resolve('/api/example/upload')} // Dynamically inject headers for the file upload POST getHeaders={async () => { const headers: { [key: string]: string } = {}; if (token) { headers['some-token'] = token; } return Promise.resolve(headers); }} // Do something when a file is uploaded successfully onFileSuccess={(file) => { if (typeof file.response !== 'string') throw new Error('BUG: no response provided to onFileSuccess callback');

            const response = JSON.parse(file.response);
            console.log('Optionally track successfully uploaded documents in state', response);
        }}
        // Do something when a file is being removed
        onFileRemove={(file) => {}}
        // A custom form component should be rendered here that is specifically geared towards
        // capturing the relevant metadata for the context in which this button is implemented
        metadataForm={<></>}
        // Yup can be leveraged here to validate the metadata that was captured with the form
        onMetadataValidate={async function (data: MetadataExample) {
            console.log('Validate metadata against schema', data);
            return true;
        }}
        // Dispatch actions/make async calls to persist the metadata
        // This effectively completes the wizard flow
        // If an exception were to be thrown from this callback it is gracefully handled with
        // some generic feedback to the end user
        onMetadataSubmit={async function (data: MetadataDataSubmitCallbackArg<MetadataExample>) {
            console.log('Persist metadata; the wizard has been completed and will be closed after this.');
        }}
        // Dispatch actions/make async calls to remove the uploaded files from DMS
        // (cancellation is only possible prior to metadata being persisted)
        onCancel={async function ({ metadata, file }: CancelCallbackArg<MetadataExample>) {
            console.log('Remove previously uploaded files and reset state.');
        }}
    />
);

} `

IMPORTANT: It is expected that you have already implemented @amsterdam/asc-ui or @amsterdam/bmi-component-library. This package is built with styled-components and depends on the ThemeProvider from @amsterdam/asc-ui.

Development

To bootstrap the app in a static frontend served by webpack dev server (and a mock-api) run npm run serve. In your browser go to http://localhost:9999/. You can also use storybook for the isolated development of components using npm run start.

The solution to working with packages for development locally is to rely on npm link. As an example, this package has @amsterdam/bmi-component-library as a dependency. To make changes in the @amsterdam/bmi-component-library package and to have these immediately reflected in your development workflow, follow these steps:

  • Checkout @amsterdam/bmi-dms-upload at /path/to/repos/bmi-dms-upload
  • Checkout @amsterdam/bmi-component-library at /path/to/repos/bmi-component-library
  • cd /path/to/repos/bmi-component-library && npm link
  • cd /path/to/repos/bmi-dms-upload && npm link @amsterdam/bmi-component-library

This will create a symlink at /path/to/repos/dms-upload/node_modules/@amsterdam/bmi-component-library which points to your clone of the @amsterdam/bmi-component-library package.

Now all you need to do is run typescript compilation in watch mode: cd /path/to/repos/bmi-component-library && npm run build:ts:es:watch

IMPORTANT: if you use NVM, it is crucial that both npm link commands are executed with the same node version.

Publish

TODO

Unit tests

npm run test

Storybook

To boot storybook, run the following command: npm run storybook. It should open your default browser at http://localhost:6006/.

React Router

This package uses react-router-dom. The v6 API is used but since the target applications that will implement this upload to DMS flow are at least partially running react-router-dom v5, we can not just install and use v6 here. Instead, the react-router-dom-v5-compat package is employed so that the v6 API can be used here, but this package remains more or less backwards compatible with applications that have not yet entirely migrated to v6 (i.e.: AIP). Only one router can exist in the component tree. For this reason it is critical that the components exported from this package are not wrapped in for example a <BrowserRouter>. It is the responsibility of the implementing party to set up a router at some (high) level in their component tree. The <Routes> (<Switch> in the v5 API) that is rendered from this package will function as a nested router from the given basePath.

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

2.0.4 (2025-01-06)

2.0.4-alpha.0 (2025-01-06)

2.0.3 (2024-10-29)

2.0.2 (2024-03-04)

2.0.1 (2024-03-04)

2.0.0 (2023-08-10)

2.0.0-alpha.2 (2023-08-10)

2.0.0-alpha.1 (2023-08-09)

2.0.0-alpha.0 (2023-08-09)

2.0.1-alpha.0 (2023-08-08)

1.3.2 (2023-03-17)

Bug Fixes

  • validation to work well together with required (ff3f276)

1.3.1 (2023-03-16)

Bug Fixes

  • added year type so fields can be validated on step 3 (0e2df34)
  • improve year type validation (7069e01)

1.3.0 (2023-03-15)

Features

  • added is-date-year validation to JSON Forms (b494a73)
  • added number field (2f22146)
  • map isDateYear to number field and upda (6e01209)

1.2.0 (2022-12-09)

1.2.0-alpha.3 (2022-11-09)

Bug Fixes

  • added lock file (6a77680)
  • don't use latest version of bmi comp lib (7af43cf)

1.2.0-alpha.2 (2022-10-19)

1.2.0-alpha.1 (2022-10-19)

Bug Fixes

  • keep edit state when nav back from step 2 (8476894)
  • prevent memory leak when component unmounts (dd3d029)

1.2.0-alpha.0 (2022-10-10)

Features

  • map all fields to editable when single mode (7bd5cd2)
  • show closing modal only when files are added (849e545)
  • skip step when only 1 file uploaded (fc5b935)
  • update state per step (31c4337)
  • update state with bulk mode and do step forward (61f05cd)
  • version bumb (54c540b)

1.0.1 (2022-07-27)

1.0.1-alpha.4 (2022-07-26)

Features

  • types: added export for generic callback type (12635eb)

1.0.1-alpha.2 (2022-07-21)

1.0.1-alpha.3 (2022-07-25)

1.0.1-alpha.2 (2022-07-21)

1.0.1-alpha.1 (2022-07-19)

1.0.1-alpha.0 (2022-07-19)

1.0.0 (2022-07-15)

Bug Fixes

  • replaced remaining import from @material-ui/core (d28ae92)

0.0.4-alpha.20 (2022-06-28)

0.0.4-alpha.19 (2022-06-28)

Bug Fixes

  • defaultfieldstable: boolean TRUE returned an empty string, multi-select had no seperators (1b604ff)

0.0.4-alpha.18 (2022-06-28)

Bug Fixes

0.0.4-alpha.17 (2022-06-22)

Bug Fixes

  • multiselect: validation when required (9c44fc6)

0.0.4-alpha.16 (2022-06-22)

Bug Fixes

  • readme: small tweak to readme (9247629)

0.0.4-alpha.15 (2022-06-21)

Bug Fixes

  • bulk: add type to IBulkFileMetadata (8661b1a)
  • metadata: support for CheckboxType (437e478)
  • validation: show validation after focus (7757042)

0.0.4-alpha.14 (2022-06-16)

Bug Fixes

  • bulk-wizard: show asset code and name in modal title (085fec4)
  • metadata: validation for (multi)select (9ef55cd)

0.0.4-alpha.13 (2022-06-09)

Bug Fixes

  • bulk: export GlobalDmsUploadStyle (6764683)
  • form: fix styling issue for centered select box (f1ebee8)

0.0.4-alpha.12 (2022-06-08)

Bug Fixes

  • datefield: datefield was still required in step3 though not required in step2 (0dddafb)
  • style: fix descriptionlist (46349ca)

0.0.4-alpha.11 (2022-06-01)

Bug Fixes

  • multi-select: fix with undefined multi select default value (5cf26db)

0.0.4-alpha.10 (2022-06-01)

Bug Fixes

  • metadata: fix problems with defaultValue for multi-select (48ea9c3)

0.0.4-alpha.9 (2022-06-01)

Bug Fixes

  • metadata: show alert when files contain validation errors (7ca8577)
  • metadata,multi-select: pr feedback (b86ca61)
  • metadata,multi-select: pr feedback (a8c4c2c)
  • multi-select: pr feedback on @ts-ignore (9189a80)
  • uischema: date was always required even if it was not a required field (4853521)

0.0.4-alpha.8 (2022-05-30)

Bug Fixes

  • metadata: cleanup db.json (8123618)
  • metadata: support user and default value from DMS (09afe87)

0.0.4-alpha.6 (2022-05-30)

Bug Fixes

  • metadata: send correct state when saving forms (44aed1d)

0.0.4-alpha.5 (2022-05-30)

Bug Fixes

  • metadata: select renders correctly when navigating files (b4cf43c)

0.0.4-alpha.4 (2022-05-24)

Bug Fixes

  • bulk: fix linting (cf62105)
  • bulk: remove obsolete commented code (683e49f)
  • dev-api: remove some lines from db.json (a9045be)
  • metadata: add header in step 2 (ea8d723)

0.0.4-alpha.3 (2022-05-18)

Bug Fixes

  • metadata: cleanup metadata when changeIndividual changes on field (eba04d2)
  • metadata: tweak width for modal (41ed956)

0.0.4-alpha.2 (2022-05-17)

Bug Fixes

  • metadata: removed obsolete test-id (f0895b1)

0.0.3-alpha.26 (2022-05-17)

Bug Fixes

  • meteadata: fix when to show save button in step 3 (69c1a31)

0.0.3-alpha.25 (2022-05-17)

0.0.3-alpha.24 (2022-05-16)

Bug Fixes

  • metadata: add more slice tests (09734b9)
  • metadata: bug BDMS-3769 (f8e1e72)
  • metadata: use proper id in state for fields (3e5384c)

0.0.3-alpha.23 (2022-05-12)

Bug Fixes

  • metadata: fix pr feedback (9bb899e)

0.0.3-alpha.22 (2022-05-11)

Bug Fixes

0.0.3-alpha.21 (2022-05-11)

Bug Fixes

  • metadata: fix onMetadataSubmit (e0f2c59)
  • metadata: fix reload documentviewer on each change in form (6b11cec)
  • metadata: linting (fe688df)
  • metadata: onMetadataSubmit submits actual data (5ce8063)
  • metadata: remove console.log (1d648de)
  • metadata: remove duplicate header filename (125c6f1)
  • metadata: small layout tweaks to fileviewer (dcc999f)

0.0.3-alpha.15 (2022-04-13)

0.0.3-alpha.20 (2022-05-09)

Bug Fixes

  • metadata: change documentviewer implementation (1e6b13f)

0.0.3-alpha.19 (2022-05-05)

Features

  • metadata: add ui for required fields (8b4d527)

0.0.3-alpha.18 (2022-05-04)

Bug Fixes

  • metadata: add token to getDocumentViewUrl, fix tests (1ed4d20)

0.0.3-alpha.17 (2022-05-03)

Features

  • metadata: edit metadata per file (3ea1930)

0.0.3-alpha.16 (2022-04-28)

Features

Bug Fixes

  • bulk: add metadata per file in step3, store in state correctly (2ead469)
  • bulk: debounce setFieldData (11c47b4)
  • bulk: first round of PR feedback (d6dc138)
  • bulk: fourth round of PR feedback, fix bug with saving form data between navigating wizard (7a1d5b1)
  • bulk: second round of PR feedback (8416d61)
  • bulk: third round of PR feedback (e1c4f80)

0.0.3-alpha.14 (2022-04-07)

0.0.3-alpha.13 (2022-04-06)

Bug Fixes

  • bulk: moved depency from dev to normal dependencies (d4f6d7f)
  • bulk: removed obsolete prop (3f575b2)

0.0.3-alpha.12 (2022-04-06)

Bug Fixes

  • bulk: make connected Single/Bulk buttons for export (f1d4453)

0.0.3-alpha.11 (2022-04-06)

Bug Fixes

  • bulk: moving code to Single and Bulk components (52b31ce)
  • bulk: undo last commit, move code back to App.tsx (3956832)

0.0.3-alpha.10 (2022-04-06)

Bug Fixes

  • bulk: export customprovider (2415fd5)

0.0.3-alpha.9 (2022-04-06)

Bug Fixes

  • bulk: add submit for bulk, add more test, add mock-api for upload-session (7bb7895)
  • bulk: few tweaks to removeFile callback (f1338d8)

0.0.3-alpha.8 (2022-04-05)

Bug Fixes

  • bulk: add more tests, fixed all test, fixed linting errors (eb18aba)
  • bulk: refactor route states, add more tests (342879b)
  • bulk: test utils, test setup for new state with sagas (14e49ca)

0.0.3-alpha.7 (2022-03-16)

Features

  • bulk-upload: Duplicated wizard into bulkUploadWizard (65226de)
  • bulk-upload: moved Step1 from feature folder to shared components folder (a2cd409)
  • bulk-upload: refactor single file upload to BulkCustomFile and fixed tests, linting (958675d)
  • bulk-upload: refactored BulkCustomFile to CustomFileLight and made CustomFileLightOrRejection (92121f3)
  • bulk-upload: wip bulk upload tests (fc3dabc)
  • bulk-upload: wip tests (fa91d73)
  • bulk-upload: Workaround for redux serialization errors when adding array of CustomFile to store (e815bd9)
  • bulkmetadata: make title/column headers optional (acae38a)
  • bulkmetadata: make title/column headers optional (fcf4452)
  • bulkmetadata: update by review (3d153d6)
  • bulkmetadata: update by review (c3bb742)
  • bulkmetadata: update tests (d863c60)
  • bulkmetadata: update tests (c67de71)
  • bulkmetadataform: updated utility to be able to handle SELECT input types (966b81e)

Bug Fixes

  • bulk-meta: get session id from api (0c8847b)
  • bulk-upload: make single and bulk upload more compatible (655b9ac)
  • bulk-upload: pr feedback from Rick fixed (5d77aa8)
  • bulk-upload: refactored store after PR feedback (f6acf80)
  • bulk-wizard: show confirmation window (56552a8)
  • creatable: Ensure that the react-select dropdown is on top in case it is present inside a modal (03ea749)
  • creatable: Special treatment when validating a new option coming from <Creatable /> (e2fcab2)
  • creatable: z-index can now be controlled via a prop (ab84eb4)
  • dms-integration: alpha release to test dms integration (26d38a7)
  • metadata-form: added local mock api (48d1d3c)
  • metadata-form: fix and add tests (152a650)

0.0.3-alpha.6 (2022-01-10)

Bug Fixes

  • creatable: Ensure that the react-select dropdown is on top in case it is present inside a modal (d7a6627)
  • creatable: Special treatment when validating a new option coming from <Creatable /> (69e5d28)
  • creatable: z-index can now be controlled via a prop (531a8be)

0.0.3-alpha.5 (2022-01-06)

0.0.3-alpha.4 (2022-01-06)

0.0.3-alpha.3 (2022-01-06)

0.0.3-alpha.2 (2021-12-31)

Bug Fixes

  • creatable: TypeScript errors no more (58604b2)

0.0.3-alpha.1 (2021-12-30)

Features

  • bulkmetadata: add StaticMetadata component (c0b4551)
  • bulkmetadata: add StaticMetadata component (c4af604)
  • bulkmetadata: add StaticMetadata tests (0c1d459)
  • bulkmetadata: add StaticMetadata tests (fc805cb)
  • bulkmetadata: update test (8263a7a)
  • bulkmetadata: updated by review comments (40c00e4)
  • bulkmetadata: updated by review comments (dfb4a1f)
  • bulkmetadata: updated by review comments (40eab59)
  • bulkmetadata: updated by review comments (44ad9b1)
  • bulkmetadata: updated by review comments (ccc0d6b)
  • step1: placeholder and maxFiles for step1 are now configurable by prop (8471ef4)

Bug Fixes

  • header: styling in line with design system (64d1461)
  • metadataform: fixed alignment of label with text field (a54dd80)
  • styling: styling fixes after design QA (2d5e62e)
  • wizard: tweaking buttons in footer after design QA (5af866d)
  • wizard: tweaking buttons in footer after design QA (3fd67ab)

0.0.3-alpha.0 (2021-12-17)

Features

  • dms-upload: bumped component library version and adjusted storybook, readme (7b08195)

0.0.2 (2021-12-15)

Features

  • bulkmetadata: add StaticMetadata component (47d03df)
  • bulkmetadata: add StaticMetadata tests (c49b413)
  • bulkmetadata: update test (533ba3c)
  • bulkmetadata: updated by review comments (81c0892)
  • bulkmetadata: updated by review comments (5bbc734)
  • bulkmetadata: updated by review comments (a9c73e8)
  • bulkmetadata: updated by review comments (1a1fa9e)

Bug Fixes

  • modal: freshly squeezed package-lock.json (08f5167)
  • modal: modal actions were not split left and right in the production build (d8a270f)

0.0.2-alpha.0 (2021-12-13)

Features

  • bulkmetadata: add StaticMetadata component (47d03df)
  • bulkmetadata: add StaticMetadata tests (c49b413)
  • bulkmetadata: update test (533ba3c)
  • bulkmetadata: updated by review comments (81c0892)
  • bulkmetadata: updated by review comments (5bbc734)
  • bulkmetadata: updated by review comments (a9c73e8)
  • bulkmetadata: updated by review comments (1a1fa9e)

Bug Fixes

  • header: styling in line with design system (36ef717)
  • metadataform: fixed alignment of label with text field (309fc33)
  • styling: styling fixes after design QA (8cf9698)
  • wizard: tweaking buttons in footer after design QA (7948562)

0.0.1 (2021-12-07)

Bug Fixes

  • header: styling in line with design system (36ef717)
  • metadataform: fixed alignment of label with text field (309fc33)
  • styling: styling fixes after design QA (8cf9698)
  • wizard: tweaking buttons in footer after design QA (7948562)

0.0.1-alpha.10 (2021-12-07)

Features

  • step1: placeholder and maxFiles for step1 are now configurable by prop (c3646a6)

0.0.1-alpha.9 (2021-11-25)

Bug Fixes

  • adddocumentbutton: changed button vairant (304c0ff)

0.0.1-alpha.8 (2021-11-24)

Bug Fixes

  • step1: file upload should only accept a single file (53f3bb8)
  • wizard: bind cancel procedure to close button in modal header (17c9e04)

0.0.1-alpha.7 (2021-11-22)

Features

  • types: exporting json schema types (09d38ed)

0.0.1-alpha.6 (2021-11-18)

Features

  • metadatacolumnheaders: added MetadataColumnHeaders component + tests + storybook entry (628b86b)
  • validation: wip commit for validation logic with latest alpha release of jsonforms (d78e55e)

Bug Fixes

  • tsconfig: ignoring */__mocks/ for TS build purposes (fdc3383)
  • tsconfig: reverted esModuleInterop back to true while fixing source of the problem (eeb3acd)

0.0.1-alpha.5 (2021-10-27)

Features

  • fileupload: http method for file upload can now be configured (a7bd9c8)

0.0.1-alpha.4 (2021-10-25)

Features

  • dummyform: created dummyform to use for the metadata in step2 (095bb19)
  • multiple tests: updated imports in tests and update provider function calls (c32ceae)
  • step1: connect with redux Toolkit and remove old redux files (0b9e142)
  • step1: implementation upload component and upgraded component-library version (fc6d0e2)
  • step1: style step 1 (b531e07)
  • step2: connect step 3 with redux toolkit (8d37037)
  • step2: prefill form with defaultValue (f498422)
  • step2: step 2 in wizard with a form prop to add generic metadata to file (39178e2)
  • sub-routing: added concept of sub-routing where all wizard routes expand on a base path (f132ee9)
  • withproviders: add browserrouter to provider (030e949)
  • withproviders: initialstate as argument to pass into Providerstore (5189feb)
  • wizard: only show 'volgende' button when there is a file in the list (ed3ad61)
  • wizard: reset state when cancelling or submitting (7b2d4d7)
  • wizard: routing (9a2a2f1)
  • wizard: submit and validate file and metadata (0311c0a)
  • wizard: validation dummyform, remove file from store, use storedFiles prop (b4a40df)
  • wizard and step1: first test and renderWithProviders (4cf561f)
  • dummyform (198bf2d)

Bug Fixes

  • wizard: import for WizardStyles contained a type (c590ade)

0.0.1-alpha.3 (2021-10-07)

Bug Fixes

  • tsconfig: tsconfig paths should not be used for imports as NodeJS has no knowledge of them (3e18f43)

0.0.1-alpha.2 (2021-09-23)

Features

  • adddocumentbutton: exporting Props interface in an attempt to get inferred prop types (6eba301)

0.0.1-alpha.1 (2021-09-23)

Features

  • adddocumentbutton: moved generic metadata type to props interface instead of individual props (e8c5fe0)

0.0.1-alpha.0 (2021-09-22)