Skip to content
Snippets Groups Projects
Unverified Commit 14672579 authored by Cal Herries's avatar Cal Herries Committed by GitHub
Browse files

Display the original field name when editing model column metadata (#24848)


* Display original field name with  form input

* Add subtitle through to input component (#24859)

* Add subtitle through input component

* Adjust layout

Co-authored-by: default avatarCallum Herries <hi@callumherries.com>

Co-authored-by: default avatarGustavo Saiani <gustavo@poe.ma>
parent 337bf792
No related branches found
No related tags found
No related merge requests found
...@@ -14,6 +14,7 @@ const propTypes = { ...@@ -14,6 +14,7 @@ const propTypes = {
autoFocus: PropTypes.bool, autoFocus: PropTypes.bool,
helperText: PropTypes.node, helperText: PropTypes.node,
tabIndex: PropTypes.string, tabIndex: PropTypes.string,
subtitle: PropTypes.string,
}; };
const FormInputWidget = forwardRef(function FormInputWidget( const FormInputWidget = forwardRef(function FormInputWidget(
...@@ -25,6 +26,7 @@ const FormInputWidget = forwardRef(function FormInputWidget( ...@@ -25,6 +26,7 @@ const FormInputWidget = forwardRef(function FormInputWidget(
autoFocus, autoFocus,
helperText, helperText,
tabIndex, tabIndex,
subtitle,
}, },
ref, ref,
) { ) {
...@@ -41,6 +43,7 @@ const FormInputWidget = forwardRef(function FormInputWidget( ...@@ -41,6 +43,7 @@ const FormInputWidget = forwardRef(function FormInputWidget(
rightIconTooltip={helperText} rightIconTooltip={helperText}
tabIndex={tabIndex} tabIndex={tabIndex}
fullWidth fullWidth
subtitle={subtitle}
ref={ref} ref={ref}
/> />
); );
......
import styled from "@emotion/styled"; import styled from "@emotion/styled";
import { css } from "@emotion/react"; import { css } from "@emotion/react";
import { color } from "metabase/lib/colors"; import { color } from "metabase/lib/colors";
import { space } from "metabase/styled-components/theme"; import { monospaceFontFamily, space } from "metabase/styled-components/theme";
import IconButtonWrapper from "metabase/components/IconButtonWrapper"; import IconButtonWrapper from "metabase/components/IconButtonWrapper";
import { InputSize } from "./types"; import { InputSize } from "./types";
...@@ -11,6 +11,7 @@ export interface InputProps { ...@@ -11,6 +11,7 @@ export interface InputProps {
fullWidth?: boolean; fullWidth?: boolean;
hasLeftIcon?: boolean; hasLeftIcon?: boolean;
hasRightIcon?: boolean; hasRightIcon?: boolean;
subtitle?: string;
} }
export const InputRoot = styled.div<InputProps>` export const InputRoot = styled.div<InputProps>`
...@@ -68,6 +69,12 @@ export const InputField = styled.input<InputProps>` ...@@ -68,6 +69,12 @@ export const InputField = styled.input<InputProps>`
line-height: 1rem; line-height: 1rem;
padding: 0.4375rem 0.625rem; padding: 0.4375rem 0.625rem;
`}; `};
${props =>
props.subtitle &&
css`
padding-top: 1.75rem;
`};
`; `;
export const InputButton = styled(IconButtonWrapper)` export const InputButton = styled(IconButtonWrapper)`
...@@ -84,3 +91,12 @@ export const InputLeftButton = styled(InputButton)` ...@@ -84,3 +91,12 @@ export const InputLeftButton = styled(InputButton)`
export const InputRightButton = styled(InputButton)` export const InputRightButton = styled(InputButton)`
right: 0; right: 0;
`; `;
export const InputSubtitle = styled.div`
color: ${color("text-light")};
position: absolute;
top: 1.25em;
left: 1.25em;
font-family: ${monospaceFontFamily};
font-size: 0.75em;
`;
...@@ -12,6 +12,7 @@ import { ...@@ -12,6 +12,7 @@ import {
InputLeftButton, InputLeftButton,
InputRightButton, InputRightButton,
InputRoot, InputRoot,
InputSubtitle,
} from "./Input.styled"; } from "./Input.styled";
import { InputSize } from "./types"; import { InputSize } from "./types";
...@@ -29,6 +30,7 @@ export interface InputProps extends InputAttributes { ...@@ -29,6 +30,7 @@ export interface InputProps extends InputAttributes {
leftIconTooltip?: ReactNode; leftIconTooltip?: ReactNode;
rightIcon?: string; rightIcon?: string;
rightIconTooltip?: ReactNode; rightIconTooltip?: ReactNode;
subtitle?: string;
onLeftIconClick?: (event: MouseEvent<HTMLButtonElement>) => void; onLeftIconClick?: (event: MouseEvent<HTMLButtonElement>) => void;
onRightIconClick?: (event: MouseEvent<HTMLButtonElement>) => void; onRightIconClick?: (event: MouseEvent<HTMLButtonElement>) => void;
} }
...@@ -47,6 +49,7 @@ const Input = forwardRef(function Input( ...@@ -47,6 +49,7 @@ const Input = forwardRef(function Input(
rightIconTooltip, rightIconTooltip,
onLeftIconClick, onLeftIconClick,
onRightIconClick, onRightIconClick,
subtitle,
...props ...props
}: InputProps, }: InputProps,
ref: Ref<HTMLDivElement>, ref: Ref<HTMLDivElement>,
...@@ -58,6 +61,8 @@ const Input = forwardRef(function Input( ...@@ -58,6 +61,8 @@ const Input = forwardRef(function Input(
style={style} style={style}
fullWidth={fullWidth} fullWidth={fullWidth}
> >
{subtitle && <InputSubtitle>{subtitle}</InputSubtitle>}
<InputField <InputField
{...props} {...props}
ref={inputRef} ref={inputRef}
...@@ -65,6 +70,7 @@ const Input = forwardRef(function Input( ...@@ -65,6 +70,7 @@ const Input = forwardRef(function Input(
hasError={error} hasError={error}
fullWidth={fullWidth} fullWidth={fullWidth}
hasRightIcon={Boolean(rightIcon)} hasRightIcon={Boolean(rightIcon)}
subtitle={subtitle}
/> />
{leftIcon && ( {leftIcon && (
<Tooltip tooltip={leftIconTooltip} placement="left" offset={[0, 24]}> <Tooltip tooltip={leftIconTooltip} placement="left" offset={[0, 24]}>
......
...@@ -68,7 +68,7 @@ function getSemanticTypeOptions() { ...@@ -68,7 +68,7 @@ function getSemanticTypeOptions() {
]; ];
} }
function getFormFields({ dataset }) { function getFormFields({ dataset, field }) {
const visibilityTypeOptions = field_visibility_types const visibilityTypeOptions = field_visibility_types
.filter(type => type.id !== "sensitive") .filter(type => type.id !== "sensitive")
.map(type => ({ .map(type => ({
...@@ -78,7 +78,11 @@ function getFormFields({ dataset }) { ...@@ -78,7 +78,11 @@ function getFormFields({ dataset }) {
return formFieldValues => return formFieldValues =>
[ [
{ name: "display_name", title: t`Display name` }, {
name: "display_name",
title: t`Display name`,
subtitle: field.name,
},
{ {
name: "description", name: "description",
title: t`Description`, title: t`Description`,
...@@ -172,9 +176,9 @@ function DatasetFieldMetadataSidebar({ ...@@ -172,9 +176,9 @@ function DatasetFieldMetadataSidebar({
const form = useMemo( const form = useMemo(
() => ({ () => ({
fields: getFormFields({ dataset }), fields: getFormFields({ dataset, field }),
}), }),
[dataset], [field, dataset],
); );
const [tab, setTab] = useState(TAB.SETTINGS); const [tab, setTab] = useState(TAB.SETTINGS);
......
export * from "./media-queries"; export * from "./media-queries";
export * from "./space"; export * from "./space";
export * from "./typography";
export const monospaceFontFamily = "Monaco, monospace";
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment