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

feat: add active email toggle and dropdown on dashboard #15852

Merged

Conversation

AAfghahi
Copy link
Member

SUMMARY

This is part of a redesign of how users can add reports in superset. Specifically, that people can add a report on a dashboard. This feature adds a dropdown when there is a report present, so that you can toggle its active status.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Screen Shot 2021-07-22 at 9 59 49 PM

Screen.Recording.2021-07-21.at.4.34.02.PM.mov

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@AAfghahi AAfghahi force-pushed the ch19374_reportsDropdown branch 2 times, most recently from e6cff06 to f09ac62 Compare July 23, 2021 02:08
@codecov
Copy link

codecov bot commented Jul 23, 2021

Codecov Report

Merging #15852 (bffde76) into selfSubscribeReports (9e31846) will decrease coverage by 0.05%.
The diff coverage is 24.48%.

Impacted file tree graph

@@                   Coverage Diff                    @@
##           selfSubscribeReports   #15852      +/-   ##
========================================================
- Coverage                 77.02%   76.97%   -0.06%     
========================================================
  Files                       988      989       +1     
  Lines                     51955    51997      +42     
  Branches                   7090     7093       +3     
========================================================
+ Hits                      40020    40026       +6     
- Misses                    11710    11746      +36     
  Partials                    225      225              
Flag Coverage Δ
javascript 71.70% <24.48%> (-0.10%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ntend/src/dashboard/containers/DashboardHeader.jsx 100.00% <ø> (ø)
...erset-frontend/src/reports/reducers/reportState.js 26.66% <0.00%> (-30.48%) ⬇️
...perset-frontend/src/reports/actions/reportState.js 30.76% <12.50%> (-29.24%) ⬇️
...frontend/src/dashboard/components/Header/index.jsx 65.47% <33.33%> (ø)
.../ReportModal/HeaderReportActionsDropdown/index.tsx 38.88% <38.88%> (ø)
superset-frontend/src/common/components/index.tsx 100.00% <100.00%> (ø)
superset-frontend/src/components/Select/Select.tsx 73.05% <0.00%> (-1.37%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9e31846...bffde76. Read the comment docs.

* specific language governing permissions and limitations
* under the License.
*/
import React, { useState } from 'react';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you think we can put this dropdown in the same root folder as the report modal?

}: {
showReportModal: () => void;
hideReportModal: () => void;
report: JsonObject;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we define a type for the report?

// useOnClickOutside(ref, () => setVisible(false));

const toggleActive = async (data: AlertObject, checked: boolean) => {
if (data && data.id) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional chaining

const toggleActive = async (data: AlertObject, checked: boolean) => {
if (data && data.id) {
const update_id = data.id;
await updateResource(update_id, { active: checked }).then(() => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the resource hooks should automatically update the state and return them. Can you use that instead of having separate state here?

@@ -156,7 +157,7 @@ class Header extends React.PureComponent {
this.hidePropertiesModal = this.hidePropertiesModal.bind(this);
this.showReportModal = this.showReportModal.bind(this);
this.hideReportModal = this.hideReportModal.bind(this);
this.handleReportClick = this.handleReportClick.bind(this);
this.reportModal = this.reportModal.bind(this);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we make this more "action/verb" sounding for a method, like renderReportModal, or else we can make it a separate component outside the header (could be the same file)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I wasn't happy with this and couldn't place my finger on it, I had spaced on using render, sorry.

if (!attachedReportExists) {
this.showReportModal();
}
return !attachedReportExists ? (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you flip the return logic so that you can lead with the positive statement rather than negative? Just for ease of readability.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, that makes so much sense.

Copy link
Member

@eschutho eschutho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good. Just a few small things

@AAfghahi AAfghahi force-pushed the ch19374_reportsDropdown branch 3 times, most recently from 751bf99 to 4be1a8f Compare July 23, 2021 22:05
@eschutho eschutho force-pushed the selfSubscribeReports branch 4 times, most recently from cb3896e to b81f120 Compare July 26, 2021 18:08
report={this.props.report.result}
/>
) : (
<>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit for another iteration, but I don't think you need these extra brackets since you only have one child

@eschutho
Copy link
Member

Just need to rebase some extra commits out of here before we merge.

@AAfghahi AAfghahi force-pushed the ch19374_reportsDropdown branch 5 times, most recently from c71c4b5 to fac1f59 Compare July 27, 2021 20:32
@eschutho eschutho merged commit 4d5f17d into apache:selfSubscribeReports Jul 27, 2021
@eschutho eschutho deleted the ch19374_reportsDropdown branch July 27, 2021 22:09
eschutho pushed a commit that referenced this pull request Jul 30, 2021
* first draft

* added testing props

* created Api call

* added click logic

* made the fetch report into a action/reducer

* abstracted report action

* first commit

* toggle started

* on blue

* event listener

* toggle

* toggle active + dropdown

* fixed cypress tests

* revisions

* removed useState

* added toggle active to state
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants