-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move set of DE2 hardcoded "metadata slices" to the backend (#31)
A "metadata slice" is a slice ID that can be used by Data Explorer 2 as a variable in a context or to color points. Previously, there was a hardcoded JSON object on the frontend that described these slices and how they can be used. Now that hardcoded data has been moved to the backend and requested asynchronously. That new async behavior is the first step in making context properties sourced from Breadbox. Eventually the hardcoded data will be removed and a request will be made to Breadbox to discover what types of metadata are available.
- Loading branch information
Showing
12 changed files
with
286 additions
and
193 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
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
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
46 changes: 46 additions & 0 deletions
46
...s/portal-frontend/src/data-explorer-2/components/ContextBuilder/ContextBuilderContext.tsx
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,46 @@ | ||
import React, { createContext, useContext, useEffect, useState } from "react"; | ||
import { fetchMetadataSlices, MetadataSlices } from "@depmap/data-explorer-2"; | ||
|
||
const ContextBuilderContext = createContext({ | ||
metadataSlices: {} as MetadataSlices, | ||
isLoading: false, | ||
}); | ||
|
||
export const useContextBuilderContext = () => { | ||
return useContext(ContextBuilderContext); | ||
}; | ||
|
||
export const ContextBuilderContextProvider = ({ | ||
dimension_type, | ||
children, | ||
}: { | ||
dimension_type: string | undefined; | ||
children: React.ReactNode; | ||
}) => { | ||
const [isLoading, setIsLoading] = useState(true); | ||
const [metadataSlices, setMetadataSlices] = useState<MetadataSlices>({}); | ||
|
||
useEffect(() => { | ||
(async () => { | ||
if (dimension_type) { | ||
setIsLoading(true); | ||
|
||
const slices = await fetchMetadataSlices(dimension_type); | ||
setMetadataSlices(slices); | ||
|
||
setIsLoading(false); | ||
} | ||
})(); | ||
}, [dimension_type]); | ||
|
||
return ( | ||
<ContextBuilderContext.Provider | ||
value={{ | ||
isLoading, | ||
metadataSlices, | ||
}} | ||
> | ||
{children} | ||
</ContextBuilderContext.Provider> | ||
); | ||
}; |
Oops, something went wrong.