eschutho commented on a change in pull request #18131:
URL: https://github.com/apache/superset/pull/18131#discussion_r803220155
##########
File path:
superset-frontend/src/components/ReportModal/HeaderReportDropdown/index.tsx
##########
@@ -29,46 +30,42 @@ import ReportModal from 'src/components/ReportModal';
import { ChartState } from 'src/explore/types';
import { UserWithPermissionsAndRoles } from 'src/types/bootstrapTypes';
import { fetchUISpecificReport } from 'src/reports/actions/reports';
+import { reportSelector } from 'src/views/CRUD/hooks';
+import { ReportType } from 'src/dashboard/util/constants';
const deleteColor = (theme: SupersetTheme) => css`
color: ${theme.colors.error.base};
`;
-export default function HeaderReportActionsDropDown({
+export interface HeaderReportProps {
+ toggleActive: (data: AlertObject, isActive: boolean) => void;
+ deleteActiveReport: (data: AlertObject) => void;
+ dashboardId?: number;
+ chart?: ChartState;
+}
+
+export default function HeaderReportDropDown({
toggleActive,
deleteActiveReport,
dashboardId,
chart,
-}: {
- toggleActive: (data: AlertObject, checked: boolean) => void;
- deleteActiveReport: (data: AlertObject) => void;
- dashboardId?: number;
- chart?: ChartState;
-}) {
+}: HeaderReportProps) {
const dispatch = useDispatch();
- const report: AlertObject = useSelector<any, AlertObject>(state => {
- if (dashboardId) {
- return state.reports.dashboards?.[dashboardId];
- }
- if (chart?.id) {
- return state.reports.charts?.[chart.id];
- }
- return {};
- });
- // const report: ReportObject = Object.values(reports).filter(report => {
- // if (dashboardId) {
- // return report.dashboards?.[dashboardId];
- // }
- // // return report.charts?.[chart?.id]
- // })[0];
+ const report = useSelector<any, AlertObject>(state => {
+ const resourceType = dashboardId
+ ? ReportType.DASHBOARDS
+ : ReportType.CHARTS;
+ return reportSelector(state, resourceType, dashboardId || chart?.id);
+ });
const user: UserWithPermissionsAndRoles = useSelector<
any,
UserWithPermissionsAndRoles
>(state => state.user || state.explore?.user);
Review comment:
actually, nm.. I guess user was added to sql lab
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]