Skip to content

Conversation

@nitishagar
Copy link
Contributor

  • Add ATXStateIndicator component to ActionBar
  • Show Power/HDD LED status when ATX extension is active
  • Add popover with Power/Reset buttons for quick access
  • Add confirmation dialogs for power actions to prevent accidents

Note: Long-press support for force power off can be added in a future iteration - the backend already supports "power-long" action.

Fixes #729

- Add ATXStateIndicator component to ActionBar
- Show Power/HDD LED status when ATX extension is active
- Add popover with Power/Reset buttons for quick access
- Add confirmation dialogs for power actions to prevent accidents

Note: Long-press support for force power off can be added in a future
iteration - the backend already supports "power-long" action.

Fixes jetkvm#729
Copy link
Contributor

@IDisposable IDisposable left a comment

Choose a reason for hiding this comment

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

The UI needs a localization pass

import { Button } from "@components/Button";
import { ConfirmDialog } from "@components/ConfirmDialog";
import { cx } from "@/cva.config";
import { JsonRpcResponse, useJsonRpc } from "@/hooks/useJsonRpc";
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be from "@hooks/useJsonRpc"; (note the removed /)... and then sort up above the @components for lint happiness.

const [showResetConfirm, setShowResetConfirm] = useState(false);
const [isActionInProgress, setIsActionInProgress] = useState(false);

const { send } = useJsonRpc(function onRequest(resp) {
Copy link
Contributor

Choose a reason for hiding this comment

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

resp is a placeholder for "response", but this is actually a request, so let's swap these to req please...


// Check if ATX extension is active
useEffect(() => {
send("getActiveExtension", {}, (resp: JsonRpcResponse) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

... this is a response, so this is correct :)

send("getATXState", {}, (resp: JsonRpcResponse) => {
if ("error" in resp) {
notifications.error(
`Failed to get ATX state: ${resp.error.data || "Unknown error"}`,
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to follow the normal localization patterns... see code like this

setIsActionInProgress(false);
if ("error" in resp) {
notifications.error(
`Failed to send ATX power action: ${resp.error.data || "Unknown error"}`,
Copy link
Contributor

Choose a reason for hiding this comment

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

}, [send]);

// Fetch ATX state when extension is active
useEffect(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Doing this useEffect( will cause us to poll for the extension state here in the indicator and in the ATXPowerControl.tsx code... it should be plausible to share that state from stores.ts

variant="warning"
confirmText="Power"
cancelText="Cancel"
onConfirm={() => handlePowerAction("power-short")}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we have two buttons here (long-press or short-press)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make ATX LEDs always visible

2 participants