@@ -15,16 +15,13 @@ import { formatDateAsTimeAgo } from '../../utils/i18n/timeAgo';
1515
1616import { YamlViewButton } from '../Yaml/YamlViewButton.tsx' ;
1717
18- import { Fragment , useCallback , useContext , useMemo , useRef } from 'react' ;
18+ import { Fragment , useCallback , useMemo , useRef } from 'react' ;
1919import { Resource } from '../../utils/removeManagedFieldsAndFilterData.ts' ;
2020import { ProviderConfigItem } from '../../lib/shared/types.ts' ;
2121import { ProviderConfigsRowActionsMenu } from './ProviderConfigsActionMenu.tsx' ;
2222import { useSplitter } from '../Splitter/SplitterContext.tsx' ;
2323import { YamlSidePanel } from '../Yaml/YamlSidePanel.tsx' ;
24- import { handleResourcePatch } from '../../lib/api/types/crossplane/handleResourcePatch.ts' ;
25- import { useToast } from '../../context/ToastContext.tsx' ;
26- import { useResourcePluralNames } from '../../hooks/useResourcePluralNames' ;
27- import { ApiConfigContext } from '../Shared/k8s' ;
24+ import { useHandleResourcePatch } from '../../lib/api/types/crossplane/useHandleResourcePatch.ts' ;
2825import { ErrorDialog , ErrorDialogHandle } from '../Shared/ErrorMessageBox.tsx' ;
2926
3027type Rows = {
@@ -42,18 +39,15 @@ interface CellRow<T> {
4239export function ProvidersConfig ( ) {
4340 const { t } = useTranslation ( ) ;
4441 const { openInAside } = useSplitter ( ) ;
45- const toast = useToast ( ) ;
46- const apiConfig = useContext ( ApiConfigContext ) ;
4742 const errorDialogRef = useRef < ErrorDialogHandle > ( null ) ;
43+ const handlePatch = useHandleResourcePatch ( errorDialogRef ) ;
4844
4945 const rows : Rows [ ] = [ ] ;
5046
5147 const { data : providerConfigsList , isLoading } = useProvidersConfigResource ( {
5248 refreshInterval : 60000 , // Resources are quite expensive to fetch, so we refresh every 60 seconds
5349 } ) ;
5450
55- const { getPluralKind } = useResourcePluralNames ( ) ;
56-
5751 if ( providerConfigsList ) {
5852 providerConfigsList . forEach ( ( provider ) => {
5953 provider . items . forEach ( ( config ) => {
@@ -77,25 +71,15 @@ export function ProvidersConfig() {
7771 isEdit = { true }
7872 resource = { item as unknown as Resource }
7973 filename = { `${ item . kind } _${ item . metadata . name } ` }
80- onApply = { async ( parsed ) =>
81- await handleResourcePatch ( {
82- item,
83- parsed,
84- getPluralKind,
85- apiConfig,
86- t,
87- toast,
88- errorDialogRef,
89- } )
90- }
74+ onApply = { async ( parsed ) => await handlePatch ( item , parsed ) }
9175 />
9276 </ Fragment > ,
9377 ) ;
9478 } ,
95- [ openInAside , getPluralKind , apiConfig , t , toast ] ,
79+ [ openInAside , handlePatch ] ,
9680 ) ;
9781
98- const columns = useMemo (
82+ const columns = useMemo < AnalyticalTableColumnDefinition [ ] > (
9983 ( ) =>
10084 [
10185 {
0 commit comments