Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aerogear 3466 delete datasource #27

Merged

Conversation

cfoskin
Copy link
Contributor

@cfoskin cfoskin commented Jul 11, 2018

JIRA: https://issues.jboss.org/browse/AEROGEAR-3466

Deletes the chosen data source when this option is selected from the dropdown
Provides a confirm window before deleting

variables: { dataSourceId },
refetchQueries: [{
query: GetDataSources,
variables: { name: "" }
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't this be undefined?

<MenuItem
eventKey={2}
onSelect={() => {
if (window.confirm("Are you sure you wish to delete this item?")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree, this component shouldn't contain specific graphql logic (otherwise edit should be here as well). Let's add a new component in DataSourcesContainer that renders patternfly's MessageDialog and add this logic inside.
You can take a look at how's implemented in #29 (the same but with a Modal):
in DataSourcesList
in DataSourcesListItem
Important also not to change the export mode data-sources/index

Copy link
Contributor

@pb82 pb82 left a comment

Choose a reason for hiding this comment

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

It works but we need to use a patternfly message dialog for the notification.

variables: { dataSourceId },
refetchQueries: [{
query: GetDataSources,
variables: { name: undefined }
Copy link
Contributor

Choose a reason for hiding this comment

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

@pb82
wasn't this have to be "" instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, "" is interpreted as a filter value while undefined returns all items.

}

removeOneDatasource(dataSourceId) {
const self = this;
Copy link
Contributor

Choose a reason for hiding this comment

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

ES6 takes care of the scope for you. Whenever you are in a class, you can forget about this.


class DataSourcesListItem extends Component {

constructor(props) { //eslint-disable-line
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't disable and remove the constructor instead

}

render() {
const self = this;
Copy link
Contributor

Choose a reason for hiding this comment

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

No need

import DeleteDataSource from "../../graphql/DeleteDataSource.graphql";
import GetDataSources from "../../graphql/GetDataSources.graphql";

class DataSourcesListItem extends Component {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a comment: unless you need to make use of the State, you don't need a class component. In this case, better stick with the functional component.

@cfoskin cfoskin force-pushed the AEROGEAR-3466-delete-datasource branch from 4e46682 to b900c86 Compare July 12, 2018 11:46
@cfoskin
Copy link
Contributor Author

cfoskin commented Jul 12, 2018

ping @pb82 @josemigallas

updated pr with restructure

}).then(() => {
onClose();
}).catch(err => {
console.log("Error", err);
Copy link
Contributor

Choose a reason for hiding this comment

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

you can use console.error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

@cfoskin cfoskin force-pushed the AEROGEAR-3466-delete-datasource branch from db07249 to d7e6e83 Compare July 12, 2018 14:20
@cfoskin cfoskin merged commit 4938e98 into aerogear-attic:master Jul 12, 2018
@cfoskin cfoskin deleted the AEROGEAR-3466-delete-datasource branch July 12, 2018 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants