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
  • Loading branch information
diegomedina248 committed Apr 6, 2022
1 parent c4baa82 commit 710d05f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
37 changes: 29 additions & 8 deletions superset-frontend/src/views/CRUD/alert/AlertList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,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 @@ -118,7 +118,7 @@ function AlertList({
addDangerToast,
true,
undefined,
initalFilters,
initialFilters,
);

const { updateResource } = useSingleViewResource<Partial<AlertObject>>(
Expand Down Expand Up @@ -261,12 +261,6 @@ function AlertList({
disableSortBy: true,
size: 'xl',
},
{
accessor: 'created_by',
disableSortBy: true,
hidden: true,
size: 'xl',
},
{
Cell: ({
row: {
Expand All @@ -278,6 +272,17 @@ function AlertList({
disableSortBy: true,
size: 'xl',
},
{
Cell: ({
row: {
original: { created_by },
},
}: any) => <FacePile users={[created_by]} />,
Header: t('Created by'),
id: 'created_by',
disableSortBy: true,
size: 'xl',
},
{
Cell: ({ row: { original } }: any) => (
<Switch
Expand Down Expand Up @@ -379,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 710d05f

Please sign in to comment.