Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce machine learning table spacing when new home page enabled #377

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion public/components/common/refresh_interval.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ const intervalUnitOptions = [
{ text: 'hours', value: 'h' },
];

const MAX_SIGNED_32_BIT_INTEGER = 2147483647;

export const RefreshInterval = ({
onRefresh,
onRefreshChange,
Expand Down Expand Up @@ -98,9 +100,14 @@ export const RefreshInterval = ({
}
} else {
if (interval !== null) {
/**
* According https://developer.mozilla.org/en-US/docs/Web/API/setInterval#return_value
* the max delayed value of setInterval is MAX_SIGNED_32_BIT_INTEGER, the inner function will be executed immediately
* if the delayed value is greater than MAX_SIGNED_32_BIT_INTEGER. Add a Math.min here to avoid been executed immediately.
**/
intervalId = window.setInterval(() => {
onRefresh();
}, interval);
}, Math.min(interval, MAX_SIGNED_32_BIT_INTEGER));
}
}

Expand Down
39 changes: 20 additions & 19 deletions public/components/monitoring/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,28 +104,29 @@ export const Monitoring = (props: MonitoringProps) => {
/>
<EuiPanel>
{!useNewPageHeader && (
<EuiText size="s">
<h2>
<FormattedMessage
id="machineLearning.aiModels.table.header.title"
defaultMessage="Models {records}"
values={{
records:
pageStatus === 'normal' ? (
<EuiTextColor aria-label="total number of results" color="subdued">
({pagination?.totalRecords ?? 0})
</EuiTextColor>
) : undefined,
}}
/>
</h2>
</EuiText>
<>
<EuiText size="s">
<h2>
<FormattedMessage
id="machineLearning.aiModels.table.header.title"
defaultMessage="Models {records}"
values={{
records:
pageStatus === 'normal' ? (
<EuiTextColor aria-label="total number of results" color="subdued">
({pagination?.totalRecords ?? 0})
</EuiTextColor>
) : undefined,
}}
/>
</h2>
</EuiText>
<EuiSpacer size="m" />
</>
)}

<EuiSpacer size="m" />
{pageStatus !== 'empty' && (
<>
<EuiFlexGroup gutterSize="l">
<EuiFlexGroup gutterSize={useNewPageHeader ? 's' : 'l'}>
<EuiFlexItem>
<SearchBar inputRef={setInputRef} onSearch={searchByNameOrId} />
</EuiFlexItem>
Expand Down
6 changes: 5 additions & 1 deletion public/components/monitoring/monitoring_page_header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ export const MonitoringPageHeader = ({
if (useNewPageHeader) {
return [
{
renderComponent: <RefreshInterval onRefresh={onRefresh} />,
renderComponent: (
<div style={{ width: 227 }}>
<RefreshInterval onRefresh={onRefresh} />
</div>
),
},
];
}
Expand Down
Loading