Skip to content

Commit

Permalink
Added new delete brew option on user page
Browse files Browse the repository at this point in the history
  • Loading branch information
stolksdorf committed Feb 18, 2017
1 parent cc8e874 commit 1885293
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# changelog

### Saturday, 18/02/2017 - v2.7.2
- Adding ability to delete a brew from the user page, incase the user creates a brew that makes the edit page unrender-able. (re:309)

## BIG NEWS
With the next major release of Homebrewery, v3.0.0, this tool *will no longer support raw HTML input for brew code*. Most issues and errors users are having are because of this feature and it's become too taxing to help and fix these issues.

Expand Down
20 changes: 20 additions & 0 deletions client/homebrew/pages/userPage/brewItem/brewItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const React = require('react');
const _ = require('lodash');
const cx = require('classnames');
const moment = require('moment');
const request = require("superagent");

const BrewItem = React.createClass({
getDefaultProps: function() {
Expand All @@ -15,6 +16,24 @@ const BrewItem = React.createClass({
};
},

deleteBrew : function(){
if(!confirm("are you sure you want to delete this brew?")) return;
if(!confirm("are you REALLY sure? You will not be able to recover it")) return;

request.get('/api/remove/' + this.props.brew.editId)
.send()
.end(function(err, res){
location.reload();
});
},

renderDeleteBrewLink: function(){
if(!this.props.brew.editId) return;

return <a onClick={this.deleteBrew}>
<i className='fa fa-trash' />
</a>
},
renderEditLink: function(){
if(!this.props.brew.editId) return;

Expand Down Expand Up @@ -47,6 +66,7 @@ const BrewItem = React.createClass({
<i className='fa fa-share-alt' />
</a>
{this.renderEditLink()}
{this.renderDeleteBrewLink()}
</div>
</div>
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "homebrewery",
"description": "Create authentic looking D&D homebrews using only markdown",
"version": "2.7.1",
"version": "2.7.2",
"scripts": {
"dev": "node scripts/dev.js",
"quick": "node scripts/quick.js",
Expand Down
1 change: 0 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ const welcomeText = require('fs').readFileSync('./client/homebrew/pages/homePage
const changelogText = require('fs').readFileSync('./changelog.md', 'utf8');



//Source page
String.prototype.replaceAll = function(s,r){return this.split(s).join(r)}
app.get('/source/:id', (req, res)=>{
Expand Down

0 comments on commit 1885293

Please sign in to comment.