-
Notifications
You must be signed in to change notification settings - Fork 699
CONSOLE-5027: Refactor public/ Directory Components to useK8sWatchResource(s) #15954
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 |
|---|---|---|
|
|
@@ -33,7 +33,7 @@ export const useBindingActions = ( | |
| filterActions?: BindingActionCreator[], | ||
| ): Action[] => { | ||
| const { t } = useTranslation(); | ||
| const [model] = useK8sModel(referenceFor(obj)); | ||
| const [model] = useK8sModel(obj ? referenceFor(obj) : null); | ||
| const dispatch = useConsoleDispatch(); | ||
| const startImpersonate = useCallback( | ||
| (kind, name) => dispatch(UIActions.startImpersonate(kind, name)), | ||
|
|
@@ -42,11 +42,11 @@ export const useBindingActions = ( | |
| const navigate = useNavigate(); | ||
| const [commonActions] = useCommonActions(model, obj, [CommonActionCreator.Delete] as const); | ||
|
|
||
| const { subjectIndex, subjects = [] } = obj; | ||
| const { subjectIndex, subjects } = obj ?? {}; | ||
| const subject = subjects?.[subjectIndex]; | ||
| const deleteBindingSubject = useWarningModal({ | ||
| title: t('public~Delete {{label}} subject?', { | ||
|
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. Consider changing “Delete {{label}} subject?” to “Delete {{label}}?” I believe "subject” is internal terminology and, if so, adds no user value. Removing it keeps confirmation clear, consistent w/standard console deletion dialogs. |
||
| label: model.kind, | ||
| label: model?.kind, | ||
|
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. Inconsistent Good safety improvement here, but Either guard consistently throughout, or add an early return when 🛡️ Proposed fix: consistent optional chaining [BindingActionCreator.DuplicateBinding]: () => ({
id: 'duplicate-binding',
label: t('public~Duplicate {{kindLabel}}', {
- kindLabel: model.kind,
+ kindLabel: model?.kind,
}),
cta: {
href: `${decodeURIComponent(
- resourceObjPath(obj, model.kind),
+ resourceObjPath(obj, model?.kind),
)}/copy?subjectIndex=${subjectIndex}`,
},Apply similar changes to lines 116, 120, and 128. 🤖 Prompt for AI Agents |
||
| }), | ||
| children: t('public~Are you sure you want to delete subject {{name}} of type {{kind}}?', { | ||
|
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. Consider changing “Are you sure you want to delete subject {{name}} of type {{kind}}?” to “Are you sure you want to delete {{kind}} {{name}}?” Removes internal term “subject;" improves clarity by using standard console pattern of resource type followed by name. Also reads more naturally/aligns w/other delete confirmations. |
||
| name: subject?.name, | ||
|
|
@@ -96,33 +96,33 @@ export const useBindingActions = ( | |
| [BindingActionCreator.DuplicateBinding]: () => ({ | ||
| id: 'duplicate-binding', | ||
| label: t('public~Duplicate {{kindLabel}}', { | ||
| kindLabel: model.kind, | ||
| kindLabel: model?.kind, | ||
| }), | ||
| cta: { | ||
| href: `${decodeURIComponent( | ||
| resourceObjPath(obj, model.kind), | ||
| resourceObjPath(obj, model?.kind), | ||
| )}/copy?subjectIndex=${subjectIndex}`, | ||
| }, | ||
| // Only perform access checks when duplicating cluster role bindings. | ||
| // It's not practical to check namespace role bindings since we don't know what namespace the user will pick in the form. | ||
| accessReview: obj.metadata?.namespace ? null : asAccessReview(model, obj, 'create'), | ||
| accessReview: obj?.metadata?.namespace ? null : asAccessReview(model, obj, 'create'), | ||
| }), | ||
| [BindingActionCreator.EditBindingSubject]: () => ({ | ||
| id: 'edit-binding-subject', | ||
| label: t('public~Edit {{kindLabel}} subject', { | ||
| kindLabel: model.kind, | ||
| kindLabel: model?.kind, | ||
| }), | ||
| cta: { | ||
| href: `${decodeURIComponent( | ||
| resourceObjPath(obj, model.kind), | ||
| resourceObjPath(obj, model?.kind), | ||
| )}/edit?subjectIndex=${subjectIndex}`, | ||
| }, | ||
| accessReview: asAccessReview(model, obj, 'update'), | ||
| }), | ||
| [BindingActionCreator.DeleteBindingSubject]: () => ({ | ||
| id: 'delete-binding-subject', | ||
| label: t('public~Delete {{label}} subject', { | ||
| label: model.kind, | ||
| label: model?.kind, | ||
| }), | ||
| cta: () => deleteBindingSubject(), | ||
| accessReview: asAccessReview(model, obj, 'patch'), | ||
|
|
@@ -143,9 +143,9 @@ export const useBindingActions = ( | |
| : []), | ||
| factory.DuplicateBinding(), | ||
| factory.EditBindingSubject(), | ||
| ...(subjects.length === 1 ? [commonActions.Delete] : [factory.DeleteBindingSubject()]), | ||
| ...(subjects?.length === 1 ? [commonActions.Delete] : [factory.DeleteBindingSubject()]), | ||
| ]; | ||
| }, [memoizedFilterActions, subject?.kind, factory, subjects.length, commonActions.Delete]); | ||
| }, [memoizedFilterActions, subject?.kind, factory, subjects?.length, commonActions.Delete]); | ||
|
|
||
| return actions; | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,6 +48,7 @@ | |
| "An error occurred. Please try again.": "An error occurred. Please try again.", | ||
|
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. "An error occurred. Please try again." Change to: “An error occurred. Try again.” Remove “Please” to follow console style guidance for direct, action-focused system messages; maintain consistency with other error messaging. |
||
| "Create ServiceAccount": "Create ServiceAccount", | ||
| "An error occurred": "An error occurred", | ||
|
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. This string duplicates the error text above. Confirm whether we need both variants. If not, reuse single shared error message to maintain consistency across UI: either "An error occurred" or "An error occurred. Try again.” Also, GLOBAL: These error messages use inconsistent punctuation. “An error occurred” has no period, while “An error occurred. Try again.” does have one. PatternFly guidance omits periods in brief error titles/short standalone messages. Update to match PatternFly punctuation guidance, keep error messaging consistent. |
||
| "Select service account": "Select service account", | ||
|
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. Confirm this is field label or button. If field label, “Select service account” is correct in sentence case. If button or primary action, it should use title case: “Select Service Account.” |
||
| "Operator Lifecycle Management version 1": "Operator Lifecycle Management version 1", | ||
|
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. Confirm this matches approved product naming/capitalization for Operator Lifecycle Manager v1. |
||
| "Learn more about OLMv1": "Learn more about OLMv1", | ||
|
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. Confirm whether “OLMv1” is approved short form. If not, use official abbreviation or full product name consistently. |
||
| "With OLMv1, you'll get a much simpler API that's easier to work with and understand. Plus, you have more direct control over updates. You can define update ranges and decide exactly how they are rolled out.": "With OLMv1, you'll get a much simpler API that's easier to work with and understand. Plus, you have more direct control over updates. You can define update ranges and decide exactly how they are rolled out.", | ||
|
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. Consider tightening to: “With OLMv1, you get a simpler API that is easier to work with and understand. You also have more direct control over updates and can define update ranges and how they roll out.” This removes conversational phrasing; aligns with direct, task-focused tone used in console informational text. |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -66,7 +66,7 @@ export const ServiceAccountDropdown: FC<ServiceAccountDropdownProps> = ({ | |
| : [] | ||
| } | ||
| desc={ServiceAccountModel.label} | ||
| placeholder={t('public~Select service account')} | ||
|
Contributor
Author
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. Oops from a recent PR change. It is timely to enhance the i18n tests to catch this type of error in CI. |
||
| placeholder={t('olm-v1~Select service account')} | ||
| selectedKey={selectedKey} | ||
| selectedKeyKind={ServiceAccountModel.kind} | ||
| onChange={handleOnChange} | ||
|
|
||
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.
Incomplete null-guard:
objis used before this line.The
obj ?? {}fallback here doesn't protect line 39 wherereferenceFor(obj)is called. Ifobjis nullish during loading states (common in the Firehose → hooks migration), that call will throw before reaching this guard.Consider either:
objis nullish (return empty actions array during loading)obj?: RoleBindingKind | ClusterRoleBindingKindand guarding before line 39🛡️ Proposed fix: early return guard
Then you can revert line 48 to the simpler form since
objis guaranteed defined:🤖 Prompt for AI Agents