Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 8 additions & 3 deletions ui/src/client/Clients.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {useStores} from '../stores';
import {TokenConfirmDialog} from '../common/TokenConfirmDialog';

const Clients = observer(() => {
const {clientStore} = useStores();
const {clientStore, currentUser} = useStores();
const [toDeleteClient, setToDeleteClient] = useState<IClient>();
const [toUpdateClient, setToUpdateClient] = useState<IClient>();
const [toElevateClient, setToElevateClient] = useState<IClient>();
Expand Down Expand Up @@ -73,6 +73,7 @@ const Clients = observer(() => {
lastUsed={client.lastUsed}
elevatedUntil={client.elevatedUntil}
expiresAt={client.expiresAt}
current={client.id === currentUser.user.clientId}
fEdit={() => setToUpdateClient(client)}
fDelete={() => setToDeleteClient(client)}
fElevate={() => setToElevateClient(client)}
Expand Down Expand Up @@ -132,6 +133,7 @@ interface IRowProps {
lastUsed: string | null;
elevatedUntil?: string;
expiresAt: string | null;
current: boolean;
fEdit: VoidFunction;
fDelete: VoidFunction;
fElevate: VoidFunction;
Expand All @@ -143,12 +145,15 @@ const Row = ({
lastUsed,
elevatedUntil,
expiresAt,
current,
fEdit,
fDelete,
fElevate,
}: IRowProps) => (
<TableRow>
<TableCell>{name}</TableCell>
<TableRow selected={current} aria-current={current ? 'true' : undefined}>
<TableCell>
<span className="name">{name}</span> {current ? <i> (current)</i> : ''}
</TableCell>
<TableCell align="right" title={elevatedUntil}>
<RemainingTime
until={
Expand Down
8 changes: 7 additions & 1 deletion ui/src/tests/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ afterAll(async () => await gotify.close());
const waitForClient =
(name: string, row: number): (() => Promise<void>) =>
async () => {
await waitForExists(page, $table.cell(row, ClientCol.Name), name);
await waitForExists(page, $table.cell(row, ClientCol.Name) + ' .name', name);
};

interface ClientFields {
Expand Down Expand Up @@ -94,6 +94,12 @@ describe('Client', () => {
expect(await innerText(page, $table.cell(2, ClientCol.Name))).toBe('phone');
expect(await innerText(page, $table.cell(3, ClientCol.Name))).toBe('desktop app');
});
it('highlights only the current session', async () => {
const currentSession = `${$table.rows()}[aria-current="true"]`;

page.waitForSelector(currentSession);
expect(await innerText(page, `${currentSession} td:first-child`)).toContain('chrome');
});
it('shows expires after for new clients', async () => {
expect(await innerText(page, $table.cell(2, ClientCol.ExpiresIn))).toBe('-');
expect(await innerText(page, $table.cell(3, ClientCol.ExpiresIn))).toBe('59m');
Expand Down
Loading