-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Split thunks on files. Refactoring * [CHORE] Refactor Topics section
- Loading branch information
Showing
42 changed files
with
789 additions
and
756 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 0 additions & 91 deletions
91
kafka-ui-react-app/src/components/Topics/Details/Overview/Overview.tsx
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
kafka-ui-react-app/src/components/Topics/Details/Settings/SettingsEditButton.tsx
This file was deleted.
Oops, something went wrong.
64 changes: 0 additions & 64 deletions
64
kafka-ui-react-app/src/components/Topics/Edit/EditContainer.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 10 additions & 18 deletions
28
kafka-ui-react-app/src/components/Topics/List/ListContainer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,21 @@ | ||
import { connect } from 'react-redux'; | ||
import { ClusterName, RootState } from 'redux/interfaces'; | ||
import { RootState } from 'redux/interfaces'; | ||
import { fetchTopicsList } from 'redux/actions'; | ||
import { | ||
getTopicList, | ||
getExternalTopicList, | ||
getAreTopicsFetching, | ||
} from 'redux/reducers/topics/selectors'; | ||
import { withRouter, RouteComponentProps } from 'react-router-dom'; | ||
import List from './List'; | ||
|
||
interface RouteProps { | ||
clusterName: ClusterName; | ||
} | ||
|
||
type OwnProps = RouteComponentProps<RouteProps>; | ||
|
||
const mapStateToProps = ( | ||
state: RootState, | ||
{ | ||
match: { | ||
params: { clusterName }, | ||
}, | ||
}: OwnProps | ||
) => ({ | ||
clusterName, | ||
const mapStateToProps = (state: RootState) => ({ | ||
areTopicsFetching: getAreTopicsFetching(state), | ||
topics: getTopicList(state), | ||
externalTopics: getExternalTopicList(state), | ||
}); | ||
|
||
export default withRouter(connect(mapStateToProps)(List)); | ||
const mapDispatchToProps = { | ||
fetchTopicsList, | ||
}; | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(List); |
37 changes: 29 additions & 8 deletions
37
kafka-ui-react-app/src/components/Topics/List/__tests__/List.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,43 @@ | ||
import { mount } from 'enzyme'; | ||
import React from 'react'; | ||
import { StaticRouter } from 'react-router-dom'; | ||
import ClusterContext from 'components/contexts/ClusterContext'; | ||
import List from '../List'; | ||
|
||
describe('List', () => { | ||
describe('when it has readonly flag', () => { | ||
it('does not render the Add a Topic button', () => { | ||
const props = { | ||
clusterName: 'Cluster', | ||
topics: [], | ||
externalTopics: [], | ||
}; | ||
const component = mount( | ||
<ClusterContext.Provider value={{ isReadOnly: true }}> | ||
<List {...props} /> | ||
</ClusterContext.Provider> | ||
<StaticRouter> | ||
<ClusterContext.Provider value={{ isReadOnly: true }}> | ||
<List | ||
areTopicsFetching={false} | ||
topics={[]} | ||
externalTopics={[]} | ||
fetchTopicsList={jest.fn()} | ||
/> | ||
</ClusterContext.Provider> | ||
</StaticRouter> | ||
); | ||
expect(component.exists('NavLink')).toBeFalsy(); | ||
}); | ||
}); | ||
|
||
describe('when it does not have readonly flag', () => { | ||
it('renders the Add a Topic button', () => { | ||
const component = mount( | ||
<StaticRouter> | ||
<ClusterContext.Provider value={{ isReadOnly: false }}> | ||
<List | ||
areTopicsFetching={false} | ||
topics={[]} | ||
externalTopics={[]} | ||
fetchTopicsList={jest.fn()} | ||
/> | ||
</ClusterContext.Provider> | ||
</StaticRouter> | ||
); | ||
expect(component.exists('NavLink')).toBeTruthy(); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.