Skip to content

Commit

Permalink
Hide temporary by default
Browse files Browse the repository at this point in the history
  • Loading branch information
tananaev committed Feb 23, 2024
1 parent 32302e6 commit 460cd9a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
1 change: 1 addition & 0 deletions modern/src/resources/l10n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@
"userFixedEmail": "No Email Change",
"userToken": "Token",
"userDeleteAccount": "Delete Account",
"userTemporary": "Temporary",
"loginTitle": "Login",
"loginLanguage": "Language",
"loginReset": "Reset Password",
Expand Down
24 changes: 21 additions & 3 deletions modern/src/settings/UsersPage.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState } from 'react';
import { useNavigate } from 'react-router-dom';
import {
Table, TableRow, TableCell, TableHead, TableBody,
Table, TableRow, TableCell, TableHead, TableBody, Switch, TableFooter, FormControlLabel, FormControl, FormGroup, Grid,
} from '@mui/material';
import LoginIcon from '@mui/icons-material/Login';
import LinkIcon from '@mui/icons-material/Link';
Expand Down Expand Up @@ -31,6 +31,7 @@ const UsersPage = () => {
const [items, setItems] = useState([]);
const [searchKeyword, setSearchKeyword] = useState('');
const [loading, setLoading] = useState(false);
const [temporary, setTemporary] = useState(false);

const handleLogin = useCatch(async (userId) => {
const response = await fetch(`/api/session/${userId}`);
Expand Down Expand Up @@ -80,11 +81,11 @@ const UsersPage = () => {
<TableCell>{t('userAdmin')}</TableCell>
<TableCell>{t('sharedDisabled')}</TableCell>
<TableCell>{t('userExpirationTime')}</TableCell>
<TableCell className={classes.columnAction} />
<TableCell className={classes.columnAction}></TableCell>
</TableRow>
</TableHead>
<TableBody>
{!loading ? items.filter(filterByKeyword(searchKeyword)).map((item) => (
{!loading ? items.filter((u) => temporary || !u.temporary).filter(filterByKeyword(searchKeyword)).map((item) => (
<TableRow key={item.id}>
<TableCell>{item.name}</TableCell>
<TableCell>{item.email}</TableCell>
Expand All @@ -103,6 +104,23 @@ const UsersPage = () => {
</TableRow>
)) : (<TableShimmer columns={6} endAction />)}
</TableBody>
<TableFooter>
<TableRow>
<TableCell colSpan={6} align="right">
<FormControlLabel
control={
<Switch
value={temporary}
onChange={(e) => setTemporary(e.target.checked)}
size="small"
/>
}
label={t('userTemporary')}
labelPlacement="start"
/>
</TableCell>
</TableRow>
</TableFooter>
</Table>
<CollectionFab editPath="/settings/user" />
</PageLayout>
Expand Down

0 comments on commit 460cd9a

Please sign in to comment.