Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: dhis2/datastore-app
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.3.2
Choose a base ref
...
head repository: dhis2/datastore-app
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 19 commits
  • 66 files changed
  • 9 contributors

Commits on Jun 1, 2021

  1. fix: obtain datastore values directly instead of from metadata (#57)

    * refactor: remove unused constant
    
    * fix: obtain datastore values directly instead of from metadata
    mediremi authored Jun 1, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    749edd7 View commit details
  2. chore(release): cut 1.3.3 [skip ci]

    ## [1.3.3](v1.3.2...v1.3.3) (2021-06-01)
    
    ### Bug Fixes
    
    * obtain datastore values directly instead of from metadata  ([#57](#57)) ([749edd7](749edd7))
    dhis2-bot committed Jun 1, 2021
    Copy the full SHA
    cab3c8c View commit details

Commits on Aug 19, 2021

  1. Unverified

    This user has not yet uploaded their public signing key.
    Copy the full SHA
    3fec169 View commit details
  2. Merge pull request #89 from dhis2/enable-preview-pr

    ci(preview): enable deploy previews
    varl authored Aug 19, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    60cc201 View commit details

Commits on Nov 18, 2021

  1. chore(deps): update d2 (#93)

    Birkbjo authored Nov 18, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    ac4f4c1 View commit details

Commits on May 11, 2022

  1. Copy the full SHA
    6f71064 View commit details

Commits on May 12, 2022

  1. style: fix prettier errors

    ismay committed May 12, 2022
    Copy the full SHA
    30fbd20 View commit details

Commits on May 19, 2022

  1. ci: fix lint script

    ismay committed May 19, 2022
    Copy the full SHA
    a007d5e View commit details
  2. ci: fix d2-style script

    ismay committed May 19, 2022
    Copy the full SHA
    8af8fef View commit details

Commits on May 23, 2022

  1. style: fix eslint errors

    ismay committed May 23, 2022
    Copy the full SHA
    6e079f5 View commit details

Commits on May 24, 2022

  1. Merge pull request #106 from dhis2/update-commit-checking-workflows

    ci: replace semantic commit checks with new workflow
    HendrikThePendric authored May 24, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    a77dc27 View commit details

Commits on Nov 8, 2022

  1. chore: update app icon

    cooper-joe committed Nov 8, 2022
    Copy the full SHA
    40f58bd View commit details

Commits on Nov 9, 2022

  1. Merge pull request #111 from dhis2/update-app-icon

    chore: update app icon
    cooper-joe authored Nov 9, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    46f3c6a View commit details

Commits on Dec 8, 2022

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    60768fb View commit details
  2. chore(release): cut 1.3.4 [skip ci]

    ## [1.3.4](v1.3.3...v1.3.4) (2022-12-08)
    
    ### Bug Fixes
    
    * show format warning when json invalid [DHIS2-14202] ([#112](#112)) ([60768fb](60768fb))
    dhis2-bot committed Dec 8, 2022
    Copy the full SHA
    b52219c View commit details

Commits on Sep 4, 2024

  1. ci: update to shared workflows (#129)

    * ci: update to shared workflows
    
    * chore: update cli-app-scripts
    
    * chore: update app-runtime
    
    * chore: update ui
    ismay authored Sep 4, 2024
    1

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    7bba6a9 View commit details
  2. fix: skip publishing to apphub

    ismay authored and ismay committed Sep 4, 2024
    1
    Copy the full SHA
    5ab22c0 View commit details
  3. chore(release): cut 1.3.5 [skip release]

    ## [1.3.5](v1.3.4...v1.3.5) (2024-09-04)
    
    ### Bug Fixes
    
    * skip publishing to apphub ([5ab22c0](5ab22c0))
    dhis2-bot committed Sep 4, 2024
    1
    Copy the full SHA
    98bf5c9 View commit details

Commits on Oct 9, 2024

  1. ci: fix main branch ref in concurrency expression (#132)

    * fix: fix main branch ref in concurrency expression
    
    * fix: fix comment and close expression
    ismay authored Oct 9, 2024
    1

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    76c14f2 View commit details
Showing with 7,518 additions and 8,559 deletions.
  1. +0 −4 .github/semantic.yml
  2. +6 −7 .github/workflows/comment-and-close.yml
  3. +14 −0 .github/workflows/deploy-pr.yml
  4. +17 −0 .github/workflows/deploy-production.yml
  5. +0 −123 .github/workflows/dhis2-verify-app.yml
  6. +13 −0 .github/workflows/lint-pr-title.yml
  7. +24 −0 .github/workflows/test-and-release.yml
  8. +1 −1 .huskyrc.js
  9. +21 −0 CHANGELOG.md
  10. +10 −10 package.json
  11. BIN public/dhis2-app-icon.png
  12. +3 −3 src/App.js
  13. +1 −1 src/actions/dialogActions.js
  14. +31 −24 src/actions/index.js
  15. +1 −1 src/actions/jsonEditorActions.js
  16. +1 −1 src/actions/navigationActions.js
  17. +1 −1 src/actions/sidebarActions.js
  18. +5 −5 src/components/app/AppContainer.js
  19. +10 −10 src/components/app/Layout.js
  20. +4 −4 src/components/dialog/ConfirmDeleteKeyDialog.js
  21. +4 −4 src/components/dialog/ConfirmDeleteNamespaceDialog.js
  22. +5 −5 src/components/dialog/ConfirmNavigationDialog.js
  23. +4 −3 src/components/dialog/DialogRoot.js
  24. +2 −2 src/components/dialog/DialogRouter.js
  25. +2 −2 src/components/dialog/ErrorDialog.js
  26. +5 −5 src/components/dialog/NewKeyDialog.js
  27. +6 −6 src/components/dialog/NewNamespaceDialog.js
  28. +3 −3 src/components/display/DisplayToolbarTitle.js
  29. +1 −1 src/components/display/ErrorArea.js
  30. +1 −1 src/components/display/LoadingArea.js
  31. +3 −3 src/components/display/edit/EditArea.js
  32. +44 −8 src/components/display/edit/EditDisplay.js
  33. +20 −28 src/components/display/edit/EditToolbar.js
  34. +2 −2 src/components/display/empty/EmptyArea.js
  35. +2 −2 src/components/display/empty/EmptyDisplay.js
  36. +4 −4 src/components/hoc/DisplayAreaHOC.js
  37. +3 −3 src/components/hoc/SidebarAreaHOC.js
  38. +3 −4 src/components/sidebar/KeyItem.js
  39. +5 −5 src/components/sidebar/KeyItemMenu.js
  40. +13 −10 src/components/sidebar/NamespaceItem.js
  41. +6 −6 src/components/sidebar/NamespaceItemMenu.js
  42. +6 −6 src/components/sidebar/NamespaceList.js
  43. +5 −5 src/components/sidebar/Searchbar.js
  44. +8 −8 src/components/sidebar/Sidebar.js
  45. +1 −1 src/components/sidebar/SidebarHeader.js
  46. +2 −2 src/components/utils/IconButtonElement.js
  47. +2 −2 src/components/utils/Icons.js
  48. +8 −8 src/components/utils/JSONEditor.js
  49. +1 −1 src/components/utils/JSONSearchBar.js
  50. +3 −3 src/components/utils/Snackbar.js
  51. +2 −0 src/constants/actionTypes.js
  52. +0 −1 src/constants/apiUrls.js
  53. +1 −1 src/reducers/dialogReducer.js
  54. +2 −2 src/reducers/displayReducer.js
  55. +6 −6 src/reducers/index.js
  56. +2 −2 src/reducers/jsonEditorReducer.js
  57. +1 −1 src/reducers/navigationReducer.js
  58. +5 −5 src/reducers/sidebarReducer.js
  59. +10 −1 src/reducers/snackbarReducer.js
  60. +1 −1 src/store/index.js
  61. +8 −14 src/utils/api.js
  62. +1 −1 src/utils/cache.test.js
  63. +3 −3 src/utils/theme.js
  64. +7 −3 src/utils/utils.js
  65. +4 −2 src/utils/validation.js
  66. +7,128 −8,178 yarn.lock
4 changes: 0 additions & 4 deletions .github/semantic.yml

This file was deleted.

13 changes: 6 additions & 7 deletions .github/workflows/comment-and-close.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
name: comment-and-close

on:
issues:
types: [opened]

jobs:
comment-and-close:
runs-on: ubuntu-latest
steps:
- uses: vardevs/candc@v1
with:
close-comment: 'If you would like to file a bug report or feature request, please refer to our issue tracker: https://jira.dhis2.org'
exempt-users: dhis2-bot,dependabot,kodiakhq
github-token: ${{secrets.DHIS2_BOT_GITHUB_TOKEN}}
uses: dhis2/workflows-platform/.github/workflows/comment-and-close.yml@v1
if: '!contains(fromJson(''["dhis2-bot", "kodiakhq", "dependabot"]''), github.event.issue.sender.login)'
with:
issue_number: ${{ github.event.issue.number }}
14 changes: 14 additions & 0 deletions .github/workflows/deploy-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: deploy-pr

on:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true

jobs:
deploy:
uses: dhis2/workflows-platform/.github/workflows/deploy-pr.yml@v1
if: '!github.event.pull_request.head.repo.fork'
secrets: inherit
17 changes: 17 additions & 0 deletions .github/workflows/deploy-production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: deploy-production

on:
push:
branches:
- master

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
deploy:
uses: dhis2/workflows-platform/.github/workflows/deploy-production.yml@v1
secrets: inherit
with:
branch: master
123 changes: 0 additions & 123 deletions .github/workflows/dhis2-verify-app.yml

This file was deleted.

13 changes: 13 additions & 0 deletions .github/workflows/lint-pr-title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: lint-pr-title

on:
pull_request:
types: ['opened', 'edited', 'reopened', 'synchronize']

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true

jobs:
lint-pr-title:
uses: dhis2/workflows-platform/.github/workflows/lint-pr-title.yml@v1
24 changes: 24 additions & 0 deletions .github/workflows/test-and-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: test-and-release

on: push

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
# Cancel previous runs if not on a release branch
cancel-in-progress: ${{ !contains(fromJSON('["refs/heads/master", "refs/heads/main"]'), github.ref) }}

jobs:
lint-commits:
uses: dhis2/workflows-platform/.github/workflows/lint-commits.yml@v1
lint:
uses: dhis2/workflows-platform/.github/workflows/lint.yml@v1
test:
uses: dhis2/workflows-platform/.github/workflows/test.yml@v1
release:
needs: [lint-commits, lint, test]
uses: dhis2/workflows-platform/.github/workflows/release.yml@v1
with:
publish_apphub: false
# Skips forks and dependabot PRs
if: '!github.event.push.repository.fork'
secrets: inherit
2 changes: 1 addition & 1 deletion .huskyrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { config } = require('@dhis2/cli-style')
const husky = require(config.husky)

const tasks = arr => arr.join(' && ')
const tasks = (arr) => arr.join(' && ')

module.exports = {
hooks: {
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
## [1.3.5](https://github.com/dhis2/datastore-app/compare/v1.3.4...v1.3.5) (2024-09-04)


### Bug Fixes

* skip publishing to apphub ([5ab22c0](https://github.com/dhis2/datastore-app/commit/5ab22c075aa63875c86b6542f2340ba892e1d24f))

## [1.3.4](https://github.com/dhis2/datastore-app/compare/v1.3.3...v1.3.4) (2022-12-08)


### Bug Fixes

* show format warning when json invalid [DHIS2-14202] ([#112](https://github.com/dhis2/datastore-app/issues/112)) ([60768fb](https://github.com/dhis2/datastore-app/commit/60768fbeda4b7cd89268d28813e16b433ba88b30))

## [1.3.3](https://github.com/dhis2/datastore-app/compare/v1.3.2...v1.3.3) (2021-06-01)


### Bug Fixes

* obtain datastore values directly instead of from metadata ([#57](https://github.com/dhis2/datastore-app/issues/57)) ([749edd7](https://github.com/dhis2/datastore-app/commit/749edd7e7c6ff05a91b4750b3f6127da4772476b))

## [1.3.2](https://github.com/dhis2/datastore-app/compare/v1.3.1...v1.3.2) (2021-03-29)


20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
{
"name": "datastore-app",
"version": "1.0.0",
"version": "1.3.5",
"description": "",
"license": "BSD-3-Clause",
"private": true,
"scripts": {
"build": "d2-app-scripts build",
"start": "d2-app-scripts start",
"test": "d2-app-scripts test",
"lint:js": "d2-style js check",
"lint:text": "d2-style text check",
"lint:js": "d2-style check js",
"lint:text": "d2-style check text",
"lint:staged": "yarn lint:js --staged && yarn lint:text --staged",
"lint": "yarn lint:js && yarn lint:text",
"format:js": "d2-style js apply",
"format:text": "d2-style text apply",
"format:js": "d2-style apply js",
"format:text": "d2-style apply text",
"format:staged": "yarn format:js --staged && yarn format:text --staged",
"format": "yarn format:js && yarn format:text"
},
"devDependencies": {
"@dhis2/cli-app-scripts": "^6.0.1",
"@dhis2/cli-style": "^7.3.0"
"@dhis2/cli-app-scripts": "^11.7.0",
"@dhis2/cli-style": "^10.4.1"
},
"dependencies": {
"@dhis2/app-runtime": "^2.8.0",
"@dhis2/app-runtime": "^3.10.6",
"@dhis2/app-runtime-adapter-d2": "^1.0.2",
"@dhis2/d2-i18n": "^1.1.0",
"@dhis2/prop-types": "^2.0.3",
"@dhis2/ui": "^6.5.5",
"d2": "^31.9.0",
"@dhis2/ui": "9",
"d2": "^31.10.2",
"jsoneditor": "^9.2.0",
"material-ui": "0.19.0",
"react-redux": "^7.2.2",
Binary file modified public/dhis2-app-icon.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useD2 } from '@dhis2/app-runtime-adapter-d2'
import React from 'react'
import AppContainer from './components/app/AppContainer'
import store from './store'
import './locales'
import AppContainer from './components/app/AppContainer.js'
import store from './store/index.js'
import './locales/index.js'

const App = () => {
const { d2 } = useD2()
2 changes: 1 addition & 1 deletion src/actions/dialogActions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as actions from '../constants/actionTypes'
import * as actions from '../constants/actionTypes.js'

/**
* openDialog - Action creator helper method for creating dialogs
55 changes: 31 additions & 24 deletions src/actions/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { hashHistory } from 'react-router'
import * as actions from '../constants/actionTypes'
import api from '../utils/api'
import * as navigationAction from './navigationActions'
import * as actions from '../constants/actionTypes.js'
import api from '../utils/api.js'
import * as navigationAction from './navigationActions.js'

/**
* receiveNamespaces - Deliver namespaces returned from request
@@ -220,6 +220,13 @@ export function rejectUpdateValue(namespace, key, value, error) {
}
}

export function rejectFormat(error) {
return {
type: actions.FORMAT_VALUE_REJECTED,
error,
}
}

/**
* requestDeleteKey - Request deleteion of a key
*
@@ -374,15 +381,15 @@ export function emptySnackbar() {
* @return {object} Action thunk
*/
export function fetchAndToggleNamespace(namespace, openNamespace = false) {
return dispatch => {
return (dispatch) => {
dispatch(requestKeys(namespace))
return api
.getKeys(namespace)
.then(keys => {
.then((keys) => {
dispatch(receiveKeys(namespace, keys))
})
.then(() => dispatch(toggleNamespace(namespace, openNamespace)))
.catch(error => {
.catch((error) => {
if (error.httpStatusCode === 404) {
// If not found, we remove the namespace from UI
return dispatch(receiveDeleteNamespace(namespace))
@@ -392,7 +399,7 @@ export function fetchAndToggleNamespace(namespace, openNamespace = false) {
}
return null
})
.catch(error => {
.catch((error) => {
dispatch(rejectKeys(namespace, error))
})
}
@@ -408,15 +415,15 @@ export function fetchAndToggleNamespace(namespace, openNamespace = false) {
* @return {object} Action thunk
*/
export function fetchAndDisplayKeyValue(namespace, key) {
return dispatch => {
return (dispatch) => {
dispatch(requestValue(namespace, key))
return api
.getValue(namespace, key)
.then(value => {
.then((value) => {
dispatch(receiveValue(namespace, key, value))
dispatch(selectKey(namespace, key, value.value))
})
.catch(error => dispatch(rejectValue(namespace, key, error)))
.catch((error) => dispatch(rejectValue(namespace, key, error)))
}
}

@@ -426,14 +433,14 @@ export function fetchAndDisplayKeyValue(namespace, key) {
* @returns action thunk
*/
export function fetchNamespaces() {
return dispatch => {
return (dispatch) => {
dispatch(requestNamespaces())
return api
.getNamespaces()
.then(namespaces => {
.then((namespaces) => {
dispatch(receiveNamespaces(namespaces))
})
.catch(error => dispatch(rejectNamespaces(error)))
.catch((error) => dispatch(rejectNamespaces(error)))
}
}

@@ -450,7 +457,7 @@ export function fetchNamespaces() {
* @return {string} Action thunk
*/
export function createValue(namespace, key, value) {
return dispatch => {
return (dispatch) => {
dispatch(requestCreateValue(namespace, key, value))
return api
.createValue(namespace, key, value)
@@ -469,11 +476,11 @@ export function createValue(namespace, key, value) {
* @return {object} Action thunk
*/
export function createAndDisplayValue(namespace, key) {
return dispatch => {
return (dispatch) => {
dispatch(createValue(namespace, key, {}))
.then(() => hashHistory.push(`/edit/${namespace}/${key}`))
.then(() => dispatch(fetchAndToggleNamespace(namespace, true)))
.catch(error =>
.catch((error) =>
dispatch({
type: actions.CREATE_VALUE_REJECTED,
namespace,
@@ -492,9 +499,9 @@ export function createAndDisplayValue(namespace, key) {
* @return {object} Action thunk
*/
export function fetchKeys(namespace) {
return dispatch => {
return (dispatch) => {
dispatch(requestKeys(namespace))
return api.getKeys(namespace).then(keys => {
return api.getKeys(namespace).then((keys) => {
if (keys.length < 1) {
return Promise.reject({ status: 404 })
}
@@ -512,7 +519,7 @@ export function fetchKeys(namespace) {
* @return {object} Action thunk
*/
export function updateValue(namespace, key, value) {
return dispatch => {
return (dispatch) => {
dispatch(requestUpdateValue(namespace, key, value))
return api
.updateValue(namespace, key, value)
@@ -536,15 +543,15 @@ export function deleteKey(namespace, key) {
return api
.deleteValue(namespace, key)
.then(() => dispatch(receiveDeleteKey(namespace, key)))
.then(res => {
.then((res) => {
if (getState().display.key == key) {
dispatch(navigationAction.setIgnoreNextNavigationConfirm())
hashHistory.push('/')
}
return res
})
.then(() => dispatch(fetchKeys(namespace)))
.catch(error => {
.catch((error) => {
if (error.httpStatusCode === 404) {
// If not found, we remove the namespace from UI
dispatch(receiveDeleteNamespace(namespace))
@@ -556,7 +563,7 @@ export function deleteKey(namespace, key) {
dispatch(toggleNamespace(namespace, true))
}
})
.catch(error => {
.catch((error) => {
dispatch(rejectDeleteKey(namespace, key, error))
})
}
@@ -574,15 +581,15 @@ export function deleteNamespace(namespace) {
dispatch(requestDeleteNamespace(namespace))
return api
.deleteNamespace(namespace)
.then(success => {
.then((success) => {
dispatch(receiveDeleteNamespace(namespace))
if (getState().display.namespace === namespace) {
dispatch(navigationAction.setIgnoreNextNavigationConfirm())
hashHistory.push('/')
}
return success
})
.catch(err => {
.catch((err) => {
console.log(err)
dispatch(rejectDeleteNamespace(namespace))
})
2 changes: 1 addition & 1 deletion src/actions/jsonEditorActions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as actions from '../constants/jsonEditorTypes'
import * as actions from '../constants/jsonEditorTypes.js'

/**
* searchJSON - Search action in json editor
2 changes: 1 addition & 1 deletion src/actions/navigationActions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SET_IGNORE_NEXT_CONFIRM_NAVIGATION } from '../constants/actionTypes'
import { SET_IGNORE_NEXT_CONFIRM_NAVIGATION } from '../constants/actionTypes.js'

export function setIgnoreNextNavigationConfirm() {
return {
2 changes: 1 addition & 1 deletion src/actions/sidebarActions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as actions from '../constants/actionTypes'
import * as actions from '../constants/actionTypes.js'

/**
* searchSidebarChange - signal search bar in sidebar change
10 changes: 5 additions & 5 deletions src/components/app/AppContainer.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { PropTypes } from '@dhis2/prop-types'
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider.js'
import React, { Component } from 'react'
import { Provider } from 'react-redux'
import { Router, Route, hashHistory, IndexRoute } from 'react-router'
import Theme from '../../utils/theme'
import EditDisplay from '../display/edit/EditDisplay'
import EmptyDisplay from '../display/empty/EmptyDisplay'
import Layout from './Layout'
import Theme from '../../utils/theme.js'
import EditDisplay from '../display/edit/EditDisplay.js'

Check warning on line 7 in src/components/app/AppContainer.js

GitHub Actions / lint / lint

Using exported name 'EditDisplay' as identifier for default export
import EmptyDisplay from '../display/empty/EmptyDisplay.js'
import Layout from './Layout.js'

class AppContainer extends Component {
shouldComponentUpdate() {
20 changes: 10 additions & 10 deletions src/components/app/Layout.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { PropTypes } from '@dhis2/prop-types'
import React, { Component } from 'react'
import * as dialog from '../../constants/dialogTypes'
import ConfirmDeleteKeyDialog from '../dialog/ConfirmDeleteKeyDialog'
import ConfirmDeleteNamespaceDialog from '../dialog/ConfirmDeleteNamespaceDialog'
import DialogRoute from '../dialog/DialogRoute'
import DialogRouter from '../dialog/DialogRouter'
import ErrorDialog from '../dialog/ErrorDialog'
import NewKeyDialog from '../dialog/NewKeyDialog'
import NewNamespaceDialog from '../dialog/NewNamespaceDialog'
import Sidebar from '../sidebar/Sidebar'
import Snackbar from '../utils/Snackbar'
import * as dialog from '../../constants/dialogTypes.js'
import ConfirmDeleteKeyDialog from '../dialog/ConfirmDeleteKeyDialog.js'

Check warning on line 4 in src/components/app/Layout.js

GitHub Actions / lint / lint

Using exported name 'ConfirmDeleteKeyDialog' as identifier for default export
import ConfirmDeleteNamespaceDialog from '../dialog/ConfirmDeleteNamespaceDialog.js'

Check warning on line 5 in src/components/app/Layout.js

GitHub Actions / lint / lint

Using exported name 'ConfirmDeleteNamespaceDialog' as identifier for default export
import DialogRoute from '../dialog/DialogRoute.js'
import DialogRouter from '../dialog/DialogRouter.js'
import ErrorDialog from '../dialog/ErrorDialog.js'

Check warning on line 8 in src/components/app/Layout.js

GitHub Actions / lint / lint

Using exported name 'ErrorDialog' as identifier for default export
import NewKeyDialog from '../dialog/NewKeyDialog.js'
import NewNamespaceDialog from '../dialog/NewNamespaceDialog.js'

Check warning on line 10 in src/components/app/Layout.js

GitHub Actions / lint / lint

Using exported name 'NewNamespaceDialog' as identifier for default export
import Sidebar from '../sidebar/Sidebar.js'

Check warning on line 11 in src/components/app/Layout.js

GitHub Actions / lint / lint

Using exported name 'Sidebar' as identifier for default export
import Snackbar from '../utils/Snackbar.js'

Check warning on line 12 in src/components/app/Layout.js

GitHub Actions / lint / lint

Using exported name 'Snackbar' as identifier for default export
import styles from './Layout.module.css'

class Layout extends Component {
8 changes: 4 additions & 4 deletions src/components/dialog/ConfirmDeleteKeyDialog.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { PropTypes } from '@dhis2/prop-types'
import React, { Component } from 'react'
import { connect } from 'react-redux'
import { deleteKey } from '../../actions'
import DialogRoot from './DialogRoot'
import { deleteKey } from '../../actions/index.js'
import DialogRoot from './DialogRoot.js'

export class ConfirmDeleteKeyDialog extends Component {
handleConfirmed = () => {
@@ -45,13 +45,13 @@ ConfirmDeleteKeyDialog.propTypes = {
namespaceStore: PropTypes.any,
}

const mapStateToProps = state => ({
const mapStateToProps = (state) => ({
namespace: state.dialog.namespace,
keyValue: state.dialog.key,
namespaceStore: state.sidebar.namespaces,
})

const mapDispatchToProps = dispatch => ({
const mapDispatchToProps = (dispatch) => ({
deleteKeyInNamespace(namespace, key) {
dispatch(deleteKey(namespace, key))
},
8 changes: 4 additions & 4 deletions src/components/dialog/ConfirmDeleteNamespaceDialog.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { PropTypes } from '@dhis2/prop-types'
import React, { Component } from 'react'
import { connect } from 'react-redux'
import { deleteNamespace } from '../../actions'
import DialogRoot from './DialogRoot'
import { deleteNamespace } from '../../actions/index.js'
import DialogRoot from './DialogRoot.js'

export class ConfirmDeleteNamespaceDialog extends Component {
handleConfirmed = () => {
@@ -33,11 +33,11 @@ ConfirmDeleteNamespaceDialog.propTypes = {
deleteNamespace: PropTypes.func,
}

const mapStateToProps = state => ({
const mapStateToProps = (state) => ({
namespace: state.dialog.namespace,
})

const mapDispatchToProps = dispatch => ({
const mapDispatchToProps = (dispatch) => ({
deleteNamespace(namespace) {
dispatch(deleteNamespace(namespace))
},
10 changes: 5 additions & 5 deletions src/components/dialog/ConfirmNavigationDialog.js
Original file line number Diff line number Diff line change
@@ -2,8 +2,8 @@ import { PropTypes } from '@dhis2/prop-types'
import Dialog from 'material-ui/Dialog'
import React, { Component } from 'react'
import { connect } from 'react-redux'
import * as navigationActions from '../../actions/navigationActions'
import DialogRoot from './DialogRoot'
import * as navigationActions from '../../actions/navigationActions.js'
import DialogRoot from './DialogRoot.js'

export class ConfirmNavigationDialog extends Component {
constructor() {
@@ -55,7 +55,7 @@ export class ConfirmNavigationDialog extends Component {
}
}

routerWillLeave = nextLocation => {
routerWillLeave = (nextLocation) => {
if (this.state.confirmed) {
this.setState({
...this.state,
@@ -109,11 +109,11 @@ ConfirmNavigationDialog.propTypes = {
setIgnoreNext: PropTypes.any,
}

const mapStateToProps = state => ({
const mapStateToProps = (state) => ({
ignoreNext: state.navigation.ignoreNextConfirm,
})

const mapDispatchToProps = dispatch => ({
const mapDispatchToProps = (dispatch) => ({
setIgnoreNext(ignoreNext) {
dispatch(navigationActions.setIgnoreNextNavigationConfirm(ignoreNext))
},
7 changes: 4 additions & 3 deletions src/components/dialog/DialogRoot.js
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ import Dialog from 'material-ui/Dialog'
import FlatButton from 'material-ui/FlatButton'
import React, { Component } from 'react'
import { connect } from 'react-redux'
import { closeDialog } from '../../actions/dialogActions'
import { closeDialog } from '../../actions/dialogActions.js'

class DialogRoot extends Component {
static buildButton(action, text, primary = false) {
@@ -36,14 +36,15 @@ class DialogRoot extends Component {
cancelLabel || 'Cancel'
)
)
if (approveAction)
if (approveAction) {
actions.push(
DialogRoot.buildButton(
finalAction,
approveLabel || 'Create',
true
)
)
}

return (
<Dialog
@@ -71,7 +72,7 @@ DialogRoot.propTypes = {
title: PropTypes.string,
}

const mapDispatchToProps = dispatch => ({
const mapDispatchToProps = (dispatch) => ({
defaultCloseDialog() {
dispatch(closeDialog())
},
4 changes: 2 additions & 2 deletions src/components/dialog/DialogRouter.js
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ import React, { Component } from 'react'
import { connect } from 'react-redux'

class DialogRouter extends Component {
matchDialog = dialogRoute =>
matchDialog = (dialogRoute) =>
dialogRoute.props.name === this.props.dialogType

render() {
@@ -23,7 +23,7 @@ DialogRouter.propTypes = {
dialogType: PropTypes.string,
}

const mapStateToProps = state => ({
const mapStateToProps = (state) => ({
dialogType: state.dialog.dialogType,
})

4 changes: 2 additions & 2 deletions src/components/dialog/ErrorDialog.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PropTypes } from '@dhis2/prop-types'
import React, { Component } from 'react'
import { connect } from 'react-redux'
import DialogRoot from './DialogRoot'
import DialogRoot from './DialogRoot.js'

export class ErrorDialog extends Component {
render() {
@@ -21,7 +21,7 @@ ErrorDialog.propTypes = {
message: PropTypes.string,
}

const mapStateToProps = state => ({
const mapStateToProps = (state) => ({
message: state.dialog.message,
})

10 changes: 5 additions & 5 deletions src/components/dialog/NewKeyDialog.js
Original file line number Diff line number Diff line change
@@ -2,9 +2,9 @@ import { PropTypes } from '@dhis2/prop-types'
import TextField from 'material-ui/TextField'
import React, { Component } from 'react'
import { connect } from 'react-redux'
import { createAndDisplayValue } from '../../actions'
import { validateKeyOrNamespace } from '../../utils/validation'
import DialogRoot from './DialogRoot'
import { createAndDisplayValue } from '../../actions/index.js'
import { validateKeyOrNamespace } from '../../utils/validation.js'
import DialogRoot from './DialogRoot.js'

export class NamespaceDialog extends Component {
constructor(props) {
@@ -83,11 +83,11 @@ NamespaceDialog.propTypes = {
createNamespace: PropTypes.func,
}

const mapStateToProps = state => ({
const mapStateToProps = (state) => ({
namespace: state.dialog.namespace,
})

const mapDispatchToProps = dispatch => ({
const mapDispatchToProps = (dispatch) => ({
createNamespace(namespace, key) {
dispatch(createAndDisplayValue(namespace, key))
},
12 changes: 6 additions & 6 deletions src/components/dialog/NewNamespaceDialog.js
Original file line number Diff line number Diff line change
@@ -2,9 +2,9 @@ import { PropTypes } from '@dhis2/prop-types'
import TextField from 'material-ui/TextField'
import React, { Component } from 'react'
import { connect } from 'react-redux'
import { createAndDisplayValue } from '../../actions'
import { validateKeyOrNamespace } from '../../utils/validation'
import DialogRoot from './DialogRoot'
import { createAndDisplayValue } from '../../actions/index.js'
import { validateKeyOrNamespace } from '../../utils/validation.js'
import DialogRoot from './DialogRoot.js'

export class NewNamespaceDialog extends Component {
constructor(props) {
@@ -18,15 +18,15 @@ export class NewNamespaceDialog extends Component {
}
}

handleNamespaceInput = event => {
handleNamespaceInput = (event) => {
const val = event.target.value
this.setState({
namespaceError: validateKeyOrNamespace(val).message,
namespaceValue: event.target.value,
})
}

handleKeyInput = event => {
handleKeyInput = (event) => {
const val = event.target.value
this.setState({
keyError: validateKeyOrNamespace(val).message,
@@ -94,7 +94,7 @@ NewNamespaceDialog.propTypes = {
createNamespace: PropTypes.func,
}

const mapDispatchToProps = dispatch => ({
const mapDispatchToProps = (dispatch) => ({
createNamespace(namespace, key) {
dispatch(createAndDisplayValue(namespace, key))
},
6 changes: 3 additions & 3 deletions src/components/display/DisplayToolbarTitle.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { PropTypes } from '@dhis2/prop-types'
import ChevronRight from 'material-ui/svg-icons/navigation/chevron-right'
import ChevronRight from 'material-ui/svg-icons/navigation/chevron-right.js'
import React, { Component } from 'react'
import Theme from '../../utils/theme'
import BreadcrumbHistoryButton from '../utils/BreadcrumbHistoryButton'
import Theme from '../../utils/theme.js'
import BreadcrumbHistoryButton from '../utils/BreadcrumbHistoryButton.js'
import styles from './DisplayToolbarTitle.module.css'

class DisplayToolbarTitle extends Component {
2 changes: 1 addition & 1 deletion src/components/display/ErrorArea.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import i18n from '@dhis2/d2-i18n'
import { PropTypes } from '@dhis2/prop-types'
import React, { Component } from 'react'
import { ErrorIconWithText } from '../utils/Icons'
import { ErrorIconWithText } from '../utils/Icons.js'

class ErrorArea extends Component {
render() {
2 changes: 1 addition & 1 deletion src/components/display/LoadingArea.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Paper from 'material-ui/Paper'
import React, { Component } from 'react'
import { Spinner } from '../utils/Loaders'
import { Spinner } from '../utils/Loaders.js'
import styles from './Display.module.css'

const alignmentStyle = {
6 changes: 3 additions & 3 deletions src/components/display/edit/EditArea.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { PropTypes } from '@dhis2/prop-types'
import React, { Component } from 'react'
import DisplayAreaHOC from '../../hoc/DisplayAreaHOC'
import JSONEditor from '../../utils/JSONEditor'
import DisplayAreaHOC from '../../hoc/DisplayAreaHOC.js'
import JSONEditor from '../../utils/JSONEditor.js'

Check warning on line 4 in src/components/display/edit/EditArea.js

GitHub Actions / lint / lint

Using exported name 'JSONEditor' as identifier for default export
import styles from '../Display.module.css'

export class EditArea extends Component {
handleDataChange = editor => {
handleDataChange = (editor) => {
try {
// throws error if not valid json
const data = editor.get()
52 changes: 44 additions & 8 deletions src/components/display/edit/EditDisplay.js
Original file line number Diff line number Diff line change
@@ -8,12 +8,17 @@
fetchAndToggleNamespace,
updateValue,
valueChange,
rejectFormat,
rejectUpdateValue,
} from '../../../actions'
import ConfirmNavigationDialog from '../../dialog/ConfirmNavigationDialog'
} from '../../../actions/index.js'
import {
jsonEditorCompact,
jsonEditorFormat,
} from '../../../actions/jsonEditorActions.js'
import ConfirmNavigationDialog from '../../dialog/ConfirmNavigationDialog.js'

Check warning on line 18 in src/components/display/edit/EditDisplay.js

GitHub Actions / lint / lint

Using exported name 'ConfirmNavigationDialog' as identifier for default export
import styles from '../Display.module.css'
import EditArea from './EditArea'
import EditToolbar from './EditToolbar'
import EditArea from './EditArea.js'

Check warning on line 20 in src/components/display/edit/EditDisplay.js

GitHub Actions / lint / lint

Using exported name 'EditArea' as identifier for default export
import EditToolbar from './EditToolbar.js'

/* eslint-disable react/prop-types */
/* eslint-disable react/sort-prop-types */
@@ -25,6 +30,10 @@
this.state = {
valueError: null,
}
this.handleChangeValue = this.handleChangeValue.bind(this)
this.handleFormatValue = this.handleFormatValue.bind(this)
this.handleFormatValueCompact = this.handleFormatValueCompact.bind(this)
this.handleSaveValue = this.handleSaveValue.bind(this)
}

componentDidMount() {
@@ -96,6 +105,22 @@
}
}

handleFormatValue() {
if (this.state.valueError) {
this.props.rejectFormat('Failed to format value: Not valid JSON')
} else {
this.props.jsonFormat()
}
}

handleFormatValueCompact() {
if (this.state.valueError) {
this.props.rejectFormat('Failed to format value: Not valid JSON')
} else {
this.props.jsonCompact()
}
}

render() {
const { namespace, selectedKey } = this.props
let path = ''
@@ -117,13 +142,15 @@
/>
<EditToolbar
path={path}
handleSave={this.handleSaveValue.bind(this)}
handleSave={this.handleSaveValue}
handleFormat={this.handleFormatValue}
handleFormatCompact={this.handleFormatValueCompact}
/>
<EditArea
namespace={namespace}
selectedKey={selectedKey}
value={this.props.value}
valueChange={this.handleChangeValue.bind(this)}
valueChange={this.handleChangeValue}
/>
</Paper>
)
@@ -144,15 +171,15 @@
}),
}

const mapStateToProps = state => ({
const mapStateToProps = (state) => ({
value: state.display.value,
selectedKey: state.display.key,
namespace: state.display.namespace,
editedValue: state.display.editedValue,
fetchedNamespaces: state.sidebar.fetched,
})

const mapDispatchToProps = dispatch => ({
const mapDispatchToProps = (dispatch) => ({
getValue(namespace, key) {
dispatch(fetchAndDisplayKeyValue(namespace, key))
},
@@ -168,6 +195,15 @@
rejectUpdateValue(namespace, key, value, err) {
dispatch(rejectUpdateValue(namespace, key, value, err))
},
rejectFormat(err) {
dispatch(rejectFormat(err))
},
jsonFormat() {
dispatch(jsonEditorFormat())
},
jsonCompact() {
dispatch(jsonEditorCompact())
},
})

export default withRouter(
48 changes: 20 additions & 28 deletions src/components/display/edit/EditToolbar.js
Original file line number Diff line number Diff line change
@@ -3,13 +3,13 @@ import DropDownMenu from 'material-ui/DropDownMenu'
import IconButton from 'material-ui/IconButton'
import MenuItem from 'material-ui/MenuItem'
import Paper from 'material-ui/Paper'
import RedoIcon from 'material-ui/svg-icons/content/redo'
import SaveIcon from 'material-ui/svg-icons/content/save'
import UndoIcon from 'material-ui/svg-icons/content/undo'
import FormatAlignJustifyIcon from 'material-ui/svg-icons/editor/format-align-justify'
import FormatAlignLeftIcon from 'material-ui/svg-icons/editor/format-align-left'
import ExpandLessIcon from 'material-ui/svg-icons/navigation/expand-less'
import ExpandMoreIcon from 'material-ui/svg-icons/navigation/expand-more'
import RedoIcon from 'material-ui/svg-icons/content/redo.js'
import SaveIcon from 'material-ui/svg-icons/content/save.js'
import UndoIcon from 'material-ui/svg-icons/content/undo.js'
import FormatAlignJustifyIcon from 'material-ui/svg-icons/editor/format-align-justify.js'
import FormatAlignLeftIcon from 'material-ui/svg-icons/editor/format-align-left.js'
import ExpandLessIcon from 'material-ui/svg-icons/navigation/expand-less.js'
import ExpandMoreIcon from 'material-ui/svg-icons/navigation/expand-more.js'
import { Toolbar, ToolbarGroup } from 'material-ui/Toolbar'
import React from 'react'
import { connect } from 'react-redux'
@@ -20,13 +20,11 @@ import {
jsonEditorUndo,
jsonEditorRedo,
jsonEditorChangeMode,
jsonEditorCompact,
jsonEditorFormat,
} from '../../../actions/jsonEditorActions'
import { debounce } from '../../../utils/utils'
import JSONSearchBar from '../../utils/JSONSearchBar'
import { Spinner } from '../../utils/Loaders'
import DisplayToolbarTitle from '../DisplayToolbarTitle'
} from '../../../actions/jsonEditorActions.js'
import { debounce } from '../../../utils/utils.js'
import JSONSearchBar from '../../utils/JSONSearchBar.js'
import { Spinner } from '../../utils/Loaders.js'
import DisplayToolbarTitle from '../DisplayToolbarTitle.js'

/* eslint-disable react/sort-prop-types */
/* eslint-disable react/prop-types */
@@ -62,12 +60,12 @@ export class EditToolbar extends React.Component {
this.props.jsonChangeMode(mode)
}

handleJsonSearch = value => {
handleJsonSearch = (value) => {
//debounce search
if (this.state.debounced) {
this.state.debounced(value)
} else {
const debounced = debounce(val => {
const debounced = debounce((val) => {
this.props.jsonSearchAction(val)
}, 250)
this.setState({ ...this.state, debounced })
@@ -167,13 +165,13 @@ export class EditToolbar extends React.Component {
<MenuItem value={'code'} primaryText="Code" />
</DropDownMenu>
<IconButton
onClick={this.props.jsonFormat}
onClick={this.props.handleFormat}
tooltip="Format"
>
<FormatAlignLeftIcon />
</IconButton>
<IconButton
onClick={this.props.jsonCompact}
onClick={this.props.handleFormatCompact}
tooltip="Format Compact"
>
<FormatAlignJustifyIcon />
@@ -199,26 +197,26 @@ export class EditToolbar extends React.Component {
}

EditToolbar.propTypes = {
handleFormat: PropTypes.func,
handleFormatCompact: PropTypes.func,
handleSave: PropTypes.func,
path: PropTypes.string,
mode: PropTypes.string,
jsonCompact: PropTypes.func,
jsonSearchAction: PropTypes.func,
jsonCollapse: PropTypes.func,
jsonExpand: PropTypes.func,
jsonFormat: PropTypes.func,
jsonUndo: PropTypes.func,
jsonRedo: PropTypes.func,
jsonChangeMode: PropTypes.func,
}

const mapStateToProps = state => ({
const mapStateToProps = (state) => ({
mode: state.jsonEditor.mode,
jsonEditor: state.jsonEditor,
saving: state.jsonEditor.saving,
})

const mapDispatchToProps = dispatch => ({
const mapDispatchToProps = (dispatch) => ({
jsonSearchAction(value) {
dispatch(searchJSON(value))
},
@@ -228,12 +226,6 @@ const mapDispatchToProps = dispatch => ({
jsonExpand() {
dispatch(jsonEditorExpand())
},
jsonCompact() {
dispatch(jsonEditorCompact())
},
jsonFormat() {
dispatch(jsonEditorFormat())
},
jsonUndo() {
dispatch(jsonEditorUndo())
},
4 changes: 2 additions & 2 deletions src/components/display/empty/EmptyArea.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component } from 'react'
import DisplayAreaHOC from '../../hoc/DisplayAreaHOC'
import { ModeCommentIconWithText } from '../../utils/Icons'
import DisplayAreaHOC from '../../hoc/DisplayAreaHOC.js'
import { ModeCommentIconWithText } from '../../utils/Icons.js'
import styles from '../Display.module.css'

export class EmptyArea extends Component {
4 changes: 2 additions & 2 deletions src/components/display/empty/EmptyDisplay.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Paper from 'material-ui/Paper'
import React, { Component } from 'react'
import styles from '../Display.module.css'
import EmptyArea from './EmptyArea'
import EmptyToolbar from './EmptyToolbar'
import EmptyArea from './EmptyArea.js'
import EmptyToolbar from './EmptyToolbar.js'

class EmptyDisplay extends Component {
render() {
8 changes: 4 additions & 4 deletions src/components/hoc/DisplayAreaHOC.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { PropTypes } from '@dhis2/prop-types'
import React, { Component } from 'react'
import { connect } from 'react-redux'
import ErrorArea from '../display/ErrorArea'
import LoadingArea from '../display/LoadingArea'
import ErrorArea from '../display/ErrorArea.js'
import LoadingArea from '../display/LoadingArea.js'

const DisplayAreaHOC = Area => {
const DisplayAreaHOC = (Area) => {
class DisplayAreaBase extends Component {
renderLoading = () => {
return <LoadingArea />
@@ -35,7 +35,7 @@ const DisplayAreaHOC = Area => {
loading: PropTypes.bool,
}

const mapStateToProps = state => ({
const mapStateToProps = (state) => ({
loading: state.display.fetching,
error: state.display.error,
errorMessage: state.display.errorMessage,
6 changes: 3 additions & 3 deletions src/components/hoc/SidebarAreaHOC.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { PropTypes } from '@dhis2/prop-types'
import IconButton from 'material-ui/IconButton'
import NavigationRefresh from 'material-ui/svg-icons/navigation/refresh'
import NavigationRefresh from 'material-ui/svg-icons/navigation/refresh.js'
import React, { Component } from 'react'
import { connect } from 'react-redux'
import styles from '../sidebar/Sidebar.module.css'
import { Spinner } from '../utils/Loaders'
import { Spinner } from '../utils/Loaders.js'

const containerStyle = {
alignItems: 'center',
@@ -54,7 +54,7 @@ const SidebarAreaHOC = (Area, errorRefresh) => {
loading: PropTypes.bool,
}

const mapStateToProps = state => ({
const mapStateToProps = (state) => ({
loading: state.sidebar.fetching,
error: state.sidebar.error,
})
7 changes: 3 additions & 4 deletions src/components/sidebar/KeyItem.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { PropTypes } from '@dhis2/prop-types'
import { ListItem } from 'material-ui/List'
import EditorInsertDriveFile from 'material-ui/svg-icons/editor/insert-drive-file'
import EditorInsertDriveFile from 'material-ui/svg-icons/editor/insert-drive-file.js'
import React, { Component } from 'react'
import { hashHistory } from 'react-router'
import { withRouter } from 'react-router'
import KeyItemMenu from './KeyItemMenu'
import { hashHistory, withRouter } from 'react-router'
import KeyItemMenu from './KeyItemMenu.js'

const styles = {
primaryText: {
10 changes: 5 additions & 5 deletions src/components/sidebar/KeyItemMenu.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { PropTypes } from '@dhis2/prop-types'
import IconMenu from 'material-ui/IconMenu'
import MenuItem from 'material-ui/MenuItem'
import Delete from 'material-ui/svg-icons/action/delete'
import Delete from 'material-ui/svg-icons/action/delete.js'
import React, { Component } from 'react'
import { connect } from 'react-redux'
import { openDialog } from '../../actions/dialogActions'
import * as dialog from '../../constants/dialogTypes'
import IconButtonElement from '../utils/IconButtonElement'
import { openDialog } from '../../actions/dialogActions.js'
import * as dialog from '../../constants/dialogTypes.js'
import IconButtonElement from '../utils/IconButtonElement.js'

const anchorOrigin = {
vertical: 'bottom',
@@ -56,7 +56,7 @@ KeyItemMenu.propTypes = {
namespace: PropTypes.string,
}

const mapDispatchToProps = dispatch => ({
const mapDispatchToProps = (dispatch) => ({
deleteKeyInNamespace(namespace, key) {
dispatch(openDialog(dialog.CONFIRM_DELETE_KEY, { namespace, key }))
},
23 changes: 13 additions & 10 deletions src/components/sidebar/NamespaceItem.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { PropTypes } from '@dhis2/prop-types'
import { ListItem } from 'material-ui/List'
import ErrorIcon from 'material-ui/svg-icons/alert/error'
import FileFolder from 'material-ui/svg-icons/file/folder'
import FileFolderOpen from 'material-ui/svg-icons/file/folder-open'
import ErrorIcon from 'material-ui/svg-icons/alert/error.js'
import FileFolderOpen from 'material-ui/svg-icons/file/folder-open.js'
import FileFolder from 'material-ui/svg-icons/file/folder.js'
import React, { Component } from 'react'
import { connect } from 'react-redux'
import { fetchAndToggleNamespace, toggleNamespace } from '../../actions'
import { Spinner } from '../utils/Loaders'
import KeyItem from './KeyItem'
import NamespaceItemMenu from './NamespaceItemMenu'
import {
fetchAndToggleNamespace,
toggleNamespace,
} from '../../actions/index.js'
import { Spinner } from '../utils/Loaders.js'
import KeyItem from './KeyItem.js'
import NamespaceItemMenu from './NamespaceItemMenu.js'

/* eslint-disable react/sort-prop-types */

@@ -44,8 +47,8 @@ export class NamespaceItem extends Component {

// Get a list of elements, filter on search-prop
const list = Object.keys(this.props.namespace.keys)
.filter(key => !search || key.toLowerCase().includes(search))
.map(key => <KeyItem namespace={name} keyName={key} key={key} />)
.filter((key) => !search || key.toLowerCase().includes(search))
.map((key) => <KeyItem namespace={name} keyName={key} key={key} />)

let leftIcon = <Spinner />
if (!fetching) {
@@ -78,7 +81,7 @@ NamespaceItem.propTypes = {
}),
}

const mapDispatchToProps = dispatch => ({
const mapDispatchToProps = (dispatch) => ({
openNamespace(namespace) {
dispatch(fetchAndToggleNamespace(namespace))
},
12 changes: 6 additions & 6 deletions src/components/sidebar/NamespaceItemMenu.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { PropTypes } from '@dhis2/prop-types'
import IconMenu from 'material-ui/IconMenu'
import MenuItem from 'material-ui/MenuItem'
import Delete from 'material-ui/svg-icons/action/delete'
import NoteAdd from 'material-ui/svg-icons/action/note-add'
import Delete from 'material-ui/svg-icons/action/delete.js'
import NoteAdd from 'material-ui/svg-icons/action/note-add.js'
import React, { Component } from 'react'
import { connect } from 'react-redux'
import { openDialog } from '../../actions/dialogActions'
import * as dialog from '../../constants/dialogTypes'
import IconButtonElement from '../utils/IconButtonElement'
import { openDialog } from '../../actions/dialogActions.js'
import * as dialog from '../../constants/dialogTypes.js'
import IconButtonElement from '../utils/IconButtonElement.js'

const anchorOrigin = {
vertical: 'bottom',
@@ -64,7 +64,7 @@ NamespaceItemMenu.propTypes = {
newKey: PropTypes.func,
}

const mapDispatchToProps = dispatch => ({
const mapDispatchToProps = (dispatch) => ({
deleteNamespace(namespace) {
dispatch(openDialog(dialog.CONFIRM_DELETE_NAMESPACE, { namespace }))
},
12 changes: 6 additions & 6 deletions src/components/sidebar/NamespaceList.js
Original file line number Diff line number Diff line change
@@ -2,8 +2,8 @@ import { PropTypes } from '@dhis2/prop-types'
import { List } from 'material-ui/List'
import React, { Component } from 'react'
import { connect } from 'react-redux'
import Theme from '../../utils/theme'
import NamespaceItem from './NamespaceItem'
import Theme from '../../utils/theme.js'
import NamespaceItem from './NamespaceItem.js'

const listStyle = {
overflowY: 'auto',
@@ -15,7 +15,7 @@ const listStyle = {
}

export class NamespaceList extends Component {
filterNamespaces = item => {
filterNamespaces = (item) => {
const searchValue = this.props.search.toLowerCase() || ''
if (!searchValue) {
return true
@@ -51,9 +51,9 @@ export class NamespaceList extends Component {
return (
<List style={listStyle}>
{Object.keys(items)
.filter(item => this.filterNamespaces(item))
.filter((item) => this.filterNamespaces(item))
.sort()
.map(item => (
.map((item) => (
<NamespaceItem
namespace={items[item]}
search={this.filterKeys()}
@@ -70,7 +70,7 @@ NamespaceList.propTypes = {
search: PropTypes.string,
}

const mapStateToProps = state => ({
const mapStateToProps = (state) => ({
search: state.sidebar.searchValue,
})

10 changes: 5 additions & 5 deletions src/components/sidebar/Searchbar.js
Original file line number Diff line number Diff line change
@@ -2,10 +2,10 @@ import { PropTypes } from '@dhis2/prop-types'
import TextField from 'material-ui/TextField'
import React, { Component } from 'react'
import { connect } from 'react-redux'
import { searchSidebarChange } from '../../actions/sidebarActions'
import { searchSidebarChange } from '../../actions/sidebarActions.js'

export class Searchbar extends Component {
handleKeys = event => {
handleKeys = (event) => {
if (event.key === 'Enter') {
this.searchField.blur()
}
@@ -25,21 +25,21 @@ export class Searchbar extends Component {
onChange={({ target: { value } }) => searchChanged(value)}
onFocus={() => searchChanged('')}
onKeyUp={this.handleKeys}
ref={searchField => {
ref={(searchField) => {
this.searchField = searchField
}}
/>
)
}
}

const mapDispatchToProps = dispatch => ({
const mapDispatchToProps = (dispatch) => ({
searchChanged(value) {
dispatch(searchSidebarChange(value))
},
})

const mapStateToProps = state => ({
const mapStateToProps = (state) => ({
searchValue: state.sidebar.searchValue,
})

16 changes: 8 additions & 8 deletions src/components/sidebar/Sidebar.js
Original file line number Diff line number Diff line change
@@ -2,13 +2,13 @@ import { PropTypes } from '@dhis2/prop-types'
import RaisedButton from 'material-ui/RaisedButton'
import React, { Component } from 'react'
import { connect } from 'react-redux'
import { fetchNamespaces } from '../../actions'
import { openDialog } from '../../actions/dialogActions'
import * as dialog from '../../constants/dialogTypes'
import SidebarAreaHOC from '../hoc/SidebarAreaHOC'
import NamespaceList from './NamespaceList'
import { openDialog } from '../../actions/dialogActions.js'
import { fetchNamespaces } from '../../actions/index.js'
import * as dialog from '../../constants/dialogTypes.js'
import SidebarAreaHOC from '../hoc/SidebarAreaHOC.js'
import NamespaceList from './NamespaceList.js'
import styles from './Sidebar.module.css'
import SidebarHeader from './SidebarHeader'
import SidebarHeader from './SidebarHeader.js'

export class Sidebar extends Component {
constructor(props) {
@@ -56,11 +56,11 @@ Sidebar.propTypes = {
openNamespaceDialog: PropTypes.func,
}

const mapStateToProps = state => ({
const mapStateToProps = (state) => ({
items: state.sidebar.namespaces,
})

const mapDispatchToProps = dispatch => ({
const mapDispatchToProps = (dispatch) => ({
openNamespaceDialog() {
dispatch(openDialog(dialog.NEW_NAMESPACE))
},
2 changes: 1 addition & 1 deletion src/components/sidebar/SidebarHeader.js
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import { PropTypes } from '@dhis2/prop-types'
import Paper from 'material-ui/Paper'
import { Toolbar, ToolbarGroup } from 'material-ui/Toolbar'
import React, { Component } from 'react'
import Searchbar from './Searchbar'
import Searchbar from './Searchbar.js'

class SidebarHeader extends Component {
render() {
4 changes: 2 additions & 2 deletions src/components/utils/IconButtonElement.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import IconButton from 'material-ui/IconButton'
import MoreVertIcon from 'material-ui/svg-icons/navigation/more-vert'
import MoreVertIcon from 'material-ui/svg-icons/navigation/more-vert.js'
import React, { Component } from 'react'
import Theme from '../../utils/theme'
import Theme from '../../utils/theme.js'

// This needs to stay as a class as it is passed a ref by a Material UI
// component and functional components do not support refs
4 changes: 2 additions & 2 deletions src/components/utils/Icons.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PropTypes } from '@dhis2/prop-types'
import ErrorIcon from 'material-ui/svg-icons/alert/error'
import ModeComment from 'material-ui/svg-icons/editor/mode-comment'
import ErrorIcon from 'material-ui/svg-icons/alert/error.js'
import ModeComment from 'material-ui/svg-icons/editor/mode-comment.js'
import React, { Component } from 'react'
import styles from '../display/Display.module.css'

16 changes: 8 additions & 8 deletions src/components/utils/JSONEditor.js
Original file line number Diff line number Diff line change
@@ -3,11 +3,11 @@ import { PropTypes } from '@dhis2/prop-types'
import JSEditor from 'jsoneditor/dist/jsoneditor.min.js'
import React, { Component } from 'react'
import { connect } from 'react-redux'
import { openDialog } from '../../actions/dialogActions'
import { jsonEditorChangeMode } from '../../actions/jsonEditorActions'
import * as dialogTypes from '../../constants/dialogTypes'
import { openDialog } from '../../actions/dialogActions.js'
import { jsonEditorChangeMode } from '../../actions/jsonEditorActions.js'
import * as dialogTypes from '../../constants/dialogTypes.js'
import 'jsoneditor/dist/jsoneditor.min.css'
import { sortObjectKeys } from '../../utils/utils'
import { sortObjectKeys } from '../../utils/utils.js'

/* eslint-disable react/prop-types */

@@ -86,7 +86,7 @@ export class JSONEditor extends Component {
}
}

handleJsonEditor = props => {
handleJsonEditor = (props) => {
const {
jsonSearchValue,
collapse,
@@ -165,7 +165,7 @@ export class JSONEditor extends Component {
<div
id="jsoneditor"
style={style}
ref={container => (this.editorContainer = container)}
ref={(container) => (this.editorContainer = container)}
></div>
)
}
@@ -177,11 +177,11 @@ JSONEditor.propTypes = {
value: PropTypes.any,
}

const mapStateToProps = state => ({
const mapStateToProps = (state) => ({
jsonEditor: state.jsonEditor,
})

const mapDispatchToProps = dispatch => ({
const mapDispatchToProps = (dispatch) => ({
jsonChangeMode(mode) {
dispatch(jsonEditorChangeMode(mode))
},
2 changes: 1 addition & 1 deletion src/components/utils/JSONSearchBar.js
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ export class JSONSearchBar extends React.Component {
style={this.props.style}
onKeyUp={this.handleKeys}
underlineStyle={{ maxWidth: '150px' }}
ref={searchField => {
ref={(searchField) => {
this.searchField = searchField
}}
{...fieldProps}
6 changes: 3 additions & 3 deletions src/components/utils/Snackbar.js
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import { PropTypes } from '@dhis2/prop-types'
import SnackbarUI from 'material-ui/Snackbar'
import React, { Component } from 'react'
import { connect } from 'react-redux'
import { emptySnackbar } from '../../actions'
import { emptySnackbar } from '../../actions/index.js'

export class Snackbar extends Component {
render() {
@@ -22,11 +22,11 @@ Snackbar.propTypes = {
message: PropTypes.string,
}

const mapStateToProps = state => ({
const mapStateToProps = (state) => ({
message: state.snackbar.message,
})

const mapDispatchToProps = dispatch => ({
const mapDispatchToProps = (dispatch) => ({
emptySnackbar() {
dispatch(emptySnackbar())
},
2 changes: 2 additions & 0 deletions src/constants/actionTypes.js
Original file line number Diff line number Diff line change
@@ -39,6 +39,8 @@ export const UPDATE_VALUE_FULFILLED = 'UPDATE_VALUE_FULFILLED'
export const UPDATE_VALUE_PENDING = 'UPDATE_VALUE_PENDING'
export const UPDATE_VALUE_REJECTED = 'UPDATE_VALUE_REJECTED'

export const FORMAT_VALUE_REJECTED = 'FORMAT_VALUE_REJECTED'

export const CREATE_VALUE_FULFILLED = 'CREATE_VALUE_FULFILLED'
export const CREATE_VALUE_PENDING = 'CREATE_VALUE_PENDING'
export const CREATE_VALUE_REJECTED = 'CREATE_VALUE_REJECTED'
1 change: 0 additions & 1 deletion src/constants/apiUrls.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/reducers/dialogReducer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as actions from '../constants/actionTypes'
import * as actions from '../constants/actionTypes.js'

const emptyDialog = { dialogType: null }
const initialState = {
4 changes: 2 additions & 2 deletions src/reducers/displayReducer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as actions from '../constants/actionTypes'
import * as jsonEditorActions from '../constants/jsonEditorTypes'
import * as actions from '../constants/actionTypes.js'
import * as jsonEditorActions from '../constants/jsonEditorTypes.js'

const fetchedState = { fetching: false, fetched: true, error: false }
const fetchingState = { fetching: true, fetched: false, error: false }
12 changes: 6 additions & 6 deletions src/reducers/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { combineReducers } from 'redux'
import dialog from './dialogReducer'
import display from './displayReducer'
import jsonEditor from './jsonEditorReducer'
import navigation from './navigationReducer'
import sidebar from './sidebarReducer'
import snackbar from './snackbarReducer'
import dialog from './dialogReducer.js'
import display from './displayReducer.js'
import jsonEditor from './jsonEditorReducer.js'
import navigation from './navigationReducer.js'
import sidebar from './sidebarReducer.js'
import snackbar from './snackbarReducer.js'

export default combineReducers({
display,
4 changes: 2 additions & 2 deletions src/reducers/jsonEditorReducer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as displayActions from '../constants/actionTypes'
import * as actions from '../constants/jsonEditorTypes'
import * as displayActions from '../constants/actionTypes.js'
import * as actions from '../constants/jsonEditorTypes.js'

const initialState = {
mode: 'tree',
2 changes: 1 addition & 1 deletion src/reducers/navigationReducer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as actions from '../constants/actionTypes'
import * as actions from '../constants/actionTypes.js'

const initalState = { ignoreNextConfirm: false }

10 changes: 5 additions & 5 deletions src/reducers/sidebarReducer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as actions from '../constants/actionTypes'
import * as actions from '../constants/actionTypes.js'

const fetchedState = { fetching: false, fetched: true, error: false }
const fetchingState = { fetching: true, fetched: false, error: false }
@@ -15,8 +15,8 @@ const initialState = {
const updateNamespaces = (currentNamespaces, newNamespaces) => {
const namespaces = {}
currentNamespaces
.filter(key => typeof newNamespaces[key] === 'undefined')
.forEach(key => {
.filter((key) => typeof newNamespaces[key] === 'undefined')
.forEach((key) => {
namespaces[key] = {
name: key,
open: false,
@@ -26,9 +26,9 @@ const updateNamespaces = (currentNamespaces, newNamespaces) => {
return namespaces
}

const createKeysFromArray = arrayOfKeys => {
const createKeysFromArray = (arrayOfKeys) => {
const keys = {}
arrayOfKeys.forEach(key => {
arrayOfKeys.forEach((key) => {
keys[key] = {
key,
}
11 changes: 10 additions & 1 deletion src/reducers/snackbarReducer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as actions from '../constants/actionTypes'
import * as actions from '../constants/actionTypes.js'

const emptySnackbar = { snackbarMessage: { message: '' } }
const initialState = {}
@@ -33,6 +33,15 @@ const snackbar = (state = initialState, action) => {
}
}

case actions.FORMAT_VALUE_REJECTED: {
const msg = action.error || 'Failed to format'

return {
...state,
message: msg,
}
}

case actions.FETCH_KEYS_REJECTED: {
return {
...state,
2 changes: 1 addition & 1 deletion src/store/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createStore, applyMiddleware } from 'redux'
import thunk from 'redux-thunk'
import reducers from '../reducers'
import reducers from '../reducers/index.js'

export default createStore(reducers, applyMiddleware(thunk))
22 changes: 8 additions & 14 deletions src/utils/api.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { getInstance } from 'd2'
import { API_URL } from '../constants/apiUrls'

export class Cache {
constructor() {
@@ -46,14 +45,14 @@ class Api {
return d2.dataStore.getAll()
}

deleteNamespace = async namespace => {
deleteNamespace = async (namespace) => {
const d2 = await getInstance()
const response = await d2.dataStore.delete(namespace)
this.cache.clearNamespace(namespace)
return response
}

getKeys = async namespace => {
getKeys = async (namespace) => {
const d2 = await getInstance()
const resName = await d2.dataStore.get(namespace)
return resName.getKeys()
@@ -64,22 +63,17 @@ class Api {
return this.cache.get(namespace, key)
}

const result = await this.getMetaData(namespace, key)
const jsonLength = result.value.length
const d2 = await getInstance()
const dataStore = await d2.dataStore.get(namespace, false)
const res = await dataStore.get(key)
const value = {
length: jsonLength,
value: JSON.parse(result.value),
value: res,
length: JSON.stringify(res).length,
}
this.cache.set(namespace, key, value)
return value
}

getMetaData = async (namespace, key) => {
const d2 = await getInstance()
const response = await d2.dataStore.get(namespace, false)
return response.getMetaData(key)
}

createValue = async (namespace, key, value) => {
const d2 = await getInstance()
const resName = await d2.dataStore.get(namespace, false)
@@ -108,5 +102,5 @@ class Api {
}
}

const apiInstance = new Api(API_URL)
const apiInstance = new Api()
export default apiInstance
2 changes: 1 addition & 1 deletion src/utils/cache.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Cache } from './api'
import { Cache } from './api.js'

describe('Cache', () => {
it('should be possible to set and get namespace/key combinations', () => {
6 changes: 3 additions & 3 deletions src/utils/theme.js
Original file line number Diff line number Diff line change
@@ -9,9 +9,9 @@ import {
white,
darkBlack,
fullBlack,
} from 'material-ui/styles/colors'
import getMuiTheme from 'material-ui/styles/getMuiTheme'
import { fade } from 'material-ui/utils/colorManipulator'
} from 'material-ui/styles/colors.js'
import getMuiTheme from 'material-ui/styles/getMuiTheme.js'
import { fade } from 'material-ui/utils/colorManipulator.js'

export default getMuiTheme({
palette: {
10 changes: 7 additions & 3 deletions src/utils/utils.js
Original file line number Diff line number Diff line change
@@ -5,16 +5,20 @@ export function debounce(func, wait, immediate) {
args = arguments
var later = function () {
timeout = null
if (!immediate) func.apply(context, args)
if (!immediate) {
func.apply(context, args)
}
}
var callNow = immediate && !timeout
clearTimeout(timeout)
timeout = setTimeout(later, wait)
if (callNow) func.apply(context, args)
if (callNow) {
func.apply(context, args)
}
}
}

export const sortObjectKeys = obj => {
export const sortObjectKeys = (obj) => {
if (!obj || typeof obj !== 'object') {
return obj
}
6 changes: 4 additions & 2 deletions src/utils/validation.js
Original file line number Diff line number Diff line change
@@ -10,10 +10,12 @@ export function validateKeyOrNamespace(value) {
message: '',
}

if (!value) return invalid
if (!value) {
return invalid
}

let matchedChar = ''
invalidSymbols.forEach(symb => {
invalidSymbols.forEach((symb) => {
if (value.includes(symb)) {
matchedChar = symb
}
15,306 changes: 7,128 additions & 8,178 deletions yarn.lock

Large diffs are not rendered by default.