Skip to content

Commit

Permalink
refactor: fix sonarcloud issues
Browse files Browse the repository at this point in the history
  • Loading branch information
edoardo committed Dec 2, 2024
1 parent 181fff6 commit 712c24c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 24 deletions.
38 changes: 16 additions & 22 deletions src/components/Item/AppItem/getIframeSrc.js
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
}
}
4 changes: 2 additions & 2 deletions src/components/Item/memoizeOne.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// Inspiration: https://github.com/alexreardon/memoize-one

const memoizeOne = (fn) => {
let lastArgs = undefined
let lastValue = undefined
let lastArgs
let lastValue

return (...args) => {
if (
Expand Down

0 comments on commit 712c24c

Please sign in to comment.