Skip to content

Commit 5aff9f7

Browse files
Ay1man2GitHub Enterprise
authored andcommitted
Issue 1920: reset image selection when renaming existing power workspaces (#1921)
* added logic to reset images when existing power workspace name changed * prettier formatting * removed unused import * removed craig from describe * remove disabled, clear images on name change * added componentdidupdate for name change * prettier formatting * updated changelog * moved changelog to latest version
1 parent 62a51bb commit 5aff9f7

File tree

6 files changed

+37
-4
lines changed

6 files changed

+37
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ All notable changes to this project will be documented in this file.
2020
- Fixed an issue causing Cloud Services with missing values not to be highlighed red on the `/v2/services` page
2121
- The Power VS POC Template Activity Tracker COS instance now correctly uses a random suffix to ensure unique resource naming
2222
- Fixed an issue causing imported VPC Security Groups to fail on Terraform Plan
23+
- Power VS Images are now reset when changing zones or changing the name of an existing workspace
2324

2425
## 1.15.5
2526

client/src/components/forms/dynamic-form/DynamicFetchMultiSelect.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,12 @@ class DynamicFetchMultiSelect extends React.Component {
4343
this._isMounted = false;
4444
}
4545

46-
// Force re-fetch of images on zone change
46+
// Force re-fetch of images on name or zone change
4747
componentDidUpdate(prevProps) {
48-
if (prevProps.parentState.zone != this.props.parentState.zone) {
48+
if (
49+
prevProps.parentState.zone != this.props.parentState.zone ||
50+
prevProps.parentState.name != this.props.parentState.name
51+
) {
4952
this._isMounted = false;
5053
this.setState({ data: ["Loading..."] }, () => {
5154
this.componentDidMount();

client/src/lib/docs/release-notes.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"Fixed an issue in the Power VS POC template where the LogDNA files were written to the AIX save files COS bucket",
1111
"Fixed an issue causing Cloud Services with missing values not to be highlighed red on the `/v2/services` page",
1212
"The Power VS POC Template Activity Tracker COS instance now correctly uses a random suffix to ensure unique resource naming",
13-
"Fixed an issue causing imported VPC Security Groups to fail on Terraform Plan"
13+
"Fixed an issue causing imported VPC Security Groups to fail on Terraform Plan",
14+
"Power VS Images are now reset when changing zones or changing the name of an existing workspace"
1415
],
1516
"upgrade_notes": [
1617
"Updated the VPN as a Service template's default authentication method and changed the Secrets Manager to the Trial plan"

client/src/lib/state/power-vs/power-vs-workspace-schema.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ function powerVsWorkspaceSchema() {
2828
? stateData.name
2929
: `${componentProps.craig.store.json._options.prefix}-power-workspace-${stateData.name}`;
3030
},
31+
onStateChange: function (stateData) {
32+
if (stateData.use_data) {
33+
stateData.imageNames = [];
34+
stateData.images = [];
35+
}
36+
},
3137
}),
3238
resource_group: resourceGroupsField(),
3339
zone: {

client/src/lib/state/reusable-fields.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,7 @@ function nameField(jsonField, options) {
529529
readOnly: options?.readOnly,
530530
tooltip: options?.tooltip,
531531
disabledText: options?.invalidText,
532+
onStateChange: options?.onStateChange,
532533
};
533534
}
534535

unit-tests/state/power-vs.test.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ describe("power-vs", () => {
440440
});
441441
});
442442
describe("power.schema", () => {
443-
describe("craig.power.name.helperText", () => {
443+
describe("power.name.helperText", () => {
444444
it("should return correct helper text for name when use data", () => {
445445
assert.deepEqual(
446446
craig.power.name.helperText({ use_data: true, name: "name" }),
@@ -469,6 +469,27 @@ describe("power-vs", () => {
469469
);
470470
});
471471
});
472+
describe("power.name.onStateChange", () => {
473+
it("should clear images when changing name of imported workspace", () => {
474+
let data = { use_data: true };
475+
let expectedData = {
476+
use_data: true,
477+
imageNames: [],
478+
images: [],
479+
};
480+
craig.power.name.onStateChange(data);
481+
assert.deepEqual(data, expectedData, "it should clear images");
482+
});
483+
it("should not clear images when changing name of CRAIG created workspace", () => {
484+
let data = { use_data: false, imageNames: ["testImage"] };
485+
let expectedData = {
486+
use_data: false,
487+
imageNames: ["testImage"],
488+
};
489+
craig.power.name.onStateChange(data);
490+
assert.deepEqual(data, expectedData, "it should not clear images");
491+
});
492+
});
472493
describe("power.zone", () => {
473494
describe("power.zone.onStateChange", () => {
474495
it("should set images when changing zone", () => {

0 commit comments

Comments
 (0)