Skip to content

Commit

Permalink
Merge pull request #425 from jay-hodgson/PORTALS-2772
Browse files Browse the repository at this point in the history
  • Loading branch information
jay-hodgson authored Aug 22, 2023
2 parents 4ce608a + 48a8353 commit 142a7cc
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
CardConfiguration,
GenericCardSchema,
IconOptions,
SynapseConstants,
} from 'synapse-react-client'
import { peopleSql } from '../resources'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useQueryVisualizationContext } from '../../QueryVisualizationWrapper'
import { Cavatica } from '../../../assets/icons/Cavatica'
import { GetAppTwoTone } from '@mui/icons-material'
import { canTableQueryBeAddedToDownloadList } from '../../../utils/functions/queryUtils'
import { getFileColumnModelId } from '../SynapseTableUtils'

export type RowSelectionControlsProps = {
showExportToCavatica?: boolean
Expand Down Expand Up @@ -39,8 +40,9 @@ export function RowSelectionControls(props: RowSelectionControlsProps) {
remount()
}
}

const showAddToDownloadCart = canTableQueryBeAddedToDownloadList(entity)
const fileColumnId = getFileColumnModelId(data?.columnModels)
const showAddToDownloadCart =
fileColumnId ?? canTableQueryBeAddedToDownloadList(entity)

return (
<RowSelectionUI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ export default function SendToCavaticaConfirmationDialog(
const { data: actions, isLoading } = useGetActionsRequiredForTableQuery(
cavaticaQueryRequest,
data?.columnModels as ColumnModel[],
undefined,
{
useErrorBoundary: true,
enabled: !!data?.columnModels && isShowingExportToCavaticaModal,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { DownloadLoginModal } from './DownloadLoginModal'
import ProgrammaticTableDownload from '../../ProgrammaticTableDownload/ProgrammaticTableDownload'
import { getNumberOfResultsToAddToDownloadListCopy } from '../TopLevelControls/TopLevelControlsUtils'
import { canTableQueryBeAddedToDownloadList } from '../../../utils/functions/queryUtils'
import { getFileColumnModelId } from '../SynapseTableUtils'

export type DownloadOptionsProps = {
onDownloadFiles: () => void
Expand All @@ -35,7 +36,9 @@ export const DownloadOptions: React.FunctionComponent<
React.useState(false)
const { onDownloadFiles, darkTheme = true } = props

const showAddQueryToDownloadList = canTableQueryBeAddedToDownloadList(entity)
const fileColumnId = getFileColumnModelId(queryResultBundle?.columnModels)
const showAddQueryToDownloadList =
fileColumnId ?? canTableQueryBeAddedToDownloadList(entity)

// SWC-5878 - Disable downloading a "Draft" dataset
const disableDownload = entity && isDataset(entity) && entity.isLatestVersion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useQueryContext } from '../QueryContext'
import { useQueryVisualizationContext } from '../QueryVisualizationWrapper'
import { displayFilesWereAddedToDownloadListSuccess } from './DownloadConfirmationUtils'
import { getPrimaryKeyINFilter } from '../../utils/functions/QueryFilterUtils'
import { getFileColumnModelId } from '../SynapseTable/SynapseTableUtils'

export function TableQueryDownloadConfirmation() {
const {
Expand All @@ -26,6 +27,10 @@ export function TableQueryDownloadConfirmation() {
SynapseConstants.BUNDLE_MASK_QUERY_COUNT |
SynapseConstants.BUNDLE_MASK_SUM_FILES_SIZE_BYTES

const fileColumnId = getFileColumnModelId(data?.columnModels)
if (fileColumnId) {
requestCopy.query.selectFileColumn = Number(fileColumnId)
}
if (hasSelectedRows && rowSelectionPrimaryKey && data?.columnModels) {
requestCopy.query.additionalFilters = [
...(requestCopy.query.additionalFilters || []),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { SynapseClientError } from '../../utils/SynapseClientError'
export function useGetActionsRequiredForTableQuery(
queryBundleRequest: QueryBundleRequest,
columnModels: ColumnModel[],
fileColumnModelId?: number,
options?: UseQueryOptions<
AsynchronousJobStatus<QueryBundleRequest, QueryResultBundle>,
SynapseClientError,
Expand All @@ -25,13 +24,13 @@ export function useGetActionsRequiredForTableQuery(
) {
const queryRequestCopy = useMemo(() => {
const request = cloneDeep(queryBundleRequest)
const fileColumnId = fileColumnModelId || getFileColumnModelId(columnModels)
const fileColumnId = getFileColumnModelId(columnModels)
if (fileColumnId) {
request.query.selectFileColumn = Number(fileColumnId)
}
request.partMask = SynapseConstants.BUNDLE_MASK_ACTIONS_REQUIRED
return request
}, [columnModels, fileColumnModelId, queryBundleRequest])
}, [columnModels, queryBundleRequest])

return useGetQueryResultBundleWithAsyncStatus<ActionRequiredCount[]>(
queryRequestCopy,
Expand Down

0 comments on commit 142a7cc

Please sign in to comment.