-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
18 additions
and
24 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,27 @@ | ||
import { FILTER_ORG_UNIT } from '../../../actions/itemFilters.js' | ||
import { getPluginOverrides } from '../../../modules/localStorage.js' | ||
|
||
export const getIframeSrc = (appDetails = {}, item, itemFilters) => { | ||
switch (appDetails.appType) { | ||
case 'APP': { | ||
// check if there is an override for the plugin | ||
const pluginOverrides = getPluginOverrides() | ||
export const getIframeSrc = (item, itemFilters, appDetails = {}) => { | ||
if (appDetails.appType === 'APP') { | ||
// check if there is an override for the plugin | ||
const pluginOverrides = getPluginOverrides() | ||
|
||
if (pluginOverrides && pluginOverrides[appDetails.key]) { | ||
return pluginOverrides[appDetails.key] | ||
} | ||
|
||
return appDetails.pluginLaunchUrl | ||
if (pluginOverrides?.[appDetails.key]) { | ||
return pluginOverrides[appDetails.key] | ||
} | ||
default: { | ||
let iframeSrc = `${appDetails.launchUrl}?dashboardItemId=${item.id}` | ||
|
||
if ( | ||
itemFilters[FILTER_ORG_UNIT] && | ||
itemFilters[FILTER_ORG_UNIT].length | ||
) { | ||
const ouIds = itemFilters[FILTER_ORG_UNIT].map(({ id, path }) => | ||
path ? path.split('/').slice(-1)[0] : id | ||
) | ||
return appDetails.pluginLaunchUrl | ||
} else { | ||
let iframeSrc = `${appDetails.launchUrl}?dashboardItemId=${item.id}` | ||
|
||
iframeSrc += `&userOrgUnit=${ouIds.join(',')}` | ||
} | ||
if (itemFilters[FILTER_ORG_UNIT]?.length) { | ||
const ouIds = itemFilters[FILTER_ORG_UNIT].map(({ id, path }) => | ||
path ? path.split('/').slice(-1)[0] : id | ||
) | ||
|
||
return iframeSrc | ||
iframeSrc += `&userOrgUnit=${ouIds.join(',')}` | ||
} | ||
|
||
return iframeSrc | ||
} | ||
} |
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