Add ListButtons to TeamList.tsx
This commit is contained in:
parent
bc64a9bfa7
commit
da6143d1aa
@ -57,7 +57,11 @@ describe('TeamConnector', () => {
|
|||||||
}]
|
}]
|
||||||
|
|
||||||
it('it fetches user teams on render', async () => {
|
it('it fetches user teams on render', async () => {
|
||||||
const {node} = createTestProvider().render({})
|
const {node} = createTestProvider().render({
|
||||||
|
history: {} as any,
|
||||||
|
location: {} as any,
|
||||||
|
match: {} as any,
|
||||||
|
})
|
||||||
await http.wait()
|
await http.wait()
|
||||||
expect(node.innerHTML).toContain('my-team')
|
expect(node.innerHTML).toContain('my-team')
|
||||||
})
|
})
|
||||||
@ -75,7 +79,11 @@ describe('TeamConnector', () => {
|
|||||||
data: {name: 'new-team'},
|
data: {name: 'new-team'},
|
||||||
}, newTeam)
|
}, newTeam)
|
||||||
const {render, store} = createTestProvider()
|
const {render, store} = createTestProvider()
|
||||||
const {node} = render({})
|
const {node} = render({
|
||||||
|
history: {} as any,
|
||||||
|
location: {} as any,
|
||||||
|
match: {} as any,
|
||||||
|
})
|
||||||
const addTeamForm = node.querySelector('.team-add') as HTMLFormElement
|
const addTeamForm = node.querySelector('.team-add') as HTMLFormElement
|
||||||
const nameInput = addTeamForm
|
const nameInput = addTeamForm
|
||||||
.querySelector('input') as HTMLInputElement
|
.querySelector('input') as HTMLInputElement
|
||||||
@ -95,7 +103,11 @@ describe('TeamConnector', () => {
|
|||||||
data: {name: 'test'},
|
data: {name: 'test'},
|
||||||
}, error, 400)
|
}, error, 400)
|
||||||
const {render} = createTestProvider()
|
const {render} = createTestProvider()
|
||||||
const {node} = render({})
|
const {node} = render({
|
||||||
|
history: {} as any,
|
||||||
|
location: {} as any,
|
||||||
|
match: {} as any,
|
||||||
|
})
|
||||||
const addTeamForm = node.querySelector('.team-add') as HTMLFormElement
|
const addTeamForm = node.querySelector('.team-add') as HTMLFormElement
|
||||||
const nameInput = addTeamForm
|
const nameInput = addTeamForm
|
||||||
.querySelector('input') as HTMLInputElement
|
.querySelector('input') as HTMLInputElement
|
||||||
|
|||||||
@ -32,6 +32,6 @@ export class TeamConnector extends Connector<ITeamState> {
|
|||||||
TeamManager,
|
TeamManager,
|
||||||
)
|
)
|
||||||
|
|
||||||
return withRouter(Component)
|
return Component
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import {TeamActions} from './TeamActions'
|
|||||||
import {TeamEditor} from './TeamEditor'
|
import {TeamEditor} from './TeamEditor'
|
||||||
|
|
||||||
export interface ITeamListProps {
|
export interface ITeamListProps {
|
||||||
|
ListButtons?: React.ComponentType<{team: ITeam}>
|
||||||
teamsById: TReadonlyRecord<number, ITeam>
|
teamsById: TReadonlyRecord<number, ITeam>
|
||||||
teamIds: ReadonlyArray<number>
|
teamIds: ReadonlyArray<number>
|
||||||
onAddTeam: TeamActions['createTeam']
|
onAddTeam: TeamActions['createTeam']
|
||||||
@ -14,6 +15,7 @@ export interface ITeamListProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ITeamProps {
|
export interface ITeamProps {
|
||||||
|
ListButtons?: React.ComponentType<{team: ITeam}>
|
||||||
team: ITeam
|
team: ITeam
|
||||||
onRemoveTeam: TeamActions['removeTeam']
|
onRemoveTeam: TeamActions['removeTeam']
|
||||||
}
|
}
|
||||||
@ -24,15 +26,17 @@ export class TeamRow extends React.PureComponent<ITeamProps> {
|
|||||||
await onRemoveTeam({id}).payload
|
await onRemoveTeam({id}).payload
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
const {team} = this.props
|
const {team, ListButtons} = this.props
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<div className='team-name'>
|
<div className='team-name'>
|
||||||
{team.name}
|
{team.name}
|
||||||
</div>
|
</div>
|
||||||
<div className='ml-auto'>
|
<div className='ml-auto'>
|
||||||
|
{!!ListButtons && <ListButtons team={team} />}
|
||||||
|
|
||||||
<Link to={`/teams/${team.id}/users`}>
|
<Link to={`/teams/${team.id}/users`}>
|
||||||
<Button isInverted isColor='link' aria-label='Edit'>
|
<Button isInverted isColor='link' aria-label='Edit Team'>
|
||||||
<FaEdit />
|
<FaEdit />
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
</Link>
|
||||||
@ -73,6 +77,7 @@ export class TeamList extends React.PureComponent<ITeamListProps> {
|
|||||||
return (
|
return (
|
||||||
<PanelBlock key={team.id}>
|
<PanelBlock key={team.id}>
|
||||||
<TeamRow
|
<TeamRow
|
||||||
|
ListButtons={this.props.ListButtons}
|
||||||
onRemoveTeam={this.props.onRemoveTeam}
|
onRemoveTeam={this.props.onRemoveTeam}
|
||||||
team={team}
|
team={team}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -14,6 +14,8 @@ export interface ITeamManagerProps {
|
|||||||
location: Location
|
location: Location
|
||||||
match: Match<any>
|
match: Match<any>
|
||||||
|
|
||||||
|
ListButtons?: React.ComponentType<{team: ITeam}>
|
||||||
|
|
||||||
createTeam: TeamActions['createTeam']
|
createTeam: TeamActions['createTeam']
|
||||||
updateTeam: TeamActions['updateTeam']
|
updateTeam: TeamActions['updateTeam']
|
||||||
removeTeam: TeamActions['removeTeam']
|
removeTeam: TeamActions['removeTeam']
|
||||||
@ -56,6 +58,7 @@ export class TeamManager extends React.PureComponent<ITeamManagerProps> {
|
|||||||
<Route exact path='/teams' render={() =>
|
<Route exact path='/teams' render={() =>
|
||||||
<>
|
<>
|
||||||
<TeamList
|
<TeamList
|
||||||
|
ListButtons={this.props.ListButtons}
|
||||||
teamsById={teamsById}
|
teamsById={teamsById}
|
||||||
teamIds={this.props.teamIds}
|
teamIds={this.props.teamIds}
|
||||||
onAddTeam={this.props.createTeam}
|
onAddTeam={this.props.createTeam}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user