Compare commits

...

2 Commits

Author SHA1 Message Date
Fraser
33c5d5f170 Tighten types for ImpersonationWarning 2026-02-10 15:56:14 +13:00
Fraser
038954de86 Convert Code to TypeScript
Closes DEV-1426

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 16:45:04 +13:00
2 changed files with 17 additions and 14 deletions

View File

@@ -16,7 +16,10 @@ interface ImpersonationWarningProps {
export const ImpersonationWarning = ({
database,
}: ImpersonationWarningProps) => {
const databaseUser = database.details && database.details.user;
const databaseUser =
database.details?.user !== null && database.details?.user !== undefined
? String(database.details.user)
: null;
const isRedshift = database.engine === "redshift";
// eslint-disable-next-line metabase/no-literal-metabase-strings -- Metabase settings

View File

@@ -1,17 +1,26 @@
/* eslint "react/prop-types": "warn" */
import PropTypes from "prop-types";
import type { ReactNode } from "react";
import { Fragment } from "react";
import CS from "metabase/css/core/index.css";
import type { TextProps } from "metabase/ui";
import { Text } from "metabase/ui";
export const BoldCode = ({ children, ...props }) => (
interface BoldCodeProps extends TextProps {
children: ReactNode;
}
export const BoldCode = ({ children, ...props }: BoldCodeProps) => (
<Text fw="bold" color="brand" component="span" {...props}>
<code>{children}</code>
</Text>
);
export const Code = ({ children, block }) => {
interface CodeProps {
children: ReactNode;
block?: boolean;
}
export const Code = ({ children, block }: CodeProps) => {
if (block) {
return <div className={CS.textCode}>{children}</div>;
} else if (typeof children === "string" && children.split(/\n/g).length > 1) {
@@ -31,12 +40,3 @@ export const Code = ({ children, block }) => {
return <span className={CS.textCode}>{children}</span>;
}
};
BoldCode.propTypes = {
children: PropTypes.any.isRequired,
};
Code.propTypes = {
children: PropTypes.any.isRequired,
block: PropTypes.bool,
};