Skip to content

Commit

Permalink
refactor: custom resources use ResourceListV2 (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
manusa authored May 8, 2024
1 parent 87f68fe commit 7258282
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 107 deletions.
82 changes: 0 additions & 82 deletions src/main/frontend/src/components/ResourceList.js

This file was deleted.

34 changes: 9 additions & 25 deletions src/main/frontend/src/customresources/List.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,11 @@
*
*/
import React, {useState} from 'react';
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import {crudDelete} from '../redux';
import {name, namespace, sortByCreationTimeStamp, uid} from '../metadata';
import {api, selectors} from './';
import {selectors as crdSelectors} from '../customresourcedefinitions';
import {Icon, Link, Table} from '../components';
import {ResourceEditModal} from '../editor';
import ResourceList from '../components/ResourceList';
import {Icon, Link, ResourceListV2, Table} from '../components';
import {api, selectors} from './';

const headers = customResourceDefinition => {
const ret = [
Expand Down Expand Up @@ -73,29 +69,17 @@ const Rows = ({
));
};

const mapDispatchToProps = dispatch =>
bindActionCreators(
{
crudDelete
},
dispatch
);

export const List = connect(
null,
mapDispatchToProps
)(({
export const List = ({
customResources,
customResourceDefinition,
version,
deleteResourceCallback,
crudDelete,
...properties
}) => {
const [editedResource, editResource] = useState(null);
const [editedResource, setEditedResource] = useState(null);
return (
<>
<ResourceList
<ResourceListV2
headers={headers(customResourceDefinition)}
resources={customResources}
{...properties}
Expand All @@ -104,10 +88,10 @@ export const List = connect(
customResources={customResources}
customResourceDefinition={customResourceDefinition}
version={version}
editResource={editResource}
editResource={setEditedResource}
deleteResourceCallback={deleteResourceCallback}
/>
</ResourceList>
</ResourceListV2>
<ResourceEditModal
resource={editedResource}
title={`${selectors.apiVersion(editedResource)} - ${
Expand All @@ -116,8 +100,8 @@ export const List = connect(
: ''
}${name(editedResource)}`}
save={toSave => api.update(customResourceDefinition, version)(toSave)}
close={() => editResource(null)}
close={() => setEditedResource(null)}
/>
</>
);
});
};

0 comments on commit 7258282

Please sign in to comment.