You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by el...@apache.org on 2021/07/30 16:34:19 UTC
[superset] branch selfSubscribeReports updated: feat: Add disable
functionality to "Add Report" button (#15937)
This is an automated email from the ASF dual-hosted git repository.
elizabeth pushed a commit to branch selfSubscribeReports
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/selfSubscribeReports by this push:
new 2385bc2 feat: Add disable functionality to "Add Report" button (#15937)
2385bc2 is described below
commit 2385bc298fa774601f74f96885a17cc658cd2d08
Author: Lyndsi Kay Williams <55...@users.noreply.github.com>
AuthorDate: Fri Jul 30 11:33:14 2021 -0500
feat: Add disable functionality to "Add Report" button (#15937)
* Disable button functional, report name field fixed
* Turned reducer trimmedState into initialState with report name
* Linter error fix
* Add redux to reportModal tests
---
.../components/ReportModal/EmailReportModal.test.jsx | 10 ++--------
superset-frontend/src/components/ReportModal/index.tsx | 17 ++++++++++++-----
2 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/superset-frontend/src/components/ReportModal/EmailReportModal.test.jsx b/superset-frontend/src/components/ReportModal/EmailReportModal.test.jsx
index d6b9ee0..92d90fa 100644
--- a/superset-frontend/src/components/ReportModal/EmailReportModal.test.jsx
+++ b/superset-frontend/src/components/ReportModal/EmailReportModal.test.jsx
@@ -18,18 +18,12 @@
*/
import React from 'react';
import userEvent from '@testing-library/user-event';
-import {
- render,
- screen,
- // within,
- // cleanup,
- // act,
-} from 'spec/helpers/testing-library';
+import { render, screen } from 'spec/helpers/testing-library';
import ReportModal from '.';
describe('Email Report Modal', () => {
it('inputs respond correctly', () => {
- render(<ReportModal show />);
+ render(<ReportModal show />, { useRedux: true });
// ----- Report name textbox
// Initial value
diff --git a/superset-frontend/src/components/ReportModal/index.tsx b/superset-frontend/src/components/ReportModal/index.tsx
index fc2f87f..ffe7018 100644
--- a/superset-frontend/src/components/ReportModal/index.tsx
+++ b/superset-frontend/src/components/ReportModal/index.tsx
@@ -106,14 +106,15 @@ const reportReducer = (
state: Partial<ReportObject> | null,
action: ReportActionType,
): Partial<ReportObject> | null => {
- const trimmedState = {
+ const initialState = {
+ name: state?.name || 'Weekly Report',
...(state || {}),
};
switch (action.type) {
case ActionType.textChange:
return {
- ...trimmedState,
+ ...initialState,
[action.payload.name]: action.payload.value,
};
default:
@@ -167,7 +168,7 @@ const ReportModal: FunctionComponent<ReportProps> = ({
dashboard: props.props.dashboardId,
chart: props.props.chartId,
description: currentReport?.description,
- name: currentReport?.name || 'Weekly Report',
+ name: currentReport?.name,
owners: [props.props.userId],
recipients: [
{
@@ -201,7 +202,12 @@ const ReportModal: FunctionComponent<ReportProps> = ({
<StyledFooterButton key="back" onClick={onClose}>
Cancel
</StyledFooterButton>
- <StyledFooterButton key="submit" buttonStyle="primary" onClick={onSave}>
+ <StyledFooterButton
+ key="submit"
+ buttonStyle="primary"
+ onClick={onSave}
+ disabled={!currentReport?.name}
+ >
Add
</StyledFooterButton>
</>
@@ -220,7 +226,8 @@ const ReportModal: FunctionComponent<ReportProps> = ({
<LabeledErrorBoundInput
id="name"
name="name"
- value={currentReport?.name || 'Weekly Report'}
+ value={currentReport?.name || ''}
+ placeholder="Weekly Report"
required
validationMethods={{
onChange: ({ target }: { target: HTMLInputElement }) =>