Skip to content

Commit 086d191

Browse files
author
Artem
committed
import large files
1 parent f4e90e9 commit 086d191

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

redisinsight/ui/src/pages/browser/components/bulk-actions/BulkUpload/BulkUpload.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export interface Props {
3434
onCancel: () => void
3535
}
3636

37-
const MAX_MB_FILE = 100
37+
const MAX_MB_FILE = 3_000
3838
const MAX_FILE_SIZE = MAX_MB_FILE * 1024 * 1024
3939

4040
const BulkUpload = (props: Props) => {

redisinsight/ui/src/slices/browser/bulkActions.ts

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ const bulkActionsSlice = createSlice({
3737
name: 'bulkActions',
3838
initialState,
3939
reducers: {
40-
setBulkActionsInitialState: () => initialState,
40+
setBulkActionsInitialState: (state) => {
41+
state.bulkUpload?.abortController?.abort()
42+
43+
return initialState
44+
},
4145

4246
setBulkDeleteStartAgain: (state) => {
4347
state.bulkDelete = initialState.bulkDelete
@@ -103,9 +107,10 @@ const bulkActionsSlice = createSlice({
103107
state.bulkDelete.loading = false
104108
},
105109

106-
bulkUpload: (state) => {
110+
bulkUpload: (state, { payload }: PayloadAction<{ abortController: AbortController }>) => {
107111
state.bulkUpload.loading = true
108112
state.bulkUpload.error = ''
113+
state.bulkUpload.abortController = payload.abortController
109114
},
110115

111116
bulkUploadSuccess: (state, { payload }: PayloadAction<{ data: IBulkActionOverview, fileName?: string }>) => {
@@ -166,7 +171,9 @@ export function bulkUploadDataAction(
166171
onFailAction?: () => void
167172
) {
168173
return async (dispatch: AppDispatch) => {
169-
dispatch(bulkUpload())
174+
const abortController = new AbortController()
175+
176+
dispatch(bulkUpload({ abortController }))
170177

171178
try {
172179
const { status, data } = await apiService.post(
@@ -179,7 +186,8 @@ export function bulkUploadDataAction(
179186
headers: {
180187
Accept: 'application/json',
181188
'Content-Type': 'multipart/form-data'
182-
}
189+
},
190+
signal: abortController.signal
183191
}
184192
)
185193

@@ -188,10 +196,13 @@ export function bulkUploadDataAction(
188196
onSuccessAction?.()
189197
}
190198
} catch (error) {
191-
const errorMessage = getApiErrorMessage(error as AxiosError)
192-
dispatch(addErrorNotification(error as AxiosError))
193-
dispatch(bulkUploadFailed(errorMessage))
194-
onFailAction?.()
199+
// show error when request wasn't aborted only
200+
if (!abortController.signal.aborted) {
201+
const errorMessage = getApiErrorMessage(error as AxiosError)
202+
dispatch(addErrorNotification(error as AxiosError))
203+
dispatch(bulkUploadFailed(errorMessage))
204+
onFailAction?.()
205+
}
195206
}
196207
}
197208
}

redisinsight/ui/src/slices/interfaces/bulkActions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export interface StateBulkActions {
2323
error: string
2424
overview: Nullable<IBulkActionOverview>
2525
fileName?: string
26+
abortController?: AbortController
2627
}
2728
}
2829

0 commit comments

Comments
 (0)