You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2019/12/20 02:00:31 UTC
[GitHub] [incubator-superset] suddjian opened a new pull request #8876:
Dashboard properties
suddjian opened a new pull request #8876: Dashboard properties
URL: https://github.com/apache/incubator-superset/pull/8876
### CATEGORY
Choose one
- [ ] Bug Fix
- [x] Enhancement (new features, refinement)
- [ ] Refactor
- [ ] Add tests
- [ ] Build / Development Environment
- [ ] Documentation
### SUMMARY
<!--- Describe the change below, including rationale and design decisions -->
Adds a new modal to the dashboard react app, which allows updating dashboard properties that are currently only updatable from the CRUD editor.
When the form is submitted, the url also gets updated to reflect any new slug.
Could use some feedback on how I accomplished the dashboard title update, I had to add some new redux flows that work around the undo functionality so that it doesn't trigger a "save" button.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
<!--- Skip this if not applicable -->
<img width="912" alt="Screen Shot 2019-12-19 at 5 54 24 PM" src="https://user-images.githubusercontent.com/1858430/71223408-c0935880-2288-11ea-82f8-fe7bc2bc6e22.png">
### TEST PLAN
<!--- What steps should be taken to verify the changes -->
Need to write some tests still, but I want to open this up to feedback.
### ADDITIONAL INFORMATION
<!--- Check any relevant boxes with "x" -->
<!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
- [ ] Has associated issue:
- [x] Changes UI
- [ ] Requires DB Migration.
- [ ] Confirm DB Migration upgrade and downgrade tested.
- [x] Introduces new feature or API
- [ ] Removes existing feature or API
### REVIEWERS
Not entirely sure. @graceguo-supercat seems active in this area?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [incubator-superset] codecov-io edited a comment on issue #8876:
[dashboard] Modal for editing dashboard properties & metadata
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on issue #8876: [dashboard] Modal for editing dashboard properties & metadata
URL: https://github.com/apache/incubator-superset/pull/8876#issuecomment-572832163
# [Codecov](https://codecov.io/gh/apache/incubator-superset/pull/8876?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`master@cfc1e69`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
> The diff coverage is `14.28%`.
[](https://codecov.io/gh/apache/incubator-superset/pull/8876?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #8876 +/- ##
=========================================
Coverage ? 58.67%
=========================================
Files ? 362
Lines ? 11412
Branches ? 2800
=========================================
Hits ? 6696
Misses ? 4538
Partials ? 178
```
| [Impacted Files](https://codecov.io/gh/apache/incubator-superset/pull/8876?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [...ssets/src/dashboard/containers/DashboardHeader.jsx](https://codecov.io/gh/apache/incubator-superset/pull/8876/diff?src=pr&el=tree#diff-c3VwZXJzZXQvYXNzZXRzL3NyYy9kYXNoYm9hcmQvY29udGFpbmVycy9EYXNoYm9hcmRIZWFkZXIuanN4) | `100% <ø> (ø)` | |
| [...src/dashboard/components/HeaderActionsDropdown.jsx](https://codecov.io/gh/apache/incubator-superset/pull/8876/diff?src=pr&el=tree#diff-c3VwZXJzZXQvYXNzZXRzL3NyYy9kYXNoYm9hcmQvY29tcG9uZW50cy9IZWFkZXJBY3Rpb25zRHJvcGRvd24uanN4) | `69.56% <ø> (ø)` | |
| [superset/assets/src/dashboard/reducers/index.js](https://codecov.io/gh/apache/incubator-superset/pull/8876/diff?src=pr&el=tree#diff-c3VwZXJzZXQvYXNzZXRzL3NyYy9kYXNoYm9hcmQvcmVkdWNlcnMvaW5kZXguanM=) | `100% <ø> (ø)` | |
| [...uperset/assets/src/dashboard/components/Header.jsx](https://codecov.io/gh/apache/incubator-superset/pull/8876/diff?src=pr&el=tree#diff-c3VwZXJzZXQvYXNzZXRzL3NyYy9kYXNoYm9hcmQvY29tcG9uZW50cy9IZWFkZXIuanN4) | `41.46% <0%> (ø)` | |
| [...t/assets/src/dashboard/reducers/dashboardLayout.js](https://codecov.io/gh/apache/incubator-superset/pull/8876/diff?src=pr&el=tree#diff-c3VwZXJzZXQvYXNzZXRzL3NyYy9kYXNoYm9hcmQvcmVkdWNlcnMvZGFzaGJvYXJkTGF5b3V0Lmpz) | `93% <0%> (ø)` | |
| [...ssets/src/dashboard/components/PropertiesModal.jsx](https://codecov.io/gh/apache/incubator-superset/pull/8876/diff?src=pr&el=tree#diff-c3VwZXJzZXQvYXNzZXRzL3NyYy9kYXNoYm9hcmQvY29tcG9uZW50cy9Qcm9wZXJ0aWVzTW9kYWwuanN4) | `7.4% <0%> (ø)` | |
| [...rset/assets/src/dashboard/actions/dashboardInfo.js](https://codecov.io/gh/apache/incubator-superset/pull/8876/diff?src=pr&el=tree#diff-c3VwZXJzZXQvYXNzZXRzL3NyYy9kYXNoYm9hcmQvYWN0aW9ucy9kYXNoYm9hcmRJbmZvLmpz) | `33.33% <33.33%> (ø)` | |
| [...et/assets/src/dashboard/actions/dashboardLayout.js](https://codecov.io/gh/apache/incubator-superset/pull/8876/diff?src=pr&el=tree#diff-c3VwZXJzZXQvYXNzZXRzL3NyYy9kYXNoYm9hcmQvYWN0aW9ucy9kYXNoYm9hcmRMYXlvdXQuanM=) | `95.09% <33.33%> (ø)` | |
| [...set/assets/src/dashboard/reducers/dashboardInfo.js](https://codecov.io/gh/apache/incubator-superset/pull/8876/diff?src=pr&el=tree#diff-c3VwZXJzZXQvYXNzZXRzL3NyYy9kYXNoYm9hcmQvcmVkdWNlcnMvZGFzaGJvYXJkSW5mby5qcw==) | `66.66% <66.66%> (ø)` | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-superset/pull/8876?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/incubator-superset/pull/8876?src=pr&el=footer). Last update [cfc1e69...5bd8eff](https://codecov.io/gh/apache/incubator-superset/pull/8876?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [incubator-superset] mistercrunch commented on issue #8876:
Dashboard properties
Posted by GitBox <gi...@apache.org>.
mistercrunch commented on issue #8876: Dashboard properties
URL: https://github.com/apache/incubator-superset/pull/8876#issuecomment-568064168
Let's clarify the PR title (that will become the commit message on master once we squash & merge) https://chris.beams.io/posts/git-commit/
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [incubator-superset] suddjian commented on issue #8876: Dashboard
properties
Posted by GitBox <gi...@apache.org>.
suddjian commented on issue #8876: Dashboard properties
URL: https://github.com/apache/incubator-superset/pull/8876#issuecomment-568067941
Oh yeah thanks I forgot to edit the default title 😁
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [incubator-superset] suddjian commented on a change in pull request
#8876: Modal for editing dashboard properties & metadata
Posted by GitBox <gi...@apache.org>.
suddjian commented on a change in pull request #8876: Modal for editing dashboard properties & metadata
URL: https://github.com/apache/incubator-superset/pull/8876#discussion_r360663006
##########
File path: superset/assets/src/dashboard/components/PropertiesModal.jsx
##########
@@ -0,0 +1,282 @@
+/**
+ * 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.
+ */
+import React from 'react';
+import PropTypes from 'prop-types';
+import { Row, Col, Button, Modal, FormControl } from 'react-bootstrap';
+import Dialog from 'react-bootstrap-dialog';
+import Select from 'react-select';
+import { t } from '@superset-ui/translation';
+import { SupersetClient } from '@superset-ui/connection';
+
+import getClientErrorObject from '../../utils/getClientErrorObject';
+import withToasts from '../../messageToasts/enhancers/withToasts';
+
+const propTypes = {
+ dashboardTitle: PropTypes.string,
+ dashboardInfo: PropTypes.object,
+ owners: PropTypes.arrayOf(PropTypes.object),
+ show: PropTypes.bool.isRequired,
+ onHide: PropTypes.func,
+ onDashboardSave: PropTypes.func,
+ addSuccessToast: PropTypes.func.isRequired,
+};
+
+const defaultProps = {
+ dashboardInfo: {},
+ dashboardTitle: '[dashboard name]',
+ owners: [],
+ onHide: () => {},
+ onDashboardSave: () => {},
+ show: false,
+};
+
+class PropertiesModal extends React.PureComponent {
+ constructor(props) {
+ super(props);
+ this.state = {
+ errors: [],
+ values: {
+ dashboard_title: this.props.dashboardTitle,
+ slug: this.props.dashboardInfo.slug,
+ owners: this.props.owners || [],
+ json_metadata: JSON.stringify(this.props.dashboardInfo.metadata),
+ },
+ isOwnersLoaded: false,
+ userOptions: null,
+ isAdvancedOpen: false,
+ };
+ this.onChange = this.onChange.bind(this);
+ this.onOwnersChange = this.onOwnersChange.bind(this);
+ this.save = this.save.bind(this);
+ this.toggleAdvanced = this.toggleAdvanced.bind(this);
+ }
+
+ componentDidMount() {
+ SupersetClient.get({ endpoint: `/users/api/read` }).then(response => {
+ const options = response.json.result.map((user, i) => ({
+ // ids are in a separate `pks` array in the results... need api v2
+ value: response.json.pks[i],
+ label: `${user.first_name} ${user.last_name}`,
Review comment:
The [docs](https://v1.react-select.com/) examples use `value`, `label`.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [incubator-superset] mistercrunch merged pull request #8876:
[dashboard] Modal for editing dashboard properties & metadata
Posted by GitBox <gi...@apache.org>.
mistercrunch merged pull request #8876: [dashboard] Modal for editing dashboard properties & metadata
URL: https://github.com/apache/incubator-superset/pull/8876
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [incubator-superset] suddjian commented on a change in pull request
#8876: Modal for editing dashboard properties & metadata
Posted by GitBox <gi...@apache.org>.
suddjian commented on a change in pull request #8876: Modal for editing dashboard properties & metadata
URL: https://github.com/apache/incubator-superset/pull/8876#discussion_r360663082
##########
File path: superset/assets/src/dashboard/components/PropertiesModal.jsx
##########
@@ -0,0 +1,282 @@
+/**
+ * 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.
+ */
+import React from 'react';
+import PropTypes from 'prop-types';
+import { Row, Col, Button, Modal, FormControl } from 'react-bootstrap';
+import Dialog from 'react-bootstrap-dialog';
+import Select from 'react-select';
+import { t } from '@superset-ui/translation';
+import { SupersetClient } from '@superset-ui/connection';
+
+import getClientErrorObject from '../../utils/getClientErrorObject';
+import withToasts from '../../messageToasts/enhancers/withToasts';
+
+const propTypes = {
+ dashboardTitle: PropTypes.string,
+ dashboardInfo: PropTypes.object,
+ owners: PropTypes.arrayOf(PropTypes.object),
+ show: PropTypes.bool.isRequired,
+ onHide: PropTypes.func,
+ onDashboardSave: PropTypes.func,
+ addSuccessToast: PropTypes.func.isRequired,
+};
+
+const defaultProps = {
+ dashboardInfo: {},
+ dashboardTitle: '[dashboard name]',
+ owners: [],
+ onHide: () => {},
+ onDashboardSave: () => {},
+ show: false,
+};
+
+class PropertiesModal extends React.PureComponent {
+ constructor(props) {
+ super(props);
+ this.state = {
+ errors: [],
+ values: {
+ dashboard_title: this.props.dashboardTitle,
+ slug: this.props.dashboardInfo.slug,
+ owners: this.props.owners || [],
+ json_metadata: JSON.stringify(this.props.dashboardInfo.metadata),
+ },
+ isOwnersLoaded: false,
+ userOptions: null,
+ isAdvancedOpen: false,
+ };
+ this.onChange = this.onChange.bind(this);
+ this.onOwnersChange = this.onOwnersChange.bind(this);
+ this.save = this.save.bind(this);
+ this.toggleAdvanced = this.toggleAdvanced.bind(this);
+ }
+
+ componentDidMount() {
+ SupersetClient.get({ endpoint: `/users/api/read` }).then(response => {
+ const options = response.json.result.map((user, i) => ({
+ // ids are in a separate `pks` array in the results... need api v2
+ value: response.json.pks[i],
+ label: `${user.first_name} ${user.last_name}`,
+ }));
+ this.setState({
+ userOptions: options,
+ });
+ });
+ SupersetClient.get({
+ endpoint: `/api/v1/dashboard/${this.props.dashboardInfo.id}`,
+ }).then(response => {
+ this.setState({ isOwnersLoaded: true });
+ const initialSelectedValues = response.json.result.owners.map(owner => ({
+ value: owner.id,
+ label: owner.username,
+ }));
+ this.onOwnersChange(initialSelectedValues);
+ });
+ }
+
+ onOwnersChange(value) {
+ this.setState(state => ({
+ values: {
+ ...state.values,
+ owners: value,
+ },
+ }));
+ }
+
+ onChange(e) {
+ const { name, value } = e.target;
+ this.setState(state => ({
+ values: {
+ ...state.values,
+ [name]: value,
+ },
+ }));
+ }
+
+ toggleAdvanced() {
+ this.setState(state => ({
+ isAdvancedOpen: !state.isAdvancedOpen,
+ }));
+ }
+
+ save(e) {
+ e.preventDefault();
+ e.stopPropagation();
+ const owners = this.state.values.owners.map(o => o.value);
+ SupersetClient.put({
+ endpoint: `/api/v1/dashboard/${this.props.dashboardInfo.id}`,
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({
+ ...this.state.values,
+ owners,
+ }),
+ })
+ .then(({ json }) => {
+ this.props.addSuccessToast(t('The dashboard has been saved'));
+ this.props.onDashboardSave({
+ title: json.result.dashboard_title,
+ slug: json.result.slug,
+ jsonMetadata: json.result.json_metadata,
+ ownerIds: json.result.owners,
+ });
+ this.props.onHide();
+ })
+ .catch(response =>
+ getClientErrorObject(response).then(({ error, statusText }) => {
+ this.dialog.show({
+ title: 'Error',
+ bsSize: 'medium',
+ bsStyle: 'danger',
+ actions: [Dialog.DefaultAction('Ok', () => {}, 'btn-danger')],
+ body: error || statusText || t('An error has occurred'),
+ });
+ }),
+ );
+ }
+
+ render() {
+ const { userOptions, values, isOwnersLoaded, isAdvancedOpen } = this.state;
+ return (
+ <Modal show={this.props.show} onHide={this.props.onHide} bsSize="lg">
+ <form onSubmit={this.save}>
+ <Modal.Header closeButton>
+ <Modal.Title>
+ <div>
+ <span className="float-left">{t('Dashboard Properties')}</span>
+ </div>
+ </Modal.Title>
+ </Modal.Header>
+ <Modal.Body>
+ <Row>
+ <Col md={12}>
+ <h3>Basic Information</h3>
+ </Col>
+ </Row>
+ <Row>
+ <Col md={6}>
+ <label className="control-label" htmlFor="embed-height">
+ {t('Title')}
Review comment:
Do you have docs on how the backend translation works? I'm happy to use that if it works better, but it seems messy to be mixing frontend and backend translations everywhere.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [incubator-superset] mistercrunch commented on a change in pull
request #8876: [dashboard] Modal for editing dashboard properties & metadata
Posted by GitBox <gi...@apache.org>.
mistercrunch commented on a change in pull request #8876: [dashboard] Modal for editing dashboard properties & metadata
URL: https://github.com/apache/incubator-superset/pull/8876#discussion_r366530164
##########
File path: superset/assets/src/dashboard/components/PropertiesModal.jsx
##########
@@ -0,0 +1,282 @@
+/**
+ * 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.
+ */
+import React from 'react';
+import PropTypes from 'prop-types';
+import { Row, Col, Button, Modal, FormControl } from 'react-bootstrap';
+import Dialog from 'react-bootstrap-dialog';
+import Select from 'react-select';
+import { t } from '@superset-ui/translation';
+import { SupersetClient } from '@superset-ui/connection';
+
+import getClientErrorObject from '../../utils/getClientErrorObject';
+import withToasts from '../../messageToasts/enhancers/withToasts';
+
+const propTypes = {
+ dashboardTitle: PropTypes.string,
+ dashboardInfo: PropTypes.object,
+ owners: PropTypes.arrayOf(PropTypes.object),
+ show: PropTypes.bool.isRequired,
+ onHide: PropTypes.func,
+ onDashboardSave: PropTypes.func,
+ addSuccessToast: PropTypes.func.isRequired,
+};
+
+const defaultProps = {
+ dashboardInfo: {},
+ dashboardTitle: '[dashboard name]',
+ owners: [],
+ onHide: () => {},
+ onDashboardSave: () => {},
+ show: false,
+};
+
+class PropertiesModal extends React.PureComponent {
+ constructor(props) {
+ super(props);
+ this.state = {
+ errors: [],
+ values: {
+ dashboard_title: this.props.dashboardTitle,
+ slug: this.props.dashboardInfo.slug,
+ owners: this.props.owners || [],
+ json_metadata: JSON.stringify(this.props.dashboardInfo.metadata),
+ },
+ isOwnersLoaded: false,
+ userOptions: null,
+ isAdvancedOpen: false,
+ };
+ this.onChange = this.onChange.bind(this);
+ this.onOwnersChange = this.onOwnersChange.bind(this);
+ this.save = this.save.bind(this);
+ this.toggleAdvanced = this.toggleAdvanced.bind(this);
+ }
+
+ componentDidMount() {
+ SupersetClient.get({ endpoint: `/users/api/read` }).then(response => {
+ const options = response.json.result.map((user, i) => ({
+ // ids are in a separate `pks` array in the results... need api v2
+ value: response.json.pks[i],
+ label: `${user.first_name} ${user.last_name}`,
+ }));
+ this.setState({
+ userOptions: options,
+ });
+ });
+ SupersetClient.get({
+ endpoint: `/api/v1/dashboard/${this.props.dashboardInfo.id}`,
+ }).then(response => {
+ this.setState({ isOwnersLoaded: true });
+ const initialSelectedValues = response.json.result.owners.map(owner => ({
+ value: owner.id,
+ label: owner.username,
+ }));
+ this.onOwnersChange(initialSelectedValues);
+ });
+ }
+
+ onOwnersChange(value) {
+ this.setState(state => ({
+ values: {
+ ...state.values,
+ owners: value,
+ },
+ }));
+ }
+
+ onChange(e) {
+ const { name, value } = e.target;
+ this.setState(state => ({
+ values: {
+ ...state.values,
+ [name]: value,
+ },
+ }));
+ }
+
+ toggleAdvanced() {
+ this.setState(state => ({
+ isAdvancedOpen: !state.isAdvancedOpen,
+ }));
+ }
+
+ save(e) {
+ e.preventDefault();
+ e.stopPropagation();
+ const owners = this.state.values.owners.map(o => o.value);
+ SupersetClient.put({
+ endpoint: `/api/v1/dashboard/${this.props.dashboardInfo.id}`,
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({
+ ...this.state.values,
+ owners,
+ }),
+ })
+ .then(({ json }) => {
+ this.props.addSuccessToast(t('The dashboard has been saved'));
+ this.props.onDashboardSave({
+ title: json.result.dashboard_title,
+ slug: json.result.slug,
+ jsonMetadata: json.result.json_metadata,
+ ownerIds: json.result.owners,
+ });
+ this.props.onHide();
+ })
+ .catch(response =>
+ getClientErrorObject(response).then(({ error, statusText }) => {
+ this.dialog.show({
+ title: 'Error',
+ bsSize: 'medium',
+ bsStyle: 'danger',
+ actions: [Dialog.DefaultAction('Ok', () => {}, 'btn-danger')],
+ body: error || statusText || t('An error has occurred'),
+ });
+ }),
+ );
+ }
+
+ render() {
+ const { userOptions, values, isOwnersLoaded, isAdvancedOpen } = this.state;
+ return (
+ <Modal show={this.props.show} onHide={this.props.onHide} bsSize="lg">
+ <form onSubmit={this.save}>
+ <Modal.Header closeButton>
+ <Modal.Title>
+ <div>
+ <span className="float-left">{t('Dashboard Properties')}</span>
+ </div>
+ </Modal.Title>
+ </Modal.Header>
+ <Modal.Body>
+ <Row>
+ <Col md={12}>
+ <h3>Basic Information</h3>
+ </Col>
+ </Row>
+ <Row>
+ <Col md={6}>
+ <label className="control-label" htmlFor="embed-height">
+ {t('Title')}
Review comment:
My take on this after a short conversation with @nytai and @suddjian is that we generally want to move more things to the frontend and rely less on the framework or framework-related assumptions at this time.
This screen and other CRUD-related screen may evolve to have more non-CRUD related things, and we want for these things to be frontend-centered as opposed to backend-driven.
I think as we add buttons, actions, headers, descriptions, we want all of the translations to be consistent and on the frontend, as opposed to having a mix backend and frontend declared strings.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [incubator-superset] dpgaspar commented on a change in pull request
#8876: Modal for editing dashboard properties & metadata
Posted by GitBox <gi...@apache.org>.
dpgaspar commented on a change in pull request #8876: Modal for editing dashboard properties & metadata
URL: https://github.com/apache/incubator-superset/pull/8876#discussion_r360654941
##########
File path: superset/assets/src/dashboard/components/PropertiesModal.jsx
##########
@@ -0,0 +1,282 @@
+/**
+ * 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.
+ */
+import React from 'react';
+import PropTypes from 'prop-types';
+import { Row, Col, Button, Modal, FormControl } from 'react-bootstrap';
+import Dialog from 'react-bootstrap-dialog';
+import Select from 'react-select';
+import { t } from '@superset-ui/translation';
+import { SupersetClient } from '@superset-ui/connection';
+
+import getClientErrorObject from '../../utils/getClientErrorObject';
+import withToasts from '../../messageToasts/enhancers/withToasts';
+
+const propTypes = {
+ dashboardTitle: PropTypes.string,
+ dashboardInfo: PropTypes.object,
+ owners: PropTypes.arrayOf(PropTypes.object),
+ show: PropTypes.bool.isRequired,
+ onHide: PropTypes.func,
+ onDashboardSave: PropTypes.func,
+ addSuccessToast: PropTypes.func.isRequired,
+};
+
+const defaultProps = {
+ dashboardInfo: {},
+ dashboardTitle: '[dashboard name]',
+ owners: [],
+ onHide: () => {},
+ onDashboardSave: () => {},
+ show: false,
+};
+
+class PropertiesModal extends React.PureComponent {
+ constructor(props) {
+ super(props);
+ this.state = {
+ errors: [],
+ values: {
+ dashboard_title: this.props.dashboardTitle,
+ slug: this.props.dashboardInfo.slug,
+ owners: this.props.owners || [],
+ json_metadata: JSON.stringify(this.props.dashboardInfo.metadata),
+ },
+ isOwnersLoaded: false,
+ userOptions: null,
+ isAdvancedOpen: false,
+ };
+ this.onChange = this.onChange.bind(this);
+ this.onOwnersChange = this.onOwnersChange.bind(this);
+ this.save = this.save.bind(this);
+ this.toggleAdvanced = this.toggleAdvanced.bind(this);
+ }
+
+ componentDidMount() {
+ SupersetClient.get({ endpoint: `/users/api/read` }).then(response => {
+ const options = response.json.result.map((user, i) => ({
+ // ids are in a separate `pks` array in the results... need api v2
+ value: response.json.pks[i],
+ label: `${user.first_name} ${user.last_name}`,
Review comment:
Talking about the new endpoint, I thought the norm was `value`, `text` for select components. Is `value`, `label` what is always expected on this components? if yes I'll change it on the API, it's cleaner
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [incubator-superset] codecov-io edited a comment on issue #8876:
[dashboard] Modal for editing dashboard properties & metadata
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on issue #8876: [dashboard] Modal for editing dashboard properties & metadata
URL: https://github.com/apache/incubator-superset/pull/8876#issuecomment-572832163
# [Codecov](https://codecov.io/gh/apache/incubator-superset/pull/8876?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`master@cfc1e69`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
> The diff coverage is `14.28%`.
[](https://codecov.io/gh/apache/incubator-superset/pull/8876?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #8876 +/- ##
=========================================
Coverage ? 58.68%
=========================================
Files ? 362
Lines ? 11415
Branches ? 2801
=========================================
Hits ? 6699
Misses ? 4538
Partials ? 178
```
| [Impacted Files](https://codecov.io/gh/apache/incubator-superset/pull/8876?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [...ssets/src/dashboard/containers/DashboardHeader.jsx](https://codecov.io/gh/apache/incubator-superset/pull/8876/diff?src=pr&el=tree#diff-c3VwZXJzZXQvYXNzZXRzL3NyYy9kYXNoYm9hcmQvY29udGFpbmVycy9EYXNoYm9hcmRIZWFkZXIuanN4) | `100% <ø> (ø)` | |
| [...src/dashboard/components/HeaderActionsDropdown.jsx](https://codecov.io/gh/apache/incubator-superset/pull/8876/diff?src=pr&el=tree#diff-c3VwZXJzZXQvYXNzZXRzL3NyYy9kYXNoYm9hcmQvY29tcG9uZW50cy9IZWFkZXJBY3Rpb25zRHJvcGRvd24uanN4) | `69.56% <ø> (ø)` | |
| [superset/assets/src/dashboard/reducers/index.js](https://codecov.io/gh/apache/incubator-superset/pull/8876/diff?src=pr&el=tree#diff-c3VwZXJzZXQvYXNzZXRzL3NyYy9kYXNoYm9hcmQvcmVkdWNlcnMvaW5kZXguanM=) | `100% <ø> (ø)` | |
| [...uperset/assets/src/dashboard/components/Header.jsx](https://codecov.io/gh/apache/incubator-superset/pull/8876/diff?src=pr&el=tree#diff-c3VwZXJzZXQvYXNzZXRzL3NyYy9kYXNoYm9hcmQvY29tcG9uZW50cy9IZWFkZXIuanN4) | `41.46% <0%> (ø)` | |
| [...t/assets/src/dashboard/reducers/dashboardLayout.js](https://codecov.io/gh/apache/incubator-superset/pull/8876/diff?src=pr&el=tree#diff-c3VwZXJzZXQvYXNzZXRzL3NyYy9kYXNoYm9hcmQvcmVkdWNlcnMvZGFzaGJvYXJkTGF5b3V0Lmpz) | `93% <0%> (ø)` | |
| [...ssets/src/dashboard/components/PropertiesModal.jsx](https://codecov.io/gh/apache/incubator-superset/pull/8876/diff?src=pr&el=tree#diff-c3VwZXJzZXQvYXNzZXRzL3NyYy9kYXNoYm9hcmQvY29tcG9uZW50cy9Qcm9wZXJ0aWVzTW9kYWwuanN4) | `7.4% <0%> (ø)` | |
| [...rset/assets/src/dashboard/actions/dashboardInfo.js](https://codecov.io/gh/apache/incubator-superset/pull/8876/diff?src=pr&el=tree#diff-c3VwZXJzZXQvYXNzZXRzL3NyYy9kYXNoYm9hcmQvYWN0aW9ucy9kYXNoYm9hcmRJbmZvLmpz) | `33.33% <33.33%> (ø)` | |
| [...et/assets/src/dashboard/actions/dashboardLayout.js](https://codecov.io/gh/apache/incubator-superset/pull/8876/diff?src=pr&el=tree#diff-c3VwZXJzZXQvYXNzZXRzL3NyYy9kYXNoYm9hcmQvYWN0aW9ucy9kYXNoYm9hcmRMYXlvdXQuanM=) | `95.09% <33.33%> (ø)` | |
| [...set/assets/src/dashboard/reducers/dashboardInfo.js](https://codecov.io/gh/apache/incubator-superset/pull/8876/diff?src=pr&el=tree#diff-c3VwZXJzZXQvYXNzZXRzL3NyYy9kYXNoYm9hcmQvcmVkdWNlcnMvZGFzaGJvYXJkSW5mby5qcw==) | `66.66% <66.66%> (ø)` | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-superset/pull/8876?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/incubator-superset/pull/8876?src=pr&el=footer). Last update [cfc1e69...c09c40a](https://codecov.io/gh/apache/incubator-superset/pull/8876?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [incubator-superset] mistercrunch commented on a change in pull
request #8876: [dashboard] Modal for editing dashboard properties & metadata
Posted by GitBox <gi...@apache.org>.
mistercrunch commented on a change in pull request #8876: [dashboard] Modal for editing dashboard properties & metadata
URL: https://github.com/apache/incubator-superset/pull/8876#discussion_r365620863
##########
File path: superset/assets/src/dashboard/actions/dashboardLayout.js
##########
@@ -213,10 +213,8 @@ export function handleComponentDrop(dropResult) {
} else if (
destination &&
source &&
- !(
- // ensure it has moved
- (destination.id === source.id && destination.index === source.index)
- )
+ !// ensure it has moved
Review comment:
It looks odd to me to have the comment in between the `!` and the `(`, seems like the kind of stuff that different JS interpreters might behave differently around...
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [incubator-superset] suddjian commented on a change in pull request
#8876: [dashboard] Modal for editing dashboard properties & metadata
Posted by GitBox <gi...@apache.org>.
suddjian commented on a change in pull request #8876: [dashboard] Modal for editing dashboard properties & metadata
URL: https://github.com/apache/incubator-superset/pull/8876#discussion_r365943605
##########
File path: superset/assets/src/dashboard/actions/dashboardLayout.js
##########
@@ -213,10 +213,8 @@ export function handleComponentDrop(dropResult) {
} else if (
destination &&
source &&
- !(
- // ensure it has moved
- (destination.id === source.id && destination.index === source.index)
- )
+ !// ensure it has moved
Review comment:
I'm not sure how this change got in. I think it might have been the result of autoformatting. Shouldn't be a problem for the interpreter, but I'll change it back anyway.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [incubator-superset] codecov-io commented on issue #8876: Modal for
editing dashboard properties & metadata
Posted by GitBox <gi...@apache.org>.
codecov-io commented on issue #8876: Modal for editing dashboard properties & metadata
URL: https://github.com/apache/incubator-superset/pull/8876#issuecomment-572832163
# [Codecov](https://codecov.io/gh/apache/incubator-superset/pull/8876?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`master@cfc1e69`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
> The diff coverage is `14.28%`.
[](https://codecov.io/gh/apache/incubator-superset/pull/8876?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #8876 +/- ##
=========================================
Coverage ? 58.67%
=========================================
Files ? 362
Lines ? 11412
Branches ? 2800
=========================================
Hits ? 6696
Misses ? 4538
Partials ? 178
```
| [Impacted Files](https://codecov.io/gh/apache/incubator-superset/pull/8876?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [...ssets/src/dashboard/containers/DashboardHeader.jsx](https://codecov.io/gh/apache/incubator-superset/pull/8876/diff?src=pr&el=tree#diff-c3VwZXJzZXQvYXNzZXRzL3NyYy9kYXNoYm9hcmQvY29udGFpbmVycy9EYXNoYm9hcmRIZWFkZXIuanN4) | `100% <ø> (ø)` | |
| [...src/dashboard/components/HeaderActionsDropdown.jsx](https://codecov.io/gh/apache/incubator-superset/pull/8876/diff?src=pr&el=tree#diff-c3VwZXJzZXQvYXNzZXRzL3NyYy9kYXNoYm9hcmQvY29tcG9uZW50cy9IZWFkZXJBY3Rpb25zRHJvcGRvd24uanN4) | `69.56% <ø> (ø)` | |
| [superset/assets/src/dashboard/reducers/index.js](https://codecov.io/gh/apache/incubator-superset/pull/8876/diff?src=pr&el=tree#diff-c3VwZXJzZXQvYXNzZXRzL3NyYy9kYXNoYm9hcmQvcmVkdWNlcnMvaW5kZXguanM=) | `100% <ø> (ø)` | |
| [...uperset/assets/src/dashboard/components/Header.jsx](https://codecov.io/gh/apache/incubator-superset/pull/8876/diff?src=pr&el=tree#diff-c3VwZXJzZXQvYXNzZXRzL3NyYy9kYXNoYm9hcmQvY29tcG9uZW50cy9IZWFkZXIuanN4) | `41.46% <0%> (ø)` | |
| [...t/assets/src/dashboard/reducers/dashboardLayout.js](https://codecov.io/gh/apache/incubator-superset/pull/8876/diff?src=pr&el=tree#diff-c3VwZXJzZXQvYXNzZXRzL3NyYy9kYXNoYm9hcmQvcmVkdWNlcnMvZGFzaGJvYXJkTGF5b3V0Lmpz) | `93% <0%> (ø)` | |
| [...ssets/src/dashboard/components/PropertiesModal.jsx](https://codecov.io/gh/apache/incubator-superset/pull/8876/diff?src=pr&el=tree#diff-c3VwZXJzZXQvYXNzZXRzL3NyYy9kYXNoYm9hcmQvY29tcG9uZW50cy9Qcm9wZXJ0aWVzTW9kYWwuanN4) | `7.4% <0%> (ø)` | |
| [...rset/assets/src/dashboard/actions/dashboardInfo.js](https://codecov.io/gh/apache/incubator-superset/pull/8876/diff?src=pr&el=tree#diff-c3VwZXJzZXQvYXNzZXRzL3NyYy9kYXNoYm9hcmQvYWN0aW9ucy9kYXNoYm9hcmRJbmZvLmpz) | `33.33% <33.33%> (ø)` | |
| [...et/assets/src/dashboard/actions/dashboardLayout.js](https://codecov.io/gh/apache/incubator-superset/pull/8876/diff?src=pr&el=tree#diff-c3VwZXJzZXQvYXNzZXRzL3NyYy9kYXNoYm9hcmQvYWN0aW9ucy9kYXNoYm9hcmRMYXlvdXQuanM=) | `95.09% <33.33%> (ø)` | |
| [...set/assets/src/dashboard/reducers/dashboardInfo.js](https://codecov.io/gh/apache/incubator-superset/pull/8876/diff?src=pr&el=tree#diff-c3VwZXJzZXQvYXNzZXRzL3NyYy9kYXNoYm9hcmQvcmVkdWNlcnMvZGFzaGJvYXJkSW5mby5qcw==) | `66.66% <66.66%> (ø)` | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-superset/pull/8876?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/incubator-superset/pull/8876?src=pr&el=footer). Last update [cfc1e69...5bd8eff](https://codecov.io/gh/apache/incubator-superset/pull/8876?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [incubator-superset] dpgaspar commented on a change in pull request
#8876: Modal for editing dashboard properties & metadata
Posted by GitBox <gi...@apache.org>.
dpgaspar commented on a change in pull request #8876: Modal for editing dashboard properties & metadata
URL: https://github.com/apache/incubator-superset/pull/8876#discussion_r360655024
##########
File path: superset/assets/src/dashboard/components/PropertiesModal.jsx
##########
@@ -0,0 +1,282 @@
+/**
+ * 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.
+ */
+import React from 'react';
+import PropTypes from 'prop-types';
+import { Row, Col, Button, Modal, FormControl } from 'react-bootstrap';
+import Dialog from 'react-bootstrap-dialog';
+import Select from 'react-select';
+import { t } from '@superset-ui/translation';
+import { SupersetClient } from '@superset-ui/connection';
+
+import getClientErrorObject from '../../utils/getClientErrorObject';
+import withToasts from '../../messageToasts/enhancers/withToasts';
+
+const propTypes = {
+ dashboardTitle: PropTypes.string,
+ dashboardInfo: PropTypes.object,
+ owners: PropTypes.arrayOf(PropTypes.object),
+ show: PropTypes.bool.isRequired,
+ onHide: PropTypes.func,
+ onDashboardSave: PropTypes.func,
+ addSuccessToast: PropTypes.func.isRequired,
+};
+
+const defaultProps = {
+ dashboardInfo: {},
+ dashboardTitle: '[dashboard name]',
+ owners: [],
+ onHide: () => {},
+ onDashboardSave: () => {},
+ show: false,
+};
+
+class PropertiesModal extends React.PureComponent {
+ constructor(props) {
+ super(props);
+ this.state = {
+ errors: [],
+ values: {
+ dashboard_title: this.props.dashboardTitle,
+ slug: this.props.dashboardInfo.slug,
+ owners: this.props.owners || [],
+ json_metadata: JSON.stringify(this.props.dashboardInfo.metadata),
+ },
+ isOwnersLoaded: false,
+ userOptions: null,
+ isAdvancedOpen: false,
+ };
+ this.onChange = this.onChange.bind(this);
+ this.onOwnersChange = this.onOwnersChange.bind(this);
+ this.save = this.save.bind(this);
+ this.toggleAdvanced = this.toggleAdvanced.bind(this);
+ }
+
+ componentDidMount() {
+ SupersetClient.get({ endpoint: `/users/api/read` }).then(response => {
+ const options = response.json.result.map((user, i) => ({
+ // ids are in a separate `pks` array in the results... need api v2
+ value: response.json.pks[i],
+ label: `${user.first_name} ${user.last_name}`,
+ }));
+ this.setState({
+ userOptions: options,
+ });
+ });
+ SupersetClient.get({
+ endpoint: `/api/v1/dashboard/${this.props.dashboardInfo.id}`,
+ }).then(response => {
+ this.setState({ isOwnersLoaded: true });
+ const initialSelectedValues = response.json.result.owners.map(owner => ({
+ value: owner.id,
+ label: owner.username,
+ }));
+ this.onOwnersChange(initialSelectedValues);
+ });
+ }
+
+ onOwnersChange(value) {
+ this.setState(state => ({
+ values: {
+ ...state.values,
+ owners: value,
+ },
+ }));
+ }
+
+ onChange(e) {
+ const { name, value } = e.target;
+ this.setState(state => ({
+ values: {
+ ...state.values,
+ [name]: value,
+ },
+ }));
+ }
+
+ toggleAdvanced() {
+ this.setState(state => ({
+ isAdvancedOpen: !state.isAdvancedOpen,
+ }));
+ }
+
+ save(e) {
+ e.preventDefault();
+ e.stopPropagation();
+ const owners = this.state.values.owners.map(o => o.value);
+ SupersetClient.put({
+ endpoint: `/api/v1/dashboard/${this.props.dashboardInfo.id}`,
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({
+ ...this.state.values,
+ owners,
+ }),
+ })
+ .then(({ json }) => {
+ this.props.addSuccessToast(t('The dashboard has been saved'));
+ this.props.onDashboardSave({
+ title: json.result.dashboard_title,
+ slug: json.result.slug,
+ jsonMetadata: json.result.json_metadata,
+ ownerIds: json.result.owners,
+ });
+ this.props.onHide();
+ })
+ .catch(response =>
+ getClientErrorObject(response).then(({ error, statusText }) => {
+ this.dialog.show({
+ title: 'Error',
+ bsSize: 'medium',
+ bsStyle: 'danger',
+ actions: [Dialog.DefaultAction('Ok', () => {}, 'btn-danger')],
+ body: error || statusText || t('An error has occurred'),
+ });
+ }),
+ );
+ }
+
+ render() {
+ const { userOptions, values, isOwnersLoaded, isAdvancedOpen } = this.state;
+ return (
+ <Modal show={this.props.show} onHide={this.props.onHide} bsSize="lg">
+ <form onSubmit={this.save}>
+ <Modal.Header closeButton>
+ <Modal.Title>
+ <div>
+ <span className="float-left">{t('Dashboard Properties')}</span>
+ </div>
+ </Modal.Title>
+ </Modal.Header>
+ <Modal.Body>
+ <Row>
+ <Col md={12}>
+ <h3>Basic Information</h3>
+ </Col>
+ </Row>
+ <Row>
+ <Col md={6}>
+ <label className="control-label" htmlFor="embed-height">
+ {t('Title')}
Review comment:
We need to define, if we are going to use backend translation for field label's, descriptions and titles or switch to frontend. By backend translation I mean that the API already has these fields translated to you on the response
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [incubator-superset] suddjian commented on issue #8876: [dashboard]
Modal for editing dashboard properties & metadata
Posted by GitBox <gi...@apache.org>.
suddjian commented on issue #8876: [dashboard] Modal for editing dashboard properties & metadata
URL: https://github.com/apache/incubator-superset/pull/8876#issuecomment-574285563
@dpgaspar Ok, I copied the description text from the MVC edit page.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [incubator-superset] codecov-io edited a comment on issue #8876:
Modal for editing dashboard properties & metadata
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on issue #8876: Modal for editing dashboard properties & metadata
URL: https://github.com/apache/incubator-superset/pull/8876#issuecomment-572832163
# [Codecov](https://codecov.io/gh/apache/incubator-superset/pull/8876?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`master@cfc1e69`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
> The diff coverage is `14.28%`.
[](https://codecov.io/gh/apache/incubator-superset/pull/8876?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #8876 +/- ##
=========================================
Coverage ? 58.67%
=========================================
Files ? 362
Lines ? 11412
Branches ? 2800
=========================================
Hits ? 6696
Misses ? 4538
Partials ? 178
```
| [Impacted Files](https://codecov.io/gh/apache/incubator-superset/pull/8876?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [...ssets/src/dashboard/containers/DashboardHeader.jsx](https://codecov.io/gh/apache/incubator-superset/pull/8876/diff?src=pr&el=tree#diff-c3VwZXJzZXQvYXNzZXRzL3NyYy9kYXNoYm9hcmQvY29udGFpbmVycy9EYXNoYm9hcmRIZWFkZXIuanN4) | `100% <ø> (ø)` | |
| [...src/dashboard/components/HeaderActionsDropdown.jsx](https://codecov.io/gh/apache/incubator-superset/pull/8876/diff?src=pr&el=tree#diff-c3VwZXJzZXQvYXNzZXRzL3NyYy9kYXNoYm9hcmQvY29tcG9uZW50cy9IZWFkZXJBY3Rpb25zRHJvcGRvd24uanN4) | `69.56% <ø> (ø)` | |
| [superset/assets/src/dashboard/reducers/index.js](https://codecov.io/gh/apache/incubator-superset/pull/8876/diff?src=pr&el=tree#diff-c3VwZXJzZXQvYXNzZXRzL3NyYy9kYXNoYm9hcmQvcmVkdWNlcnMvaW5kZXguanM=) | `100% <ø> (ø)` | |
| [...uperset/assets/src/dashboard/components/Header.jsx](https://codecov.io/gh/apache/incubator-superset/pull/8876/diff?src=pr&el=tree#diff-c3VwZXJzZXQvYXNzZXRzL3NyYy9kYXNoYm9hcmQvY29tcG9uZW50cy9IZWFkZXIuanN4) | `41.46% <0%> (ø)` | |
| [...t/assets/src/dashboard/reducers/dashboardLayout.js](https://codecov.io/gh/apache/incubator-superset/pull/8876/diff?src=pr&el=tree#diff-c3VwZXJzZXQvYXNzZXRzL3NyYy9kYXNoYm9hcmQvcmVkdWNlcnMvZGFzaGJvYXJkTGF5b3V0Lmpz) | `93% <0%> (ø)` | |
| [...ssets/src/dashboard/components/PropertiesModal.jsx](https://codecov.io/gh/apache/incubator-superset/pull/8876/diff?src=pr&el=tree#diff-c3VwZXJzZXQvYXNzZXRzL3NyYy9kYXNoYm9hcmQvY29tcG9uZW50cy9Qcm9wZXJ0aWVzTW9kYWwuanN4) | `7.4% <0%> (ø)` | |
| [...rset/assets/src/dashboard/actions/dashboardInfo.js](https://codecov.io/gh/apache/incubator-superset/pull/8876/diff?src=pr&el=tree#diff-c3VwZXJzZXQvYXNzZXRzL3NyYy9kYXNoYm9hcmQvYWN0aW9ucy9kYXNoYm9hcmRJbmZvLmpz) | `33.33% <33.33%> (ø)` | |
| [...et/assets/src/dashboard/actions/dashboardLayout.js](https://codecov.io/gh/apache/incubator-superset/pull/8876/diff?src=pr&el=tree#diff-c3VwZXJzZXQvYXNzZXRzL3NyYy9kYXNoYm9hcmQvYWN0aW9ucy9kYXNoYm9hcmRMYXlvdXQuanM=) | `95.09% <33.33%> (ø)` | |
| [...set/assets/src/dashboard/reducers/dashboardInfo.js](https://codecov.io/gh/apache/incubator-superset/pull/8876/diff?src=pr&el=tree#diff-c3VwZXJzZXQvYXNzZXRzL3NyYy9kYXNoYm9hcmQvcmVkdWNlcnMvZGFzaGJvYXJkSW5mby5qcw==) | `66.66% <66.66%> (ø)` | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-superset/pull/8876?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/incubator-superset/pull/8876?src=pr&el=footer). Last update [cfc1e69...5bd8eff](https://codecov.io/gh/apache/incubator-superset/pull/8876?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [incubator-superset] dpgaspar commented on a change in pull request
#8876: Modal for editing dashboard properties & metadata
Posted by GitBox <gi...@apache.org>.
dpgaspar commented on a change in pull request #8876: Modal for editing dashboard properties & metadata
URL: https://github.com/apache/incubator-superset/pull/8876#discussion_r360655264
##########
File path: superset/assets/src/dashboard/components/PropertiesModal.jsx
##########
@@ -0,0 +1,282 @@
+/**
+ * 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.
+ */
+import React from 'react';
+import PropTypes from 'prop-types';
+import { Row, Col, Button, Modal, FormControl } from 'react-bootstrap';
+import Dialog from 'react-bootstrap-dialog';
+import Select from 'react-select';
+import { t } from '@superset-ui/translation';
+import { SupersetClient } from '@superset-ui/connection';
+
+import getClientErrorObject from '../../utils/getClientErrorObject';
+import withToasts from '../../messageToasts/enhancers/withToasts';
+
+const propTypes = {
+ dashboardTitle: PropTypes.string,
+ dashboardInfo: PropTypes.object,
+ owners: PropTypes.arrayOf(PropTypes.object),
+ show: PropTypes.bool.isRequired,
+ onHide: PropTypes.func,
+ onDashboardSave: PropTypes.func,
+ addSuccessToast: PropTypes.func.isRequired,
+};
+
+const defaultProps = {
+ dashboardInfo: {},
+ dashboardTitle: '[dashboard name]',
+ owners: [],
+ onHide: () => {},
+ onDashboardSave: () => {},
+ show: false,
+};
+
+class PropertiesModal extends React.PureComponent {
+ constructor(props) {
+ super(props);
+ this.state = {
+ errors: [],
+ values: {
+ dashboard_title: this.props.dashboardTitle,
+ slug: this.props.dashboardInfo.slug,
+ owners: this.props.owners || [],
+ json_metadata: JSON.stringify(this.props.dashboardInfo.metadata),
+ },
+ isOwnersLoaded: false,
+ userOptions: null,
+ isAdvancedOpen: false,
+ };
+ this.onChange = this.onChange.bind(this);
+ this.onOwnersChange = this.onOwnersChange.bind(this);
+ this.save = this.save.bind(this);
+ this.toggleAdvanced = this.toggleAdvanced.bind(this);
+ }
+
+ componentDidMount() {
+ SupersetClient.get({ endpoint: `/users/api/read` }).then(response => {
+ const options = response.json.result.map((user, i) => ({
+ // ids are in a separate `pks` array in the results... need api v2
+ value: response.json.pks[i],
+ label: `${user.first_name} ${user.last_name}`,
+ }));
+ this.setState({
+ userOptions: options,
+ });
+ });
+ SupersetClient.get({
+ endpoint: `/api/v1/dashboard/${this.props.dashboardInfo.id}`,
+ }).then(response => {
+ this.setState({ isOwnersLoaded: true });
+ const initialSelectedValues = response.json.result.owners.map(owner => ({
+ value: owner.id,
+ label: owner.username,
+ }));
+ this.onOwnersChange(initialSelectedValues);
+ });
+ }
+
+ onOwnersChange(value) {
+ this.setState(state => ({
+ values: {
+ ...state.values,
+ owners: value,
+ },
+ }));
+ }
+
+ onChange(e) {
+ const { name, value } = e.target;
+ this.setState(state => ({
+ values: {
+ ...state.values,
+ [name]: value,
+ },
+ }));
+ }
+
+ toggleAdvanced() {
+ this.setState(state => ({
+ isAdvancedOpen: !state.isAdvancedOpen,
+ }));
+ }
+
+ save(e) {
+ e.preventDefault();
+ e.stopPropagation();
+ const owners = this.state.values.owners.map(o => o.value);
+ SupersetClient.put({
+ endpoint: `/api/v1/dashboard/${this.props.dashboardInfo.id}`,
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({
+ ...this.state.values,
+ owners,
+ }),
+ })
+ .then(({ json }) => {
+ this.props.addSuccessToast(t('The dashboard has been saved'));
+ this.props.onDashboardSave({
+ title: json.result.dashboard_title,
+ slug: json.result.slug,
+ jsonMetadata: json.result.json_metadata,
+ ownerIds: json.result.owners,
+ });
+ this.props.onHide();
+ })
+ .catch(response =>
+ getClientErrorObject(response).then(({ error, statusText }) => {
+ this.dialog.show({
+ title: 'Error',
+ bsSize: 'medium',
+ bsStyle: 'danger',
+ actions: [Dialog.DefaultAction('Ok', () => {}, 'btn-danger')],
+ body: error || statusText || t('An error has occurred'),
+ });
+ }),
+ );
+ }
+
+ render() {
+ const { userOptions, values, isOwnersLoaded, isAdvancedOpen } = this.state;
+ return (
+ <Modal show={this.props.show} onHide={this.props.onHide} bsSize="lg">
+ <form onSubmit={this.save}>
+ <Modal.Header closeButton>
+ <Modal.Title>
+ <div>
+ <span className="float-left">{t('Dashboard Properties')}</span>
+ </div>
+ </Modal.Title>
+ </Modal.Header>
+ <Modal.Body>
+ <Row>
+ <Col md={12}>
+ <h3>Basic Information</h3>
+ </Col>
+ </Row>
+ <Row>
+ <Col md={6}>
+ <label className="control-label" htmlFor="embed-height">
+ {t('Title')}
+ </label>
+ <FormControl
+ name="dashboard_title"
+ type="text"
+ bsSize="sm"
+ value={values.dashboard_title}
+ onChange={this.onChange}
+ />
+ </Col>
+ <Col md={6}>
+ <label className="control-label" htmlFor="embed-height">
+ {t('URL Slug')}
+ </label>
+ <FormControl
+ name="slug"
Review comment:
Can we include the description on this case is `To get a readable URL for your dashboard`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [incubator-superset] dpgaspar commented on a change in pull request
#8876: Modal for editing dashboard properties & metadata
Posted by GitBox <gi...@apache.org>.
dpgaspar commented on a change in pull request #8876: Modal for editing dashboard properties & metadata
URL: https://github.com/apache/incubator-superset/pull/8876#discussion_r360654655
##########
File path: superset/assets/src/dashboard/components/PropertiesModal.jsx
##########
@@ -0,0 +1,282 @@
+/**
+ * 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.
+ */
+import React from 'react';
+import PropTypes from 'prop-types';
+import { Row, Col, Button, Modal, FormControl } from 'react-bootstrap';
+import Dialog from 'react-bootstrap-dialog';
+import Select from 'react-select';
+import { t } from '@superset-ui/translation';
+import { SupersetClient } from '@superset-ui/connection';
+
+import getClientErrorObject from '../../utils/getClientErrorObject';
+import withToasts from '../../messageToasts/enhancers/withToasts';
+
+const propTypes = {
+ dashboardTitle: PropTypes.string,
+ dashboardInfo: PropTypes.object,
+ owners: PropTypes.arrayOf(PropTypes.object),
+ show: PropTypes.bool.isRequired,
+ onHide: PropTypes.func,
+ onDashboardSave: PropTypes.func,
+ addSuccessToast: PropTypes.func.isRequired,
+};
+
+const defaultProps = {
+ dashboardInfo: {},
+ dashboardTitle: '[dashboard name]',
+ owners: [],
+ onHide: () => {},
+ onDashboardSave: () => {},
+ show: false,
+};
+
+class PropertiesModal extends React.PureComponent {
+ constructor(props) {
+ super(props);
+ this.state = {
+ errors: [],
+ values: {
+ dashboard_title: this.props.dashboardTitle,
+ slug: this.props.dashboardInfo.slug,
+ owners: this.props.owners || [],
+ json_metadata: JSON.stringify(this.props.dashboardInfo.metadata),
+ },
+ isOwnersLoaded: false,
+ userOptions: null,
+ isAdvancedOpen: false,
+ };
+ this.onChange = this.onChange.bind(this);
+ this.onOwnersChange = this.onOwnersChange.bind(this);
+ this.save = this.save.bind(this);
+ this.toggleAdvanced = this.toggleAdvanced.bind(this);
+ }
+
+ componentDidMount() {
+ SupersetClient.get({ endpoint: `/users/api/read` }).then(response => {
+ const options = response.json.result.map((user, i) => ({
+ // ids are in a separate `pks` array in the results... need api v2
+ value: response.json.pks[i],
+ label: `${user.first_name} ${user.last_name}`,
+ }));
+ this.setState({
+ userOptions: options,
+ });
+ });
+ SupersetClient.get({
+ endpoint: `/api/v1/dashboard/${this.props.dashboardInfo.id}`,
+ }).then(response => {
+ this.setState({ isOwnersLoaded: true });
+ const initialSelectedValues = response.json.result.owners.map(owner => ({
+ value: owner.id,
+ label: owner.username,
+ }));
+ this.onOwnersChange(initialSelectedValues);
+ });
+ }
+
+ onOwnersChange(value) {
+ this.setState(state => ({
+ values: {
+ ...state.values,
+ owners: value,
+ },
+ }));
+ }
+
+ onChange(e) {
+ const { name, value } = e.target;
+ this.setState(state => ({
+ values: {
+ ...state.values,
+ [name]: value,
+ },
+ }));
+ }
+
+ toggleAdvanced() {
+ this.setState(state => ({
+ isAdvancedOpen: !state.isAdvancedOpen,
+ }));
+ }
+
+ save(e) {
+ e.preventDefault();
+ e.stopPropagation();
+ const owners = this.state.values.owners.map(o => o.value);
+ SupersetClient.put({
+ endpoint: `/api/v1/dashboard/${this.props.dashboardInfo.id}`,
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({
+ ...this.state.values,
+ owners,
+ }),
+ })
+ .then(({ json }) => {
+ this.props.addSuccessToast(t('The dashboard has been saved'));
+ this.props.onDashboardSave({
+ title: json.result.dashboard_title,
+ slug: json.result.slug,
+ jsonMetadata: json.result.json_metadata,
+ ownerIds: json.result.owners,
+ });
+ this.props.onHide();
+ })
+ .catch(response =>
+ getClientErrorObject(response).then(({ error, statusText }) => {
+ this.dialog.show({
+ title: 'Error',
+ bsSize: 'medium',
+ bsStyle: 'danger',
+ actions: [Dialog.DefaultAction('Ok', () => {}, 'btn-danger')],
+ body: error || statusText || t('An error has occurred'),
+ });
+ }),
+ );
+ }
+
+ render() {
+ const { userOptions, values, isOwnersLoaded, isAdvancedOpen } = this.state;
+ return (
+ <Modal show={this.props.show} onHide={this.props.onHide} bsSize="lg">
+ <form onSubmit={this.save}>
+ <Modal.Header closeButton>
+ <Modal.Title>
+ <div>
+ <span className="float-left">{t('Dashboard Properties')}</span>
+ </div>
+ </Modal.Title>
+ </Modal.Header>
+ <Modal.Body>
+ <Row>
+ <Col md={12}>
+ <h3>Basic Information</h3>
Review comment:
Missing translation
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org