-
Notifications
You must be signed in to change notification settings - Fork 674
CONSOLE-5030 Refactor remaining firehose impacted components #16039
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
base: main
Are you sure you want to change the base?
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 |
|---|---|---|
|
|
@@ -15,9 +15,7 @@ import type { | |
| RowFunctionArgs, | ||
| } from '@console/internal/components/factory'; | ||
| import { DetailsPage, Table, TableData, MultiListPage } from '@console/internal/components/factory'; | ||
| import type { FirehoseResult } from '@console/internal/components/utils'; | ||
| import { | ||
| Firehose, | ||
| LoadingBox, | ||
| ConsoleEmptyState, | ||
| navFactory, | ||
|
|
@@ -27,6 +25,7 @@ import { | |
| ResourceSummary, | ||
| DetailsItem, | ||
| } from '@console/internal/components/utils'; | ||
| import { useK8sWatchResources } from '@console/internal/components/utils/k8s-watch-hook'; | ||
| import i18n from '@console/internal/i18n'; | ||
| import { ConfigMapModel } from '@console/internal/models'; | ||
| import type { K8sKind, K8sModel } from '@console/internal/module/k8s'; | ||
|
|
@@ -213,12 +212,30 @@ export const CatalogSourceDetailsPage: FC = (props) => { | |
|
|
||
| export const CreateSubscriptionYAML: FC = (props) => { | ||
| type CreateProps = { | ||
| packageManifest: { loaded: boolean; data?: PackageManifestKind }; | ||
| operatorGroup: { loaded: boolean; data?: OperatorGroupKind[] }; | ||
| packageManifest: { loaded: boolean; data?: PackageManifestKind; loadError?: unknown }; | ||
| operatorGroup: { loaded: boolean; data?: OperatorGroupKind[]; loadError?: unknown }; | ||
| }; | ||
| const { t } = useTranslation(); | ||
| const params = useParams(); | ||
| const location = useLocation(); | ||
|
|
||
| const resources = useK8sWatchResources<{ | ||
| packageManifest: PackageManifestKind; | ||
| operatorGroup: OperatorGroupKind[]; | ||
| }>({ | ||
| packageManifest: { | ||
| kind: referenceForModel(PackageManifestModel), | ||
| isList: false, | ||
| name: new URLSearchParams(location.search).get('pkg'), | ||
| namespace: new URLSearchParams(location.search).get('catalogNamespace'), | ||
|
Comment on lines
+229
to
+230
Member
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. feels like we should use useSearchParams
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. Not new, and appears to be out of scope for this work. We can open a ticket if this cleanup is required. |
||
| }, | ||
| operatorGroup: { | ||
| kind: referenceForModel(OperatorGroupModel), | ||
| isList: true, | ||
| namespace: params.ns, | ||
| }, | ||
| }); | ||
|
|
||
| const Create = requireOperatorGroup( | ||
| withFallback<CreateProps>( | ||
| (createProps) => { | ||
|
|
@@ -256,26 +273,11 @@ export const CreateSubscriptionYAML: FC = (props) => { | |
| ); | ||
|
|
||
| return ( | ||
| <Firehose | ||
| resources={[ | ||
| { | ||
| kind: referenceForModel(PackageManifestModel), | ||
| isList: false, | ||
| name: new URLSearchParams(location.search).get('pkg'), | ||
| namespace: new URLSearchParams(location.search).get('catalogNamespace'), | ||
| prop: 'packageManifest', | ||
| }, | ||
| { | ||
| kind: referenceForModel(OperatorGroupModel), | ||
| isList: true, | ||
| namespace: params.ns, | ||
| prop: 'operatorGroup', | ||
| }, | ||
| ]} | ||
| > | ||
| {/* FIXME(alecmerdler): Hack because `Firehose` injects props without TypeScript knowing about it */} | ||
| <Create {...(props as any)} /> | ||
| </Firehose> | ||
| <Create | ||
| {...(props as any)} | ||
| packageManifest={resources.packageManifest} | ||
| operatorGroup={resources.operatorGroup} | ||
| /> | ||
| ); | ||
| }; | ||
|
|
||
|
|
@@ -546,8 +548,8 @@ type DisabledPopoverProps = { | |
| }; | ||
|
|
||
| type FlattenArgType = { | ||
| catalogSources?: FirehoseResult<CatalogSourceKind[]>; | ||
| packageManifests?: FirehoseResult<PackageManifestKind[]>; | ||
| catalogSources?: { data?: CatalogSourceKind[]; loaded?: boolean; loadError?: unknown }; | ||
| packageManifests?: { data?: PackageManifestKind[]; loaded?: boolean; loadError?: unknown }; | ||
| operatorHub: OperatorHubKind; | ||
| }; | ||
|
|
||
|
|
||
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.
I'd prefer using the
Errortype here to avoid verbose type guard forunknownwhen accessing.messagein theloadError.Or casting it:
error={(loadError as Error).message}.