[v10.0.x] AzureMonitor: Fix resource selection growing over resource selection table (#71862)

AzureMonitor: Fix resource selection growing over resource selection table (#71463)

* AzureMonitor: Fix resource selection growing over resource selection table

* Unstick ResourcePicker footer, fix sizing

(cherry picked from commit 409eae6ff9)
This commit is contained in:
Adam Yeats
2023-07-18 17:51:44 +03:00
committed by GitHub
parent a347d3d9c2
commit 55784a2201
3 changed files with 40 additions and 35 deletions
+3 -3
View File
@@ -11,10 +11,10 @@ const absRequire = createRequire(absPnpApiPath);
if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require prettier/index.js
// Setup the environment to be able to require prettier
require(absPnpApiPath).setup();
}
}
// Defer to the real prettier/index.js your application uses
module.exports = absRequire(`prettier/index.js`);
// Defer to the real prettier your application uses
module.exports = absRequire(`prettier`);
@@ -2,7 +2,7 @@ import { cx } from '@emotion/css';
import React, { useCallback, useEffect, useState } from 'react';
import { useEffectOnce } from 'react-use';
import { Alert, Button, LoadingPlaceholder, useStyles2 } from '@grafana/ui';
import { Alert, Button, LoadingPlaceholder, Modal, useStyles2 } from '@grafana/ui';
import { selectors } from '../../e2e/selectors';
import ResourcePickerData, { ResourcePickerQueryType } from '../../resourcePicker/resourcePickerData';
@@ -170,7 +170,7 @@ const ResourcePicker = ({
);
return (
<div>
<>
<Search searchFn={handleSearch} />
{shouldShowLimitFlag ? (
<p className={styles.resultLimit}>Showing first {resourcePickerData.resultLimit} results</p>
@@ -188,7 +188,7 @@ const ResourcePicker = ({
</thead>
</table>
<div className={styles.tableScroller}>
<div className={cx(styles.scrollableTable, styles.tableScroller)}>
<table className={styles.table}>
<tbody>
{isLoading && (
@@ -223,12 +223,12 @@ const ResourcePicker = ({
</table>
</div>
<div className={styles.selectionFooter}>
<footer className={styles.selectionFooter}>
{selectedRows.length > 0 && (
<>
<h5>Selection</h5>
<div className={styles.tableScroller}>
<div className={cx(styles.scrollableTable, styles.selectedTableScroller)}>
<table className={styles.table}>
<tbody>
{selectedRows.map((row) => (
@@ -263,30 +263,29 @@ const ResourcePicker = ({
<Space v={2} />
<Button
disabled={!!errorMessage || !internalSelected.every(isValid)}
onClick={handleApply}
data-testid={selectors.components.queryEditor.resourcePicker.apply.button}
>
Apply
</Button>
{errorMessage && (
<>
<Space v={2} />
<Alert severity="error" title="An error occurred while requesting resources from Azure Monitor">
{errorMessage}
</Alert>
</>
)}
<Space layout="inline" h={1} />
<Button onClick={onCancel} variant="secondary">
Cancel
</Button>
</div>
{errorMessage && (
<>
<Space v={2} />
<Alert severity="error" title="An error occurred while requesting resources from Azure Monitor">
{errorMessage}
</Alert>
</>
)}
</div>
<Modal.ButtonRow>
<Button onClick={onCancel} variant="secondary" fill="outline">
Cancel
</Button>
<Button
disabled={!!errorMessage || !internalSelected.every(isValid)}
onClick={handleApply}
data-testid={selectors.components.queryEditor.resourcePicker.apply.button}
>
Apply
</Button>
</Modal.ButtonRow>
</footer>
</>
);
};
@@ -6,11 +6,19 @@ const getStyles = (theme: GrafanaTheme2) => ({
table: css({
width: '100%',
tableLayout: 'fixed',
overflow: 'scroll',
}),
scrollableTable: css({
overflow: 'auto',
}),
tableScroller: css({
maxHeight: '50vh',
overflow: 'auto',
maxHeight: '16vh',
}),
selectedTableScroller: css({
maxHeight: '13vh',
}),
header: css({
@@ -81,8 +89,6 @@ const getStyles = (theme: GrafanaTheme2) => ({
}),
selectionFooter: css({
position: 'sticky',
bottom: 0,
background: theme.colors.background.primary,
paddingTop: theme.spacing(2),
}),