-
Notifications
You must be signed in to change notification settings - Fork 10
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
Aerogear 3466 delete datasource #27
Conversation
variables: { dataSourceId }, | ||
refetchQueries: [{ | ||
query: GetDataSources, | ||
variables: { name: "" } |
There was a problem hiding this comment.
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?")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use a patternfly confirmation box here: https://rawgit.com/patternfly/patternfly-react/gh-pages/index.html?selectedKind=patternfly-react%2FCommunication%2FMessage%20Dialog&selectedStory=Question%20Dialog%20Example&full=0&addons=1&stories=1&panelRight=0&addonPanel=storybooks%2Fstorybook-addon-knobs
There was a problem hiding this comment.
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
There was a problem hiding this 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 } |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
4e46682
to
b900c86
Compare
ping @pb82 @josemigallas updated pr with restructure |
}).then(() => { | ||
onClose(); | ||
}).catch(err => { | ||
console.log("Error", err); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
db07249
to
d7e6e83
Compare
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