Fix: prevent queryDisplyText in QueryRowHeader from overflowing (#40094)

* Revert "Fix Query Editor Row horizontal overflow (#39419)"

This reverts commit 42b1fa0f62.

* fix: prevent queryDisplyText in QueryRowHeader from overflowing
This commit is contained in:
Giordano Ricci 2021-10-07 09:13:07 +01:00 committed by GitHub
parent d9ca3c5c5d
commit 95d9722afa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 86 additions and 80 deletions

View File

@ -75,6 +75,7 @@ export const QueryOperationRow: React.FC<QueryOperationRowProps> = ({
const rowHeader = ( const rowHeader = (
<div className={styles.header}> <div className={styles.header}>
<div className={styles.column}>
<Icon <Icon
name={isContentVisible ? 'angle-down' : 'angle-right'} name={isContentVisible ? 'angle-down' : 'angle-right'}
className={styles.collapseIcon} className={styles.collapseIcon}
@ -86,11 +87,15 @@ export const QueryOperationRow: React.FC<QueryOperationRowProps> = ({
</div> </div>
)} )}
{headerElementRendered} {headerElementRendered}
{actions && <div>{actionsElement}</div>} </div>
<div className={styles.column}>
{actionsElement}
{draggable && ( {draggable && (
<Icon title="Drag and drop to reorder" name="draggabledots" size="lg" className={styles.dragIcon} /> <Icon title="Drag and drop to reorder" name="draggabledots" size="lg" className={styles.dragIcon} />
)} )}
</div> </div>
</div>
); );
if (draggable) { if (draggable) {
@ -124,11 +129,13 @@ const getQueryOperationRowStyles = stylesFactory((theme: GrafanaTheme) => {
margin-bottom: ${theme.spacing.md}; margin-bottom: ${theme.spacing.md};
`, `,
header: css` header: css`
label: Header;
padding: ${theme.spacing.xs} ${theme.spacing.sm}; padding: ${theme.spacing.xs} ${theme.spacing.sm};
border-radius: ${theme.border.radius.sm}; border-radius: ${theme.border.radius.sm};
background: ${theme.colors.bg2}; background: ${theme.colors.bg2};
min-height: ${theme.spacing.formInputHeight}px; min-height: ${theme.spacing.formInputHeight}px;
display: flex; display: grid;
grid-template-columns: minmax(100px, max-content) min-content;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
white-space: nowrap; white-space: nowrap;
@ -137,6 +144,11 @@ const getQueryOperationRowStyles = stylesFactory((theme: GrafanaTheme) => {
outline: none; outline: none;
} }
`, `,
column: css`
label: Column;
display: flex;
align-items: center;
`,
dragIcon: css` dragIcon: css`
cursor: grab; cursor: grab;
color: ${theme.colors.textWeak}; color: ${theme.colors.textWeak};
@ -164,6 +176,7 @@ const getQueryOperationRowStyles = stylesFactory((theme: GrafanaTheme) => {
color: ${theme.colors.textBlue}; color: ${theme.colors.textBlue};
margin-left: ${theme.spacing.sm}; margin-left: ${theme.spacing.sm};
overflow: hidden; overflow: hidden;
text-overflow: ellipsis;
`, `,
content: css` content: css`
margin-top: ${theme.spacing.inlineFormMargin}; margin-top: ${theme.spacing.inlineFormMargin};

View File

@ -80,6 +80,7 @@ export const QueryEditorRowHeader = <TQuery extends DataQuery>(props: Props<TQue
}; };
return ( return (
<>
<div className={styles.wrapper}> <div className={styles.wrapper}>
{!isEditing && ( {!isEditing && (
<button <button
@ -93,6 +94,7 @@ export const QueryEditorRowHeader = <TQuery extends DataQuery>(props: Props<TQue
<Icon name="pen" className={styles.queryEditIcon} size="sm" /> <Icon name="pen" className={styles.queryEditIcon} size="sm" />
</button> </button>
)} )}
{isEditing && ( {isEditing && (
<> <>
<Input <Input
@ -113,13 +115,14 @@ export const QueryEditorRowHeader = <TQuery extends DataQuery>(props: Props<TQue
{renderDataSource(props, styles)} {renderDataSource(props, styles)}
{renderExtras && <div className={styles.itemWrapper}>{renderExtras()}</div>} {renderExtras && <div className={styles.itemWrapper}>{renderExtras()}</div>}
{disabled && <em className={styles.contextInfo}>Disabled</em>} {disabled && <em className={styles.contextInfo}>Disabled</em>}
</div>
{collapsedText && ( {collapsedText && (
<div className={styles.collapsedText} onClick={onClick}> <div className={styles.collapsedText} onClick={onClick}>
{collapsedText} {collapsedText}
</div> </div>
)} )}
</div> </>
); );
}; };
@ -143,25 +146,12 @@ const renderDataSource = <TQuery extends DataQuery>(
const getStyles = (theme: GrafanaTheme) => { const getStyles = (theme: GrafanaTheme) => {
return { return {
wrapper: css` wrapper: css`
label: Wrapper;
display: flex; display: flex;
align-items: center; align-items: center;
flex-grow: 1;
margin-left: ${theme.spacing.xs}; margin-left: ${theme.spacing.xs};
overflow: hidden;
&:hover {
.query-name-wrapper {
background: ${theme.colors.bg3};
border: 1px dashed ${theme.colors.border3};
}
.query-name-edit-icon {
visibility: visible;
}
}
`, `,
queryNameWrapper: cx( queryNameWrapper: css`
css`
display: flex; display: flex;
cursor: pointer; cursor: pointer;
border: 1px solid transparent; border: 1px solid transparent;
@ -171,16 +161,22 @@ const getStyles = (theme: GrafanaTheme) => {
margin: 0; margin: 0;
background: transparent; background: transparent;
&:hover {
background: ${theme.colors.bg3};
border: 1px dashed ${theme.colors.border3};
}
&:focus { &:focus {
border: 2px solid ${theme.colors.formInputBorderActive}; border: 2px solid ${theme.colors.formInputBorderActive};
}
&:hover,
&:focus {
.query-name-edit-icon { .query-name-edit-icon {
visibility: visible; visibility: visible;
} }
} }
`, `,
'query-name-wrapper'
),
queryName: css` queryName: css`
font-weight: ${theme.typography.weight.semibold}; font-weight: ${theme.typography.weight.semibold};
color: ${theme.colors.textBlue}; color: ${theme.colors.textBlue};
@ -207,10 +203,8 @@ const getStyles = (theme: GrafanaTheme) => {
align-items: center; align-items: center;
overflow: hidden; overflow: hidden;
font-style: italic; font-style: italic;
overflow: hidden;
white-space: nowrap; white-space: nowrap;
text-overflow: ellipsis; text-overflow: ellipsis;
min-width: 0;
`, `,
contextInfo: css` contextInfo: css`
font-size: ${theme.typography.size.sm}; font-size: ${theme.typography.size.sm};

View File

@ -141,7 +141,6 @@
display: flex; display: flex;
flex: 1 1 auto; flex: 1 1 auto;
flex-direction: column; flex-direction: column;
width: 100%;
} }
.explore.explore-live { .explore.explore-live {