Provisioning: Update branch selection (#110389)

This commit is contained in:
Alex Khomenko 2025-09-02 11:27:33 +03:00 committed by GitHub
parent 13594b2b2e
commit c1c51beee4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 15 additions and 14 deletions

View File

@ -240,7 +240,7 @@ describe('SaveProvisionedDashboardForm', () => {
await waitFor(() => {
expect(mockAction).toHaveBeenCalledWith({
ref: undefined,
ref: 'dashboard/2023-01-01-abcde',
name: 'test-repo',
path: 'test-dashboard.json',
message: 'Initial commit',
@ -296,7 +296,7 @@ describe('SaveProvisionedDashboardForm', () => {
await user.click(submitButton);
await waitFor(() => {
expect(mockAction).toHaveBeenCalledWith({
ref: undefined,
ref: 'dashboard/2023-01-01-abcde',
name: 'test-repo',
path: 'test-dashboard.json',
message: 'Update dashboard',
@ -351,7 +351,7 @@ describe('SaveProvisionedDashboardForm', () => {
await waitFor(() => {
expect(mockAction).toHaveBeenCalledWith({
ref: undefined,
ref: 'dashboard/2023-01-01-abcde',
name: 'test-repo',
path: 'error-dashboard.json',
message: 'Error commit',

View File

@ -136,10 +136,11 @@ export function SaveProvisionedDashboardForm({
return;
}
// If user is writing to the original branch, override ref with whatever we loaded from
if (workflow === 'write') {
ref = loadedFromRef;
}
// TODO: Revisit after we decide on whether to keep the branch selection functionality
// If user is updating a dashboard in the original branch, override ref with whatever we loaded from
// if (workflow === 'write' && !isNew) {
// ref = loadedFromRef;
// }
const message = comment || `Save dashboard: ${dashboard.state.title}`;

View File

@ -162,7 +162,7 @@ function FormContent({ initialValues, repository, workflowOptions, folder, onDis
<ResourceEditFormSharedFields
resourceType="folder"
isNew={false}
isNew
workflow={workflow}
workflowOptions={workflowOptions}
repository={repository}

View File

@ -41,18 +41,19 @@ export const ResourceEditFormSharedFields = memo<DashboardEditFormSharedFieldsPr
);
const branchOptions = useMemo(() => {
const options: Array<{ label: string; value: string }> = [];
const options: Array<{ label: string; value: string; description?: string }> = [];
const configuredBranch = repository?.branch;
const prefix = t(
'provisioned-resource-form.save-or-delete-resource-shared-fields.suffix-configured-branch',
'(Configured branch)'
'Configured branch'
);
// Show the configured branch first in the list
if (configuredBranch) {
options.push({
label: `${configuredBranch} ${prefix}`,
label: `${configuredBranch}`,
value: configuredBranch,
description: prefix,
});
}
@ -129,6 +130,7 @@ export const ResourceEditFormSharedFields = memo<DashboardEditFormSharedFieldsPr
<RadioButtonGroup
id="provisioned-resource-form-workflow"
{...field}
options={workflowOptions}
onChange={(nextWorkflow) => {
onChange(nextWorkflow);
clearErrors('ref');
@ -138,7 +140,6 @@ export const ResourceEditFormSharedFields = memo<DashboardEditFormSharedFieldsPr
setValue('ref', repository.branch);
}
}}
options={workflowOptions}
/>
)}
/>
@ -178,7 +179,6 @@ export const ResourceEditFormSharedFields = memo<DashboardEditFormSharedFieldsPr
)}
options={branchOptions}
loading={branchLoading}
createCustomValue
isClearable
/>
) : (

View File

@ -11164,7 +11164,7 @@
"label-workflow": "Workflow",
"placeholder-branch": "Select or enter branch name",
"placeholder-new-branch": "Enter new branch name",
"suffix-configured-branch": "(Configured branch)"
"suffix-configured-branch": "Configured branch"
}
},
"provisioned-resource-preview-banner": {