Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
its-felix committed Dec 22, 2023
1 parent fc3dfde commit d08d547
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/lib/api/api.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ export interface ApplicationListItem {
id: string;
displayName: string;
userId: string;
lastUsed: string;
lastUsed?: string;
authorizedScopes: ReadonlyArray<string>;
}

export interface Application {
displayName: string;
userId: string;
lastUsed: string;
lastUsed?: string;
authorizedScopes: ReadonlyArray<string>;
authorizedGw2Accounts: ReadonlyArray<ApplicationGw2Account>;
}
Expand Down
4 changes: 2 additions & 2 deletions src/pages/account/applications-detail.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
Alert, Box, Button, ColumnLayout, Container, ContentLayout, Header, Spinner,
Alert, Box, Button, ColumnLayout, Container, ContentLayout, Header, Spinner, StatusIndicator,
} from '@cloudscape-design/components';
import React, { useEffect, useState } from 'react';
import { useHref, useNavigate, useParams } from 'react-router-dom';
Expand Down Expand Up @@ -119,7 +119,7 @@ function Overview({ id, application }: { id: string, application: Application })
<Copy copyText={id}><Box variant={'samp'} fontSize={'body-s'}>{application.userId}</Box></Copy>
</ValueWithLabel>
<ValueWithLabel label={'Last Used'}>
<Box>{i18n.dateTime(new Date(application.lastUsed))}</Box>
<Box>{application.lastUsed !== undefined ? i18n.dateTime(new Date(application.lastUsed)) : <StatusIndicator type={'info'}>Never</StatusIndicator>}</Box>
</ValueWithLabel>
</KeyValuePairs>
);
Expand Down
10 changes: 8 additions & 2 deletions src/pages/account/applications.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
Box,
ContentLayout,
Header,
Header, StatusIndicator,
} from '@cloudscape-design/components';
import React, { useEffect, useState } from 'react';
import { useHref } from 'react-router-dom';
Expand Down Expand Up @@ -40,7 +40,13 @@ function buildColumnDefinitions(i18n: I18nFormats) {
{
id: 'last_used',
header: 'Last Used',
cell: (v) => i18n.dateTime(new Date(v.lastUsed)),
cell: (v) => {
if (v.lastUsed === undefined) {
return <StatusIndicator type={'info'}>Never</StatusIndicator>;
}

return i18n.dateTime(new Date(v.lastUsed));
},
sortingField: 'lastUsed',
},
{
Expand Down
12 changes: 4 additions & 8 deletions src/pages/developer/applications-detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { useI18n } from '../../components/util/context/i18n';
import { usePreferences } from '../../components/util/state/use-preferences';
import { expectSuccess } from '../../lib/api/api';
import {
ApprovalStatus, DevApplication, DevApplicationUser, PagedResponse,
ApprovalStatus, DevApplication, DevApplicationClientListItem, DevApplicationUser, PagedResponse,
} from '../../lib/api/api.model';
import { I18nFormats } from '../../lib/i18n/i18n-strings';
import { OAUTH2_SCOPES } from '../../lib/oauth2.model';
Expand Down Expand Up @@ -61,19 +61,15 @@ export function DevApplicationsDetail() {

let overview: React.ReactNode;
let clients: React.ReactNode;
let users: React.ReactNode;
if (isLoading) {
overview = <Spinner size={'large'} />;
clients = <Container variant={'stacked'}><Spinner size={'large'} /></Container>;
users = <Container variant={'stacked'}><Spinner size={'large'} /></Container>;
} else if (devApplication === undefined) {
overview = <Box>Failed to load</Box>;
clients = <Container variant={'stacked'}><Box>Failed to load</Box></Container>;
users = <Container variant={'stacked'}><Box>Failed to load</Box></Container>;
} else {
overview = <Overview id={id} devApplication={devApplication} />;
clients = <ClientTable id={id} devApplication={devApplication} />;
users = <UserTable id={id} devApplication={devApplication} />;
}

return (
Expand Down Expand Up @@ -122,7 +118,7 @@ export function DevApplicationsDetail() {
<ColumnLayout columns={1}>
<Container variant={'stacked'}>{overview}</Container>
{clients}
{users}
<UserTable id={id} clients={devApplication?.clients ?? []} />
</ColumnLayout>
</ContentLayout>
</>
Expand Down Expand Up @@ -313,7 +309,7 @@ function visibleByDefault(id: string): boolean {
return id !== 'id';
}

function UserTable({ id, devApplication }: { id: string; devApplication: DevApplication }) {
function UserTable({ id, clients }: { id: string; clients: ReadonlyArray<DevApplicationClientListItem> }) {
const i18n = useI18n();
const { apiClient } = useHttpClient();
const { notification } = useAppControls();
Expand Down Expand Up @@ -415,7 +411,7 @@ function UserTable({ id, devApplication }: { id: string; devApplication: DevAppl
pages: [],
}));
}}
clientIds={devApplication.clients.map((v) => [v.id, v.displayName])}
clientIds={clients.map((v) => [v.id, v.displayName])}
disabled={isLoading}
/>
}
Expand Down
1 change: 1 addition & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function localTarget(target: string): ProxyOptions {
const proxyConfig: Record<string, string | ProxyOptions> = {
'/api/': localTarget('http://127.0.0.1:9000'),
'/api-v2/': localTarget('http://127.0.0.1:8090'),
'/api-app/': localTarget('http://127.0.0.1:8090'),
'/auth/': localTarget('http://127.0.0.1:9000'),
'/oauth2/': localTarget('http://127.0.0.1:9000'),
'/.well-known/oauth-authorization-server': localTarget('http://127.0.0.1:9000'),
Expand Down

0 comments on commit d08d547

Please sign in to comment.