Skip to content

Commit eff3c47

Browse files
fix(debug-files): Fix modal reload & initialValue issues (#26622)
1 parent c767c65 commit eff3c47

File tree

4 files changed

+28
-18
lines changed

4 files changed

+28
-18
lines changed

static/app/actionCreators/modal.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,10 @@ export type SentryAppDetailsModalOptions = {
196196

197197
type DebugFileSourceModalOptions = {
198198
sourceType: DebugFileSource;
199-
onSave: (data: Record<string, string>) => void;
199+
onSave: (data: Record<string, any>) => void;
200200
appStoreConnectContext?: AppStoreConnectContextProps;
201201
onClose?: () => void;
202-
sourceConfig?: Record<string, string>;
202+
sourceConfig?: Record<string, any>;
203203
};
204204

205205
export async function openDebugFileSourceModal({

static/app/components/modals/debugFileCustomRepository/index.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import FieldFromConfig from 'app/views/settings/components/forms/fieldFromConfig
1212
import Form from 'app/views/settings/components/forms/form';
1313

1414
import AppStoreConnect from './appStoreConnect';
15-
import {getFormFields} from './utils';
15+
import {getFormFields, getInitialData} from './utils';
1616

1717
type AppStoreConnectInitialData = React.ComponentProps<
1818
typeof AppStoreConnect
@@ -27,7 +27,7 @@ type Props = WithRouterProps<RouteParams, {}> & {
2727
/**
2828
* Callback invoked with the updated config value.
2929
*/
30-
onSave: (config: Record<string, string>) => void;
30+
onSave: (config: Record<string, any>) => void;
3131
/**
3232
* Type of this source.
3333
*/
@@ -37,11 +37,10 @@ type Props = WithRouterProps<RouteParams, {}> & {
3737
/**
3838
* The sourceConfig. May be empty to create a new one.
3939
*/
40-
sourceConfig?: Record<string, string>;
41-
} & ModalRenderProps;
40+
sourceConfig?: Record<string, any>;
41+
} & Pick<ModalRenderProps, 'Header' | 'Body' | 'Footer'>;
4242

4343
function DebugFileCustomRepository({
44-
closeModal,
4544
Header,
4645
Body,
4746
Footer,
@@ -52,9 +51,8 @@ function DebugFileCustomRepository({
5251
location,
5352
appStoreConnectContext,
5453
}: Props) {
55-
function handleSave(data: Record<string, string>) {
54+
function handleSave(data: Record<string, any>) {
5655
onSave({...data, type: sourceType});
57-
closeModal();
5856
}
5957

6058
if (sourceType === 'appStoreConnect') {
@@ -74,6 +72,7 @@ function DebugFileCustomRepository({
7472
}
7573

7674
const fields = getFormFields(sourceType);
75+
const initialData = getInitialData(sourceConfig);
7776

7877
return (
7978
<Fragment>
@@ -86,7 +85,7 @@ function DebugFileCustomRepository({
8685
<Form
8786
allowUndo
8887
requireChanges
89-
initialData={sourceConfig}
88+
initialData={initialData}
9089
onSubmit={handleSave}
9190
footerClass="modal-footer"
9291
>

static/app/components/modals/debugFileCustomRepository/utils.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,20 @@ export function getFormFields(type: DebugFileSource) {
212212
commonFields.layoutCasing,
213213
];
214214
default:
215-
return null;
215+
return undefined;
216216
}
217217
}
218+
219+
export function getInitialData(sourceConfig?: Record<string, any>) {
220+
if (!sourceConfig) {
221+
return undefined;
222+
}
223+
224+
if (sourceConfig.layout) {
225+
const {layout, ...initialData} = sourceConfig;
226+
const {casing, type} = layout;
227+
return {...initialData, ['layout.casing']: casing, ['layout.type']: type};
228+
}
229+
230+
return sourceConfig;
231+
}

static/app/views/settings/projectDebugFiles/externalSources/symbolSources.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {Location} from 'history';
55
import omit from 'lodash/omit';
66

77
import {addErrorMessage, addSuccessMessage} from 'app/actionCreators/indicator';
8-
import {openDebugFileSourceModal} from 'app/actionCreators/modal';
8+
import {closeModal, openDebugFileSourceModal} from 'app/actionCreators/modal';
99
import ProjectActions from 'app/actions/projectActions';
1010
import {Client} from 'app/api';
1111
import Feature from 'app/components/acl/feature';
@@ -211,10 +211,7 @@ function SymbolSources({
211211
sourceType: item.type,
212212
appStoreConnectContext,
213213
onSave: updatedData => handleUpdateSymbolSource(updatedData as Item, item.index),
214-
onClose:
215-
sourceConfig && sourceConfig.type === 'appStoreConnect'
216-
? undefined
217-
: handleCloseImageDetailsModal,
214+
onClose: handleCloseImageDetailsModal,
218215
});
219216
}
220217

@@ -263,12 +260,12 @@ function SymbolSources({
263260

264261
ProjectActions.updateSuccess(updatedProjectDetails);
265262
addSuccessMessage(successMessage);
263+
closeModal();
266264
if (updatedItem && updatedItem.type === 'appStoreConnect') {
267-
handleCloseImageDetailsModal();
268265
reloadPage();
269266
}
270267
} catch {
271-
handleCloseImageDetailsModal();
268+
closeModal();
272269
addErrorMessage(errorMessage);
273270
}
274271
}

0 commit comments

Comments
 (0)