Skip to content

Commit c3fb6a6

Browse files
committed
add dropdown for toggling settings on small screens
1 parent f956b7b commit c3fb6a6

File tree

8 files changed

+89
-48
lines changed

8 files changed

+89
-48
lines changed

public/locales/en.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -446,16 +446,15 @@
446446
"orgSettings": {
447447
"title": "Talawa Setting",
448448
"pageName": "Settings",
449-
"generalSettings": "General",
450-
"actionItemCategorySettings": "Action Item Categories",
449+
"general": "General",
450+
"actionItemCategories": "Action Item Categories",
451451
"updateOrganization": "Update Organization",
452452
"seeRequest": "See Request",
453453
"settings": "Settings",
454454
"noData": "No data",
455455
"otherSettings": "Other Settings",
456456
"changeLanguage": "Change Language",
457-
"manageCustomFields": "Manage Custom Fields",
458-
"actionItemCategories": "Action Item Categories"
457+
"manageCustomFields": "Manage Custom Fields"
459458
},
460459
"deleteOrg": {
461460
"deleteOrganization": "Delete Organization",

public/locales/fr.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,8 @@
441441
"orgSettings": {
442442
"title": "Paramètre Talawa",
443443
"pageName": "Paramètres",
444-
"generalSettings": "Général",
445-
"actionItemCategorySettings": "Catégories d’éléments d’action",
444+
"general": "Général",
445+
"actionItemCategories": "Catégories d’éléments d’action",
446446
"updateYourDetails": "Mettre à jour vos informations",
447447
"updateYourPassword": "Mettez à jour votre mot de passe",
448448
"updateOrganization": "Mettre à jour l'organisation",
@@ -451,8 +451,7 @@
451451
"noData": "Pas de données",
452452
"otherSettings": "Autres paramètres",
453453
"changeLanguage": "Changer la langue",
454-
"manageCustomFields": "Gérer les Champs Personnalisés",
455-
"actionItemCategories": "Catégories d’éléments d’action"
454+
"manageCustomFields": "Gérer les Champs Personnalisés"
456455
},
457456
"deleteOrg": {
458457
"deleteOrganization": "Supprimer l'organisation",

public/locales/hi.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,8 @@
441441
"orgSettings": {
442442
"title": "तलावा सेटिंग",
443443
"pageName": "सेटिंग्स",
444-
"generalSettings": "सामान्य",
445-
"actionItemCategorySettings": "कार्रवाई आइटम श्रेणियाँ",
444+
"general": "सामान्य",
445+
"actionItemCategories": "कार्रवाई आइटम श्रेणियाँ",
446446
"updateYourDetails": "अपना विवरण अपडेट करें",
447447
"updateYourPassword": "अपना पासवर्ड अपडेट करें",
448448
"updateOrganization": "अद्यतन संगठन",
@@ -451,8 +451,7 @@
451451
"noData": "कोई डेटा नहीं",
452452
"otherSettings": "अन्य सेटिंग्स",
453453
"changeLanguage": "भाषा बदलें",
454-
"manageCustomFields": "कस्टम फ़ील्ड प्रबंधन करें",
455-
"actionItemCategories": "कार्रवाई आइटम श्रेणियाँ"
454+
"manageCustomFields": "कस्टम फ़ील्ड प्रबंधन करें"
456455
},
457456
"deleteOrg": {
458457
"deleteOrganization": "संगठन हटाएं",

public/locales/sp.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -440,8 +440,8 @@
440440
"orgSettings": {
441441
"title": "Configuración Talawa",
442442
"pageName": "Configuración",
443-
"generalSettings": "General",
444-
"actionItemCategorySettings": "Categorías de elementos de acción",
443+
"general": "General",
444+
"actionItemCategories": "Categorías de elementos de acción",
445445
"updateYourDetails": "Actualiza tus datos",
446446
"updateYourPassword": "Actualice su contraseña",
447447
"updateOrganization": "Actualizar Organización",
@@ -450,8 +450,7 @@
450450
"noData": "Sin datos",
451451
"otherSettings": "Otras Configuraciones",
452452
"changeLanguage": "Cambiar Idioma",
453-
"manageCustomFields": "Gestionar Campos Personalizados",
454-
"actionItemCategories": "Categorías de elementos de acción"
453+
"manageCustomFields": "Gestionar Campos Personalizados"
455454
},
456455
"deleteOrg": {
457456
"deleteOrganization": "Eliminar organización",

public/locales/zh.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,8 @@
441441
"orgSettings": {
442442
"title": "塔拉瓦設置",
443443
"pageName": "设置",
444-
"generalSettings": "一般",
445-
"actionItemCategorySettings": "措施项类别",
444+
"general": "一般",
445+
"actionItemCategories": "措施项类别",
446446
"updateYourDetails": "更新您的詳細信息",
447447
"updateYourPassword": "更新您的密碼",
448448
"updateOrganization": "更新組織",
@@ -451,8 +451,7 @@
451451
"noData": "沒有數據",
452452
"otherSettings": "其他设置",
453453
"changeLanguage": "更改语言",
454-
"manageCustomFields": "管理自定义字段",
455-
"actionItemCategories": "措施项类别"
454+
"manageCustomFields": "管理自定义字段"
456455
},
457456
"deleteOrg": {
458457
"deleteOrganization": "删除组织",

src/screens/OrgSettings/OrgSettings.module.css

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,20 @@ hr {
3434
height: 1px;
3535
background-color: var(--bs-gray-500);
3636
}
37+
38+
.settingsTabs {
39+
display: none;
40+
}
41+
42+
@media (min-width: 577px) {
43+
.settingsDropdown {
44+
display: none;
45+
border: 1px solid black;
46+
}
47+
}
48+
49+
@media (min-width: 577px) {
50+
.settingsTabs {
51+
display: block;
52+
}
53+
}

src/screens/OrgSettings/OrgSettings.test.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import { MockedProvider } from '@apollo/react-testing';
3-
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
3+
import { render, screen, waitFor } from '@testing-library/react';
44
import 'jest-location-mock';
55
import { I18nextProvider } from 'react-i18next';
66
import { Provider } from 'react-redux';
@@ -12,6 +12,7 @@ import { StaticMockLink } from 'utils/StaticMockLink';
1212
import i18nForTest from 'utils/i18nForTest';
1313
import OrgSettings from './OrgSettings';
1414
import { ORGANIZATIONS_LIST } from 'GraphQl/Queries/Queries';
15+
import userEvent from '@testing-library/user-event';
1516

1617
const MOCKS = [
1718
{
@@ -127,7 +128,7 @@ describe('Organisation Settings Page', () => {
127128
window.location.assign('/orgsetting/id=123');
128129
localStorage.setItem('UserType', 'SUPERADMIN');
129130

130-
const { getByText, queryByText } = render(
131+
const { queryByText } = render(
131132
<MockedProvider addTypename={false} link={link}>
132133
<BrowserRouter>
133134
<Provider store={store}>
@@ -140,14 +141,14 @@ describe('Organisation Settings Page', () => {
140141
);
141142

142143
await waitFor(() => {
143-
fireEvent.click(getByText(translations.actionItemCategorySettings));
144+
userEvent.click(screen.getByTestId('actionItemCategoriesSettings'));
144145
expect(
145146
queryByText(translations.actionItemCategories)
146147
).toBeInTheDocument();
147148
});
148149

149150
await waitFor(() => {
150-
fireEvent.click(getByText(translations.generalSettings));
151+
userEvent.click(screen.getByTestId('generalSettings'));
151152
expect(queryByText(translations.updateOrganization)).toBeInTheDocument();
152153
});
153154
});

src/screens/OrgSettings/OrgSettings.tsx

Lines changed: 52 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,31 @@ import ChangeLanguageDropDown from 'components/ChangeLanguageDropdown/ChangeLang
33
import DeleteOrg from 'components/DeleteOrg/DeleteOrg';
44
import OrgUpdate from 'components/OrgUpdate/OrgUpdate';
55
import OrganizationScreen from 'components/OrganizationScreen/OrganizationScreen';
6-
import { Button, Card, Form } from 'react-bootstrap';
6+
import { Button, Card, Dropdown, Form } from 'react-bootstrap';
7+
import type { DropDirection } from 'react-bootstrap/esm/DropdownContext';
78
import Col from 'react-bootstrap/Col';
89
import Row from 'react-bootstrap/Row';
910
import { useTranslation } from 'react-i18next';
1011
import styles from './OrgSettings.module.css';
1112
import OrgProfileFieldSettings from 'components/OrgProfileFieldSettings/OrgProfileFieldSettings';
1213
import OrgActionItemCategories from 'components/OrgActionItemCategories/OrgActionItemCategories';
1314

14-
type SettingType = 'General' | 'ActionItemCategories';
15+
type SettingType = 'general' | 'actionItemCategories';
1516

1617
function orgSettings(): JSX.Element {
1718
const { t } = useTranslation('translation', {
1819
keyPrefix: 'orgSettings',
1920
});
2021

21-
const [orgSetting, setOrgSetting] = useState<SettingType>('General');
22+
const orgSettings: SettingType[] = ['general', 'actionItemCategories'];
23+
24+
const [orgSetting, setOrgSetting] = useState<SettingType>('general');
2225

2326
document.title = t('title');
2427
const orgId = window.location.href.split('=')[1];
2528

29+
const dropDirection: DropDirection = 'down';
30+
2631
return (
2732
<>
2833
<OrganizationScreen screenName="Settings" title={t('pageName')}>
@@ -31,34 +36,57 @@ function orgSettings(): JSX.Element {
3136
>
3237
<Row className="mx-3 mt-4">
3338
<Col>
34-
<Button
35-
className="me-3 border rounded-3"
36-
variant={
37-
orgSetting === 'General' ? `success` : `outline-secondary`
38-
}
39-
onClick={() => setOrgSetting('General')}
40-
>
41-
{t('generalSettings')}
42-
</Button>
43-
<Button
44-
className="border rounded-3"
45-
variant={
46-
orgSetting === 'ActionItemCategories'
47-
? `success`
48-
: `outline-secondary`
49-
}
50-
onClick={() => setOrgSetting('ActionItemCategories')}
39+
<div className={styles.settingsTabs}>
40+
{orgSettings.map((setting, index) => (
41+
<Button
42+
key={index}
43+
className="me-3 border rounded-3"
44+
variant={
45+
orgSetting === setting ? `success` : `outline-secondary`
46+
}
47+
onClick={() => setOrgSetting(setting)}
48+
data-testid={`${setting}Settings`}
49+
>
50+
{t(setting)}
51+
</Button>
52+
))}
53+
</div>
54+
55+
<Dropdown
56+
className={styles.settingsDropdown}
57+
data-testid="settingsDropdownContainer"
58+
drop={dropDirection}
5159
>
52-
{t('actionItemCategorySettings')}
53-
</Button>
60+
<Dropdown.Toggle
61+
variant="success"
62+
id="dropdown-basic"
63+
data-testid="settingsDropdownToggle"
64+
>
65+
<span className="me-1">{t(orgSetting)}</span>
66+
</Dropdown.Toggle>
67+
<Dropdown.Menu>
68+
{orgSettings.map((setting, index) => (
69+
<Dropdown.Item
70+
key={index}
71+
onClick={
72+
/* istanbul ignore next */
73+
() => setOrgSetting(setting)
74+
}
75+
className={orgSetting === setting ? 'text-secondary' : ''}
76+
>
77+
{t(setting)}
78+
</Dropdown.Item>
79+
))}
80+
</Dropdown.Menu>
81+
</Dropdown>
5482
</Col>
5583

5684
<Row className="mt-3">
5785
<hr />
5886
</Row>
5987
</Row>
6088

61-
{orgSetting === 'General' && (
89+
{orgSetting === 'general' && (
6290
<Row className={`${styles.settingsBody} mt-3`}>
6391
<Col lg={7}>
6492
<Card className="rounded-4 mb-4 mx-auto shadow-sm border border-light-subtle">
@@ -103,7 +131,7 @@ function orgSettings(): JSX.Element {
103131
</Row>
104132
)}
105133

106-
{orgSetting === 'ActionItemCategories' && (
134+
{orgSetting === 'actionItemCategories' && (
107135
<Row
108136
className={`${styles.actionItemStyles} mt-3 mb-3 mx-4 position-relative shadow-sm rounded-4`}
109137
>

0 commit comments

Comments
 (0)