SaveProvisionedDashboardForm: Bug fix repo type incorrectly showing in preview banner (#113120)

* SaveProvisionedDashboardForm: fix repo type incorrectly showing in preview banner
This commit is contained in:
Yunwen Zheng
2025-10-29 12:14:12 -04:00
committed by GitHub
parent 3bfbbb1961
commit 269c145051
4 changed files with 9 additions and 13 deletions
@@ -86,7 +86,7 @@ export function SaveProvisionedDashboardForm({
);
const navigateToPreview = useCallback(
(ref: string, path: string, repoType: string) => {
(ref: string, path: string, repoType?: string) => {
const url = buildResourceBranchRedirectUrl({
baseUrl: `${PROVISIONING_URL}/${defaultValues.repo}/dashboard/preview/${path}`,
paramName: 'ref',
@@ -110,7 +110,7 @@ export function SaveProvisionedDashboardForm({
}, [dashboard, defaultValues.folder?.uid, drawer, panelEditor, request?.data?.resource]);
const onWriteSuccess = useCallback(
({ repoType }: ProvisionedOperationInfo, upsert: Resource<Dashboard>) => {
(upsert: Resource<Dashboard>) => {
handleDismiss();
if (isNew && upsert?.metadata.name) {
handleNewDashboard(upsert);
@@ -118,7 +118,7 @@ export function SaveProvisionedDashboardForm({
// if pushed to an existing but non-configured branch, navigate to preview page
if (ref !== repository?.branch && ref) {
navigateToPreview(ref, path, repoType);
navigateToPreview(ref, path, repository?.type);
return;
}
@@ -127,7 +127,7 @@ export function SaveProvisionedDashboardForm({
editPanel: null,
});
},
[isNew, path, ref, repository?.branch, handleDismiss, handleNewDashboard, navigateToPreview]
[isNew, path, ref, repository?.branch, repository?.type, handleDismiss, handleNewDashboard, navigateToPreview]
);
const onBranchSuccess = useCallback(
@@ -147,6 +147,7 @@ export function SaveProvisionedDashboardForm({
request,
workflow,
resourceType: 'dashboard',
repository,
handlers: {
onBranchSuccess: ({ ref, path }, info, resource) => onBranchSuccess(ref, path, info, resource),
onWriteSuccess,
@@ -92,7 +92,7 @@ function FormContent({ initialValues, repository, workflowOptions, folder, onDis
handlers: {
onDismiss,
onBranchSuccess,
onWriteSuccess: (_, resource) => onWriteSuccess(resource),
onWriteSuccess,
onError,
},
});
@@ -153,12 +153,7 @@ describe('useProvisionedRequestHandler', () => {
);
expect(handlers.onWriteSuccess).toHaveBeenCalledWith(
expect.objectContaining({
resourceType: 'dashboard',
repoType: 'git',
workflow: 'write',
}),
expect.any(Object)
expect.objectContaining({ kind: 'Dashboard', metadata: expect.objectContaining({ name: 'test-dashboard' }) })
);
expect(handlers.onDismiss).toHaveBeenCalled();
});
@@ -29,7 +29,7 @@ interface RequestHandlers<T> {
info: ProvisionedOperationInfo,
resource: Resource<T>
) => void;
onWriteSuccess?: (info: ProvisionedOperationInfo, resource: Resource<T>) => void;
onWriteSuccess?: (resource: Resource<T>) => void;
onError?: (error: unknown, info: ProvisionedOperationInfo) => void;
onDismiss?: () => void;
}
@@ -116,7 +116,7 @@ export function useProvisionedRequestHandler<T>({
// refetch folder items after success if folderUID is passed in
dispatch(refetchChildren({ parentUID: folderUID || repository?.name, pageSize: PAGE_SIZE }));
}
handlers.onWriteSuccess(info, resourceData);
handlers.onWriteSuccess(resourceData);
}
handlers.onDismiss?.();