Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

Clear History button will look disabled when there is no history

Andrew Bastine6f6c17c80cc
diff --git a/index.html b/index.html
index ffbb3d116..179f625d3 100644
--- a/index.html
+++ b/index.html
@@ -108,7 +108,7 @@
<legend v-on:click="collapse">History ↕</legend>
<div class="collapsible">
<ul>
- <li><button v-on:click="clearHistory">Clear History</button></li>
+ <li><button v-bind:class="{ disabled: noHistoryToClear }" v-on:click="clearHistory">Clear History</button></li>
</ul>
<ul v-for="entry in history">
<li>
diff --git a/script.js b/script.js
index 705ec9f02..85df1955b 100644
--- a/script.js
+++ b/script.js
@@ -29,6 +29,11 @@ const app = new Vue({
history: window.localStorage.getItem('history') ? JSON.parse(window.localStorage.getItem('history')) : []
},
computed: {
+
+ noHistoryToClear() {
+ return this.history.length === 0;
+ },
+
urlNotValid() {
const pattern = new RegExp('^(https?:\\/\\/)?' +
'((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' +