Skip to content

Commit

Permalink
[Platform]: Moving aotf playground to another component (#363)
Browse files Browse the repository at this point in the history
  • Loading branch information
chinmehta authored Apr 20, 2024
1 parent 99763d6 commit 3df5282
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 63 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { ApiPlaygroundDrawer } from "ui";
import useAotfContext from "./hooks/useAotfContext";

function AotfApiPlayground() {
const {
id,
pagination,
searhFilter,
sorting,
enableIndirect,
dataSourcesWeights,
entity,
dataSourcesRequired,
query,
} = useAotfContext();

const aggregationFilters = dataSourcesRequired.map(({ id, ...obj }) => ({ ...obj }));

const variables = {
id,
index: pagination.pageIndex,
size: pagination.pageSize,
filter: searhFilter,
sortBy: sorting[0].id,
enableIndirect,
datasources: dataSourcesWeights,
entity,
aggregationFilters,
};

return <ApiPlaygroundDrawer query={query.loc.source.body} variables={variables} />;
}
export default AotfApiPlayground;
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ const actions = {
}),
};

function DataDownloader({ fileStem }) {
function DataDownloader() {
const [state, dispatch] = useReducer(reducer, initialState);
const { version } = useConfigContext();
const classes = styles();
Expand All @@ -166,6 +166,7 @@ function DataDownloader({ fileStem }) {
dataSourcesWeights,
dataSourcesRequired,
} = useAotfContext();
const fileStem = `OT-${id}-associated-${entityToGet}s`;
const [onlyPinnedCheckBox, setOnlyPinnedCheckBox] = useState(false);
const [weightControlCheckBox, setWeightControlCheckBox] = useState(modifiedSourcesDataControls);
const [onlyTargetData, setOnlyTargetData] = useState(false);
Expand Down
1 change: 1 addition & 0 deletions apps/platform/src/components/AssociationsToolkit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export { default as TargetPrioritisationSwitch } from "./TargetPrioritisationSwi
export { default as SearhInput } from "./SearchInput";
export { default as DataDownloader } from "./DataDownloader";
export { default as DataUploader } from "./DataUploader/DataUploader";
export { default as AotfApiPlayground } from "./AotfApiPlayground";
export {
default as AssociationsContext,
AssociationsStateProvider as AssociationsProvider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,12 @@ import {
OptionsControlls,
AotFLoader,
DataUploader,
AotfApiPlayground,
} from "../../../components/AssociationsToolkit";
import DISEASE_ASSOCIATIONS_QUERY from "./DiseaseAssociationsQuery.gql";
import { ApiPlaygroundDrawer } from "ui";

function AssociationsWrapper() {
const {
initialLoading,
id,
pagination,
searhFilter,
sorting,
enableIndirect,
dataSourcesWeights,
entity,
dataSourcesRequired,
} = useAotfContext();

const aggregationFilters = dataSourcesRequired.map(({ id, ...obj }) => ({ ...obj }));

const variables = {
id,
index: pagination.pageIndex,
size: pagination.pageSize,
filter: searhFilter,
sortBy: sorting[0].id,
enableIndirect,
datasources: dataSourcesWeights,
entity,
aggregationFilters,
};
const { initialLoading, id } = useAotfContext();

if (initialLoading) return <AotFLoader />;

Expand All @@ -56,11 +32,8 @@ function AssociationsWrapper() {
<DataUploader />
</PrivateWrapper>
<Divider orientation="vertical" />
<DataDownloader fileStem={`OT-${id}-associated-targets`} />
<ApiPlaygroundDrawer
query={DISEASE_ASSOCIATIONS_QUERY.loc.source.body}
variables={variables}
/>
<DataDownloader />
<AotfApiPlayground />
</OptionsControlls>
</Box>
<Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,12 @@ import {
OptionsControlls,
AotFLoader,
DataUploader,
AotfApiPlayground,
} from "../../../components/AssociationsToolkit";
import TARGET_ASSOCIATIONS_QUERY from "./TargetAssociationsQuery.gql";
import { ApiPlaygroundDrawer } from "ui";

function AssociationsWrapper() {
const {
initialLoading,
id,
pagination,
searhFilter,
sorting,
enableIndirect,
dataSourcesWeights,
entity,
dataSourcesRequired,
} = useContext(AssociationsContext);

const aggregationFilters = dataSourcesRequired.map(({ id, ...obj }) => ({ ...obj }));

const variables = {
id,
index: pagination.pageIndex,
size: pagination.pageSize,
filter: searhFilter,
sortBy: sorting[0].id,
enableIndirect,
datasources: dataSourcesWeights,
entity,
aggregationFilters,
};
const { initialLoading, id } = useContext(AssociationsContext);

if (initialLoading) return <AotFLoader />;

Expand All @@ -56,11 +32,8 @@ function AssociationsWrapper() {
<DataUploader />
</PrivateWrapper>
<Divider orientation="vertical" />
<DataDownloader fileStem={`OT-${id}-associated-diseases`} />
<ApiPlaygroundDrawer
query={TARGET_ASSOCIATIONS_QUERY.loc.source.body}
variables={variables}
/>
<DataDownloader />
<AotfApiPlayground />
</OptionsControlls>
</Box>
<Box></Box>
Expand Down

0 comments on commit 3df5282

Please sign in to comment.