-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: fix unit test after refactoring
- Loading branch information
Showing
2 changed files
with
137 additions
and
71 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
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,73 @@ | ||
import PropTypes from 'prop-types' | ||
import React, { useContext, createContext } from 'react' | ||
|
||
export const InstalledAppsCtx = createContext({ | ||
apps: [], | ||
bundledApps: [], | ||
}) | ||
|
||
//const DV_APP_KEY = 'data-visualizer' | ||
//const LL_APP_KEY = 'line-listing' | ||
//const MAPS_APP_KEY = 'maps' | ||
// | ||
//const findAppVersion = (apps, bundledApps, appKey) => | ||
// apps.find((app) => app.key === appKey)?.version || | ||
// bundledApps.find((app) => app.name === appKey)?.version || | ||
// '0.0.0' | ||
|
||
const InstalledAppsProvider = ({ children }) => { | ||
return ( | ||
<InstalledAppsCtx.Provider | ||
value={{ | ||
apps: [ | ||
{ | ||
key: 'app-widget', | ||
name: 'Scorecard', | ||
appType: 'DASHBOARD_WIDGET', | ||
launchUrl: 'https://iframe/app/widget/scorecard', | ||
}, | ||
{ | ||
key: 'app-widget-no-title', | ||
name: 'Scorecard but hide the title', | ||
launchUrl: 'https://iframe/app/widget/scorecard', | ||
appType: 'DASHBOARD_WIDGET', | ||
settings: { | ||
dashboardWidget: { | ||
hideTitle: true, | ||
}, | ||
}, | ||
}, | ||
{ | ||
key: 'dashboard-plugin', | ||
name: 'Dashboard plugin', | ||
appType: 'APP', | ||
pluginLaunchUrl: 'https://plugin/iframe/url', | ||
}, | ||
], | ||
bundledApps: [], | ||
}} | ||
> | ||
{children} | ||
</InstalledAppsCtx.Provider> | ||
) | ||
} | ||
|
||
InstalledAppsProvider.propTypes = { | ||
children: PropTypes.node, | ||
} | ||
|
||
//const useInstalledAppVersion = (key) => { | ||
// const { apps, bundledApps } = useContext(InstalledAppsCtx) | ||
// return findAppVersion(apps, bundledApps, key) | ||
//} | ||
|
||
export default InstalledAppsProvider | ||
|
||
export const useInstalledApps = () => { | ||
const { apps } = useContext(InstalledAppsCtx) | ||
return apps | ||
} | ||
//export const useInstalledDVVersion = () => useInstalledAppVersion(DV_APP_KEY) | ||
//export const useInstalledLLVersion = () => useInstalledAppVersion(LL_APP_KEY) | ||
//export const useInstalledMapsVersion = () => | ||
// useInstalledAppVersion(MAPS_APP_KEY) |