Skip to content

Commit

Permalink
Revert contexts to jsx for now to avoid breaking storybook
Browse files Browse the repository at this point in the history
  • Loading branch information
NickAkhmetov committed Jul 10, 2023
1 parent 94b91f8 commit e489b1f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 23 deletions.
23 changes: 23 additions & 0 deletions context/app/static/js/components/Contexts.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { useContext, createContext } from 'react';

// TODO:
// I tried converting this to a .tsx file, but it made storybook fail; created HMP-250 to track this
// We should continue specifying shapes of contexts as we start using them in our TS files
const FlaskDataContext = createContext({});

/**
* @typedef AppContextType
* @property {string} assetsEndpoint
* @property {string} groupsToken
*/

/**
* @type {AppContextType}
*/
const AppContext = createContext({});

FlaskDataContext.displayName = 'FlaskDataContext';

export { FlaskDataContext, AppContext };
export const useAppContext = () => useContext(AppContext);
export const useFlaskDataContext = () => useContext(FlaskDataContext);
19 changes: 0 additions & 19 deletions context/app/static/js/components/Contexts.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,19 @@ export function usePublicationVignetteConfs({ uuid, vignetteDirName, vignette }:

if (data) {
const urlHandler = (url: string, isZarr: boolean) => {
return `${url.replace('{{ base_url }}', `${assetsEndpoint}/${uuid}/data`)}${isZarr ? '' : `?token=${groupsToken}`}`;
return `${url.replace('{{ base_url }}', `${assetsEndpoint}/${uuid}/data`)}${
isZarr ? '' : `?token=${groupsToken}`
}`;
};

const requestInitHandler = () => {
return {
headers: { Authorization: `Bearer ${groupsToken}` },
};
};
// Formats the vitessce config data to replace the {{ base_url }} placeholder with the actual url.
// TODO: Fix this any; I couldn't figure out how to import the appropriate type from Vitessce.
const formattedData: any[] = data.map(d => fillUrls(d, urlHandler, requestInitHandler));
// TODO: Improve this `unknown`; I couldn't figure out how to import the appropriate `VitessceConfig` type from Vitessce.
const formattedData: unknown[] = data.map((d) => fillUrls(d, urlHandler, requestInitHandler));
return formattedData;
}
return undefined;
Expand Down

0 comments on commit e489b1f

Please sign in to comment.