Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMPROVE] Replace SortListItem and CreateListItem with ListItem #24007

Merged
merged 19 commits into from
Dec 22, 2021
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/user-status/client/lib/userStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ export const userStatus: UserStatusTypes = {
statusType: UserStatus.OFFLINE,
},
},
};
} as const;
14 changes: 14 additions & 0 deletions client/components/Sidebar/ListItem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Option, OptionColumn } from '@rocket.chat/fuselage';
import React from 'react';

function ListItem({ text, icon, input, action }) {
return (
<Option onClick={action || null}>
{icon && <Option.Icon name={icon} size={20} />}
<Option.Content>{text}</Option.Content>
{input && <OptionColumn>{input}</OptionColumn>}
</Option>
);
}

export default ListItem;
2 changes: 2 additions & 0 deletions client/components/Sidebar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Content from './Content';
import GenericItem from './GenericItem';
import Header from './Header';
import ItemsAssembler from './ItemsAssembler';
import ListItem from './ListItem';
import NavigationItem from './NavigationItem';
import Sidebar from './Sidebar';

Expand All @@ -11,4 +12,5 @@ export default Object.assign(Sidebar, {
GenericItem,
NavigationItem,
ItemsAssembler,
ListItem,
});
86 changes: 44 additions & 42 deletions client/components/SortList/GroupingList.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { Box, Margins, CheckBox } from '@rocket.chat/fuselage';
import { CheckBox, OptionTitle } from '@rocket.chat/fuselage';
import React, { useCallback } from 'react';

import { useMethod } from '../../contexts/ServerContext';
import { useTranslation } from '../../contexts/TranslationContext';
import { useUserPreference } from '../../contexts/UserContext';
import SortListItem from './SortListItem';
import ListItem from '../Sidebar/ListItem';

const style = {
textTransform: 'uppercase',
};

const checkBoxStyle = {
'padding-left': '24px',
};

function GroupingList() {
const sidebarGroupByType = useUserPreference('sidebarGroupByType');
const sidebarShowFavorites = useUserPreference('sidebarShowFavorites');
Expand All @@ -25,49 +29,47 @@ function GroupingList() {
const handleChangeShowUnread = useHandleChange('sidebarShowUnread', !sidebarShowUnread);

const t = useTranslation();

return (
<>
<Margins block='x8'>
<Box is='p' style={style} fontScale='c1'>
{t('Group_by')}
</Box>
</Margins>
<OptionTitle style={style}>{t('Group_by')}</OptionTitle>
<ul className='rc-popover__list'>
<Margins block='x8'>
<SortListItem
icon={'flag'}
text={t('Unread')}
input={
<CheckBox
onChange={handleChangeShowUnread}
name='sidebarShowUnread'
checked={sidebarShowUnread}
/>
}
/>
<SortListItem
icon={'star'}
text={t('Favorites')}
input={
<CheckBox
onChange={handleChangeShoFavorite}
name='sidebarShowFavorites'
checked={sidebarShowFavorites}
/>
}
/>
<SortListItem
icon={'group-by-type'}
text={t('Types')}
input={
<CheckBox
onChange={handleChangeGroupByType}
name='sidebarGroupByType'
checked={sidebarGroupByType}
/>
}
/>
</Margins>
<ListItem
icon={'flag'}
text={t('Unread')}
input={
<CheckBox
style={checkBoxStyle}
onChange={handleChangeShowUnread}
name='sidebarShowUnread'
checked={sidebarShowUnread}
/>
}
/>
<ListItem
icon={'star'}
text={t('Favorites')}
input={
<CheckBox
style={checkBoxStyle}
onChange={handleChangeShoFavorite}
name='sidebarShowFavorites'
checked={sidebarShowFavorites}
/>
}
/>
<ListItem
icon={'group-by-type'}
text={t('Types')}
input={
<CheckBox
style={checkBoxStyle}
onChange={handleChangeGroupByType}
name='sidebarGroupByType'
checked={sidebarGroupByType}
/>
}
/>
</ul>
</>
);
Expand Down
14 changes: 6 additions & 8 deletions client/components/SortList/SortList.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Divider } from '@rocket.chat/fuselage';
import { Option } from '@rocket.chat/fuselage';
import React from 'react';

import GroupingList from './GroupingList';
Expand All @@ -8,13 +8,11 @@ import ViewModeList from './ViewModeList';
function SortList() {
return (
<>
<div className='rc-popover__column'>
<ViewModeList />
<Divider />
<SortModeList />
<Divider />
<GroupingList />
</div>
<ViewModeList />
<Option.Divider />
<SortModeList />
<Option.Divider />
<GroupingList />
</>
);
}
Expand Down
30 changes: 0 additions & 30 deletions client/components/SortList/SortListItem.js

This file was deleted.

62 changes: 31 additions & 31 deletions client/components/SortList/SortModeList.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { RadioButton, Box, Margins } from '@rocket.chat/fuselage';
import { RadioButton, OptionTitle } from '@rocket.chat/fuselage';
import React, { useCallback } from 'react';

import { useMethod } from '../../contexts/ServerContext';
import { useTranslation } from '../../contexts/TranslationContext';
import { useUserPreference } from '../../contexts/UserContext';
import SortListItem from './SortListItem';
import ListItem from '../Sidebar/ListItem';

const style = {
textTransform: 'uppercase',
};

const checkBoxStyle = {
'padding-left': '24px',
};

function SortModeList() {
const t = useTranslation();
const saveUserPreferences = useMethod('saveUserPreferences');
Expand All @@ -23,36 +27,32 @@ function SortModeList() {

return (
<>
<Margins block='x8'>
<Box is='p' style={style} fontScale='c1'>
{t('Sort_By')}
</Box>
</Margins>
<OptionTitle style={style}>{t('Sort_By')}</OptionTitle>
<ul className='rc-popover__list'>
<Margins block='x8'>
<SortListItem
icon={'clock'}
text={t('Activity')}
input={
<RadioButton
name='sidebarSortby'
onChange={setToActivity}
checked={sidebarSortBy === 'activity'}
/>
}
/>
<SortListItem
icon={'sort-az'}
text={t('Name')}
input={
<RadioButton
name='sidebarSortby'
onChange={setToAlphabetical}
checked={sidebarSortBy === 'alphabetical'}
/>
}
/>
</Margins>
<ListItem
icon={'clock'}
text={t('Activity')}
input={
<RadioButton
style={checkBoxStyle}
name='sidebarSortby'
onChange={setToActivity}
checked={sidebarSortBy === 'activity'}
/>
}
/>
<ListItem
icon={'sort-az'}
text={t('Name')}
input={
<RadioButton
style={checkBoxStyle}
name='sidebarSortby'
onChange={setToAlphabetical}
checked={sidebarSortBy === 'alphabetical'}
/>
}
/>
</ul>
</>
);
Expand Down
Loading