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

fix: Fixed spacing in alert modal #22066

Merged
merged 11 commits into from
Dec 20, 2022
46 changes: 15 additions & 31 deletions superset-frontend/src/views/CRUD/alert/AlertReportModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
SupersetClient,
css,
SupersetTheme,
supersetTheme,
} from '@superset-ui/core';
import rison from 'rison';
import { useSingleViewResource } from 'src/views/CRUD/hooks';
Expand Down Expand Up @@ -555,31 +556,23 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
delete data.last_value_row_json;

updateResource(update_id, data).then(response => {
if (!response) {
return;
}
if (!response) return;

addSuccessToast(t('%s updated', data.type));

if (onAdd) {
onAdd();
}
if (onAdd) onAdd();

hide();
});
}
} else if (currentAlert) {
// Create
createResource(data).then(response => {
if (!response) {
return;
}
if (!response) return;

addSuccessToast(t('%s updated', data.type));

if (onAdd) {
onAdd(response);
}
if (onAdd) onAdd(response);

hide();
});
Expand Down Expand Up @@ -614,9 +607,7 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
(db?: MetaObject) => {
const database = db || currentAlert?.database;

if (!database || database.label) {
return null;
}
if (!database || database.label) return null;

let result;

Expand Down Expand Up @@ -699,9 +690,7 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
const getDashboardData = (db?: MetaObject) => {
const dashboard = db || currentAlert?.dashboard;

if (!dashboard || dashboard.label) {
return null;
}
if (!dashboard || dashboard.label) return null;

let result;

Expand All @@ -719,9 +708,7 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
(chartData?: MetaObject) => {
const chart = chartData || currentAlert?.chart;

if (!chart || chart.label) {
return null;
}
if (!chart || chart.label) return null;

let result;

Expand Down Expand Up @@ -880,9 +867,7 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({

// Make sure notification settings has the required info
const checkNotificationSettings = () => {
if (!notificationSettings.length) {
return false;
}
if (!notificationSettings.length) return false;

let hasInfo = false;

Expand Down Expand Up @@ -1040,9 +1025,7 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
]);

// Show/hide
if (isHidden && show) {
setIsHidden(false);
}
if (isHidden && show) setIsHidden(false);

return (
<StyledModal
Expand Down Expand Up @@ -1128,7 +1111,7 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
onChange={onActiveSwitch}
checked={currentAlert ? currentAlert.active : true}
/>
<div className="switch-label">Active</div>
<div className="switch-label">{t('Active')}</div>
</StyledSwitchContainer>
</div>
<div className="column-section">
Expand Down Expand Up @@ -1285,7 +1268,7 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
placeholder={t('Time in seconds')}
onChange={onTimeoutVerifyChange}
/>
<span className="input-label">seconds</span>
<span className="input-label">{t('seconds')}</span>
</div>
</StyledInputContainer>
{!isReport && (
Expand All @@ -1300,7 +1283,7 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
placeholder={t('Time in seconds')}
onChange={onTimeoutVerifyChange}
/>
<span className="input-label">seconds</span>
<span className="input-label">{t('seconds')}</span>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You got it! Done in this commit. (I think I got them all!)

</div>
</StyledInputContainer>
)}
Expand Down Expand Up @@ -1335,6 +1318,7 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
ariaLabel={t('Dashboard')}
css={{
display: contentType === 'dashboard' ? 'inline' : 'none',
margin: `${supersetTheme.gridUnit * 2}px 0`,
}}
name="dashboard"
value={
Expand Down Expand Up @@ -1374,7 +1358,7 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
checked={forceScreenshot}
onChange={onForceScreenshotChange}
>
Ignore cache when generating screenshot
{t('Ignore cache when generating screenshot')}
</StyledCheckbox>
</div>
)}
Expand Down