Skip to content
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: allow sharing embedded dashboards #1674

Merged
merged 1 commit into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions components/sharing-dialog/src/sharing-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
initialSharingSettings = defaultInitialSharingSettings,
dataTest = 'dhis2-uicore-sharingdialog',
dataSharing = false,
cascadeDashboardSharing = true,
}) => {
const { show: showError } = useAlert((error) => error, { critical: true })
const mappedInitialSharingSettings = mapInitialSharingSettings(
Expand Down Expand Up @@ -131,7 +132,7 @@

useEffect(() => {
refetch({ type, id })
}, [type, id])

Check warning on line 135 in components/sharing-dialog/src/sharing-dialog.js

View workflow job for this annotation

GitHub Actions / lint

React Hook useEffect has a missing dependency: 'refetch'. Either include it or remove the dependency array

Check warning on line 135 in components/sharing-dialog/src/sharing-dialog.js

View workflow job for this annotation

GitHub Actions / lint

React Hook useEffect has a missing dependency: 'refetch'. Either include it or remove the dependency array

/**
* Block interaction during the initial load
Expand Down Expand Up @@ -161,6 +162,7 @@
onChange={() => {}}
onRemove={() => {}}
dataSharing={dataSharing}
cascadeDashboardSharing={cascadeDashboardSharing}
/>
</Modal>
</FetchingContext.Provider>
Expand Down Expand Up @@ -224,6 +226,7 @@
onChange={onChange}
onRemove={onRemove}
dataSharing={dataSharing}
cascadeDashboardSharing={cascadeDashboardSharing}
/>
</Modal>
</FetchingContext.Provider>
Expand All @@ -235,6 +238,8 @@
id: PropTypes.string.isRequired,
/** The type of object to share */
type: PropTypes.oneOf(DIALOG_TYPES_LIST).isRequired,
/** Whether to show the tabbed sharing interface for applying cascade sharing of dashboard items */
cascadeDashboardSharing: PropTypes.bool,
/** Whether to expose the ability to set data sharing (in addition to metadata sharing) */
dataSharing: PropTypes.bool,
dataTest: PropTypes.string,
Expand Down
12 changes: 12 additions & 0 deletions components/sharing-dialog/src/sharing-dialog.prod.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,18 @@ ForDashboardWithCascadeSharingPartialSuccess.storyName =
'For dashboard with cascading sharing partial success'
ForDashboardWithCascadeSharingPartialSuccess.args = { type: 'dashboard' }

export const ForDashboardWithoutCascadeSharing = (args) => (
<CustomDataProvider data={{ ...dashboardData }}>
<SharingDialog {...args} />
</CustomDataProvider>
)
ForDashboardWithoutCascadeSharing.storyName =
'For dashboard without cascading sharing (embedded dashboard)'
ForDashboardWithoutCascadeSharing.args = {
type: 'dashboard',
cascadeDashboardSharing: false,
}

export const RTL = (args) => {
useEffect(() => {
document.body.dir = 'rtl'
Expand Down
4 changes: 3 additions & 1 deletion components/sharing-dialog/src/tabs/tabbed-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ export const TabbedContent = ({
onChange,
onRemove,
dataSharing,
cascadeDashboardSharing,
}) => {
const [activeTabIndex, setActiveTabIndex] = useState(0)

if (type === DIALOG_TYPES.DASHBOARD) {
if (type === DIALOG_TYPES.DASHBOARD && cascadeDashboardSharing) {
return (
<>
<TabBar>
Expand Down Expand Up @@ -91,6 +92,7 @@ export const TabbedContent = ({

TabbedContent.propTypes = {
allowPublicAccess: PropTypes.bool.isRequired,
cascadeDashboardSharing: PropTypes.bool.isRequired,
dataSharing: PropTypes.bool.isRequired,
groups: PropTypes.arrayOf(
PropTypes.shape({
Expand Down
1 change: 1 addition & 0 deletions components/sharing-dialog/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export interface SharingDialogProps {
*/
initialSharingSettings?: SharingDialogInitialSharingSettings
dataSharing?: boolean
cascadeDashboardSharing?: boolean
onClose?: ModalOnCloseEventHandler
onError?: (error: any) => void
onSave?: () => void
Expand Down
Loading