Skip to content
Snippets Groups Projects
Unverified Commit 85f486c2 authored by Oisin Coveney's avatar Oisin Coveney Committed by GitHub
Browse files

Convert AccountHeader to TS (#41181)

parent 450ab94d
Branches
Tags
No related merge requests found
import PropTypes from "prop-types";
import type { Path } from "history";
import { useMemo } from "react";
import { t } from "ttag";
import Radio from "metabase/core/components/Radio";
import { getFullName } from "metabase/lib/user";
import { PLUGIN_IS_PASSWORD_USER } from "metabase/plugins";
import type { User } from "metabase-types/api";
import {
AccountHeaderRoot,
HeaderAvatar,
HeaderSection,
HeaderTitle,
HeaderSubtitle,
HeaderTitle,
} from "./AccountHeader.styled";
const propTypes = {
user: PropTypes.object.isRequired,
path: PropTypes.string,
onChangeLocation: PropTypes.func,
type AccountHeaderProps = {
user: User;
path?: string;
onChangeLocation?: (nextLocation: Path) => void;
};
const AccountHeader = ({ user, path, onChangeLocation }) => {
export const AccountHeader = ({
user,
path,
onChangeLocation,
}: AccountHeaderProps) => {
const hasPasswordChange = useMemo(
() => PLUGIN_IS_PASSWORD_USER.every(predicate => predicate(user)),
[user],
......@@ -56,7 +61,3 @@ const AccountHeader = ({ user, path, onChangeLocation }) => {
</AccountHeaderRoot>
);
};
AccountHeader.propTypes = propTypes;
export default AccountHeader;
import { fireEvent, render, screen } from "@testing-library/react";
import { PLUGIN_IS_PASSWORD_USER } from "metabase/plugins";
import { createMockUser } from "metabase-types/api/mocks";
import AccountHeader from "./AccountHeader";
import { AccountHeader } from "./AccountHeader";
const getUser = () => ({
id: 1,
first_name: "John",
last_name: "Doe",
email: "john@metabase.test",
google_auth: true,
});
const getUser = () =>
createMockUser({
id: 1,
first_name: "John",
last_name: "Doe",
email: "john@metabase.test",
google_auth: true,
});
describe("AccountHeader", () => {
const ORIGINAL_PLUGIN_IS_PASSWORD_USER = [...PLUGIN_IS_PASSWORD_USER];
......
export { default } from "./AccountHeader";
export { AccountHeader } from "./AccountHeader";
import PropTypes from "prop-types";
import AccountHeader from "../AccountHeader";
import { AccountHeader } from "../AccountHeader";
import { AccountContent } from "./AccountLayout.styled";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment