mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-05-19 06:44:03 +01:00
ux fix
This commit is contained in:
parent
441c3c5752
commit
2a44c619c5
@ -36,6 +36,7 @@ export const CloudShellTerminalComponent: React.FC<CloudShellTerminalComponentPr
|
||||
|
||||
term.loadAddon(fitAddon);
|
||||
|
||||
fitAddon.fit(); // Fit the terminal to the container size
|
||||
// Attach terminal to the DOM
|
||||
if (terminalRef.current) {
|
||||
term.open(terminalRef.current);
|
||||
|
@ -19,6 +19,11 @@ import { ShellTypeHandlerFactory } from "./ShellTypes/ShellTypeFactory";
|
||||
import { AttachAddon } from "./Utils/AttachAddOn";
|
||||
import { askConfirmation, wait } from "./Utils/CommonUtils";
|
||||
import { getNormalizedRegion } from "./Utils/RegionUtils";
|
||||
import {
|
||||
formatErrorMessage,
|
||||
formatInfoMessage,
|
||||
formatWarningMessage
|
||||
} from "./Utils/TerminalLogFormats";
|
||||
|
||||
// Constants
|
||||
const DEFAULT_CLOUDSHELL_REGION = "westus";
|
||||
@ -36,12 +41,12 @@ export const startCloudShellTerminal =
|
||||
|
||||
const resolvedRegion = determineCloudShellRegion();
|
||||
// Ask for user consent for region
|
||||
const consentGranted = await askConfirmation(terminal, "This shell might be in a different region than the database region. Do you want to proceed?");
|
||||
const consentGranted = await askConfirmation(terminal, formatWarningMessage("This shell might be in a different region than the database region. Do you want to proceed?"));
|
||||
if (!consentGranted) {
|
||||
return null; // Exit if user declined
|
||||
}
|
||||
|
||||
terminal.writeln(`Connecting to CloudShell.....`);
|
||||
terminal.writeln(formatInfoMessage("Connecting to CloudShell....."));
|
||||
|
||||
let sessionDetails: {
|
||||
socketUri?: string;
|
||||
@ -52,6 +57,7 @@ export const startCloudShellTerminal =
|
||||
sessionDetails = await provisionCloudShellSession(resolvedRegion, terminal);
|
||||
|
||||
if (!sessionDetails.socketUri) {
|
||||
terminal.writeln(formatErrorMessage("Failed to establish a connection. Please try again later."));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,6 @@ export class MongoShellHandler extends AbstractShellHandler {
|
||||
}
|
||||
|
||||
public getTerminalSuppressedData(): string {
|
||||
return "Non-Generic MongoDB Shell";
|
||||
return "Warning: Non-Genuine MongoDB Detected";
|
||||
}
|
||||
}
|
@ -36,6 +36,6 @@ export class VCoreMongoShellHandler extends AbstractShellHandler {
|
||||
}
|
||||
|
||||
public getTerminalSuppressedData(): string {
|
||||
return "Non-Generic MongoDB Shell";
|
||||
return "Warning: Non-Genuine MongoDB Detected";
|
||||
}
|
||||
}
|
40
src/Explorer/Tabs/CloudShellTab/Utils/TerminalLogFormats.tsx
Normal file
40
src/Explorer/Tabs/CloudShellTab/Utils/TerminalLogFormats.tsx
Normal file
@ -0,0 +1,40 @@
|
||||
|
||||
// Terminal color codes
|
||||
export const TERMINAL_COLORS = {
|
||||
RESET: "\x1b[0m",
|
||||
BRIGHT: "\x1b[1m",
|
||||
DIM: "\x1b[2m",
|
||||
BLACK: "\x1b[30m",
|
||||
RED: "\x1b[31m",
|
||||
GREEN: "\x1b[32m",
|
||||
YELLOW: "\x1b[33m",
|
||||
BLUE: "\x1b[34m",
|
||||
MAGENTA: "\x1b[35m",
|
||||
CYAN: "\x1b[36m",
|
||||
WHITE: "\x1b[37m",
|
||||
BG_BLACK: "\x1b[40m",
|
||||
BG_RED: "\x1b[41m",
|
||||
BG_GREEN: "\x1b[42m",
|
||||
BG_YELLOW: "\x1b[43m",
|
||||
BG_BLUE: "\x1b[44m",
|
||||
BG_MAGENTA: "\x1b[45m",
|
||||
BG_CYAN: "\x1b[46m",
|
||||
BG_WHITE: "\x1b[47m"
|
||||
};
|
||||
|
||||
export const START_MARKER = `echo "START INITIALIZATION" > /dev/null`;
|
||||
export const END_MARKER = `echo "END INITIALIZATION" > /dev/null`;
|
||||
|
||||
// Terminal message formatting functions
|
||||
export const formatInfoMessage = (message: string): string =>
|
||||
`${TERMINAL_COLORS.BRIGHT}${TERMINAL_COLORS.CYAN}${message}${TERMINAL_COLORS.RESET}`;
|
||||
|
||||
export const formatSuccessMessage = (message: string): string =>
|
||||
`${TERMINAL_COLORS.BRIGHT}${TERMINAL_COLORS.GREEN}${message}${TERMINAL_COLORS.RESET}`;
|
||||
|
||||
export const formatWarningMessage = (message: string): string =>
|
||||
`${TERMINAL_COLORS.BRIGHT}${TERMINAL_COLORS.YELLOW}${message}${TERMINAL_COLORS.RESET}`;
|
||||
|
||||
export const formatErrorMessage = (message: string): string =>
|
||||
`${TERMINAL_COLORS.BRIGHT}${TERMINAL_COLORS.RED}${message}${TERMINAL_COLORS.RESET}`;
|
||||
|
Loading…
x
Reference in New Issue
Block a user