mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
[MM-57722] Convert ./components/admin_console/team_channel_settings/group/group_list.tsx
from Class Component to Function Component (#26721)
* [MM-57722] Convert `./components/admin_console/team_channel_settings/group/group_list.tsx` from Class Component to Function Component * :refactor: improve code structure
This commit is contained in:
parent
af8bcc4c6d
commit
8ba157f284
@ -58,7 +58,7 @@ exports[`admin_console/team_channel_settings/channel/ChannelGroups should match
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Connect(GroupList)
|
<Connect(Component)
|
||||||
channel={
|
channel={
|
||||||
Object {
|
Object {
|
||||||
"group_constrained": false,
|
"group_constrained": false,
|
||||||
|
@ -34,12 +34,9 @@ exports[`admin_console/team_channel_settings/group/GroupList should match snapsh
|
|||||||
noPadding={false}
|
noPadding={false}
|
||||||
onGroupRemoved={[MockFunction]}
|
onGroupRemoved={[MockFunction]}
|
||||||
onPageChangedCallback={[MockFunction]}
|
onPageChangedCallback={[MockFunction]}
|
||||||
removeGroup={[MockFunction]}
|
|
||||||
renderRow={[Function]}
|
renderRow={[Function]}
|
||||||
setNewGroupRole={[MockFunction]}
|
|
||||||
total={1}
|
total={1}
|
||||||
totalGroups={0}
|
totalGroups={0}
|
||||||
type="team"
|
|
||||||
/>
|
/>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@ -512,11 +509,8 @@ exports[`admin_console/team_channel_settings/group/GroupList should match snapsh
|
|||||||
noPadding={false}
|
noPadding={false}
|
||||||
onGroupRemoved={[MockFunction]}
|
onGroupRemoved={[MockFunction]}
|
||||||
onPageChangedCallback={[MockFunction]}
|
onPageChangedCallback={[MockFunction]}
|
||||||
removeGroup={[MockFunction]}
|
|
||||||
renderRow={[Function]}
|
renderRow={[Function]}
|
||||||
setNewGroupRole={[MockFunction]}
|
|
||||||
total={30}
|
total={30}
|
||||||
totalGroups={0}
|
totalGroups={0}
|
||||||
type="team"
|
|
||||||
/>
|
/>
|
||||||
`;
|
`;
|
||||||
|
@ -38,7 +38,7 @@ describe('admin_console/team_channel_settings/group/GroupList', () => {
|
|||||||
type='team'
|
type='team'
|
||||||
setNewGroupRole={jest.fn()}
|
setNewGroupRole={jest.fn()}
|
||||||
/>);
|
/>);
|
||||||
wrapper.setState({loading: false});
|
|
||||||
expect(wrapper).toMatchSnapshot();
|
expect(wrapper).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ describe('admin_console/team_channel_settings/group/GroupList', () => {
|
|||||||
removeGroup={jest.fn()}
|
removeGroup={jest.fn()}
|
||||||
setNewGroupRole={jest.fn()}
|
setNewGroupRole={jest.fn()}
|
||||||
/>);
|
/>);
|
||||||
wrapper.setState({loading: false});
|
|
||||||
expect(wrapper).toMatchSnapshot();
|
expect(wrapper).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||||
// See LICENSE.txt for license information.
|
// See LICENSE.txt for license information.
|
||||||
|
|
||||||
import React from 'react';
|
import React, {memo, useCallback} from 'react';
|
||||||
import {FormattedMessage} from 'react-intl';
|
import {FormattedMessage} from 'react-intl';
|
||||||
|
|
||||||
import type {Group} from '@mattermost/types/groups';
|
import type {Group} from '@mattermost/types/groups';
|
||||||
@ -42,27 +42,33 @@ const Header = () => {
|
|||||||
|
|
||||||
type Props = OwnProps & PropsFromRedux;
|
type Props = OwnProps & PropsFromRedux;
|
||||||
|
|
||||||
export default class GroupList extends React.PureComponent<Props> {
|
const GroupList = ({
|
||||||
renderRow = (item: Partial<Group>) => {
|
removeGroup,
|
||||||
|
setNewGroupRole,
|
||||||
|
type,
|
||||||
|
isDisabled,
|
||||||
|
...restProps
|
||||||
|
}: Props) => {
|
||||||
|
const renderRow = useCallback((item: Partial<Group>) => {
|
||||||
return (
|
return (
|
||||||
<GroupRow
|
<GroupRow
|
||||||
key={item.id}
|
key={item.id}
|
||||||
group={item}
|
group={item}
|
||||||
removeGroup={this.props.removeGroup}
|
removeGroup={removeGroup}
|
||||||
setNewGroupRole={this.props.setNewGroupRole}
|
setNewGroupRole={setNewGroupRole}
|
||||||
type={this.props.type}
|
type={type}
|
||||||
isDisabled={this.props.isDisabled}
|
isDisabled={isDisabled}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
}, [isDisabled, removeGroup, setNewGroupRole, type]);
|
||||||
|
|
||||||
render(): JSX.Element {
|
return (
|
||||||
return (
|
<AbstractList
|
||||||
<AbstractList
|
header={<Header/>}
|
||||||
header={<Header/>}
|
renderRow={renderRow}
|
||||||
renderRow={this.renderRow}
|
{...restProps}
|
||||||
{...this.props}
|
/>
|
||||||
/>
|
);
|
||||||
);
|
};
|
||||||
}
|
|
||||||
}
|
export default memo(GroupList);
|
||||||
|
@ -77,7 +77,7 @@ exports[`admin_console/team_channel_settings/team/TeamGroups should match snapsh
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Connect(GroupList)
|
<Connect(Component)
|
||||||
groups={
|
groups={
|
||||||
Array [
|
Array [
|
||||||
Object {
|
Object {
|
||||||
|
Loading…
Reference in New Issue
Block a user