Skip to content

Commit e313240

Browse files
committed
Add loading indicator when loading passkey prompt
1 parent 1f21a34 commit e313240

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

src/components/terminal/Terminal.tsx

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ const Terminal = (
7474
if (adminConsoleMode?.screen && adminConsoleMode.provisionForm) {
7575
const form = adminConsoleMode.provisionForm;
7676

77-
if (form.currentField === 'flavorName' || form.currentField === 'color') {
77+
if (form.currentField === "flavorName" || form.currentField === "color") {
7878
e.preventDefault();
79-
const pastedText = e.clipboardData.getData('text');
79+
const pastedText = e.clipboardData.getData("text");
8080

8181
emulatorState.setAdminConsoleMode({
8282
...adminConsoleMode,
@@ -206,6 +206,7 @@ const Terminal = (
206206
0 updates are ready to be installed.
207207
`;
208208

209+
const passwordPrompt = emulatorState.getPasswordPromptState();
209210
return (
210211
<>
211212
{showMOTD && (
@@ -260,19 +261,23 @@ const Terminal = (
260261
<AdminConsole emulatorState={emulatorState} theme={props.theme} />
261262
</Box>
262263
)}
263-
{emulatorState.getPasswordPromptState() ? (
264+
{passwordPrompt ? (
264265
<Box sx={{ display: "flex", alignItems: "center", gap: 1 }}>
265266
<Box component="span" style={{ color: props.theme.outputColor }}>
266267
Password:
267268
</Box>
268-
<Box
269-
width={8}
270-
height={18}
271-
sx={{
272-
visibility: visibleCursor ? "visible" : "hidden",
273-
background: "#FFFFFF"
274-
}}
275-
/>
269+
{passwordPrompt.loading ? (
270+
<>...</>
271+
) : (
272+
<Box
273+
width={8}
274+
height={18}
275+
sx={{
276+
visibility: visibleCursor ? "visible" : "hidden",
277+
background: "#FFFFFF"
278+
}}
279+
/>
280+
)}
276281
<input
277282
ref={ref}
278283
type="text"

src/javascript-terminal/commands/sudo.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export const authenticateWithPasskey = async (
5353
if (!promptState) return;
5454

5555
try {
56+
emulatorState.setPasswordPromptState({ ...promptState, loading: true });
5657
const { data: authOptions } = await axios.post(`${API_URL}/admin/passkey-auth-options`);
5758

5859
const authResponse = await startAuthentication({ optionsJSON: authOptions });

src/javascript-terminal/emulator-state/EmulatorState.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export type AdminConsoleState = {
4545
export type PasswordPromptState = {
4646
targetCommand: string;
4747
targetOptions: string[];
48+
loading?: boolean;
4849
};
4950

5051
const TAB_COUNT_KEY = "tabCount";

0 commit comments

Comments
 (0)