Provisioning: Update branch selection (#110389)
This commit is contained in:
+3
-3
@@ -240,7 +240,7 @@ describe('SaveProvisionedDashboardForm', () => {
|
|||||||
|
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(mockAction).toHaveBeenCalledWith({
|
expect(mockAction).toHaveBeenCalledWith({
|
||||||
ref: undefined,
|
ref: 'dashboard/2023-01-01-abcde',
|
||||||
name: 'test-repo',
|
name: 'test-repo',
|
||||||
path: 'test-dashboard.json',
|
path: 'test-dashboard.json',
|
||||||
message: 'Initial commit',
|
message: 'Initial commit',
|
||||||
@@ -296,7 +296,7 @@ describe('SaveProvisionedDashboardForm', () => {
|
|||||||
await user.click(submitButton);
|
await user.click(submitButton);
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(mockAction).toHaveBeenCalledWith({
|
expect(mockAction).toHaveBeenCalledWith({
|
||||||
ref: undefined,
|
ref: 'dashboard/2023-01-01-abcde',
|
||||||
name: 'test-repo',
|
name: 'test-repo',
|
||||||
path: 'test-dashboard.json',
|
path: 'test-dashboard.json',
|
||||||
message: 'Update dashboard',
|
message: 'Update dashboard',
|
||||||
@@ -351,7 +351,7 @@ describe('SaveProvisionedDashboardForm', () => {
|
|||||||
|
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(mockAction).toHaveBeenCalledWith({
|
expect(mockAction).toHaveBeenCalledWith({
|
||||||
ref: undefined,
|
ref: 'dashboard/2023-01-01-abcde',
|
||||||
name: 'test-repo',
|
name: 'test-repo',
|
||||||
path: 'error-dashboard.json',
|
path: 'error-dashboard.json',
|
||||||
message: 'Error commit',
|
message: 'Error commit',
|
||||||
|
|||||||
+5
-4
@@ -136,10 +136,11 @@ export function SaveProvisionedDashboardForm({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If user is writing to the original branch, override ref with whatever we loaded from
|
// TODO: Revisit after we decide on whether to keep the branch selection functionality
|
||||||
if (workflow === 'write') {
|
// If user is updating a dashboard in the original branch, override ref with whatever we loaded from
|
||||||
ref = loadedFromRef;
|
// if (workflow === 'write' && !isNew) {
|
||||||
}
|
// ref = loadedFromRef;
|
||||||
|
// }
|
||||||
|
|
||||||
const message = comment || `Save dashboard: ${dashboard.state.title}`;
|
const message = comment || `Save dashboard: ${dashboard.state.title}`;
|
||||||
|
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ function FormContent({ initialValues, repository, workflowOptions, folder, onDis
|
|||||||
|
|
||||||
<ResourceEditFormSharedFields
|
<ResourceEditFormSharedFields
|
||||||
resourceType="folder"
|
resourceType="folder"
|
||||||
isNew={false}
|
isNew
|
||||||
workflow={workflow}
|
workflow={workflow}
|
||||||
workflowOptions={workflowOptions}
|
workflowOptions={workflowOptions}
|
||||||
repository={repository}
|
repository={repository}
|
||||||
|
|||||||
@@ -41,18 +41,19 @@ export const ResourceEditFormSharedFields = memo<DashboardEditFormSharedFieldsPr
|
|||||||
);
|
);
|
||||||
|
|
||||||
const branchOptions = useMemo(() => {
|
const branchOptions = useMemo(() => {
|
||||||
const options: Array<{ label: string; value: string }> = [];
|
const options: Array<{ label: string; value: string; description?: string }> = [];
|
||||||
|
|
||||||
const configuredBranch = repository?.branch;
|
const configuredBranch = repository?.branch;
|
||||||
const prefix = t(
|
const prefix = t(
|
||||||
'provisioned-resource-form.save-or-delete-resource-shared-fields.suffix-configured-branch',
|
'provisioned-resource-form.save-or-delete-resource-shared-fields.suffix-configured-branch',
|
||||||
'(Configured branch)'
|
'Configured branch'
|
||||||
);
|
);
|
||||||
// Show the configured branch first in the list
|
// Show the configured branch first in the list
|
||||||
if (configuredBranch) {
|
if (configuredBranch) {
|
||||||
options.push({
|
options.push({
|
||||||
label: `${configuredBranch} ${prefix}`,
|
label: `${configuredBranch}`,
|
||||||
value: configuredBranch,
|
value: configuredBranch,
|
||||||
|
description: prefix,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,6 +130,7 @@ export const ResourceEditFormSharedFields = memo<DashboardEditFormSharedFieldsPr
|
|||||||
<RadioButtonGroup
|
<RadioButtonGroup
|
||||||
id="provisioned-resource-form-workflow"
|
id="provisioned-resource-form-workflow"
|
||||||
{...field}
|
{...field}
|
||||||
|
options={workflowOptions}
|
||||||
onChange={(nextWorkflow) => {
|
onChange={(nextWorkflow) => {
|
||||||
onChange(nextWorkflow);
|
onChange(nextWorkflow);
|
||||||
clearErrors('ref');
|
clearErrors('ref');
|
||||||
@@ -138,7 +140,6 @@ export const ResourceEditFormSharedFields = memo<DashboardEditFormSharedFieldsPr
|
|||||||
setValue('ref', repository.branch);
|
setValue('ref', repository.branch);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
options={workflowOptions}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
@@ -178,7 +179,6 @@ export const ResourceEditFormSharedFields = memo<DashboardEditFormSharedFieldsPr
|
|||||||
)}
|
)}
|
||||||
options={branchOptions}
|
options={branchOptions}
|
||||||
loading={branchLoading}
|
loading={branchLoading}
|
||||||
createCustomValue
|
|
||||||
isClearable
|
isClearable
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -11164,7 +11164,7 @@
|
|||||||
"label-workflow": "Workflow",
|
"label-workflow": "Workflow",
|
||||||
"placeholder-branch": "Select or enter branch name",
|
"placeholder-branch": "Select or enter branch name",
|
||||||
"placeholder-new-branch": "Enter new branch name",
|
"placeholder-new-branch": "Enter new branch name",
|
||||||
"suffix-configured-branch": "(Configured branch)"
|
"suffix-configured-branch": "Configured branch"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"provisioned-resource-preview-banner": {
|
"provisioned-resource-preview-banner": {
|
||||||
|
|||||||
Reference in New Issue
Block a user