Skip to content

Commit bb8f047

Browse files
dgadingbrianseek
andauthored
1.x Release (#24)
* Update Resource and useDatastore to work with filtered resources (#8) * Add conditions from options on initial load of useDatastore * Add basic test for intitial condition * Fix condtion on test * Add basic url query code to useDatastore and Resource * Clean up basic test for new url to json function * Update version to alpha.2 * Add Conditions and Operators to the URL Datastore query function (#9) * Update urlQuery function to work only with conditions and condition operators * update to alpha.3 * Fix comman in package.json and add new yarn.lock * Add react-dom to devDependencies * Add QS library and dataset search url functions (#10) * Add QS library and functions for url parameters * Change to function from arrow function * Add new functions to index.js * Update version to alpha.4 * Add manual mode and remove check for children in Resource (#12) * Update to 1.x alpha 5 * Added new require conditions option and updated sort to sorts in data… (#13) * Added new require conditions option and updated sort to sorts in datastore call. * copy paste fix. * Update version to 1.x alpha 6 * Fix npm issue update to 1.x-alpha7 * Revert sorts to sort fix * Dataset error catch (#14) * Catch axios error and send back for metastoreDataset. * bump version * Datastore sort v2 (#17) * Adjusted sort handling. * Added in ability to set properties from hook. * Bumped version * allowed initial sort. * Bump alpha version * WCMS-4505: added export of properties and setProperties for datastore hook. (#19) * Add additional params (#20) * Add additional parameters to the hooks for aca/redirect keys * Additional params are now an object * Add back params to useDatastore * bump 1.x alpha to 14 * Fix undefined additionalParams in metastore * Bug fix: Add catch method to metadatastore hook/fetch (#21) * Remove pagination hook and fix bug when changing limits (#22) * Remove pagination hook and fix bug when changing limits * Add beta version * Change offset to 0 when conditions change * Remove legacy Resource component (#23) Co-authored-by: Brian Seek <[email protected]>
1 parent 042303f commit bb8f047

20 files changed

Lines changed: 1977 additions & 7834 deletions

package.json

Lines changed: 40 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@civicactions/data-catalog-services",
3-
"version": "0.1.4",
3+
"version": "1.0.0",
44
"description": "Functions and React components to connect to the DKAN api.",
55
"main": "lib/index.js",
66
"scripts": {
@@ -11,29 +11,26 @@
1111
"lint": "eslint ./src",
1212
"test": "jest --verbose",
1313
"test:watch": "npm run test -- --watch",
14-
"test:coverage": "npm run test -- --coverage",
15-
"docz:dev": "docz dev",
16-
"docz:build": "docz build",
17-
"docz:serve": "docz build && docz serve",
18-
"docz:publish": "docz build && gh-pages -d ./docs"
14+
"test:coverage": "npm run test -- --coverage"
1915
},
2016
"author": "CivicActions <[email protected]>",
2117
"license": "GPL-3.0",
2218
"dependencies": {
23-
"@civicactions/data-catalog-components": "^1.1.0",
24-
"@fortawesome/fontawesome-svg-core": "^1.2.25",
25-
"@fortawesome/free-brands-svg-icons": "^5.11.2",
26-
"@fortawesome/free-solid-svg-icons": "^5.11.2",
27-
"@fortawesome/react-fontawesome": "^0.1.4",
19+
"@civicactions/data-catalog-components": "^1.7.0",
20+
"@fortawesome/fontawesome-svg-core": "^1.2.34",
21+
"@fortawesome/free-brands-svg-icons": "^5.15.2",
22+
"@fortawesome/free-solid-svg-icons": "^5.15.2",
23+
"@fortawesome/react-fontawesome": "^0.1.14",
2824
"@reach/router": "^1.3.3",
2925
"axios": "^0.19.0",
30-
"bootstrap": "^4.2.1",
26+
"bootstrap": "^4.6.0",
3127
"excerpts": "0.0.3",
3228
"html-to-react": "^1.3.4",
3329
"immutability-helper": "^3.0.2",
34-
"lodash": "^4.17.15",
30+
"lodash": "^4.17.21",
3531
"prop-types": "^15.6.2",
36-
"query-string": "^6.8.3",
32+
"qs": "^6.10.1",
33+
"query-string": "^6.14.0",
3734
"react-aria-modal": "^4.0.0",
3835
"react-dnd": "^10.0.2",
3936
"react-dnd-cjs": "^9.5.1",
@@ -46,41 +43,41 @@
4643
"react-js-pagination": "^3.0.2",
4744
"react-loader-advanced": "^1.7.1",
4845
"react-loading-spin": "^1.0.9",
49-
"react-table": "^7.0.4",
46+
"react-table": "^7.6.3",
5047
"reactstrap": "^7.1.0",
5148
"styled-components": "^5.0.1",
5249
"swagger-ui-react": "3.25.0",
5350
"validator": "^12.2.0"
5451
},
5552
"devDependencies": {
56-
"@babel/cli": "^7.0.0",
57-
"@babel/code-frame": "^7.8.3",
58-
"@babel/core": "^7.3.4",
59-
"@babel/plugin-proposal-class-properties": "^7.0.0",
60-
"@babel/plugin-proposal-decorators": "^7.0.0",
61-
"@babel/plugin-proposal-do-expressions": "^7.0.0",
62-
"@babel/plugin-proposal-export-default-from": "^7.0.0",
63-
"@babel/plugin-proposal-export-namespace-from": "^7.0.0",
64-
"@babel/plugin-proposal-function-bind": "^7.0.0",
65-
"@babel/plugin-proposal-function-sent": "^7.0.0",
66-
"@babel/plugin-proposal-json-strings": "^7.0.0",
67-
"@babel/plugin-proposal-logical-assignment-operators": "^7.0.0",
68-
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0",
69-
"@babel/plugin-proposal-numeric-separator": "^7.0.0",
70-
"@babel/plugin-proposal-optional-chaining": "^7.0.0",
71-
"@babel/plugin-proposal-pipeline-operator": "^7.0.0",
72-
"@babel/plugin-proposal-throw-expressions": "^7.0.0",
53+
"@babel/cli": "^7.12.17",
54+
"@babel/code-frame": "^7.12.13",
55+
"@babel/core": "^7.12.17",
56+
"@babel/plugin-proposal-class-properties": "^7.12.13",
57+
"@babel/plugin-proposal-decorators": "^7.12.13",
58+
"@babel/plugin-proposal-do-expressions": "^7.12.13",
59+
"@babel/plugin-proposal-export-default-from": "^7.12.13",
60+
"@babel/plugin-proposal-export-namespace-from": "^7.12.13",
61+
"@babel/plugin-proposal-function-bind": "^7.12.13",
62+
"@babel/plugin-proposal-function-sent": "^7.12.13",
63+
"@babel/plugin-proposal-json-strings": "^7.12.13",
64+
"@babel/plugin-proposal-logical-assignment-operators": "^7.12.13",
65+
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.12.13",
66+
"@babel/plugin-proposal-numeric-separator": "^7.12.13",
67+
"@babel/plugin-proposal-optional-chaining": "^7.12.17",
68+
"@babel/plugin-proposal-pipeline-operator": "^7.12.13",
69+
"@babel/plugin-proposal-throw-expressions": "^7.12.13",
7370
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
7471
"@babel/plugin-syntax-import-meta": "^7.0.0",
75-
"@babel/plugin-transform-runtime": "^7.6.2",
76-
"@babel/preset-env": "^7.5.5",
77-
"@babel/preset-react": "^7.0.0",
78-
"@babel/runtime": "^7.6.2",
79-
"@testing-library/dom": "^7.29.0",
80-
"@testing-library/jest-dom": "^5.10.1",
72+
"@babel/plugin-transform-runtime": "^7.12.17",
73+
"@babel/preset-env": "^7.12.17",
74+
"@babel/preset-react": "^7.12.13",
75+
"@babel/runtime": "^7.12.18",
76+
"@testing-library/dom": "^7.29.6",
77+
"@testing-library/jest-dom": "^5.11.9",
8178
"@testing-library/react": "^10.2.1",
8279
"@testing-library/react-hooks": "^3.3.0",
83-
"@testing-library/user-event": "^12.6.0",
80+
"@testing-library/user-event": "^12.7.2",
8481
"babel-core": "^6.26.3",
8582
"babel-eslint": "^10.0.3",
8683
"babel-jest": "^24.9.0",
@@ -92,21 +89,21 @@
9289
"babel-preset-stage-0": "^6.24.1",
9390
"core-js": "^2.6.5",
9491
"css-loader": "^2.1.0",
95-
"docz": "^2.3.1",
9692
"enzyme": "^3.10.0",
97-
"enzyme-adapter-react-16": "^1.14.0",
93+
"enzyme-adapter-react-16": "^1.15.6",
9894
"eslint": "^6.2.1",
9995
"eslint-config-airbnb": "^18.0.1",
10096
"eslint-plugin-import": "^2.18.2",
10197
"eslint-plugin-jsx-a11y": "^6.2.3",
102-
"eslint-plugin-react": "^7.14.3",
98+
"eslint-plugin-react": "^7.22.0",
10399
"eslint-plugin-react-hooks": "^1.7.0",
104100
"extract-text-webpack-plugin": "^3.0.2",
105101
"gh-pages": "^2.2.0",
106102
"jest": "^24.9.0",
107103
"node-sass": "^4.13.1",
108104
"prettier": "^1.16.0",
109-
"react-scripts": "^4.0.1",
105+
"react-dom": "^16.13.1",
106+
"react-scripts": "^4.0.3",
110107
"react-test-renderer": "^16.9.0",
111108
"sass-loader": "^7.1.0",
112109
"url-loader": "^1.1.2"

src/Resource/helpers.jsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
import { createContext } from 'react';
2-
3-
export const ResourceDispatch = createContext(null);
4-
51
// Build columns in correct structure for Datatable component.
62
export function prepareColumns(columns) {
73
return columns.map((column) => ({

src/Resource/helpers.test.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/Resource/index.jsx

Lines changed: 0 additions & 74 deletions
This file was deleted.

src/Resource/resource.test.jsx

Lines changed: 0 additions & 63 deletions
This file was deleted.

src/hooks/useDatastore/fetch.js

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
11
import axios from 'axios';
2+
import qs from 'qs'
23

3-
export async function fetchDataFromQuery(id, rootUrl, options) {
4-
const { keys, limit, offset, conditions, sort, prepareColumns, setValues, setCount, setColumns, setLoading } = options;
4+
export async function fetchDataFromQuery(id, rootUrl, options, additionalParams) {
5+
const { keys, limit, offset, conditions, sort, prepareColumns, properties, setValues, setCount, setColumns, setLoading, setSchema } = options;
56
if(!id) {
67
// TODO: Throw error
78
return false;
89
}
910
if(typeof setLoading === 'function') {
1011
setLoading(true);
1112
}
12-
return await axios.post(`${rootUrl}/datastore/query/?`, {
13-
resources: [{id: id, alias: 't'}],
14-
keys: keys,
15-
limit: limit,
16-
offset: offset,
17-
conditions: conditions,
18-
sort: sort,
13+
return await axios({
14+
method: 'GET',
15+
url: `${rootUrl}/datastore/query/${id}`,
16+
params: {
17+
keys: keys,
18+
limit: limit,
19+
offset: offset,
20+
conditions: conditions,
21+
sorts: sort,
22+
properties: properties,
23+
...additionalParams,
24+
},
25+
paramsSerializer: (params) => {
26+
return qs.stringify(params)
27+
}
1928
})
2029
.then((res) => {
2130
const { data } = res;
@@ -24,6 +33,7 @@ export async function fetchDataFromQuery(id, rootUrl, options) {
2433
if(data.results.length) {
2534
setColumns(prepareColumns ? prepareColumns(Object.keys(data.results[0])) : Object.keys(data.results[0]))
2635
}
36+
setSchema(data.schema)
2737
if(typeof setLoading === 'function') {
2838
setLoading(false);
2939
}

src/hooks/useDatastore/fetch.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ describe('fetchDataFromQuery', () => {
2626
limit: 20,
2727
offset: 0,
2828
conditions: [],
29-
sort: {asc: [], desc: []},
29+
sorts: [],
3030
setValues: () => {},
3131
setCount: () => {},
32-
setColumns: () => {}
32+
setColumns: () => {},
33+
setSchema: () => {}
3334
})
3435
expect(results.count).toEqual(data.data.count);
3536
expect(results.results).toEqual(data.data.results);

0 commit comments

Comments
 (0)