Skip to content

Commit

Permalink
Merge pull request #1887 from SUNET/cat-post-obs-fixes
Browse files Browse the repository at this point in the history
Cat post obs fixes
  • Loading branch information
eunjuhuss authored Nov 11, 2024
2 parents 67a5891 + 1da1b95 commit f68ef8a
Show file tree
Hide file tree
Showing 13 changed files with 98 additions and 20 deletions.
4 changes: 4 additions & 0 deletions src/components/Common/ConfirmModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import EduIDButton from "./EduIDButton";
interface ConfirmModalProps {
readonly id: string;
readonly title: React.ReactNode;
readonly mainText?: React.ReactNode;
readonly placeholder: string;
readonly showModal: boolean;
readonly closeModal: () => void;
Expand Down Expand Up @@ -71,6 +72,9 @@ function ConfirmModal(props: ConfirmModalProps): JSX.Element {
/>
</React.Fragment>
)}

{props.mainText ? props.mainText : null}

<div id="confirmation-code-area">
<FinalField<string>
component={CustomInput}
Expand Down
29 changes: 29 additions & 0 deletions src/components/Common/CopyToClipboardButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import EduIDButton from "components/Common/EduIDButton";
import { forwardRef, useState } from "react";
import { FormattedMessage } from "react-intl";

