diff --git a/superset-frontend/cypress-base/cypress/integration/dashboard/edit_properties.test.ts b/superset-frontend/cypress-base/cypress/integration/dashboard/edit_properties.test.ts index 7f2618bcd1..b33ad43c45 100644 --- a/superset-frontend/cypress-base/cypress/integration/dashboard/edit_properties.test.ts +++ b/superset-frontend/cypress-base/cypress/integration/dashboard/edit_properties.test.ts @@ -87,19 +87,19 @@ describe('Dashboard edit action', () => { const dashboardTitle = `Test dashboard [${shortid.generate()}]`; // update title - cy.get('.modal-body') + cy.get('.ant-modal-body') .should('be.visible') .contains('Title') .siblings('input') .type(`{selectall}{backspace}${dashboardTitle}`); // save edit changes - cy.get('.modal-footer') + cy.get('.ant-modal-footer') .contains('Save') .click() .then(() => { // assert that modal edit window has closed - cy.get('.modal-body').should('not.exist'); + cy.get('.ant-modal-body').should('not.exist'); // assert title has been updated cy.get('.editable-title input').should('have.value', dashboardTitle); diff --git a/superset-frontend/cypress-base/cypress/integration/dashboard/save.test.js b/superset-frontend/cypress-base/cypress/integration/dashboard/save.test.js index 79b4dff0e6..f321f15b63 100644 --- a/superset-frontend/cypress-base/cypress/integration/dashboard/save.test.js +++ b/superset-frontend/cypress-base/cypress/integration/dashboard/save.test.js @@ -90,7 +90,7 @@ describe('Dashboard save action', () => { openDashboardEditProperties(); // open color scheme dropdown - cy.get('.modal-body') + cy.get('.ant-modal-body') .contains('Color Scheme') .parents('.ControlHeader') .next('.Select') @@ -105,7 +105,7 @@ describe('Dashboard save action', () => { }); // remove json metadata - cy.get('.modal-body') + cy.get('.ant-modal-body') .contains('Advanced') .click() .then(() => { @@ -113,18 +113,18 @@ describe('Dashboard save action', () => { }); // update title - cy.get('.modal-body') + cy.get('.ant-modal-body') .contains('Title') .siblings('input') .type(`{selectall}{backspace}${dashboardTitle}`); // save edit changes - cy.get('.modal-footer') + cy.get('.ant-modal-footer') .contains('Save') .click() .then(() => { // assert that modal edit window has closed - cy.get('.modal-body').should('not.exist'); + cy.get('.ant-modal-body').should('not.exist'); // save dashboard changes cy.get('.dashboard-header').contains('Save').click(); diff --git a/superset-frontend/cypress-base/cypress/integration/dashboard_list/card_view.test.ts b/superset-frontend/cypress-base/cypress/integration/dashboard_list/card_view.test.ts index 42f790f34b..e0f5e9c8c0 100644 --- a/superset-frontend/cypress-base/cypress/integration/dashboard_list/card_view.test.ts +++ b/superset-frontend/cypress-base/cypress/integration/dashboard_list/card_view.test.ts @@ -101,11 +101,9 @@ describe('Dashboard card view', () => { cy.get('.ant-dropdown-trigger').last().trigger('mouseover'); cy.get('.ant-dropdown-menu-item').contains('Edit').should('exist'); cy.get('.ant-dropdown-menu-item').contains('Edit').click(); - cy.get('.modal-dialog').should('be.visible'); - cy.get('.modal-dialog input[name="dashboard_title"]').should( - 'not.have.value', - ); - cy.get('.modal-dialog input[name="slug"]').should('not.have.value'); - cy.get('.modal-dialog .btn-default').contains('Cancel').click(); + cy.get('.ant-modal').should('be.visible'); + cy.get('.ant-modal input[name="dashboard_title"]').should('not.have.value'); + cy.get('.ant-modal input[name="slug"]').should('not.have.value'); + cy.get('.ant-modal .btn-default').contains('Cancel').click(); }); }); diff --git a/superset-frontend/src/common/components/Modal.tsx b/superset-frontend/src/common/components/Modal/Modal.tsx similarity index 94% rename from superset-frontend/src/common/components/Modal.tsx rename to superset-frontend/src/common/components/Modal/Modal.tsx index 7e7606ded5..ffc88cd6f7 100644 --- a/superset-frontend/src/common/components/Modal.tsx +++ b/superset-frontend/src/common/components/Modal/Modal.tsx @@ -47,10 +47,12 @@ interface StyledModalProps extends SupersetThemeProps { } const StyledModal = styled(BaseModal)` - ${({ responsive, maxWidth }) => + ${({ theme, responsive, maxWidth }) => responsive && css` max-width: ${maxWidth ?? '900px'}; + padding-left: ${theme.gridUnit * 3}px; + padding-right: ${theme.gridUnit * 3}px; `} .ant-modal-header { @@ -137,7 +139,7 @@ export default function Modal({ ] : footer; - const modalWidth = width || responsive ? 'calc(100vw - 24px)' : '600px'; + const modalWidth = width || (responsive ? '100vw' : '600px'); return ( } footer={!hideFooter ? modalFooter : null} + data-test={`${title}-modal`} {...rest} > {children} diff --git a/superset-frontend/src/common/components/Modal/index.ts b/superset-frontend/src/common/components/Modal/index.ts new file mode 100644 index 0000000000..9466591c7a --- /dev/null +++ b/superset-frontend/src/common/components/Modal/index.ts @@ -0,0 +1,20 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +export * from './Modal'; +export { default } from './Modal'; diff --git a/superset-frontend/src/components/ErrorMessage/ErrorAlert.tsx b/superset-frontend/src/components/ErrorMessage/ErrorAlert.tsx index 8f7b8b233f..74ef9ffc54 100644 --- a/superset-frontend/src/components/ErrorMessage/ErrorAlert.tsx +++ b/superset-frontend/src/components/ErrorMessage/ErrorAlert.tsx @@ -17,9 +17,9 @@ * under the License. */ import React, { useState, ReactNode } from 'react'; -import { Modal } from 'react-bootstrap'; import { styled, supersetTheme, t } from '@superset-ui/core'; import { noOp } from 'src/utils/common'; +import Modal from 'src/common/components/Modal'; import Button from 'src/components/Button'; import Icon from '../Icon'; @@ -64,17 +64,10 @@ const ErrorModal = styled(Modal)<{ level: ErrorLevel }>` } .header { + display: flex; align-items: center; background-color: ${({ level, theme }) => theme.colors[level].light2}; - display: flex; - justify-content: space-between; font-size: ${({ theme }) => theme.typography.sizes.l}px; - - // Remove clearfix hack as Superset is only used on modern browsers - ::before, - ::after { - content: unset; - } } `; @@ -157,46 +150,41 @@ export default function ErrorAlert({ level={level} show={isModalOpen} onHide={() => setIsModalOpen(false)} - > - - + title={ +
{title}
- - setIsModalOpen(false)} - > - - - - +
+ } + footer={ + <> + {copyText && ( + {t('Copy Message')}} + /> + )} + + + } + > + <>

