mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-09 09:22:38 +00:00
Remove checkForScript state
This commit is contained in:
@@ -14,28 +14,26 @@ const BrewLookup = createClass({
|
|||||||
},
|
},
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
return {
|
return {
|
||||||
query : '',
|
query : '',
|
||||||
foundBrew : null,
|
foundBrew : null,
|
||||||
searching : false,
|
searching : false,
|
||||||
error : null,
|
error : null,
|
||||||
checkForScript : false,
|
scriptCount : 0
|
||||||
scriptCount : undefined
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
handleChange(e){
|
handleChange(e){
|
||||||
this.setState({ query: e.target.value });
|
this.setState({ query: e.target.value });
|
||||||
},
|
},
|
||||||
lookup(){
|
lookup(){
|
||||||
this.setState({ searching: true, error: null, checkForScript: false, scriptCount: undefined });
|
this.setState({ searching: true, error: null, scriptCount: 0 });
|
||||||
|
|
||||||
request.get(`/admin/lookup/${this.state.query}`)
|
request.get(`/admin/lookup/${this.state.query}`)
|
||||||
.then((res)=>{
|
.then((res)=>{
|
||||||
const foundBrew = res.body;
|
const foundBrew = res.body;
|
||||||
const scriptCheck = foundBrew?.text.match(/(<\/?s)cript/g);
|
const scriptCheck = foundBrew?.text.match(/(<\/?s)cript/g);
|
||||||
this.setState({
|
this.setState({
|
||||||
foundBrew : foundBrew,
|
foundBrew : foundBrew,
|
||||||
scriptCount : scriptCheck?.length || 0,
|
scriptCount : scriptCheck?.length || 0,
|
||||||
checkForScript : scriptCheck?.length > 0
|
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch((err)=>this.setState({ error: err }))
|
.catch((err)=>this.setState({ error: err }))
|
||||||
@@ -52,7 +50,7 @@ const BrewLookup = createClass({
|
|||||||
request.put(`/admin/clean/script/${this.state.foundBrew.shareId}`)
|
request.put(`/admin/clean/script/${this.state.foundBrew.shareId}`)
|
||||||
.then((res)=>this.setState({ foundBrew: res.body }))
|
.then((res)=>this.setState({ foundBrew: res.body }))
|
||||||
.catch((err)=>this.setState({ error: err }))
|
.catch((err)=>this.setState({ error: err }))
|
||||||
.finally(()=>this.setState({ checkForScript: false, scriptCount: 0 }));
|
.finally(()=>this.setState({ scriptCount: 0 }));
|
||||||
},
|
},
|
||||||
|
|
||||||
renderFoundBrew(){
|
renderFoundBrew(){
|
||||||
@@ -83,7 +81,7 @@ const BrewLookup = createClass({
|
|||||||
<dt>Number of SCRIPT tags detected</dt>
|
<dt>Number of SCRIPT tags detected</dt>
|
||||||
<dd>{this.state.scriptCount}</dd>
|
<dd>{this.state.scriptCount}</dd>
|
||||||
</dl>
|
</dl>
|
||||||
{this.state.checkForScript &&
|
{this.state.scriptCount > 0 &&
|
||||||
<div className='cleanButton'>
|
<div className='cleanButton'>
|
||||||
<button onClick={this.cleanScript}>CLEAN BREW</button>
|
<button onClick={this.cleanScript}>CLEAN BREW</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user