-
Notifications
You must be signed in to change notification settings - Fork 698
CONSOLE-4447: Migrate knative-plugin modals to PatternFly 6 #16065
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,17 @@ | ||
| import type { FC } from 'react'; | ||
| import { useCallback, useMemo } from 'react'; | ||
| import { ActionGroup, Button } from '@patternfly/react-core'; | ||
| import { Button, Modal, ModalBody, ModalFooter, ModalHeader } from '@patternfly/react-core'; | ||
| import type { FormikHelpers, FormikValues } from 'formik'; | ||
| import { Formik } from 'formik'; | ||
| import { useTranslation } from 'react-i18next'; | ||
| import { useNavigate } from 'react-router-dom-v5-compat'; | ||
| import type { OverlayComponent } from '@console/dynamic-plugin-sdk/src/app/modal-support/OverlayProvider'; | ||
| import { useOverlay } from '@console/dynamic-plugin-sdk/src/app/modal-support/useOverlay'; | ||
| import type { ModalComponentProps } from '@console/internal/components/factory'; | ||
| import { | ||
| ModalBody, | ||
| ModalFooter, | ||
| ModalTitle, | ||
| ModalWrapper, | ||
| } from '@console/internal/components/factory'; | ||
| import { resourceListPathFromModel } from '@console/internal/components/utils'; | ||
| import { useK8sWatchResources } from '@console/internal/components/utils/k8s-watch-hook'; | ||
| import type { K8sResourceKind } from '@console/internal/module/k8s'; | ||
| import { k8sKill, k8sPatch, referenceForModel } from '@console/internal/module/k8s'; | ||
| import { RedExclamationCircleIcon } from '@console/shared'; | ||
| import { KNATIVE_SERVING_LABEL } from '../../const'; | ||
| import { ConfigurationModel, RevisionModel, ServiceModel } from '../../models'; | ||
| import { getKnativeRevisionsData } from '../../topology/knative-topology-utils'; | ||
|
|
@@ -90,11 +83,15 @@ const DeleteRevisionModalController: FC<DeleteRevisionModalControllerProps> = ({ | |
|
|
||
| if (revisions.length === 0) { | ||
| return ( | ||
| <form className="modal-content" onSubmit={close}> | ||
| <ModalTitle> | ||
| <RedExclamationCircleIcon className="co-icon-space-r" /> | ||
| {t('knative-plugin~Unable to delete {{revlabel}}', { revlabel: RevisionModel.label })} | ||
| </ModalTitle> | ||
| <> | ||
| <ModalHeader | ||
| title={t('knative-plugin~Unable to delete {{revlabel}}', { | ||
| revlabel: RevisionModel.label, | ||
| })} | ||
| titleIconVariant="danger" | ||
| labelId="delete-revision-modal-title" | ||
| data-test-id="modal-title" | ||
| /> | ||
|
Comment on lines
+87
to
+94
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: cd frontend/packages/knative-plugin && find . -name "DeleteRevisionModalController.tsx" -type fRepository: openshift/console Length of output: 121 🏁 Script executed: cat -n frontend/packages/knative-plugin/src/components/revisions/DeleteRevisionModalController.tsx | head -220Repository: openshift/console Length of output: 8718 🌐 Web query:
💡 Result: In PatternFly, a Modal must have an accessible name. The recommended/default way is to set For PatternFly React specifically:
Sources Citations:
🏁 Script executed: cat -n frontend/packages/knative-plugin/src/components/revisions/DeleteRevisionModal.tsx | head -150Repository: openshift/console Length of output: 3479 Add PatternFly's Modal component requires an accessible name via ♿ Fix outline- labelId="unable-delete-revision-modal-title"
+ labelId="delete-revision-modal-title"
@@
- <Modal isOpen onClose={props.closeOverlay} variant="small">
+ <Modal
+ isOpen
+ onClose={props.closeOverlay}
+ variant="small"
+ aria-labelledby="delete-revision-modal-title"
+ >🤖 Prompt for AI Agents |
||
| <ModalBody> | ||
| <p> | ||
| {t('knative-plugin~You cannot delete the last {{revlabel}} for the {{serviceLabel}}.', { | ||
|
|
@@ -103,19 +100,17 @@ const DeleteRevisionModalController: FC<DeleteRevisionModalControllerProps> = ({ | |
| })} | ||
| </p> | ||
| </ModalBody> | ||
| <ModalFooter inProgress={false}> | ||
| <ActionGroup className="pf-v6-c-form pf-v6-c-form__actions--right pf-v6-c-form__group--no-top-margin"> | ||
| <Button | ||
| type="button" | ||
| variant="secondary" | ||
| data-test-id="modal-cancel-action" | ||
| onClick={close} | ||
| > | ||
| {t('knative-plugin~OK')} | ||
| </Button> | ||
| </ActionGroup> | ||
| <ModalFooter> | ||
| <Button | ||
| type="button" | ||
| variant="secondary" | ||
| data-test-id="modal-cancel-action" | ||
| onClick={close} | ||
| > | ||
| {t('knative-plugin~OK')} | ||
| </Button> | ||
| </ModalFooter> | ||
| </form> | ||
| </> | ||
| ); | ||
| } | ||
|
|
||
|
|
@@ -206,13 +201,18 @@ type Props = DeleteRevisionModalControllerProps & ModalComponentProps; | |
|
|
||
| const DeleteRevisionModalProvider: OverlayComponent<Props> = (props) => { | ||
| return ( | ||
| <ModalWrapper blocking onClose={props.closeOverlay}> | ||
| <Modal | ||
| isOpen | ||
| onClose={props.closeOverlay} | ||
| variant="small" | ||
| aria-labelledby="delete-revision-modal-title" | ||
| > | ||
| <DeleteRevisionModalController | ||
| cancel={props.closeOverlay} | ||
| close={props.closeOverlay} | ||
| {...props} | ||
| /> | ||
| </ModalWrapper> | ||
| </Modal> | ||
| ); | ||
| }; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep the confirmation sentence in one translation key.
The three separate
t()calls around the<strong>markers hard-code English word order and punctuation. That won't localize cleanly once translators need to reorderrevision,service, andnamespace. Please switch this paragraph to a singleTransor interpolated message.🤖 Prompt for AI Agents