The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Convert PasswordReveal to TypeScript (#69061)
Fraser3bceaecf2b35
diff --git a/frontend/src/metabase/common/components/PasswordReveal/PasswordReveal.jsx b/frontend/src/metabase/common/components/PasswordReveal/PasswordReveal.jsxdeleted file mode 100644index 3da7ccb1e85..00000000000--- a/frontend/src/metabase/common/components/PasswordReveal/PasswordReveal.jsx+++ /dev/null@@ -1,89 +0,0 @@-/* eslint-disable react/prop-types */-/* flow */-import cx from "classnames";-import { Component } from "react";-import { t } from "ttag";--import CS from "metabase/css/core/index.css";-import { color } from "metabase/ui/utils/colors";--import { PasswordCopyButton } from "./PasswordReveal.styled";--const styles = {- input: {- fontSize: "1.2rem",- letterSpacing: "2",- color: color("text-primary"),- outline: "none",- },-};--const Label = () => (- <div- style={{ top: -12 }}- className={cx(CS.absolute, CS.textCentered, CS.left, CS.right)}- >- <span- className={cx(- CS.px1,- CS.bgWhite,- CS.h6,- CS.textBold,- CS.textMedium,- CS.textUppercase,- )}- >- {t`Temporary Password`}- </span>- </div>-);--export class PasswordReveal extends Component {- state = { visible: false };-- render() {- const { password } = this.props;- const { visible } = this.state;-- return (- <div- style={{ borderWidth: 2 }}- className={cx(- CS.bordered,- CS.rounded,- CS.flex,- CS.alignCenter,- CS.p3,- CS.relative,- )}- >- <Label />- {visible ? (- <input- style={styles.input}- className={cx(CS.textLight, CS.textNormal, CS.mr3, CS.borderless)}- value={password}- onClick={({ target }) =>- target.setSelectionRange(0, target.value.length)- }- />- ) : (- // eslint-disable-next-line i18next/no-literal-string- <span style={styles.input} className={CS.mr3}>- ●●●●●●●●●●●●- </span>- )}- <div className={cx(CS.mlAuto, CS.flex, CS.alignCenter)}>- <a- className={cx(CS.link, CS.textBold, CS.mr2)}- onClick={() => this.setState({ visible: !visible })}- >- {visible ? t`Hide` : t`Show`}- </a>-- <PasswordCopyButton value={password} />- </div>- </div>- );- }-}diff --git a/frontend/src/metabase/common/components/PasswordReveal/PasswordReveal.tsx b/frontend/src/metabase/common/components/PasswordReveal/PasswordReveal.tsxnew file mode 100644index 00000000000..5a7e5f69516--- /dev/null+++ b/frontend/src/metabase/common/components/PasswordReveal/PasswordReveal.tsx@@ -0,0 +1,88 @@+import cx from "classnames";+import { useState } from "react";+import { t } from "ttag";++import CS from "metabase/css/core/index.css";+import { color } from "metabase/ui/utils/colors";++import { PasswordCopyButton } from "./PasswordReveal.styled";++const styles = {+ input: {+ fontSize: "1.2rem",+ letterSpacing: "2",+ color: color("text-primary"),+ outline: "none",+ },+};++const Label = () => (+ <div+ style={{ top: -12 }}+ className={cx(CS.absolute, CS.textCentered, CS.left, CS.right)}+ >+ <span+ className={cx(+ CS.px1,+ CS.bgWhite,+ CS.h6,+ CS.textBold,+ CS.textMedium,+ CS.textUppercase,+ )}+ >+ {t`Temporary Password`}+ </span>+ </div>+);++interface PasswordRevealProps {+ password: string;+}++export const PasswordReveal = ({ password }: PasswordRevealProps) => {+ const [visible, setVisible] = useState(false);++ return (+ <div+ style={{ borderWidth: 2 }}+ className={cx(+ CS.bordered,+ CS.rounded,+ CS.flex,+ CS.alignCenter,+ CS.p3,+ CS.relative,+ )}+ >+ <Label />+ {visible ? (+ <input+ style={styles.input}+ className={cx(CS.textLight, CS.textNormal, CS.mr3, CS.borderless)}+ value={password}+ onClick={(e) => {+ const target = e.currentTarget;+ target.setSelectionRange(0, target.value.length);+ }}+ readOnly+ />+ ) : (+ // eslint-disable-next-line i18next/no-literal-string+ <span style={styles.input} className={CS.mr3}>+ ●●●●●●●●●●●●+ </span>+ )}+ <div className={cx(CS.mlAuto, CS.flex, CS.alignCenter)}>+ <a+ className={cx(CS.link, CS.textBold, CS.mr2)}+ onClick={() => setVisible(!visible)}+ >+ {visible ? t`Hide` : t`Show`}+ </a>++ <PasswordCopyButton value={password} />+ </div>+ </div>+ );+};