Skip to content

Commit

Permalink
feat(sharing-dialog): allow sharing dashboards without cascading shar…
Browse files Browse the repository at this point in the history
…ing (#1674)
  • Loading branch information
HendrikThePendric authored Feb 26, 2025
1 parent d68c85c commit 18af4f7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
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 @@ export const SharingDialog = ({
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 @@ -161,6 +162,7 @@ export const SharingDialog = ({
onChange={() => {}}
onRemove={() => {}}
dataSharing={dataSharing}
cascadeDashboardSharing={cascadeDashboardSharing}
/>
</Modal>
</FetchingContext.Provider>
Expand Down Expand Up @@ -224,6 +226,7 @@ export const SharingDialog = ({
onChange={onChange}
onRemove={onRemove}
dataSharing={dataSharing}
cascadeDashboardSharing={cascadeDashboardSharing}
/>
</Modal>
</FetchingContext.Provider>
Expand All @@ -235,6 +238,8 @@ SharingDialog.propTypes = {
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

0 comments on commit 18af4f7

Please sign in to comment.