{subtitle}


{body} - - - {copyText && ( - {t('Copy Message')}} - /> - )} - - + )} diff --git a/superset-frontend/src/components/OmniContainer.jsx b/superset-frontend/src/components/OmniContainer.jsx index 7249f3f105..22a4c50e59 100644 --- a/superset-frontend/src/components/OmniContainer.jsx +++ b/superset-frontend/src/components/OmniContainer.jsx @@ -17,11 +17,11 @@ * under the License. */ import React from 'react'; -import { Modal } from 'react-bootstrap'; import PropTypes from 'prop-types'; -import { t, SupersetClient } from '@superset-ui/core'; +import { styled, t, SupersetClient } from '@superset-ui/core'; import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags'; import Omnibar from 'omnibar'; +import Modal from 'src/common/components/Modal'; import { LOG_ACTIONS_OMNIBAR_TRIGGERED } from '../logger/LogUtils'; const propTypes = { @@ -44,6 +44,14 @@ const getDashboards = query => title: t('An error occurred while fethching Dashboards'), })); +const OmniModal = styled(Modal)` + margin-top: 20%; + + .ant-modal-body { + padding: 0; + } +`; + class OmniContainer extends React.Component { constructor(props) { super(props); @@ -79,13 +87,13 @@ class OmniContainer extends React.Component { render() { return ( - + - + ); } } diff --git a/superset-frontend/src/dashboard/components/PropertiesModal.jsx b/superset-frontend/src/dashboard/components/PropertiesModal.jsx index 93c4de0917..6832843f50 100644 --- a/superset-frontend/src/dashboard/components/PropertiesModal.jsx +++ b/superset-frontend/src/dashboard/components/PropertiesModal.jsx @@ -18,7 +18,7 @@ */ import React from 'react'; import PropTypes from 'prop-types'; -import { Row, Col, Modal, FormControl } from 'react-bootstrap'; +import { Row, Col, FormControl } from 'react-bootstrap'; import Button from 'src/components/Button'; import Dialog from 'react-bootstrap-dialog'; import { AsyncSelect } from 'src/components/Select'; @@ -30,6 +30,7 @@ import { getCategoricalSchemeRegistry, } from '@superset-ui/core'; +import Modal from 'src/common/components/Modal'; import FormLabel from 'src/components/FormLabel'; import { JsonEditor } from 'src/components/AsyncAceEditor'; @@ -292,145 +293,141 @@ class PropertiesModal extends React.PureComponent { const saveLabel = onlyApply ? t('Apply') : t('Save'); return ( - + + + + { + this.dialog = ref; + }} + /> + + } + responsive + >
- - -
- {t('Dashboard Properties')} -
-
-
- - - -

{t('Basic Information')}

- -
- - - {t('Title')} - - - - {t('URL Slug')} - -

- {t('A readable URL for your dashboard')} -

- -
- - -

{t('Access')}

- {t('Owners')} - -

- {t( - 'Owners is a list of users who can alter the dashboard. Searchable by name or username.', - )} -

- - -

{t('Colors')}

- - -
- - -

- -

- {isAdvancedOpen && ( - <> - - {t('JSON Metadata')} - - -

- {t( - 'This JSON object is generated dynamically when clicking the save or overwrite button in the dashboard view. It is exposed here for reference and for power users who may want to alter specific parameters.', - )} -

- - )} - -
-
- - - - - { - this.dialog = ref; - }} + + +

{t('Basic Information')}

+ +
+ + + {t('Title')} + -
-
+ + + {t('URL Slug')} + +

+ {t('A readable URL for your dashboard')} +

+ + + + +

{t('Access')}

+ {t('Owners')} + +

+ {t( + 'Owners is a list of users who can alter the dashboard. Searchable by name or username.', + )} +

+ + +

{t('Colors')}

+ + +
+ + +

+ +

+ {isAdvancedOpen && ( + <> + + {t('JSON Metadata')} + + +

+ {t( + 'This JSON object is generated dynamically when clicking the save or overwrite button in the dashboard view. It is exposed here for reference and for power users who may want to alter specific parameters.', + )} +

+ + )} + +
);