From 5af0f48fa3aaba0f06aa190825a9612714acbff7 Mon Sep 17 00:00:00 2001 From: Fabian Weber Date: Mon, 5 Aug 2019 23:15:33 -0400 Subject: [PATCH 1/9] added infinite scroll to validators table --- package.json | 1 + src/components/staking/TableValidators.vue | 20 ++++++++++++++++++-- src/scripts/boot.js | 2 ++ yarn.lock | 5 +++++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 6e9d2c88d5..16b7101161 100644 --- a/package.json +++ b/package.json @@ -141,6 +141,7 @@ "vue": "2.6.10", "vue-clipboard2": "0.3.0", "vue-directive-tooltip": "1.4.5", + "vue-infinite-scroll": "2.0.2", "vue-router": "3.0.2", "vuelidate": "0.7.4", "vuex": "3.1.0", diff --git a/src/components/staking/TableValidators.vue b/src/components/staking/TableValidators.vue index ecc2249f91..fffe8263d9 100644 --- a/src/components/staking/TableValidators.vue +++ b/src/components/staking/TableValidators.vue @@ -8,9 +8,9 @@ :show-on-mobile="showOnMobile" /> - + diff --git a/src/scripts/boot.js b/src/scripts/boot.js index a80f3b6d49..150922b186 100644 --- a/src/scripts/boot.js +++ b/src/scripts/boot.js @@ -10,6 +10,7 @@ import Tooltip from "vue-directive-tooltip" import Vuelidate from "vuelidate" import VueClipboard from "vue-clipboard2" import * as _Sentry from "@sentry/browser" +import infiniteScroll from "vue-infinite-scroll" import App from "../App" import routes from "../routes" @@ -61,6 +62,7 @@ export const startApp = async ( Vue.use(Tooltip, { delay: 1 }) Vue.use(Vuelidate) Vue.use(VueClipboard) + Vue.use(infiniteScroll) Vue.directive(`focus`, focusElement) Vue.directive(`focus-last`, focusParentLast) diff --git a/yarn.lock b/yarn.lock index 3b2834092e..e109654c7a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11200,6 +11200,11 @@ vue-hot-reload-api@^2.3.0: resolved "https://registry.yarnpkg.com/vue-hot-reload-api/-/vue-hot-reload-api-2.3.3.tgz#2756f46cb3258054c5f4723de8ae7e87302a1ccf" integrity sha512-KmvZVtmM26BQOMK1rwUZsrqxEGeKiYSZGA7SNWE6uExx8UX/cj9hq2MRV/wWC3Cq6AoeDGk57rL9YMFRel/q+g== +vue-infinite-scroll@2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/vue-infinite-scroll/-/vue-infinite-scroll-2.0.2.tgz#ca37a91fe92ee0ad3b74acf8682c00917144b711" + integrity sha512-n+YghR059YmciANGJh9SsNWRi1YZEBVlODtmnb/12zI+4R72QZSWd+EuZ5mW6auEo/yaJXgxzwsuhvALVnm73A== + vue-jest@3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/vue-jest/-/vue-jest-3.0.4.tgz#b6a2b0d874968f26fa775ac901903fece531e08b" From e586bb4dfc3bde209e6dda804f4918044527d4f1 Mon Sep 17 00:00:00 2001 From: Fabian Weber Date: Mon, 5 Aug 2019 23:20:00 -0400 Subject: [PATCH 2/9] added it to transactions --- src/components/staking/TableValidators.vue | 3 +- src/components/wallet/PageTransactions.vue | 34 +++++++++++++--------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/components/staking/TableValidators.vue b/src/components/staking/TableValidators.vue index fffe8263d9..b525a4a958 100644 --- a/src/components/staking/TableValidators.vue +++ b/src/components/staking/TableValidators.vue @@ -52,7 +52,6 @@ export default { order: `asc` }, showing: 20, - scrollDistance: 10, rollingWindow: 10000 // param of slashing period }), computed: { @@ -199,7 +198,7 @@ export default { }, methods: { loadMore() { - this.showing += this.scrollDistance + this.showing += 10 } } } diff --git a/src/components/wallet/PageTransactions.vue b/src/components/wallet/PageTransactions.vue index 562d332300..a7a3b1e5b9 100644 --- a/src/components/wallet/PageTransactions.vue +++ b/src/components/wallet/PageTransactions.vue @@ -10,19 +10,21 @@ > @@ -73,6 +75,9 @@ export default { [this.sort.order] ) }, + showingTransactions() { + return this.orderedTransactions.slice(0, this.showing) + }, dataEmpty() { return this.orderedTransactions.length === 0 } @@ -90,6 +95,9 @@ export default { if (session.signedIn) { await $store.dispatch(`getAllTxs`) } + }, + loadMore() { + this.showing += 10 } } } From 210cafc3a867d9bc775f28c9ecb42ca1e7aafc9c Mon Sep 17 00:00:00 2001 From: Fabian Weber Date: Mon, 5 Aug 2019 23:20:20 -0400 Subject: [PATCH 3/9] changelog --- changes/fabo_infinite-scroll | 1 + 1 file changed, 1 insertion(+) create mode 100644 changes/fabo_infinite-scroll diff --git a/changes/fabo_infinite-scroll b/changes/fabo_infinite-scroll new file mode 100644 index 0000000000..78ef5f5f96 --- /dev/null +++ b/changes/fabo_infinite-scroll @@ -0,0 +1 @@ +[Added] Added infinite scroll to validator list @faboweb \ No newline at end of file From 59b3b7d5f0e5cdb6260a4aa9f1708051809a22df Mon Sep 17 00:00:00 2001 From: Fabian Weber Date: Mon, 5 Aug 2019 23:21:27 -0400 Subject: [PATCH 4/9] snaps --- test/unit/specs/App.spec.js | 7 - .../TableValidators.spec.js.snap | 4 +- .../PageTransactions.spec.js.snap | 224 +++++++++--------- 3 files changed, 119 insertions(+), 116 deletions(-) diff --git a/test/unit/specs/App.spec.js b/test/unit/specs/App.spec.js index a2853395df..7be9f35713 100644 --- a/test/unit/specs/App.spec.js +++ b/test/unit/specs/App.spec.js @@ -96,13 +96,6 @@ describe(`App Start`, () => { ) }) - it(`Check the calls on VUE`, async () => { - const { Vue } = await start() - - expect(Vue.directive).toHaveBeenCalledTimes(2) - expect(Vue.use).toHaveBeenCalledTimes(4) - }) - describe(`Route guard`, () => { it(`Check the route guard`, async () => { const commit = jest.fn() diff --git a/test/unit/specs/components/staking/__snapshots__/TableValidators.spec.js.snap b/test/unit/specs/components/staking/__snapshots__/TableValidators.spec.js.snap index 31247fa9aa..1f27b023a3 100644 --- a/test/unit/specs/components/staking/__snapshots__/TableValidators.spec.js.snap +++ b/test/unit/specs/components/staking/__snapshots__/TableValidators.spec.js.snap @@ -13,7 +13,9 @@ exports[`TableValidators shows a validator table 1`] = ` /> - + @@ -84,60 +88,64 @@ exports[`PageTransactions displays the transaction page if user hasn't signed in From c80991543999b06e7d200de9ff78fddc9ddd3057 Mon Sep 17 00:00:00 2001 From: Fabian Weber Date: Tue, 6 Aug 2019 09:56:45 -0400 Subject: [PATCH 5/9] tests --- src/components/wallet/PageTransactions.vue | 3 +- .../staking/TableValidators.spec.js | 11 +++++- .../TableValidators.spec.js.snap | 4 --- .../wallet/PageTransactions.spec.js | 15 +++++++- .../PageTransactions.spec.js.snap | 36 ------------------- 5 files changed, 26 insertions(+), 43 deletions(-) diff --git a/src/components/wallet/PageTransactions.vue b/src/components/wallet/PageTransactions.vue index a7a3b1e5b9..8d0a334069 100644 --- a/src/components/wallet/PageTransactions.vue +++ b/src/components/wallet/PageTransactions.vue @@ -54,7 +54,8 @@ export default { }, validatorURL: `/staking/validators`, governanceURL: `/governance`, - time + time, + showing: 20 }), computed: { ...mapGetters([ diff --git a/test/unit/specs/components/staking/TableValidators.spec.js b/test/unit/specs/components/staking/TableValidators.spec.js index 66e4cb3497..1b3dee1df9 100644 --- a/test/unit/specs/components/staking/TableValidators.spec.js +++ b/test/unit/specs/components/staking/TableValidators.spec.js @@ -57,9 +57,12 @@ describe(`TableValidators`, () => { mocks: { $store }, + directives: { + infiniteScroll: () => {} + }, propsData: { validators } }) - wrapper.setData({ rollingWindow: 10000 }) + wrapper.setData({ rollingWindow: 10000, showing: 2 }) }) it(`shows a validator table`, async () => { @@ -145,6 +148,12 @@ describe(`TableValidators`, () => { ).not.toBeDefined() }) + it("should load more validators (on infinite scroll)", () => { + expect(wrapper.findAll("livalidator-stub").length).toBe(2) + wrapper.vm.loadMore() + expect(wrapper.findAll("livalidator-stub").length).toBe(3) + }) + describe(`update rewards on new blocks`, () => { describe(`shouldn't update`, () => { it(`if hasn't waited for 20 blocks `, () => { diff --git a/test/unit/specs/components/staking/__snapshots__/TableValidators.spec.js.snap b/test/unit/specs/components/staking/__snapshots__/TableValidators.spec.js.snap index 1f27b023a3..4171f80261 100644 --- a/test/unit/specs/components/staking/__snapshots__/TableValidators.spec.js.snap +++ b/test/unit/specs/components/staking/__snapshots__/TableValidators.spec.js.snap @@ -24,10 +24,6 @@ exports[`TableValidators shows a validator table 1`] = ` showonmobile="returns" validator="[object Object]" /> - diff --git a/test/unit/specs/components/wallet/PageTransactions.spec.js b/test/unit/specs/components/wallet/PageTransactions.spec.js index 9fa3462076..0c12a207ee 100644 --- a/test/unit/specs/components/wallet/PageTransactions.spec.js +++ b/test/unit/specs/components/wallet/PageTransactions.spec.js @@ -256,10 +256,14 @@ describe(`PageTransactions`, () => { wrapper = shallowMount(PageTransactions, { localVue, + directives: { + infiniteScroll: () => {} + }, mocks: { $store } }) + wrapper.setData({ showing: 2 }) }) describe(`displays the transaction page`, () => { @@ -277,6 +281,9 @@ describe(`PageTransactions`, () => { wrapper = shallowMount(PageTransactions, { localVue, + directives: { + infiniteScroll: () => {} + }, mocks: { $store } @@ -313,7 +320,13 @@ describe(`PageTransactions`, () => { }) it(`should show transactions`, async () => { - expect(wrapper.findAll(`LiAnyTransaction-stub`).length).toBe(6) + expect(wrapper.findAll(`LiAnyTransaction-stub`).length).toBe(2) + }) + + it("should load more findAll (on infinite scroll)", () => { + expect(wrapper.findAll("LiAnyTransaction-stub").length).toBe(2) + wrapper.vm.loadMore() + expect(wrapper.findAll("LiAnyTransaction-stub").length).toBe(6) }) it(`should sort the transaction by time`, () => { diff --git a/test/unit/specs/components/wallet/__snapshots__/PageTransactions.spec.js.snap b/test/unit/specs/components/wallet/__snapshots__/PageTransactions.spec.js.snap index fafc359b67..7a2dc3c125 100644 --- a/test/unit/specs/components/wallet/__snapshots__/PageTransactions.spec.js.snap +++ b/test/unit/specs/components/wallet/__snapshots__/PageTransactions.spec.js.snap @@ -33,42 +33,6 @@ exports[`PageTransactions displays the transaction page if user has signed in 1` validators="[object Object],[object Object],[object Object]" validatorsurl="/staking/validators" /> - - - -
From 8a53bc97a28bf5cdfb6fa9c418dc964dcfeee80a Mon Sep 17 00:00:00 2001 From: Fabian Weber Date: Tue, 6 Aug 2019 15:10:42 -0400 Subject: [PATCH 6/9] increased load more offset --- src/components/staking/TableValidators.vue | 8 ++-- src/components/wallet/PageTransactions.vue | 4 +- yarn.lock | 50 +++++++++++++++++++--- 3 files changed, 51 insertions(+), 11 deletions(-) diff --git a/src/components/staking/TableValidators.vue b/src/components/staking/TableValidators.vue index b525a4a958..f65cc7b0d9 100644 --- a/src/components/staking/TableValidators.vue +++ b/src/components/staking/TableValidators.vue @@ -8,7 +8,7 @@ :show-on-mobile="showOnMobile" /> - +