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

Preset io ch28954 refactor reports #19129

Merged
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
615dffd
pexdax refactor (#16333)
AAfghahi Aug 18, 2021
6d78318
refactor progress (#16339)
lyndsiWilliams Aug 19, 2021
6d89d8c
fix: Header Actions test refactor (#16336)
AAfghahi Aug 19, 2021
5a35f4c
code dry (#16358)
AAfghahi Aug 20, 2021
d25c841
Fetch bug fixed (#16376)
lyndsiWilliams Aug 20, 2021
80c936e
continued refactoring (#16377)
AAfghahi Aug 20, 2021
18a04cd
pexdax refactor (#16333)
AAfghahi Aug 18, 2021
3fb8eec
refactor progress (#16339)
lyndsiWilliams Aug 19, 2021
3c8fda4
fix: Header Actions test refactor (#16336)
AAfghahi Aug 19, 2021
39f6f8a
code dry (#16358)
AAfghahi Aug 20, 2021
9ee469d
Fetch bug fixed (#16376)
lyndsiWilliams Aug 20, 2021
4387935
continued refactoring (#16377)
AAfghahi Aug 20, 2021
82004da
refactor: Arash/new state report (#16987)
AAfghahi Oct 28, 2021
d8f4733
refactor: Reports code clean 10-29 (#17424)
lyndsiWilliams Nov 19, 2021
a17d5ca
fix(Explore): Remove changes to the properties on cancel (#17184)
geido Nov 2, 2021
98bb7f9
fix(dashboard): don't show report modal for anonymous user (#17106)
mayurnewase Nov 11, 2021
2908169
fix(explore): Metric control breaks when saved metric deleted from da…
kgabryje Nov 24, 2021
20e54c0
Add functionality is now working (#17578)
lyndsiWilliams Dec 7, 2021
fd66de2
refactoring reports
AAfghahi Jan 21, 2022
e0b9268
ready for review
AAfghahi Jan 24, 2022
9abc803
added testing
AAfghahi Feb 9, 2022
af5d00d
removed user reducer
AAfghahi Feb 10, 2022
1e8b10f
elizabeth suggestions
AAfghahi Feb 18, 2022
66f328f
merge conflicts
AAfghahi Mar 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(explore): Metric control breaks when saved metric deleted from da…
…taset (#17503)
kgabryje authored and AAfghahi committed Feb 9, 2022
commit 29081699d61fa358d01f4db5074fe900aea2f9fc
Original file line number Diff line number Diff line change
@@ -46,15 +46,21 @@ export default function HeaderReportActionsDropDown({
chart?: ChartState;
}) {
const dispatch = useDispatch();
const reports: Record<number, AlertObject> = useSelector<any, AlertObject>(
state => state.reports,
);
const report: AlertObject = Object.values(reports).filter(report => {
const report: AlertObject = useSelector<any, AlertObject>(state => {
if (dashboardId) {
return report.dashboard_id === dashboardId;
return state.reports.dashboards?.[dashboardId];
}
if (chart?.id) {
return state.reports.charts?.[chart.id];
}
return report.chart_id === chart?.id;
})[0];
return {};
});
// const report: ReportObject = Object.values(reports).filter(report => {
// if (dashboardId) {
// return report.dashboards?.[dashboardId];
// }
// // return report.charts?.[chart?.id]
// })[0];

const user: UserWithPermissionsAndRoles = useSelector<
any,
4 changes: 4 additions & 0 deletions superset-frontend/src/components/ReportModal/index.tsx
Original file line number Diff line number Diff line change
@@ -84,7 +84,11 @@ interface ReportProps {
userEmail: string;
dashboardId?: number;
chart?: ChartState;
<<<<<<< HEAD
props?: any;
=======
props: any;
>>>>>>> be2e1ecf6... code dry (#16358)
}

interface ReportPayloadType {
7 changes: 7 additions & 0 deletions superset-frontend/src/dashboard/components/Header/index.jsx
Original file line number Diff line number Diff line change
@@ -167,6 +167,13 @@ class Header extends React.PureComponent {
this.startPeriodicRender(refreshFrequency * 1000);
}

componentDidUpdate(prevProps) {
if (this.props.refreshFrequency !== prevProps.refreshFrequency) {
const { refreshFrequency } = this.props;
this.startPeriodicRender(refreshFrequency * 1000);
}
}

UNSAFE_componentWillReceiveProps(nextProps) {
if (
UNDO_LIMIT - nextProps.undoLength <= 0 &&
Original file line number Diff line number Diff line change
@@ -123,31 +123,26 @@ export class ExploreChartHeader extends React.PureComponent {

async fetchChartDashboardData() {
const { dashboardId, slice } = this.props;
await SupersetClient.get({
const response = await SupersetClient.get({
endpoint: `/api/v1/chart/${slice.slice_id}`,
})
.then(res => {
const response = res?.json?.result;
if (response && response.dashboards && response.dashboards.length) {
const { dashboards } = response;
const dashboard =
dashboardId &&
dashboards.length &&
dashboards.find(d => d.id === dashboardId);
});
const chart = response.json.result;
const dashboards = chart.dashboards || [];
const dashboard =
dashboardId &&
dashboards.length &&
dashboards.find(d => d.id === dashboardId);

if (dashboard && dashboard.json_metadata) {
// setting the chart to use the dashboard custom label colors if any
const labelColors =
JSON.parse(dashboard.json_metadata).label_colors || {};
const categoricalNamespace = CategoricalColorNamespace.getNamespace();
if (dashboard && dashboard.json_metadata) {
// setting the chart to use the dashboard custom label colors if any
const labelColors =
JSON.parse(dashboard.json_metadata).label_colors || {};
const categoricalNamespace = CategoricalColorNamespace.getNamespace();

Object.keys(labelColors).forEach(label => {
categoricalNamespace.setColor(label, labelColors[label]);
});
}
}
})
.catch(() => {});
Object.keys(labelColors).forEach(label => {
categoricalNamespace.setColor(label, labelColors[label]);
});
}
}

getSliceName() {
20 changes: 12 additions & 8 deletions superset-frontend/src/reports/reducers/reports.js
Original file line number Diff line number Diff line change
@@ -43,14 +43,13 @@ export default function reportsReducer(state = {}, action) {
[SET_REPORT]() {
// Grabs the first report with a dashboard id that
// matches the parameter report's dashboard_id
const reportWithDashboard = action.report.result.find(
const reportWithDashboard = action.report.result?.find(
report => !!report.dashboard_id,
);

// Grabs the first report with a chart id that
// matches the parameter report's chart.id
const reportWithChart = action.report.result.find(
report => !!report.chart.id,
const reportWithChart = action.report.result?.find(
report => !!report.chart?.id,
);

// This organizes report by its type, dashboard or chart
@@ -64,12 +63,17 @@ export default function reportsReducer(state = {}, action) {
},
};
}
if (reportWithChart) {
return {
...state,
charts: {
...state.chart,
[reportWithChart.chart.id]: reportWithChart,
},
};
}
return {
...state,
charts: {
...state.chart,
[reportWithChart.chart.id]: reportWithChart,
},
};
},