Skip to content

Commit

Permalink
Fix typing on page (#139)
Browse files Browse the repository at this point in the history
* update button labels

* adjust typing

* add another action to run a test as part of a PR

* remove ci skip line
  • Loading branch information
pnzrr authored Mar 4, 2024
1 parent a01164a commit 4c53cc9
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 27 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: test

on:
pull_request:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Build and Test
uses: qcastel/github-actions-maven-cmd@master
env:
CI: ""
with:
maven-args: "clean install -Dmaven.test.skip=true -Ddockerfile.skip -DdockerCompose.skip -Djib.skip"
76 changes: 49 additions & 27 deletions src/pages/profile/signin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ import { AIACommand } from "services/aia-command";
import P2Toast from "components/utils/toast";
import { Key, Lock, Smartphone } from "lucide-react";

const PASSWORD = "password";
const TWO_FACTOR_AUTH = "2fa";
const WEB_AUTH_N = "webauthn";
const WEB_AUTH_N_REGISTER = "webauthn-register";
const WEB_AUTH_N_PASSWORDLESS = "webauthn-passwordless";
const WEB_AUTH_N_PASSWORDLESS_REGISTER = "webauthn-register-passwordless";
const OTP = "otp";

type CredentialType = PASSWORD | TWO_FACTOR_AUTH | WEB_AUTH_N | OTP;
enum CredentialType {
PASSWORD = "password",
TWO_FACTOR_AUTH = "2fa",
WEB_AUTH_N = "webauthn",
WEB_AUTH_N_REGISTER = "webauthn-register",
WEB_AUTH_N_PASSWORDLESS = "webauthn-passwordless",
WEB_AUTH_N_PASSWORDLESS_REGISTER = "webauthn-register-passwordless",
OTP = "otp",
}

const time = (time: string | undefined): string => {
if (time === undefined) return "unknown";
Expand All @@ -42,11 +42,13 @@ const SigninProfile = () => {
});
const [deleteCredential] = useDeleteCredentialMutation();

const hasWebAuthN = credentials.find((cred) => cred.type === WEB_AUTH_N);
const hasWebAuthN = credentials.find(
(cred) => cred.type === CredentialType.WEB_AUTH_N
);
const hasWebAuthNPasswordLess = credentials.find(
(cred) => cred.type === WEB_AUTH_N_PASSWORDLESS
(cred) => cred.type === CredentialType.WEB_AUTH_N_PASSWORDLESS
);
const hasOTP = credentials.find((cred) => cred.type === OTP);
const hasOTP = credentials.find((cred) => cred.type === CredentialType.OTP);

const removeCredential = (
credential: CredentialMetadataRepresentation
Expand Down Expand Up @@ -109,14 +111,16 @@ const SigninProfile = () => {
isCompact
className="inline-flex w-full justify-center sm:ml-3 sm:w-auto"
onClick={() => {
if (credentialType === "password") {
if (credentialType === CredentialType.PASSWORD) {
updateAIA("UPDATE_PASSWORD");
} else {
removeCredential(metadata.credential!);
}
}}
>
{credentialType === "password" ? t("update") : t("remove")}
{credentialType === CredentialType.PASSWORD
? t("update")
: t("remove")}
</Button>
)}
</>
Expand Down Expand Up @@ -151,7 +155,7 @@ const SigninProfile = () => {
/>
<Table
columns={cols}
rows={rowsForType(PASSWORD, credentials)}
rows={rowsForType(CredentialType.PASSWORD, credentials)}
isLoading={isLoading}
/>
</div>
Expand All @@ -172,7 +176,10 @@ const SigninProfile = () => {
{isLoading && (
<Table
columns={cols}
rows={rowsForType(TWO_FACTOR_AUTH, credentials)}
rows={rowsForType(
CredentialType.TWO_FACTOR_AUTH,
credentials
)}
isLoading={isLoading}
/>
)}
Expand All @@ -188,7 +195,8 @@ const SigninProfile = () => {
variant="small"
/>

{rowsForType(OTP, credentials).length !== 0 && (
{rowsForType(CredentialType.OTP, credentials).length !==
0 && (
<Button
isBlackButton
onClick={() => setUpCredential("CONFIGURE_TOTP")}
Expand All @@ -199,7 +207,7 @@ const SigninProfile = () => {
</div>
<Table
columns={cols}
rows={rowsForType(OTP, credentials)}
rows={rowsForType(CredentialType.OTP, credentials)}
isLoading={isLoading}
emptyState={
<div>
Expand All @@ -223,24 +231,29 @@ const SigninProfile = () => {
description={t("useYourSecurityKeyToSignIn")}
variant="small"
/>
{rowsForType(WEB_AUTH_N, credentials).length !== 0 && (
{rowsForType(CredentialType.WEB_AUTH_N, credentials)
.length !== 0 && (
<Button
isBlackButton
onClick={() => setUpCredential(WEB_AUTH_N_REGISTER)}
onClick={() =>
setUpCredential(CredentialType.WEB_AUTH_N_REGISTER)
}
>
{t("setUpSecurityKey")}
</Button>
)}
</div>
<Table
columns={cols}
rows={rowsForType(WEB_AUTH_N, credentials)}
rows={rowsForType(CredentialType.WEB_AUTH_N, credentials)}
isLoading={isLoading}
emptyState={
<div>
<Button
isBlackButton
onClick={() => setUpCredential(WEB_AUTH_N_REGISTER)}
onClick={() =>
setUpCredential(CredentialType.WEB_AUTH_N_REGISTER)
}
>
{t("setUpSecurityKey")}
</Button>
Expand Down Expand Up @@ -270,12 +283,16 @@ const SigninProfile = () => {
description={t("useYourSecurityKeyForPasswordlessSignIn")}
variant="small"
/>
{rowsForType(WEB_AUTH_N_PASSWORDLESS, credentials).length !==
0 && (
{rowsForType(
CredentialType.WEB_AUTH_N_PASSWORDLESS,
credentials
).length !== 0 && (
<Button
isBlackButton
onClick={() =>
setUpCredential(WEB_AUTH_N_PASSWORDLESS_REGISTER)
setUpCredential(
CredentialType.WEB_AUTH_N_PASSWORDLESS_REGISTER
)
}
>
{t("setUpSecurityKey")}
Expand All @@ -284,14 +301,19 @@ const SigninProfile = () => {
</div>
<Table
columns={cols}
rows={rowsForType(WEB_AUTH_N_PASSWORDLESS, credentials)}
rows={rowsForType(
CredentialType.WEB_AUTH_N_PASSWORDLESS,
credentials
)}
isLoading={isLoading}
emptyState={
<div>
<Button
isBlackButton
onClick={() =>
setUpCredential(WEB_AUTH_N_PASSWORDLESS_REGISTER)
setUpCredential(
CredentialType.WEB_AUTH_N_PASSWORDLESS_REGISTER
)
}
>
{t("setUpSecurityKey")}
Expand Down

0 comments on commit 4c53cc9

Please sign in to comment.