mirror of
https://github.com/apache/superset.git
synced 2024-09-12 16:49:40 -04:00
refactor: Use Antd Modals instead of react-bootstrap Modals (#11366)
* Make Modal responsive * ErrorAlert * OmniContainer * dashboard/PropertiesModal * Fix e2e tests * Lint fix * E2E test fix * Fix test * Use grid units * Change padding to padding-left/right
This commit is contained in:
parent
a99d795eaf
commit
155b5edec1
@ -87,19 +87,19 @@ describe('Dashboard edit action', () => {
|
|||||||
const dashboardTitle = `Test dashboard [${shortid.generate()}]`;
|
const dashboardTitle = `Test dashboard [${shortid.generate()}]`;
|
||||||
|
|
||||||
// update title
|
// update title
|
||||||
cy.get('.modal-body')
|
cy.get('.ant-modal-body')
|
||||||
.should('be.visible')
|
.should('be.visible')
|
||||||
.contains('Title')
|
.contains('Title')
|
||||||
.siblings('input')
|
.siblings('input')
|
||||||
.type(`{selectall}{backspace}${dashboardTitle}`);
|
.type(`{selectall}{backspace}${dashboardTitle}`);
|
||||||
|
|
||||||
// save edit changes
|
// save edit changes
|
||||||
cy.get('.modal-footer')
|
cy.get('.ant-modal-footer')
|
||||||
.contains('Save')
|
.contains('Save')
|
||||||
.click()
|
.click()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// assert that modal edit window has closed
|
// 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
|
// assert title has been updated
|
||||||
cy.get('.editable-title input').should('have.value', dashboardTitle);
|
cy.get('.editable-title input').should('have.value', dashboardTitle);
|
||||||
|
@ -90,7 +90,7 @@ describe('Dashboard save action', () => {
|
|||||||
openDashboardEditProperties();
|
openDashboardEditProperties();
|
||||||
|
|
||||||
// open color scheme dropdown
|
// open color scheme dropdown
|
||||||
cy.get('.modal-body')
|
cy.get('.ant-modal-body')
|
||||||
.contains('Color Scheme')
|
.contains('Color Scheme')
|
||||||
.parents('.ControlHeader')
|
.parents('.ControlHeader')
|
||||||
.next('.Select')
|
.next('.Select')
|
||||||
@ -105,7 +105,7 @@ describe('Dashboard save action', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// remove json metadata
|
// remove json metadata
|
||||||
cy.get('.modal-body')
|
cy.get('.ant-modal-body')
|
||||||
.contains('Advanced')
|
.contains('Advanced')
|
||||||
.click()
|
.click()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
@ -113,18 +113,18 @@ describe('Dashboard save action', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// update title
|
// update title
|
||||||
cy.get('.modal-body')
|
cy.get('.ant-modal-body')
|
||||||
.contains('Title')
|
.contains('Title')
|
||||||
.siblings('input')
|
.siblings('input')
|
||||||
.type(`{selectall}{backspace}${dashboardTitle}`);
|
.type(`{selectall}{backspace}${dashboardTitle}`);
|
||||||
|
|
||||||
// save edit changes
|
// save edit changes
|
||||||
cy.get('.modal-footer')
|
cy.get('.ant-modal-footer')
|
||||||
.contains('Save')
|
.contains('Save')
|
||||||
.click()
|
.click()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// assert that modal edit window has closed
|
// 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
|
// save dashboard changes
|
||||||
cy.get('.dashboard-header').contains('Save').click();
|
cy.get('.dashboard-header').contains('Save').click();
|
||||||
|
@ -101,11 +101,9 @@ describe('Dashboard card view', () => {
|
|||||||
cy.get('.ant-dropdown-trigger').last().trigger('mouseover');
|
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').should('exist');
|
||||||
cy.get('.ant-dropdown-menu-item').contains('Edit').click();
|
cy.get('.ant-dropdown-menu-item').contains('Edit').click();
|
||||||
cy.get('.modal-dialog').should('be.visible');
|
cy.get('.ant-modal').should('be.visible');
|
||||||
cy.get('.modal-dialog input[name="dashboard_title"]').should(
|
cy.get('.ant-modal input[name="dashboard_title"]').should('not.have.value');
|
||||||
'not.have.value',
|
cy.get('.ant-modal input[name="slug"]').should('not.have.value');
|
||||||
);
|
cy.get('.ant-modal .btn-default').contains('Cancel').click();
|
||||||
cy.get('.modal-dialog input[name="slug"]').should('not.have.value');
|
|
||||||
cy.get('.modal-dialog .btn-default').contains('Cancel').click();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -47,10 +47,12 @@ interface StyledModalProps extends SupersetThemeProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const StyledModal = styled(BaseModal)<StyledModalProps>`
|
const StyledModal = styled(BaseModal)<StyledModalProps>`
|
||||||
${({ responsive, maxWidth }) =>
|
${({ theme, responsive, maxWidth }) =>
|
||||||
responsive &&
|
responsive &&
|
||||||
css`
|
css`
|
||||||
max-width: ${maxWidth ?? '900px'};
|
max-width: ${maxWidth ?? '900px'};
|
||||||
|
padding-left: ${theme.gridUnit * 3}px;
|
||||||
|
padding-right: ${theme.gridUnit * 3}px;
|
||||||
`}
|
`}
|
||||||
|
|
||||||
.ant-modal-header {
|
.ant-modal-header {
|
||||||
@ -137,7 +139,7 @@ export default function Modal({
|
|||||||
]
|
]
|
||||||
: footer;
|
: footer;
|
||||||
|
|
||||||
const modalWidth = width || responsive ? 'calc(100vw - 24px)' : '600px';
|
const modalWidth = width || (responsive ? '100vw' : '600px');
|
||||||
return (
|
return (
|
||||||
<StyledModal
|
<StyledModal
|
||||||
centered={!!centered}
|
centered={!!centered}
|
||||||
@ -154,6 +156,7 @@ export default function Modal({
|
|||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
footer={!hideFooter ? modalFooter : null}
|
footer={!hideFooter ? modalFooter : null}
|
||||||
|
data-test={`${title}-modal`}
|
||||||
{...rest}
|
{...rest}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
20
superset-frontend/src/common/components/Modal/index.ts
Normal file
20
superset-frontend/src/common/components/Modal/index.ts
Normal file
@ -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';
|
@ -17,9 +17,9 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
import React, { useState, ReactNode } from 'react';
|
import React, { useState, ReactNode } from 'react';
|
||||||
import { Modal } from 'react-bootstrap';
|
|
||||||
import { styled, supersetTheme, t } from '@superset-ui/core';
|
import { styled, supersetTheme, t } from '@superset-ui/core';
|
||||||
import { noOp } from 'src/utils/common';
|
import { noOp } from 'src/utils/common';
|
||||||
|
import Modal from 'src/common/components/Modal';
|
||||||
import Button from 'src/components/Button';
|
import Button from 'src/components/Button';
|
||||||
|
|
||||||
import Icon from '../Icon';
|
import Icon from '../Icon';
|
||||||
@ -64,17 +64,10 @@ const ErrorModal = styled(Modal)<{ level: ErrorLevel }>`
|
|||||||
}
|
}
|
||||||
|
|
||||||
.header {
|
.header {
|
||||||
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
background-color: ${({ level, theme }) => theme.colors[level].light2};
|
background-color: ${({ level, theme }) => theme.colors[level].light2};
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
font-size: ${({ theme }) => theme.typography.sizes.l}px;
|
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}
|
level={level}
|
||||||
show={isModalOpen}
|
show={isModalOpen}
|
||||||
onHide={() => setIsModalOpen(false)}
|
onHide={() => setIsModalOpen(false)}
|
||||||
>
|
title={
|
||||||
<Modal.Header className="header">
|
<div className="header">
|
||||||
<LeftSideContent>
|
|
||||||
<Icon
|
<Icon
|
||||||
className="icon"
|
className="icon"
|
||||||
name={level === 'error' ? 'error-solid' : 'warning-solid'}
|
name={level === 'error' ? 'error-solid' : 'warning-solid'}
|
||||||
color={supersetTheme.colors[level].base}
|
color={supersetTheme.colors[level].base}
|
||||||
/>
|
/>
|
||||||
<div className="title">{title}</div>
|
<div className="title">{title}</div>
|
||||||
</LeftSideContent>
|
</div>
|
||||||
<span
|
}
|
||||||
role="button"
|
footer={
|
||||||
tabIndex={0}
|
<>
|
||||||
onClick={() => setIsModalOpen(false)}
|
{copyText && (
|
||||||
>
|
<CopyToClipboard
|
||||||
<Icon name="close" />
|
text={copyText}
|
||||||
</span>
|
shouldShowText={false}
|
||||||
</Modal.Header>
|
wrapped={false}
|
||||||
<Modal.Body>
|
copyNode={<Button onClick={noOp}>{t('Copy Message')}</Button>}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<Button
|
||||||
|
cta
|
||||||
|
buttonStyle="primary"
|
||||||
|
onClick={() => setIsModalOpen(false)}
|
||||||
|
>
|
||||||
|
{t('Close')}
|
||||||
|
</Button>
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<>
|
||||||
<p>{subtitle}</p>
|
<p>{subtitle}</p>
|
||||||
<br />
|
<br />
|
||||||
{body}
|
{body}
|
||||||
</Modal.Body>
|
</>
|
||||||
<Modal.Footer>
|
|
||||||
{copyText && (
|
|
||||||
<CopyToClipboard
|
|
||||||
text={copyText}
|
|
||||||
shouldShowText={false}
|
|
||||||
wrapped={false}
|
|
||||||
copyNode={<Button onClick={noOp}>{t('Copy Message')}</Button>}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<Button
|
|
||||||
cta
|
|
||||||
buttonStyle="primary"
|
|
||||||
onClick={() => setIsModalOpen(false)}
|
|
||||||
>
|
|
||||||
{t('Close')}
|
|
||||||
</Button>
|
|
||||||
</Modal.Footer>
|
|
||||||
</ErrorModal>
|
</ErrorModal>
|
||||||
)}
|
)}
|
||||||
</ErrorAlertDiv>
|
</ErrorAlertDiv>
|
||||||
|
@ -17,11 +17,11 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Modal } from 'react-bootstrap';
|
|
||||||
import PropTypes from 'prop-types';
|
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 { isFeatureEnabled, FeatureFlag } from 'src/featureFlags';
|
||||||
import Omnibar from 'omnibar';
|
import Omnibar from 'omnibar';
|
||||||
|
import Modal from 'src/common/components/Modal';
|
||||||
import { LOG_ACTIONS_OMNIBAR_TRIGGERED } from '../logger/LogUtils';
|
import { LOG_ACTIONS_OMNIBAR_TRIGGERED } from '../logger/LogUtils';
|
||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
@ -44,6 +44,14 @@ const getDashboards = query =>
|
|||||||
title: t('An error occurred while fethching Dashboards'),
|
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 {
|
class OmniContainer extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
@ -79,13 +87,13 @@ class OmniContainer extends React.Component {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<Modal show={this.state.showOmni} style={{ marginTop: '25%' }}>
|
<OmniModal show={this.state.showOmni} hideFooter closable={false}>
|
||||||
<Omnibar
|
<Omnibar
|
||||||
className="Omnibar"
|
className="Omnibar"
|
||||||
placeholder="Search all dashboards"
|
placeholder="Search all dashboards"
|
||||||
extensions={[getDashboards]}
|
extensions={[getDashboards]}
|
||||||
/>
|
/>
|
||||||
</Modal>
|
</OmniModal>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
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 Button from 'src/components/Button';
|
||||||
import Dialog from 'react-bootstrap-dialog';
|
import Dialog from 'react-bootstrap-dialog';
|
||||||
import { AsyncSelect } from 'src/components/Select';
|
import { AsyncSelect } from 'src/components/Select';
|
||||||
@ -30,6 +30,7 @@ import {
|
|||||||
getCategoricalSchemeRegistry,
|
getCategoricalSchemeRegistry,
|
||||||
} from '@superset-ui/core';
|
} from '@superset-ui/core';
|
||||||
|
|
||||||
|
import Modal from 'src/common/components/Modal';
|
||||||
import FormLabel from 'src/components/FormLabel';
|
import FormLabel from 'src/components/FormLabel';
|
||||||
import { JsonEditor } from 'src/components/AsyncAceEditor';
|
import { JsonEditor } from 'src/components/AsyncAceEditor';
|
||||||
|
|
||||||
@ -292,145 +293,141 @@ class PropertiesModal extends React.PureComponent {
|
|||||||
const saveLabel = onlyApply ? t('Apply') : t('Save');
|
const saveLabel = onlyApply ? t('Apply') : t('Save');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal show={this.props.show} onHide={this.props.onHide} bsSize="lg">
|
<Modal
|
||||||
|
show={this.props.show}
|
||||||
|
onHide={this.props.onHide}
|
||||||
|
title={t('Dashboard Properties')}
|
||||||
|
footer={
|
||||||
|
<>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
buttonSize="sm"
|
||||||
|
onClick={onHide}
|
||||||
|
data-test="properties-modal-cancel-button"
|
||||||
|
cta
|
||||||
|
>
|
||||||
|
{t('Cancel')}
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
onClick={this.submit}
|
||||||
|
buttonSize="sm"
|
||||||
|
buttonStyle="primary"
|
||||||
|
className="m-r-5"
|
||||||
|
disabled={errors.length > 0}
|
||||||
|
cta
|
||||||
|
>
|
||||||
|
{saveLabel}
|
||||||
|
</Button>
|
||||||
|
<Dialog
|
||||||
|
ref={ref => {
|
||||||
|
this.dialog = ref;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
responsive
|
||||||
|
>
|
||||||
<form onSubmit={this.submit}>
|
<form onSubmit={this.submit}>
|
||||||
<Modal.Header closeButton data-test="dashboard-properties-modal">
|
<Row>
|
||||||
<Modal.Title>
|
<Col md={12}>
|
||||||
<div>
|
<h3>{t('Basic Information')}</h3>
|
||||||
<span className="float-left">{t('Dashboard Properties')}</span>
|
</Col>
|
||||||
</div>
|
</Row>
|
||||||
</Modal.Title>
|
<Row>
|
||||||
</Modal.Header>
|
<Col md={6}>
|
||||||
<Modal.Body>
|
<FormLabel htmlFor="embed-height">{t('Title')}</FormLabel>
|
||||||
<Row>
|
<FormControl
|
||||||
<Col md={12}>
|
data-test="dashboard-title-input"
|
||||||
<h3>{t('Basic Information')}</h3>
|
name="dashboard_title"
|
||||||
</Col>
|
type="text"
|
||||||
</Row>
|
bsSize="sm"
|
||||||
<Row>
|
value={values.dashboard_title}
|
||||||
<Col md={6}>
|
onChange={this.onChange}
|
||||||
<FormLabel htmlFor="embed-height">{t('Title')}</FormLabel>
|
disabled={!isDashboardLoaded}
|
||||||
<FormControl
|
|
||||||
data-test="dashboard-title-input"
|
|
||||||
name="dashboard_title"
|
|
||||||
type="text"
|
|
||||||
bsSize="sm"
|
|
||||||
value={values.dashboard_title}
|
|
||||||
onChange={this.onChange}
|
|
||||||
disabled={!isDashboardLoaded}
|
|
||||||
/>
|
|
||||||
</Col>
|
|
||||||
<Col md={6}>
|
|
||||||
<FormLabel htmlFor="embed-height">{t('URL Slug')}</FormLabel>
|
|
||||||
<FormControl
|
|
||||||
name="slug"
|
|
||||||
type="text"
|
|
||||||
bsSize="sm"
|
|
||||||
value={values.slug || ''}
|
|
||||||
onChange={this.onChange}
|
|
||||||
disabled={!isDashboardLoaded}
|
|
||||||
/>
|
|
||||||
<p className="help-block">
|
|
||||||
{t('A readable URL for your dashboard')}
|
|
||||||
</p>
|
|
||||||
</Col>
|
|
||||||
</Row>
|
|
||||||
<Row>
|
|
||||||
<Col md={6}>
|
|
||||||
<h3 style={{ marginTop: '1em' }}>{t('Access')}</h3>
|
|
||||||
<FormLabel htmlFor="owners">{t('Owners')}</FormLabel>
|
|
||||||
<AsyncSelect
|
|
||||||
name="owners"
|
|
||||||
isMulti
|
|
||||||
value={values.owners}
|
|
||||||
loadOptions={this.loadOwnerOptions}
|
|
||||||
defaultOptions // load options on render
|
|
||||||
cacheOptions
|
|
||||||
onChange={this.onOwnersChange}
|
|
||||||
disabled={!isDashboardLoaded}
|
|
||||||
filterOption={null} // options are filtered at the api
|
|
||||||
/>
|
|
||||||
<p className="help-block">
|
|
||||||
{t(
|
|
||||||
'Owners is a list of users who can alter the dashboard. Searchable by name or username.',
|
|
||||||
)}
|
|
||||||
</p>
|
|
||||||
</Col>
|
|
||||||
<Col md={6}>
|
|
||||||
<h3 style={{ marginTop: '1em' }}>{t('Colors')}</h3>
|
|
||||||
<ColorSchemeControlWrapper
|
|
||||||
onChange={this.onColorSchemeChange}
|
|
||||||
colorScheme={values.colorScheme}
|
|
||||||
/>
|
|
||||||
</Col>
|
|
||||||
</Row>
|
|
||||||
<Row>
|
|
||||||
<Col md={12}>
|
|
||||||
<h3 style={{ marginTop: '1em' }}>
|
|
||||||
<Button buttonStyle="link" onClick={this.toggleAdvanced}>
|
|
||||||
<i
|
|
||||||
className={`fa fa-angle-${
|
|
||||||
isAdvancedOpen ? 'down' : 'right'
|
|
||||||
}`}
|
|
||||||
style={{ minWidth: '1em' }}
|
|
||||||
/>
|
|
||||||
{t('Advanced')}
|
|
||||||
</Button>
|
|
||||||
</h3>
|
|
||||||
{isAdvancedOpen && (
|
|
||||||
<>
|
|
||||||
<FormLabel htmlFor="json_metadata">
|
|
||||||
{t('JSON Metadata')}
|
|
||||||
</FormLabel>
|
|
||||||
<StyledJsonEditor
|
|
||||||
showLoadingForImport
|
|
||||||
name="json_metadata"
|
|
||||||
defaultValue={this.defaultMetadataValue}
|
|
||||||
value={values.json_metadata}
|
|
||||||
onChange={this.onMetadataChange}
|
|
||||||
tabSize={2}
|
|
||||||
width="100%"
|
|
||||||
height="200px"
|
|
||||||
wrapEnabled
|
|
||||||
/>
|
|
||||||
<p className="help-block">
|
|
||||||
{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.',
|
|
||||||
)}
|
|
||||||
</p>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</Col>
|
|
||||||
</Row>
|
|
||||||
</Modal.Body>
|
|
||||||
<Modal.Footer>
|
|
||||||
<span className="float-right">
|
|
||||||
<Button
|
|
||||||
type="button"
|
|
||||||
buttonSize="sm"
|
|
||||||
onClick={onHide}
|
|
||||||
data-test="properties-modal-cancel-button"
|
|
||||||
cta
|
|
||||||
>
|
|
||||||
{t('Cancel')}
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
type="submit"
|
|
||||||
buttonSize="sm"
|
|
||||||
buttonStyle="primary"
|
|
||||||
className="m-r-5"
|
|
||||||
disabled={errors.length > 0}
|
|
||||||
cta
|
|
||||||
>
|
|
||||||
{saveLabel}
|
|
||||||
</Button>
|
|
||||||
<Dialog
|
|
||||||
ref={ref => {
|
|
||||||
this.dialog = ref;
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
</span>
|
</Col>
|
||||||
</Modal.Footer>
|
<Col md={6}>
|
||||||
|
<FormLabel htmlFor="embed-height">{t('URL Slug')}</FormLabel>
|
||||||
|
<FormControl
|
||||||
|
name="slug"
|
||||||
|
type="text"
|
||||||
|
bsSize="sm"
|
||||||
|
value={values.slug || ''}
|
||||||
|
onChange={this.onChange}
|
||||||
|
disabled={!isDashboardLoaded}
|
||||||
|
/>
|
||||||
|
<p className="help-block">
|
||||||
|
{t('A readable URL for your dashboard')}
|
||||||
|
</p>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
<Row>
|
||||||
|
<Col md={6}>
|
||||||
|
<h3 style={{ marginTop: '1em' }}>{t('Access')}</h3>
|
||||||
|
<FormLabel htmlFor="owners">{t('Owners')}</FormLabel>
|
||||||
|
<AsyncSelect
|
||||||
|
name="owners"
|
||||||
|
isMulti
|
||||||
|
value={values.owners}
|
||||||
|
loadOptions={this.loadOwnerOptions}
|
||||||
|
defaultOptions // load options on render
|
||||||
|
cacheOptions
|
||||||
|
onChange={this.onOwnersChange}
|
||||||
|
disabled={!isDashboardLoaded}
|
||||||
|
filterOption={null} // options are filtered at the api
|
||||||
|
/>
|
||||||
|
<p className="help-block">
|
||||||
|
{t(
|
||||||
|
'Owners is a list of users who can alter the dashboard. Searchable by name or username.',
|
||||||
|
)}
|
||||||
|
</p>
|
||||||
|
</Col>
|
||||||
|
<Col md={6}>
|
||||||
|
<h3 style={{ marginTop: '1em' }}>{t('Colors')}</h3>
|
||||||
|
<ColorSchemeControlWrapper
|
||||||
|
onChange={this.onColorSchemeChange}
|
||||||
|
colorScheme={values.colorScheme}
|
||||||
|
/>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
<Row>
|
||||||
|
<Col md={12}>
|
||||||
|
<h3 style={{ marginTop: '1em' }}>
|
||||||
|
<Button buttonStyle="link" onClick={this.toggleAdvanced}>
|
||||||
|
<i
|
||||||
|
className={`fa fa-angle-${
|
||||||
|
isAdvancedOpen ? 'down' : 'right'
|
||||||
|
}`}
|
||||||
|
style={{ minWidth: '1em' }}
|
||||||
|
/>
|
||||||
|
{t('Advanced')}
|
||||||
|
</Button>
|
||||||
|
</h3>
|
||||||
|
{isAdvancedOpen && (
|
||||||
|
<>
|
||||||
|
<FormLabel htmlFor="json_metadata">
|
||||||
|
{t('JSON Metadata')}
|
||||||
|
</FormLabel>
|
||||||
|
<StyledJsonEditor
|
||||||
|
showLoadingForImport
|
||||||
|
name="json_metadata"
|
||||||
|
defaultValue={this.defaultMetadataValue}
|
||||||
|
value={values.json_metadata}
|
||||||
|
onChange={this.onMetadataChange}
|
||||||
|
tabSize={2}
|
||||||
|
width="100%"
|
||||||
|
height="200px"
|
||||||
|
wrapEnabled
|
||||||
|
/>
|
||||||
|
<p className="help-block">
|
||||||
|
{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.',
|
||||||
|
)}
|
||||||
|
</p>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
</form>
|
</form>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user