export const CopyToClipboardButton = forwardRef((props, ref: any) => {
const [tooltipCopied, setTooltipCopied] = useState(false); // say "Copy to clipboard" or "Copied!" in tooltip

function copyToClipboard() {
if (ref && ref.current) {
ref.current.select();
document.execCommand("copy");
setTooltipCopied(true);

setTimeout(() => {
setTooltipCopied(false);
}, 10000);
}
}

return (
<EduIDButton className="txt-toggle-btn" buttonstyle="link" size="sm" onClick={copyToClipboard}>
{tooltipCopied ? (
<FormattedMessage defaultMessage="COPIED" description="copied button label" />
) : (
<FormattedMessage defaultMessage="COPY" description="copy button label" />
)}
</EduIDButton>
);
});
10 changes: 6 additions & 4 deletions src/components/Common/PasswordInput.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import EduIDButton from "components/Common/EduIDButton";
import React, { useState } from "react";
import { FieldRenderProps, Field as FinalField } from "react-final-form";
import { FormattedMessage, useIntl } from "react-intl";
Expand Down Expand Up @@ -68,10 +69,11 @@ export function PasswordInputElement(props: InputProps): JSX.Element {
autoFocus={props.autoFocus}
/>

<button
type="button"
<EduIDButton
className="txt-toggle-btn"
buttonstyle="link"
size="sm"
aria-label={showPassword ? "hide password" : "show password"}
className="show-hide-button"
onClick={toggleShowPassword}
tabIndex={-1}
>
Expand All @@ -80,7 +82,7 @@ export function PasswordInputElement(props: InputProps): JSX.Element {
) : (
<FormattedMessage defaultMessage="SHOW" description="nin/password button label" />
)}
</button>
</EduIDButton>
</div>
);
}
8 changes: 8 additions & 0 deletions src/components/Common/Security.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,14 @@ export function Security(): React.ReactElement | null {
defaultMessage="Add a name for your security key"
/>
}
mainText={
<p>
<FormattedMessage
description="security webauthn describe paragraph"
defaultMessage={`Note: this is only for your own use to be able to distinguish between your added keys.`}
/>
</p>
}
placeholder={placeholder}
showModal={showSecurityKeyNameModal}
closeModal={handleStopAskingWebauthnDescription}
Expand Down
4 changes: 2 additions & 2 deletions src/components/Dashboard/AccountId.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CopyToClipboard } from "components/Common/CopyToClipboard";
import { CopyToClipboardButton } from "components/Common/CopyToClipboardButton";
import { useAppSelector } from "eduid-hooks";
import { useRef } from "react";
import { FormattedMessage } from "react-intl";
Expand Down Expand Up @@ -30,7 +30,7 @@ export function AccountId(): JSX.Element {
</span>
<div className="display-data">
<input readOnly={true} name={eppn} id={idUserEppn} ref={ref} defaultValue={eppn} />
<CopyToClipboard ref={ref} />
<CopyToClipboardButton ref={ref} />
</div>
</div>
</article>
Expand Down
5 changes: 3 additions & 2 deletions src/components/Dashboard/ChangePasswordSuggested.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CopyToClipboard } from "components/Common/CopyToClipboard";
import { CopyToClipboardButton } from "components/Common/CopyToClipboardButton";
import { NewPasswordForm } from "components/Common/NewPasswordForm";
import React, { useRef } from "react";
import { FormattedMessage } from "react-intl";
Expand All @@ -13,14 +13,15 @@ export default function ChangePasswordSuggestedForm(props: ChangePasswordChildFo
<label htmlFor="copy-new-password">
<FormattedMessage defaultMessage="New password" description="new password" />
</label>

<input
name="copy-new-password"
id="copy-new-password"
ref={ref}
defaultValue={props.suggestedPassword}
readOnly={true}
/>
<CopyToClipboard ref={ref} />
<CopyToClipboardButton ref={ref} />
</div>
<NewPasswordForm
suggested_password={props.suggestedPassword}
Expand Down
6 changes: 6 additions & 0 deletions src/components/Dashboard/VerifyIdentity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ function VerifiedIdentitiesTable(): JSX.Element {
const frontend_action = useAppSelector((state) => state.authn.response?.frontend_action);
const [showConfirmRemoveIdentityVerificationModal, setShowConfirmRemoveIdentityVerificationModal] = useState(false);

const intl = useIntl();

useEffect(() => {
if (frontend_action) {
if (frontend_action === "removeIdentity") {
Expand Down Expand Up @@ -209,6 +211,10 @@ function VerifiedIdentitiesTable(): JSX.Element {
buttonstyle="close"
size="sm"
onClick={() => handleConfirmDeleteModal()}
title={intl.formatMessage({
id: "verified identity delete button",
defaultMessage: "Delete this verified identity",
})}
></EduIDButton>
</figure>
)}
Expand Down
2 changes: 2 additions & 0 deletions src/components/IndexMain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import Login from "./Login/Login";
import { LoginExternalReturnHandler } from "./Login/LoginExternalReturnHandler";
import UseOtherDevice2 from "./Login/UseOtherDevice2";
import { ResetPasswordApp } from "./ResetPassword/ResetPasswordApp";
import ScrollToTop from "./ScrollToTop";
import { SignupApp } from "./Signup/SignupApp";
import { Errors } from "./SwamidErrors/Errors";

Expand Down Expand Up @@ -50,6 +51,7 @@ export function IndexMain(): JSX.Element {
<ErrorBoundary FallbackComponent={GenericError}>
<Splash showChildren={isLoaded}>
<section id="content" className="horizontal-content-margin content">
<ScrollToTop />
<Routes>
<Route path="/" element={<Index />} />
{/* Signup */}
Expand Down
12 changes: 12 additions & 0 deletions src/components/ScrollToTop.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { useEffect } from "react";
import { useLocation } from "react-router-dom";

export default function ScrollToTop() {
const { pathname } = useLocation();

useEffect(() => {
window.scrollTo(0, 0);
}, [pathname]);

return null;
}
5 changes: 3 additions & 2 deletions src/styles/_ResetPassword.scss
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ a#resend-phone:not(.button-active) {

.copybutton {
position: absolute;
right: 1rem;
width: auto !important;
right: 1rem;

svg {
color: $txt-black;
Expand All @@ -129,7 +129,8 @@ a#resend-phone:not(.button-active) {
margin-left: -75px;
opacity: 0;
transition: opacity 0.3s;
text-transform: capitalize;
text-transform: none;
line-height: 1.2;
}

.tool-tip-text::after {
Expand Down
6 changes: 2 additions & 4 deletions src/styles/_buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,8 @@ button.btn-icon {
}
}

// login username-pw / reset-password set-new-password
.show-hide-button {
@extend #{".btn", ".btn-link", ".btn-sm"};

//textual toggle control, eg. copy/show
.txt-toggle-btn {
position: absolute;
right: 1rem;
}
Expand Down
12 changes: 6 additions & 6 deletions src/styles/_label.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ label,
}

.border-toggle-area {
flex-basis: 100%;
border-color: var(--borderColor-default,var(--color-border-default,#d0d7de));
border-width: 1px;
border-style: solid;
border-radius: 10px;
padding: 16px;
flex-basis: 100%;
border-color: $border-gray;
border-width: 1px;
border-style: solid;
border-radius: 10px;
padding: 16px;
}
15 changes: 15 additions & 0 deletions src/translation/extractedMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,10 @@
"developer_comment": "security key status",
"string": "Verify"
},
"HgfPrt": {
"developer_comment": "security webauthn describe paragraph",
"string": "Note: this is only for your own use to be able to distinguish between your added keys."
},
"HgjRtU": {
"developer_comment": "button add more",
"string": "+ add more"
Expand Down Expand Up @@ -1336,6 +1340,10 @@
"developer_comment": "eidas proofing help text",
"string": "To use this option you will need to first create a digital ID-card in the {freja_eid_link} app."
},
"YhOtY3": {
"developer_comment": "copied button label",
"string": "COPIED"
},
"Z4yZ3N": {
"developer_comment": "Use another device, finished",
"string": "After using the code on the other device, please close this browser window."
Expand Down Expand Up @@ -1986,6 +1994,10 @@
"developer_comment": "Account recovery cancel information",
"string": "If you decide to cancel, simply click the Go Back button to return to the login page."
},
"kKMiD/": {
"developer_comment": "copy button label",
"string": "COPY"
},
"kN1GC+": {
"developer_comment": "Make primary button",
"string": "make primary"
Expand Down Expand Up @@ -2913,6 +2925,9 @@
"developer_comment": "verification status sub text",
"string": "Your eduID is ready to use."
},
"verified identity delete button": {
"string": "Delete this verified identity"
},
"vmreyb": {
"developer_comment": "accordion item Adding name",
"string": "Add your name"
Expand Down

0 comments on commit f68ef8a

Please sign in to comment.