Skip to content

EDM-4070: Handle non-editable image promotions#685

Open
celdrake wants to merge 1 commit into
flightctl:mainfrom
celdrake:EDM-4070-non-editable-image-promotion
Open

EDM-4070: Handle non-editable image promotions#685
celdrake wants to merge 1 commit into
flightctl:mainfrom
celdrake:EDM-4070-non-editable-image-promotion

Conversation

@celdrake

@celdrake celdrake commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

Image promotions cannot be edited when there are no additional formats from the ImageBuild to select.
Now, when the image promotion cannot be edited and user has the permission to edit IP, we show a disabled reason.

Besides that, there was no "View image promotion" action for viewer users to review the ImagePromotion details.
Now, that action is always avaiable.

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 0944d28b-ecbd-4350-9630-8a8bd5dfb552

📥 Commits

Reviewing files that changed from the base of the PR and between 8987896 and e3cbec2.

📒 Files selected for processing (6)
  • libs/i18n/locales/en/translation.json
  • libs/ui-components/src/components/ImageBuilds/ImageBuildDetails/ImageBuildDetailsTab.tsx
  • libs/ui-components/src/components/ImagePromotion/ImagePromotionForm.tsx
  • libs/ui-components/src/components/ImagePromotion/ImagePromotionFormatsField.tsx
  • libs/ui-components/src/components/ImagePromotion/ImagePromotionModal.tsx
  • libs/ui-components/src/components/ImagePromotion/utils.ts

Summary by CodeRabbit

  • New Features

    • Added ability to view image promotions with dedicated UI
    • Enhanced export format selection management with granular controls
  • Refactor

    • Improved promotion action workflows with unified state management
    • Updated promotion modal to distinguish between view and edit modes based on user permissions
    • Streamlined promotion row action rendering and modal control flow
  • Localization

    • Added new UI messages for promotion states, permission restrictions, and format availability

Walkthrough

This PR adds edit-gating to image promotions, preventing modifications when promotions are publishing, already published, failed, or when all available export formats are already included. The change extracts format selection UI into a dedicated component, refactors the form and modal to respect edit restrictions, and unifies promotion action state in the table component.

Changes

Image Promotion Edit-Gating

Layer / File(s) Summary
Edit-gating utilities and translations
libs/ui-components/src/components/ImagePromotion/utils.ts, libs/i18n/locales/en/translation.json
Introduces canPromotionBeEdited() to check if a promotion can accept new formats, and getPromotionEditDisabledReason() to return localized disable explanations. Adds translation keys for "View image promotion", "No formats selected", and edit-restriction reasons (permissions, publishing/failed/build states, all formats included).
Export formats field component
libs/ui-components/src/components/ImagePromotion/ImagePromotionFormatsField.tsx
New Formik-connected field component that displays export format labels and per-format add/remove buttons; disables toggles during read-only mode and shows an empty-state message when no formats exist.
Form refactoring to use formats field
libs/ui-components/src/components/ImagePromotion/ImagePromotionForm.tsx
Replaces inline format management with ImagePromotionFormatsField, adds canAmendExportFormats prop, narrows Formik context to read-only values, and removes setFieldValue from this file.
Modal read-only vs editable behavior
libs/ui-components/src/components/ImagePromotion/ImagePromotionModal.tsx
Computes canBeEdited using the gating utility; conditionally renders "Edit" vs "View" headers, controls footer button visibility and labels, passes canAmendExportFormats to the form, and handles read-only prop.
Tab unified action state and edit gating
libs/ui-components/src/components/ImageBuilds/ImageBuildDetails/ImageBuildDetailsTab.tsx
Consolidates promotion edit/delete/view state into a single promotionAction object; computes edit-disable reasons for tooltip display; refactors modal rendering to branch on action type; ensures delete and edit operations refetch the promotion list.

Sequence Diagram

sequenceDiagram
  participant User
  participant ImageBuildDetailsTab as Tab
  participant ImagePromotionModal as Modal
  participant PromotionUtils as Utils
  participant ImagePromotionForm as Form
  
  User->>Tab: Click View/Edit/Delete action
  activate Tab
  Tab->>PromotionUtils: getPromotionEditDisabledReason(promotion, formats)
  activate PromotionUtils
  PromotionUtils-->>Tab: Disabled reason or undefined
  deactivate PromotionUtils
  Tab->>Tab: Update promotionAction state
  deactivate Tab
  
  alt Action is Edit
    Tab->>Modal: Open with isEdit=true
    activate Modal
    Modal->>PromotionUtils: canPromotionBeEdited(promotion, formats)
    activate PromotionUtils
    PromotionUtils-->>Modal: true/false
    deactivate PromotionUtils
    Modal->>Modal: Compute canBeEdited, set header & buttons
    Modal->>Form: Pass canAmendExportFormats
    activate Form
    Form-->>Modal: Renders editable/read-only field
    deactivate Form
    deactivate Modal
  else Action is View
    Tab->>Modal: Open with readOnly=true
    activate Modal
    Modal->>Modal: Set canBeEdited=false, show View header
    Modal->>Form: Pass canAmendExportFormats=false
    activate Form
    Form-->>Modal: Renders read-only field
    deactivate Form
    deactivate Modal
  else Action is Delete
    Tab->>Modal: Open delete confirmation
    Modal->>User: Confirm deletion
    User->>Modal: Confirm
    Modal->>Tab: On delete success, refetchPromotions()
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: handling non-editable image promotions, which aligns with the core objective of preventing edits when no additional formats are available.
Description check ✅ Passed The description is directly related to the changeset, explaining the image promotion editability restrictions and the new view action, which corresponds to the changes made across multiple components.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant