-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add DHIS2 Sharing Dialog (TECH-274) #24
Merged
Merged
Changes from 48 commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
758bb10
feat: Add DHIS2 Sharing Dialog
amcgee 4d67257
chore: add PropTypes and mark translatable strings
edoardo 91f6737
fix: fix imports after merging alpha
edoardo 5fd447c
feat: search as you type for user/groups
edoardo 2d8ceb8
fix: pass label for the search input
edoardo dc9fcc1
refactor: use ui components, make it fully reusable
edoardo f3f5040
fix: implement latest design
edoardo c2149d9
fix: add remove for user/groups
edoardo 4938603
fix: implement disabled access select (external/public)
edoardo 1e16f85
refactor: conversion from server response to internal object
edoardo ca0e459
chore: remove debug console logs
edoardo f4fdf0a
chore: cleanup styles
edoardo d3625e6
refactor: implement CRUD operations
edoardo 66d9c78
docs: added more stories for Storybook
edoardo 30ba950
refactor: replace Table components with divs and fix styling
edoardo 3f37669
refactor: use name initials icon for users
edoardo 7cb1297
refactor: use same prop types import for consistency
edoardo 15550cc
fix: use the callback format for error handling
edoardo fcbf226
chore: update deps for using useAlert hook
edoardo f9ca3e5
fix: fix crash when an access string contains data settings
edoardo 6ec315a
refactor: add error handling using useAlert hook
edoardo 1b63d1a
chore: remove unused icon
edoardo bcf4c22
fix: fix icons while waiting for ui-icons to be released
edoardo bf02805
fix: fix i18n.t usage
edoardo 4df6838
test: add basic tests for SharingDialog widget/components
edoardo 2f8d490
chore: fix lint/prettier
edoardo e048b35
chore: remove unused file
edoardo 725b6f9
fix: fix imports
edoardo da68680
fix: prevent access-before-initialisation storybook errors (#414)
HendrikThePendric 3459e65
refactor: use icons from @dhis2/ui-icons
edoardo 3eb8e7b
chore: fix linting errors
edoardo 1b0ada7
fix: make clear the type of access as per latest design
edoardo 919a287
fix: fix wrong boolean default for view and edit access
edoardo 752b641
fix: fix i18n string interpolation
edoardo 82737f2
refactor: improve proptype definition
edoardo da9f35e
fix: fix import
edoardo 2aa4e6c
refactor: move SharingDialog to the new folder structure
edoardo 6d89ba4
fix: use fixed version for @dhis2-ui dependencies
edoardo 4f81b75
refactor: debounce user/group data fetch
edoardo a00b1ea
fix: fix prop types
edoardo efff245
feat: implement cascading sharing for dashboards
edoardo e4251fe
fix: add stories for dashboard cascading sharing
edoardo 374ca57
fix: fix prop types
edoardo 9d91931
fix: minor text correction
edoardo b1f7fcd
feat: implement cascade sharing for dashboard TECH-274
edoardo 1183a5d
test: add stories for dashboard cascade sharing dialog
edoardo 048f44a
chore: update dependencies
edoardo da61dac
chore(deps): dedupe dependencies
varl 122d4e9
test: fix failing test after changes for dashboard cascading sharing
edoardo 70f2196
chore: use the same import format everywhere
edoardo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
> :warning: | ||
> This is currently considered internal, please use `@dhis2/ui`. | ||
> | ||
> See the [Getting started | ||
> guide](https://github.com/dhis2/ui/blob/master/docs/getting-started.md) | ||
> for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
type: 'lib', | ||
entryPoints: { | ||
lib: 'src/index.js', | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: i18next-conv\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=utf-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Plural-Forms: nplurals=2; plural=(n != 1)\n" | ||
"POT-Creation-Date: 2021-08-17T10:24:25.305Z\n" | ||
"PO-Revision-Date: 2021-08-17T10:24:25.305Z\n" | ||
|
||
msgid "Remove access" | ||
msgstr "Remove access" | ||
|
||
msgid "Apply dashboard sharing settings to dashboard items" | ||
msgstr "Apply dashboard sharing settings to dashboard items" | ||
|
||
msgid "" | ||
"All dashboard items will be updated. Users and groups with access to this " | ||
"dashboard will have the same access level for all dashboard items. Public " | ||
"sharing will not be applied to dashboard items. Applying sharing can not be " | ||
"undone, and needs to be performed each time you update a dashboard's " | ||
"sharing settings or items." | ||
msgstr "" | ||
"All dashboard items will be updated. Users and groups with access to this " | ||
"dashboard will have the same access level for all dashboard items. Public " | ||
"sharing will not be applied to dashboard items. Applying sharing can not be " | ||
"undone, and needs to be performed each time you update a dashboard's " | ||
"sharing settings or items." | ||
|
||
msgid "" | ||
"\n" | ||
" {{dashboardItemsCount}} dashboard items will be updated with " | ||
"sharing settings\n" | ||
" from {{usersGroupsCount}} users and groups. Public " | ||
"access is not affected." | ||
msgstr "" | ||
"\n" | ||
" {{dashboardItemsCount}} dashboard items will be updated with " | ||
"sharing settings\n" | ||
" from {{usersGroupsCount}} users and groups. Public " | ||
"access is not affected." | ||
|
||
msgid "" | ||
"There aren't any sharing settings to apply to dashboard items. Public " | ||
"access cannot be applied to items." | ||
msgstr "" | ||
"There aren't any sharing settings to apply to dashboard items. Public " | ||
"access cannot be applied to items." | ||
|
||
msgid "Apply sharing to dashboard items" | ||
msgstr "Apply sharing to dashboard items" | ||
|
||
msgid "Updating sharing settings..." | ||
msgstr "Updating sharing settings..." | ||
|
||
msgid "" | ||
"There was a problem updating dashboard items. No dashboard items were " | ||
"updated. Try again, or contact a system administrator" | ||
msgstr "" | ||
"There was a problem updating dashboard items. No dashboard items were " | ||
"updated. Try again, or contact a system administrator" | ||
|
||
msgid "" | ||
"{{updatedDashboardItemsCount}} dashboard items were updated, but " | ||
"{{ignoredDashboardItemsCount}} could not be updated. Check that you have " | ||
"permission to change sharing for all items." | ||
msgstr "" | ||
"{{updatedDashboardItemsCount}} dashboard items were updated, but " | ||
"{{ignoredDashboardItemsCount}} could not be updated. Check that you have " | ||
"permission to change sharing for all items." | ||
|
||
msgid "" | ||
"Successfully updated sharing for {{updatedDashboardItemsCount}} dashboard " | ||
"items" | ||
msgstr "" | ||
"Successfully updated sharing for {{updatedDashboardItemsCount}} dashboard " | ||
"items" | ||
|
||
msgid "Dashboard sharing" | ||
msgstr "Dashboard sharing" | ||
|
||
msgid "Give access to a user, group or role" | ||
msgstr "Give access to a user, group or role" | ||
|
||
msgid "Search" | ||
msgstr "Search" | ||
|
||
msgid "User, group or role" | ||
msgstr "User, group or role" | ||
|
||
msgid "Access level" | ||
msgstr "Access level" | ||
|
||
msgid "Select a level" | ||
msgstr "Select a level" | ||
|
||
msgid "Give access" | ||
msgstr "Give access" | ||
|
||
msgid "No access" | ||
msgstr "No access" | ||
|
||
msgid "Anyone logged in can view" | ||
msgstr "Anyone logged in can view" | ||
|
||
msgid "Can view" | ||
msgstr "Can view" | ||
|
||
msgid "View only" | ||
msgstr "View only" | ||
|
||
msgid "Anyone logged in can view and edit" | ||
msgstr "Anyone logged in can view and edit" | ||
|
||
msgid "Can view and edit" | ||
msgstr "Can view and edit" | ||
|
||
msgid "View and edit" | ||
msgstr "View and edit" | ||
|
||
msgid "Sharing & Access" | ||
msgstr "Sharing & Access" | ||
|
||
msgid "Close" | ||
msgstr "Close" | ||
|
||
msgid "Metadata" | ||
msgstr "Metadata" | ||
|
||
msgid "Users, groups and roles that currently have access" | ||
msgstr "Users, groups and roles that currently have access" | ||
|
||
msgid "User / Group / Role" | ||
msgstr "User / Group / Role" | ||
|
||
msgid "External users" | ||
msgstr "External users" | ||
|
||
msgid "All users" | ||
msgstr "All users" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
{ | ||
"name": "@dhis2-ui/sharing-dialog", | ||
"version": "6.16.0", | ||
"description": "UI SharingDialog", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/dhis2/ui.git", | ||
"directory": "components/sharing-dialog" | ||
}, | ||
"homepage": "https://github.com/dhis2/ui#readme", | ||
"license": "BSD-3-Clause", | ||
"private": false, | ||
"main": "./build/cjs/index.js", | ||
"module": "./build/es/index.js", | ||
"exports": { | ||
"import": "./build/es/index.js", | ||
"require": "./build/cjs/index.js" | ||
}, | ||
"sideEffects": false, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"scripts": { | ||
"start": "start-storybook -c ../../storybook/config --port 5000", | ||
"build": "d2-app-scripts build" | ||
}, | ||
"peerDependencies": { | ||
"@dhis2/app-runtime": "^2", | ||
"@dhis2/d2-i18n": "^1", | ||
"react": "^16.8", | ||
"react-dom": "^16.8", | ||
"styled-jsx": "^3.2" | ||
}, | ||
"dependencies": { | ||
"@dhis2-ui/button": "6.16.0", | ||
"@dhis2-ui/card": "6.16.0", | ||
"@dhis2-ui/divider": "6.16.0", | ||
"@dhis2-ui/input": "6.16.0", | ||
"@dhis2-ui/layer": "6.16.0", | ||
"@dhis2-ui/loader": "6.16.0", | ||
"@dhis2-ui/menu": "6.16.0", | ||
"@dhis2-ui/modal": "6.16.0", | ||
"@dhis2-ui/notice-box": "6.16.0", | ||
"@dhis2-ui/popper": "6.16.0", | ||
"@dhis2-ui/select": "6.16.0", | ||
"@dhis2-ui/tab": "6.16.0", | ||
"@dhis2/prop-types": "^1.6.4", | ||
"@dhis2/ui-constants": "6.16.0", | ||
"@dhis2/ui-icons": "6.16.0", | ||
"classnames": "^2.3.1", | ||
"prop-types": "^15.7.2" | ||
}, | ||
"files": [ | ||
"build" | ||
], | ||
"devDependencies": { | ||
"@dhis2/app-runtime": "^2.7.1", | ||
"@dhis2/d2-i18n": "^1.1.0", | ||
"react": "16.13", | ||
"react-dom": "16.13", | ||
"styled-jsx": "^3.4.4" | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
components/sharing-dialog/src/__tests__/AccessSelect.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { SingleSelectField } from '@dhis2-ui/select' | ||
import { shallow } from 'enzyme' | ||
import React from 'react' | ||
import { AccessSelect } from '../access-select.js' | ||
import { ACCESS_VIEW_ONLY, ACCESS_VIEW_AND_EDIT } from '../sharing-constants.js' | ||
|
||
describe('SharingDialog widget - AccessSelect component', () => { | ||
let shallowAccessSelectComponent | ||
let props | ||
|
||
const onChange = jest.fn() | ||
|
||
const getAccessSelectComponent = props => { | ||
if (!shallowAccessSelectComponent) { | ||
shallowAccessSelectComponent = shallow(<AccessSelect {...props} />) | ||
} | ||
|
||
return shallowAccessSelectComponent | ||
} | ||
|
||
beforeEach(() => { | ||
shallowAccessSelectComponent = undefined | ||
props = { | ||
access: ACCESS_VIEW_ONLY, | ||
accessOptions: [ACCESS_VIEW_ONLY, ACCESS_VIEW_AND_EDIT], | ||
disabled: false, | ||
label: 'Label', | ||
placeholder: 'Placeholder', | ||
prefix: 'Prefix', | ||
showRemoveOption: false, | ||
onChange, | ||
} | ||
}) | ||
|
||
it('renders a SingleSelectField component ', () => { | ||
expect( | ||
getAccessSelectComponent(props).find(SingleSelectField) | ||
).toHaveLength(1) | ||
}) | ||
}) |
45 changes: 45 additions & 0 deletions
45
components/sharing-dialog/src/__tests__/ShareBlock.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { Button } from '@dhis2-ui/button' | ||
import { shallow } from 'enzyme' | ||
import React from 'react' | ||
import { AccessSelect } from '../access-select.js' | ||
import { Autocomplete } from '../autocomplete/autocomplete.js' | ||
import { ShareBlock } from '../share-block.js' | ||
|
||
describe('SharingDialog widget - ShareBlock component', () => { | ||
let shallowShareBlockComponent | ||
let props | ||
|
||
const onAdd = jest.fn() | ||
|
||
const getShareBlockComponent = props => { | ||
if (!shallowShareBlockComponent) { | ||
shallowShareBlockComponent = shallow(<ShareBlock {...props} />) | ||
} | ||
|
||
return shallowShareBlockComponent | ||
} | ||
|
||
beforeEach(() => { | ||
shallowShareBlockComponent = undefined | ||
props = { | ||
onAdd, | ||
} | ||
}) | ||
|
||
it('renders the Autocomplete component ', () => | ||
expect(getShareBlockComponent(props).find(Autocomplete)).toHaveLength( | ||
1 | ||
)) | ||
|
||
it('renders the AccessSelect component', () => | ||
expect(getShareBlockComponent(props).find(AccessSelect)).toHaveLength( | ||
1 | ||
)) | ||
|
||
it('renders the Give access button', () => { | ||
const button = getShareBlockComponent(props).find(Button) | ||
|
||
expect(button).toHaveLength(1) | ||
expect(button.html()).toMatch('Give access') | ||
}) | ||
}) |
70 changes: 70 additions & 0 deletions
70
components/sharing-dialog/src/__tests__/SharingDialog.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { Button } from '@dhis2-ui/button' | ||
import { Modal, ModalTitle } from '@dhis2-ui/modal' | ||
import { shallow } from 'enzyme' | ||
import React from 'react' | ||
import { ShareBlock } from '../share-block.js' | ||
import { defaultSharingSettings } from '../sharing-constants.js' | ||
import { SharingDialog } from '../sharing-dialog.js' | ||
import { SharingList } from '../sharing-list.js' | ||
|
||
describe('SharingDialog widget', () => { | ||
const onClose = jest.fn() | ||
const onSave = jest.fn() | ||
const onError = jest.fn() | ||
|
||
let shallowSharingDialog | ||
let props | ||
|
||
const getSharingDialogWidget = props => { | ||
if (!shallowSharingDialog) { | ||
shallowSharingDialog = shallow(<SharingDialog {...props} />) | ||
} | ||
|
||
return shallowSharingDialog | ||
} | ||
|
||
beforeEach(() => { | ||
shallowSharingDialog = undefined | ||
props = { | ||
type: 'dashboard', | ||
onClose, | ||
onError, | ||
onSave, | ||
} | ||
}) | ||
|
||
it('renders a Modal', () => | ||
expect(getSharingDialogWidget(props).find(Modal)).toHaveLength(1)) | ||
|
||
it('renders the ModalTitle with the name of the AO if passed in props', () => { | ||
props.initialSharingSettings = { | ||
...defaultSharingSettings, | ||
name: 'test object', | ||
} | ||
|
||
expect(getSharingDialogWidget(props).find(ModalTitle).html()).toMatch( | ||
props.initialSharingSettings.name | ||
) | ||
}) | ||
|
||
it('renders a ShareBlock component', () => | ||
expect(getSharingDialogWidget(props).find(ShareBlock)).toHaveLength(1)) | ||
|
||
it('renders a SharingList component', () => | ||
expect(getSharingDialogWidget(props).find(SharingList)).toHaveLength(1)) | ||
|
||
it('renders a Close button', () => { | ||
const button = getSharingDialogWidget(props).find(Button) | ||
|
||
expect(button).toHaveLength(1) | ||
expect(button.html()).toMatch('Close') | ||
}) | ||
|
||
it('calls the Close callback when the Close button is clicked', () => { | ||
const button = getSharingDialogWidget(props).find(Button) | ||
|
||
button.simulate('click') | ||
|
||
expect(onClose).toHaveBeenCalled() | ||
}) | ||
}) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once ready, this line should be added to the
@dhis2/ui
package, but we can release it inalpha
without exposing it.