Skip to content

Commit b0944f7

Browse files
committed
cleanup and fix the non-react path
1 parent 154575e commit b0944f7

File tree

8 files changed

+28
-88
lines changed

8 files changed

+28
-88
lines changed

package-lock.json

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/compass-components/src/components/document-list/document-edit-actions-footer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ const EditActionsFooter: React.FunctionComponent<{
339339
size="xsmall"
340340
onClick={() =>
341341
showErrorDetails({
342-
details: error.details,
342+
details: error.details!,
343343
closeAction: 'close',
344344
})
345345
}

packages/compass-components/src/components/modals/error-details-modal.tsx

Lines changed: 0 additions & 69 deletions
This file was deleted.

packages/compass-components/src/hooks/use-confirmation.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export const ConfirmationModalArea: React.FC = ({ children }) => {
106106
const contextValue = React.useMemo(
107107
() => ({
108108
showConfirmation: (props: ConfirmationProperties) => {
109-
return new Promise((resolve, reject) => {
109+
return new Promise<boolean>((resolve, reject) => {
110110
const event = new CustomEvent<ShowConfirmationEventDetail>(
111111
'show-confirmation',
112112
{

packages/compass-components/src/hooks/use-error-details.tsx

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
1-
import { useConfirmationModal } from './use-confirmation';
1+
import {
2+
type showConfirmation as originalShowConfirmation,
3+
showConfirmation,
4+
useConfirmationModal,
5+
} from './use-confirmation';
26
import { Code } from '../components/leafygreen';
37
import React from 'react';
48

5-
export function useErrorDetailsModal() {
6-
const { showConfirmation } = useConfirmationModal();
7-
8-
const showErrorDetails = ({
9+
const getShowErrorDetails = (
10+
showConfirmation: typeof originalShowConfirmation
11+
) => {
12+
return ({
913
details,
1014
closeAction,
1115
}: {
1216
details: Record<string, unknown>;
1317
closeAction: 'back' | 'close';
1418
}) =>
15-
showConfirmation({
19+
void showConfirmation({
1620
title: 'Error details',
1721
description: (
1822
<Code
@@ -28,6 +32,12 @@ export function useErrorDetailsModal() {
2832
// modalProps
2933
// buttonProps
3034
});
35+
};
3136

32-
return { showErrorDetails };
37+
export function useErrorDetailsModal() {
38+
const { showConfirmation } = useConfirmationModal();
39+
40+
return { showErrorDetails: getShowErrorDetails(showConfirmation) };
3341
}
42+
43+
export const showErrorDetails = getShowErrorDetails(showConfirmation);

packages/compass-components/src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ export { ModalBody } from './components/modals/modal-body';
9292
export { ModalHeader } from './components/modals/modal-header';
9393
export { FormModal } from './components/modals/form-modal';
9494
export { InfoModal } from './components/modals/info-modal';
95-
export { ErrorDetailsModal } from './components/modals/error-details-modal';
9695

9796
export type {
9897
FileInputBackend,
@@ -185,7 +184,6 @@ export {
185184
} from './hooks/use-confirmation';
186185
export {
187186
useErrorDetailsModal,
188-
ErrorDetailsModalArea,
189187
showErrorDetails,
190188
} from './hooks/use-error-details';
191189
export {

packages/compass-crud/src/components/insert-document-dialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ const InsertDocumentDialog: React.FC<InsertDocumentDialogProps> = ({
349349
className={errorDetailsBtnStyles}
350350
onClick={() =>
351351
showErrorDetails({
352-
details: error.info,
352+
details: error.info!,
353353
closeAction: 'back',
354354
})
355355
}

packages/compass-import-export/src/modules/import.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -378,11 +378,14 @@ export const startImport = (): ImportThunkAction<Promise<void>> => {
378378
progressCallback.flush();
379379
const errInfo =
380380
err?.writeErrors?.length && err?.writeErrors[0]?.err?.errInfo;
381-
showFailedToast(err as Error, () =>
382-
showErrorDetails({
383-
details: errInfo,
384-
closeAction: 'close',
385-
})
381+
showFailedToast(
382+
err as Error,
383+
errInfo &&
384+
(() =>
385+
showErrorDetails({
386+
details: errInfo,
387+
closeAction: 'close',
388+
}))
386389
);
387390

388391
dispatch(onFailed(err as Error));

0 commit comments

Comments
 (0)