Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(machines): Add 'Power cycle' as a feature-flagged action MAASENG-3945 #5566

Merged

Conversation

ndv99
Copy link
Contributor

@ndv99 ndv99 commented Dec 11, 2024

Done

  • Added VITE_APP_DPU_PROVISIONING feature flag to env (default: false)
  • Added "Power cycle" to power action menu
  • Refactored getFormComponent in MachineActionFormWrapper to an object of key-value pairs to reduce complexity*
  • (drive-by) Replaced for loop test for valid ports with a handful of explicit test cases in src/app/utils/isValidPortNumber.test.ts**

QA steps

  • Add VITE_APP_DPU_PROVISIONING = true to your .env.local
  • Go to the machine list and select >= 1 machine
  • Click "Power" in the top menu
  • Ensurer "Power cycle" is shown as an option
  • Click "Power cycle"
  • Ensure a form opens with a heading "Power cycle" and button "Power cycle machine"

Fixes

Resolves MAASENG-3945

Screenshots

image

image

Notes

*Adding another case to the existing switch pushes the function over the complexity limit of 25.
**I decided that this was probably a bit silly, even if it didn't take that long to run.

@webteam-app
Copy link

- Added empty reducer for powerCycle action to machine state slice
Copy link
Collaborator

@tmerten tmerten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QA: singular, plural form and design 👍
Code: 👍

return formComponents[action]();
};

const formComponents = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You just translated the zen of python to JS. Explicit is better than implicit. Looks cleaner albeit being a little more code.

return formComponents[action]();
};

const formComponents = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You just translated the zen of python to JS. Explicit is better than implicit. Looks cleaner albeit being a little more code.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

had some network glitches, sorry for the duplicates

@@ -1,9 +1,13 @@
import { isValidPortNumber } from ".";

it("returns true for any number between 0 and 65535", () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though shall not smuggle in unrelated changes in a PR.
(It's a good change and I can see it won't break things so let's merge it with this one)

return formComponents[action]();
};

const formComponents = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You just translated the zen of python to JS. Explicit is better than implicit. Looks cleaner albeit being a little more code.

@ndv99 ndv99 merged commit 8bd7e81 into canonical:main Dec 13, 2024
8 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants