@statisticsnorway/dapla-variable-search v0.5.4
dapla-variable-search
This application is built for in-house use in Statistics Norway and it aims to create a smart and interactive variable and dataset search with the help of the graphql-api exposed by Linked Data Store.
Functionality includes:
- Searching through variables and datasets
- Listing connections between variables and datasets (which datasets use which variables and vice versa)
The project makes limited use of the ssb-component-library and is based upon react-reference-app.
Use as a library
If you want to use this application as a library in your project, simply add it with yarn.
yarn add @statisticsnorway/dapla-variable-search
The component requires a few peer dependencies to work, namely:
- @statisticsnorway/dapla-js-utilities
- axios-hooks
- graphql-hooks
- React
- SemanticUI
In your application import the component.
import { VariableSearch } from '@statisticsnorway/dapla-variable-search'
The component needs two properties to function correctly, lineageUrl
and language
.
<VariableSearch lineageUrl='http://localhost:3001' language='en' />
lineageUrl
is the base url for creating links to a dapla-lineage-viewer
and language
sets the language of the component. en
(English) and nb
(Norwegian) is available.
In your application housing this component you also need to set up graphql-hooks in a React Context
.
You can checkout how to do it in /src/utilities/ContextHandling.js
in this project. This is done because the component
needs several instances of graphql-hooks to run, and without setting up a GraphQLClient that, is impossible.
Try this application locally
The first time you clone the repository, remember to run yarn
or yarn install
.
Run yarn start
and navigate to http://localhost:3000/
.
yarn test
runs all tests and yarn coverage
calculates (rather unreliably) test coverage.
Docker locally
yarn build
docker build -t dapla-variable-search .
docker run -p 8000:80 dapla-variable-search:latest
- Alternatively with custom environment variables:
docker run -p 8000:80 -e REACT_APP_API=http://localhost:29090 dapla-variable-search:latest
- Alternatively with custom environment variables:
- Navigate to
http://localhost:8000
Note that this application requires dapla-project (localstack) running to function locally (or atleast a running instance of Linked Data Store). It also needs a running instance of dapla-lineage-viewer running for the lineage links to work.
Publish library
To publish to npm you need a user and a membership in the statisticsnorway
organization on
npm. The user must also have 2FA authentication enabled. Steps to follow:
- Login into your npm account in a terminal with
npm login
- Make sure all tests works (test components in the example application aswell, if you made a new one)
- Bump version in
package.json
- Run
yarn package
- Dry run a release with
npm pack
- Publish with
npm publish --access public --otp=<code>
(<code>
is your 2FA code, without<>
)