Open Bug 1540094 Opened 1 year ago Updated 1 year ago

[remote-dbg-next] SidebarRuntimeItem could take a runtime as prop

Categories

(DevTools :: about:debugging, enhancement, P1)

enhancement

Tracking

(Not tracked)

ASSIGNED

People

(Reporter: jdescottes, Assigned: jdescottes)

References

(Blocks 1 open bug)

Details

(Whiteboard: remote-debugging-technical-debt)

The SidebarRuntimeItem can only render runtimes.

Right now we are not passing a runtime directly as a prop and the parent component has to implement the logic to translate a runtime object to the props expected by SidebarRuntimeItem:

      const keyId = `${runtime.type}-${runtime.id}`;
      const runtimeHasDetails = !!runtime.runtimeDetails;
      const isSelected = selectedPage === PAGE_TYPES.RUNTIME &&
        runtime.id === selectedRuntimeId;

      let name = runtime.name;
      if (runtime.type === RUNTIMES.USB && runtimeHasDetails) {
        // Update the name to be same to the runtime page.
        name = runtime.runtimeDetails.info.name;
      }

      return SidebarRuntimeItem({
        deviceName: runtime.extra.deviceName,
        dispatch,
        icon,
        key: keyId,
        isConnected: runtimeHasDetails,
        isSelected,
        isUnknown: runtime.isUnknown,
        name,
        runtimeId: runtime.id,
      });

link

All this logic could be done in the specialized SidebarRuntimeItem component and we could simply call it as:

      const keyId = `${runtime.type}-${runtime.id}`;
      return SidebarRuntimeItem({
        dispatch,
        key: keyId,
        isSelected,
        runtime,
      });
Priority: -- → P3

Will do some cleanup around runtimes for Bug 1542286, otherwise it gets really hard to follow.

Assignee: nobody → jdescottes
Status: NEW → ASSIGNED
Priority: P3 → P1
Blocks: 1542286
You need to log in before you can comment on or make changes to this bug.