-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
dougfabris
committed
Mar 23, 2021
1 parent
816882d
commit b04b511
Showing
16 changed files
with
331 additions
and
312 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
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
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
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 |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import React from 'react'; | ||
import { Box, CheckBox, Table, Icon, Margins } from '@rocket.chat/fuselage'; | ||
import { useMutableCallback } from '@rocket.chat/fuselage-hooks'; | ||
|
||
import GenericTable from '../../components/GenericTable'; | ||
import { useRoomIcon } from '../../hooks/useRoomIcon'; | ||
import { useFormatDateAndTime } from '../../hooks/useFormatDateAndTime'; | ||
import { useTranslation } from '../../contexts/TranslationContext'; | ||
|
||
const ChannelRow = ({ onChange, selected, room, lastOwnerWarning = '', formatDate }) => { | ||
const { name, fname, ts, isLastOwner } = room; | ||
|
||
const handleChange = useMutableCallback(() => onChange(room)); | ||
|
||
return <Table.Row action> | ||
<Table.Cell maxWidth='x300' withTruncatedText > | ||
<CheckBox checked={selected} onChange={handleChange} disabled={isLastOwner}/> | ||
<Margins inline='x8'> | ||
<Icon size='x16' {...useRoomIcon(room)} /> | ||
{fname ?? name} | ||
{isLastOwner && <Icon size='x16' name='info-circled' color='danger' title={lastOwnerWarning}/>} | ||
</Margins> | ||
</Table.Cell> | ||
|
||
<Table.Cell align='end' withTruncatedText> | ||
{formatDate(ts)} | ||
</Table.Cell> | ||
</Table.Row>; | ||
}; | ||
|
||
const ChannelDesertionTable = ({ | ||
rooms, | ||
eligibleRoomsLength, | ||
params, | ||
onChangeParams, | ||
onChangeRoomSelection, | ||
selectedRooms, | ||
onToggleAllRooms, | ||
lastOwnerWarning, | ||
}) => { | ||
const t = useTranslation(); | ||
|
||
const selectedRoomsLength = Object.values(selectedRooms).filter(Boolean).length; | ||
|
||
const checked = eligibleRoomsLength === selectedRoomsLength; | ||
const indeterminate = eligibleRoomsLength > selectedRoomsLength && selectedRoomsLength > 0; | ||
|
||
const formatDate = useFormatDateAndTime(); | ||
|
||
return <Box display='flex' flexDirection='column' height='x200' mbs='x24'> | ||
<GenericTable | ||
header={<> | ||
<GenericTable.HeaderCell key='name' sort='name'> | ||
<CheckBox indeterminate={indeterminate} checked={checked} onChange={onToggleAllRooms}/> | ||
<Box mi='x8'>{t('Channel_name')}</Box> | ||
</GenericTable.HeaderCell> | ||
<GenericTable.HeaderCell key='joinedAt' sort='joinedAt'> | ||
<Box width='100%' textAlign='end'>{t('Joined_at')}</Box> | ||
</GenericTable.HeaderCell> | ||
</>} | ||
results={rooms} | ||
params={params} | ||
setParams={onChangeParams} | ||
fixed={false} | ||
pagination={false} | ||
> | ||
{({ key, ...room }) => <ChannelRow | ||
formatDate={formatDate} | ||
room={room} | ||
key={key} | ||
onChange={onChangeRoomSelection} | ||
selected={!!selectedRooms[room._id]} | ||
lastOwnerWarning={lastOwnerWarning} | ||
/>} | ||
</GenericTable> | ||
</Box>; | ||
}; | ||
|
||
export default ChannelDesertionTable; |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.