Skip to content

Commit

Permalink
improve some typing
Browse files Browse the repository at this point in the history
  • Loading branch information
philippotto committed May 13, 2022
1 parent 9eeede6 commit 1016d85
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,19 +116,17 @@ export default function DownloadModalView(props: Props): JSX.Element {
// const layers = chooseSegmentationLayer ? getSegmentationLayers(dataset) : getColorLayers(dataset);
const tracing = useSelector((state: OxalisState) => state.tracing);
const dataset = useSelector((state: OxalisState) => state.dataset);
const [startedExports, setStartedExports] = useState([]);
const [startedExports, setStartedExports] = useState<string[]>([]);
const layers = getDataLayers(dataset);

const isMergerModeEnabled = useSelector(
// @ts-expect-error ts-migrate(2339) FIXME: Property 'temporaryConfiguration' does not exist o... Remove this comment to see the full error message
(state) => state.temporaryConfiguration.isMergerModeEnabled,
(state: OxalisState) => state.temporaryConfiguration.isMergerModeEnabled,
);
const activeMappingInfos = useSelector(
// @ts-expect-error ts-migrate(2339) FIXME: Property 'temporaryConfiguration' does not exist o... Remove this comment to see the full error message
(state) => state.temporaryConfiguration.activeMappingByLayer,
(state: OxalisState) => state.temporaryConfiguration.activeMappingByLayer,
);

const [selectedLayerName, setSelectedLayerName] = useState("");
const [selectedLayerName, setSelectedLayerName] = useState<string | null>(null);
const [selectedBoundingBoxID, setSelectedBoundingBoxId] = useState(-1);

const handleOk = async () => {
Expand All @@ -137,11 +135,11 @@ export default function DownloadModalView(props: Props): JSX.Element {
downloadAnnotation(annotationId, annotationType, hasVolumeFallback, {}, includeVolumeData);
onClose();
} else if (activeTabKey === "export") {
const missingSelection = selectedLayerName === "" || selectedBoundingBoxID === -1;
const missingSelection = selectedLayerName == null || selectedBoundingBoxID === -1;
const basicWarning = "Starting an export job with the chosen parameters was not possible.";
const missingSelectionWarning = " Please choose a layer and a bounding box for export.";

if (missingSelection) {
if (selectedLayerName == null || selectedBoundingBoxID === -1) {
Toast.warning(basicWarning + missingSelectionWarning);
} else {
const selectedLayer = getLayerByName(dataset, selectedLayerName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React, { useState } from "react";
import type { APIDataset, APIDataLayer } from "types/api_flow_types";
import type { BoundingBoxType } from "oxalis/constants";
import { MappingStatusEnum } from "oxalis/constants";
import type { Tracing, AnnotationType, HybridTracing } from "oxalis/store";
import type { OxalisState, Tracing, AnnotationType, HybridTracing } from "oxalis/store";
import { getResolutionInfo, getMappingInfo } from "oxalis/model/accessors/dataset_accessor";
import { getVolumeTracingById } from "oxalis/model/accessors/volumetracing_accessor";
import { startExportTiffJob } from "admin/admin_rest_api";
Expand Down Expand Up @@ -112,11 +112,10 @@ export async function handleStartExport(
dataset: APIDataset,
layerInfos: LayerInfos,
boundingBox: BoundingBoxType,
startedExports: never[],
setStartedExports?: React.Dispatch<React.SetStateAction<never[]>>,
startedExports: string[],
setStartedExports?: React.Dispatch<React.SetStateAction<string[]>>,
) {
if (setStartedExports) {
// @ts-expect-error ts-migrate(2769) FIXME: No overload matches this call.
setStartedExports(startedExports.concat(exportKey(layerInfos)));
}

Expand All @@ -139,22 +138,19 @@ export async function handleStartExport(
}

function ExportBoundingBoxModal({ handleClose, dataset, boundingBox, tracing }: Props) {
const [startedExports, setStartedExports] = useState([]);
const [startedExports, setStartedExports] = useState<string[]>([]);
const isMergerModeEnabled = useSelector(
// @ts-expect-error ts-migrate(2339) FIXME: Property 'temporaryConfiguration' does not exist o... Remove this comment to see the full error message
(state) => state.temporaryConfiguration.isMergerModeEnabled,
(state: OxalisState) => state.temporaryConfiguration.isMergerModeEnabled,
);
const activeMappingInfos = useSelector(
// @ts-expect-error ts-migrate(2339) FIXME: Property 'temporaryConfiguration' does not exist o... Remove this comment to see the full error message
(state) => state.temporaryConfiguration.activeMappingByLayer,
(state: OxalisState) => state.temporaryConfiguration.activeMappingByLayer,
);

const allLayerInfos = dataset.dataSource.dataLayers.map((layer: APIDataLayer) =>
getLayerInfos(layer, tracing, activeMappingInfos, isMergerModeEnabled),
);
const exportButtonsList = allLayerInfos.map((layerInfos) => {
const parenthesesInfos = [
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'string' is not assignable to par... Remove this comment to see the full error message
startedExports.includes(exportKey(layerInfos)) ? "started" : null,
layerInfos.mappingName != null ? `using mapping "${layerInfos.mappingName}"` : null,
!layerInfos.hasMag1 ? "resolution 1 missing" : null,
Expand All @@ -169,7 +165,6 @@ function ExportBoundingBoxModal({ handleClose, dataset, boundingBox, tracing }:
}
disabled={
// The export is already running or...
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'string' is not assignable to par... Remove this comment to see the full error message
startedExports.includes(exportKey(layerInfos)) || // The layer has no mag 1 or...
!layerInfos.hasMag1 || // Merger mode is enabled and this layer is the volume tracing layer.
(isMergerModeEnabled && layerInfos.tracingId != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export function LayerSelection({
tracing: HybridTracing;
fixedLayerName?: string;
layerType?: string;
setSelectedLayerName?: React.Dispatch<React.SetStateAction<string>>;
setSelectedLayerName?: React.Dispatch<React.SetStateAction<string | null>>;
style?: React.CSSProperties;
}): JSX.Element {
const onSelect = setSelectedLayerName
Expand Down

0 comments on commit 1016d85

Please sign in to comment.