Skip to content

Commit

Permalink
fix: alert/report created by filter inconsistency with table display (#…
Browse files Browse the repository at this point in the history
…19518)

* fix: alert/report created by filter inconsistency with table display

* Match column order to dashboard list
  • Loading branch information
diegomedina248 committed Apr 18, 2022
1 parent cf51459 commit a05ff5e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
30 changes: 26 additions & 4 deletions superset-frontend/src/views/CRUD/alert/AlertList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function AlertList({
const title = isReportEnabled ? t('report') : t('alert');
const titlePlural = isReportEnabled ? t('reports') : t('alerts');
const pathName = isReportEnabled ? 'Reports' : 'Alerts';
const initalFilters = useMemo(
const initialFilters = useMemo(
() => [
{
id: 'type',
Expand Down Expand Up @@ -117,7 +117,7 @@ function AlertList({
addDangerToast,
true,
undefined,
initalFilters,
initialFilters,
);

const { updateResource } = useSingleViewResource<Partial<AlertObject>>(
Expand Down Expand Up @@ -261,9 +261,15 @@ function AlertList({
size: 'xl',
},
{
accessor: 'created_by',
Cell: ({
row: {
original: { created_by },
},
}: any) =>
created_by ? `${created_by.first_name} ${created_by.last_name}` : '',
Header: t('Created by'),
id: 'created_by',
disableSortBy: true,
hidden: true,
size: 'xl',
},
{
Expand Down Expand Up @@ -378,6 +384,22 @@ function AlertList({

const filters: Filters = useMemo(
() => [
{
Header: t('Owner'),
id: 'owners',
input: 'select',
operator: FilterOperator.relationManyMany,
unfilteredLabel: 'All',
fetchSelects: createFetchRelated(
'report',
'owners',
createErrorHandler(errMsg =>
t('An error occurred while fetching owners values: %s', errMsg),
),
user,
),
paginate: true,
},
{
Header: t('Created by'),
id: 'created_by',
Expand Down
2 changes: 2 additions & 0 deletions superset/reports/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ def ensure_alert_reports_enabled(self) -> Optional[Response]:
"name",
"active",
"created_by",
"owners",
"type",
"last_state",
"creation_method",
Expand All @@ -212,6 +213,7 @@ def ensure_alert_reports_enabled(self) -> Optional[Response]:
"chart": "slice_name",
"database": "database_name",
"created_by": RelatedFieldFilter("first_name", FilterRelatedOwners),
"owners": RelatedFieldFilter("first_name", FilterRelatedOwners),
}

apispec_parameter_schemas = {
Expand Down

0 comments on commit a05ff5e

Please sign in to comment.