mirror of
https://github.com/apache/superset.git
synced 2024-09-06 22:07:34 -04:00
fix(alerts/reports): modal submit button, copy changes, select apis (#12110)
This commit is contained in:
parent
6e7f276775
commit
ddd2ec59af
@ -101,6 +101,7 @@ const RETENTION_OPTIONS = [
|
||||
|
||||
const DEFAULT_RETENTION = 90;
|
||||
const DEFAULT_WORKING_TIMEOUT = 3600;
|
||||
const DEFAULT_CRON_VALUE = '* * * * *'; // every minute
|
||||
|
||||
const StyledIcon = styled(Icon)`
|
||||
margin: auto ${({ theme }) => theme.gridUnit * 2}px auto 0;
|
||||
@ -612,7 +613,7 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
|
||||
const loadOwnerOptions = (input = '') => {
|
||||
const query = rison.encode({ filter: input });
|
||||
return SupersetClient.get({
|
||||
endpoint: `/api/v1/dashboard/related/owners?q=${query}`,
|
||||
endpoint: `/api/v1/report/related/owners?q=${query}`,
|
||||
}).then(
|
||||
response => {
|
||||
return response.json.result.map((item: any) => ({
|
||||
@ -629,7 +630,7 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
|
||||
const loadSourceOptions = (input = '') => {
|
||||
const query = rison.encode({ filter: input });
|
||||
return SupersetClient.get({
|
||||
endpoint: `/api/v1/dataset/related/database?q=${query}`,
|
||||
endpoint: `/api/v1/report/related/database?q=${query}`,
|
||||
}).then(
|
||||
response => {
|
||||
const list = response.json.result.map((item: any) => ({
|
||||
@ -678,12 +679,12 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
|
||||
const loadDashboardOptions = (input = '') => {
|
||||
const query = rison.encode({ filter: input });
|
||||
return SupersetClient.get({
|
||||
endpoint: `/api/v1/dashboard?q=${query}`,
|
||||
endpoint: `/api/v1/report/related/dashboard?q=${query}`,
|
||||
}).then(
|
||||
response => {
|
||||
const list = response.json.result.map((item: any) => ({
|
||||
value: item.id,
|
||||
label: item.dashboard_title,
|
||||
value: item.value,
|
||||
label: item.text,
|
||||
}));
|
||||
|
||||
setDashboardOptions(list);
|
||||
@ -727,12 +728,12 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
|
||||
const loadChartOptions = (input = '') => {
|
||||
const query = rison.encode({ filter: input });
|
||||
return SupersetClient.get({
|
||||
endpoint: `/api/v1/chart?q=${query}`,
|
||||
endpoint: `/api/v1/report/related/chart?q=${query}`,
|
||||
}).then(
|
||||
response => {
|
||||
const list = response.json.result.map((item: any) => ({
|
||||
value: item.id,
|
||||
label: item.slice_name,
|
||||
value: item.value,
|
||||
label: item.text,
|
||||
}));
|
||||
|
||||
setChartOptions(list);
|
||||
@ -771,12 +772,10 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
|
||||
|
||||
// Updating alert/report state
|
||||
const updateAlertState = (name: string, value: any) => {
|
||||
const data = {
|
||||
...currentAlert,
|
||||
setCurrentAlert(currentAlertData => ({
|
||||
...currentAlertData,
|
||||
[name]: value,
|
||||
};
|
||||
|
||||
setCurrentAlert(data);
|
||||
}));
|
||||
};
|
||||
|
||||
// Handle input/textarea updates
|
||||
@ -960,7 +959,7 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
|
||||
) {
|
||||
setCurrentAlert({
|
||||
active: true,
|
||||
crontab: '',
|
||||
crontab: DEFAULT_CRON_VALUE,
|
||||
log_retention: DEFAULT_RETENTION,
|
||||
working_timeout: DEFAULT_WORKING_TIMEOUT,
|
||||
name: '',
|
||||
@ -1047,7 +1046,7 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
|
||||
<div className="header-section">
|
||||
<StyledInputContainer>
|
||||
<div className="control-label">
|
||||
{t('Alert Name')}
|
||||
{isReport ? t('Report Name') : t('Alert Name')}
|
||||
<span className="required">*</span>
|
||||
</div>
|
||||
<div className="input-container">
|
||||
@ -1055,7 +1054,7 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
|
||||
type="text"
|
||||
name="name"
|
||||
value={currentAlert ? currentAlert.name : ''}
|
||||
placeholder={t('Alert Name')}
|
||||
placeholder={isReport ? t('Report Name') : t('Alert Name')}
|
||||
onChange={onTextChange}
|
||||
/>
|
||||
</div>
|
||||
@ -1189,10 +1188,16 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
|
||||
)}
|
||||
<div className="column schedule">
|
||||
<StyledSectionTitle>
|
||||
<h4>{t('Alert Condition Schedule')}</h4>
|
||||
<h4>
|
||||
{isReport
|
||||
? t('Report Schedule')
|
||||
: t('Alert Condition Schedule')}
|
||||
</h4>
|
||||
</StyledSectionTitle>
|
||||
<AlertReportCronScheduler
|
||||
value={(currentAlert && currentAlert.crontab) || undefined}
|
||||
value={
|
||||
(currentAlert && currentAlert.crontab) || DEFAULT_CRON_VALUE
|
||||
}
|
||||
onChange={newVal => updateAlertState('crontab', newVal)}
|
||||
/>
|
||||
<StyledSectionTitle>
|
||||
|
@ -25,12 +25,12 @@ import { CronPicker, CronError } from 'src/common/components/CronPicker';
|
||||
import { StyledInputContainer } from '../AlertReportModal';
|
||||
|
||||
interface AlertReportCronSchedulerProps {
|
||||
value?: string;
|
||||
value: string;
|
||||
onChange: (change: string) => any;
|
||||
}
|
||||
|
||||
export const AlertReportCronScheduler: FunctionComponent<AlertReportCronSchedulerProps> = ({
|
||||
value = '* * * * *',
|
||||
value,
|
||||
onChange,
|
||||
}) => {
|
||||
const theme = useTheme();
|
||||
|
@ -161,7 +161,7 @@ class ReportScheduleRestApi(BaseSupersetModelRestApi):
|
||||
]
|
||||
search_columns = ["name", "active", "created_by", "type", "last_state"]
|
||||
search_filters = {"name": [ReportScheduleAllTextFilter]}
|
||||
allowed_rel_fields = {"owners", "chart", "dashboard", "database"}
|
||||
allowed_rel_fields = {"owners", "chart", "dashboard", "database", "created_by"}
|
||||
filter_rel_fields = {
|
||||
"chart": [["id", ChartFilter, lambda: []]],
|
||||
"dashboard": [["id", DashboardFilter, lambda: []]],
|
||||
|
Loading…
Reference in New Issue
Block a user