Browse Source

add 'isRegistered' check to guard against many buttons

playwright-pwa-install-test
Trent Larson 3 months ago
parent
commit
ca8da9fd5e
  1. 2
      src/libs/util.ts
  2. 4
      src/views/ClaimView.vue
  3. 18
      src/views/ConfirmGiftView.vue
  4. 12
      src/views/ProjectViewView.vue
  5. 12
      src/views/ProjectsView.vue

2
src/libs/util.ts

@ -102,11 +102,13 @@ export const doCopyTwoSecRedo = (text: string, fn: () => void) => {
* @param veriClaim is expected to have fields: claim, claimType, and issuer * @param veriClaim is expected to have fields: claim, claimType, and issuer
*/ */
export const isGiveRecordTheUserCanConfirm = ( export const isGiveRecordTheUserCanConfirm = (
isRegistered: boolean,
veriClaim: GenericCredWrapper<GenericVerifiableCredential>, veriClaim: GenericCredWrapper<GenericVerifiableCredential>,
activeDid: string, activeDid: string,
confirmerIdList: string[] = [], confirmerIdList: string[] = [],
) => { ) => {
return ( return (
isRegistered &&
isGiveAction(veriClaim) && isGiveAction(veriClaim) &&
!confirmerIdList.includes(activeDid) && !confirmerIdList.includes(activeDid) &&
veriClaim.issuer !== activeDid && veriClaim.issuer !== activeDid &&

4
src/views/ClaimView.vue

@ -136,6 +136,7 @@
class="col-span-1 bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-4 py-2 rounded-md" class="col-span-1 bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-4 py-2 rounded-md"
v-if=" v-if="
libsUtil.isGiveRecordTheUserCanConfirm( libsUtil.isGiveRecordTheUserCanConfirm(
isRegistered,
veriClaim, veriClaim,
activeDid, activeDid,
confirmerIdList, confirmerIdList,
@ -472,6 +473,7 @@ export default class ClaimView extends Vue {
fullClaimDump = ""; fullClaimDump = "";
fullClaimMessage = ""; fullClaimMessage = "";
isEditedGlobalId = false; isEditedGlobalId = false;
isRegistered = false;
numConfsNotVisible = 0; // number of hidden DIDs in the confirmerIdList, minus the issuer if they aren't visible numConfsNotVisible = 0; // number of hidden DIDs in the confirmerIdList, minus the issuer if they aren't visible
showDidCopy = false; showDidCopy = false;
showIdCopy = false; showIdCopy = false;
@ -496,6 +498,7 @@ export default class ClaimView extends Vue {
this.fullClaimDump = ""; this.fullClaimDump = "";
this.fullClaimMessage = ""; this.fullClaimMessage = "";
this.isEditedGlobalId = false; this.isEditedGlobalId = false;
this.isRegistered = false;
this.numConfsNotVisible = 0; this.numConfsNotVisible = 0;
this.veriClaim = serverUtil.BLANK_GENERIC_SERVER_RECORD; this.veriClaim = serverUtil.BLANK_GENERIC_SERVER_RECORD;
this.veriClaimDump = ""; this.veriClaimDump = "";
@ -507,6 +510,7 @@ export default class ClaimView extends Vue {
this.activeDid = settings?.activeDid || ""; this.activeDid = settings?.activeDid || "";
this.apiServer = settings?.apiServer || ""; this.apiServer = settings?.apiServer || "";
this.allContacts = await db.contacts.toArray(); this.allContacts = await db.contacts.toArray();
this.isRegistered = settings?.isRegistered || false;
await accountsDB.open(); await accountsDB.open();
const accounts = accountsDB.accounts; const accounts = accountsDB.accounts;

18
src/views/ConfirmGiftView.vue

@ -15,6 +15,7 @@
<span <span
v-if=" v-if="
libsUtil.isGiveRecordTheUserCanConfirm( libsUtil.isGiveRecordTheUserCanConfirm(
isRegistered,
veriClaim, veriClaim,
activeDid, activeDid,
confirmerIdList, confirmerIdList,
@ -33,6 +34,7 @@
class="col-span-1 bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-4 py-2 rounded-md" class="col-span-1 bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-4 py-2 rounded-md"
v-if=" v-if="
libsUtil.isGiveRecordTheUserCanConfirm( libsUtil.isGiveRecordTheUserCanConfirm(
isRegistered,
veriClaim, veriClaim,
activeDid, activeDid,
confirmerIdList, confirmerIdList,
@ -52,6 +54,7 @@
<fa icon="circle-check" class="ml-2 text-white cursor-pointer" /> <fa icon="circle-check" class="ml-2 text-white cursor-pointer" />
</button> </button>
<a <a
v-if="isRegistered"
class="col-span-1 bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white ml-2 px-4 py-2 rounded-md" class="col-span-1 bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white ml-2 px-4 py-2 rounded-md"
:href="urlForNewGive" :href="urlForNewGive"
> >
@ -431,6 +434,7 @@ export default class ClaimView extends Vue {
giverName = ""; giverName = "";
issuerName = ""; issuerName = "";
isLoading = false; isLoading = false;
isRegistered = false;
numConfsNotVisible = 0; // number of hidden DIDs in the confirmerIdList, minus the issuer if they aren't visible numConfsNotVisible = 0; // number of hidden DIDs in the confirmerIdList, minus the issuer if they aren't visible
recipientName = ""; recipientName = "";
showDetails = false; showDetails = false;
@ -450,6 +454,7 @@ export default class ClaimView extends Vue {
this.confsVisibleErrorMessage = ""; this.confsVisibleErrorMessage = "";
this.confsVisibleToIdList = []; this.confsVisibleToIdList = [];
this.giveDetails = null; this.giveDetails = null;
this.isRegistered = false;
this.numConfsNotVisible = 0; this.numConfsNotVisible = 0;
this.urlForNewGive = ""; this.urlForNewGive = "";
this.veriClaim = serverUtil.BLANK_GENERIC_SERVER_RECORD; this.veriClaim = serverUtil.BLANK_GENERIC_SERVER_RECORD;
@ -463,6 +468,7 @@ export default class ClaimView extends Vue {
this.activeDid = settings?.activeDid || ""; this.activeDid = settings?.activeDid || "";
this.apiServer = settings?.apiServer || ""; this.apiServer = settings?.apiServer || "";
this.allContacts = await db.contacts.toArray(); this.allContacts = await db.contacts.toArray();
this.isRegistered = settings?.isRegistered || false;
await accountsDB.open(); await accountsDB.open();
const accounts = accountsDB.accounts; const accounts = accountsDB.accounts;
@ -782,7 +788,17 @@ export default class ClaimView extends Vue {
} }
notifyWhyCannotConfirm() { notifyWhyCannotConfirm() {
if (!isGiveAction(this.veriClaim)) { if (!this.isRegistered) {
this.$notify(
{
group: "alert",
type: "info",
title: "Not Registered",
text: "Someone needs to register you before you can contribute.",
},
3000,
);
} else if (!isGiveAction(this.veriClaim)) {
this.$notify( this.$notify(
{ {
group: "alert", group: "alert",

12
src/views/ProjectViewView.vue

@ -159,7 +159,7 @@
</div> </div>
</div> </div>
<div v-if="activeDid" class="mt-4"> <div v-if="activeDid && isRegistered" class="mt-4">
<div class="text-center"> <div class="text-center">
<button <button
@click="openOfferDialog()" @click="openOfferDialog()"
@ -171,7 +171,7 @@
</div> </div>
<OfferDialog ref="customOfferDialog" :projectId="this.projectId" /> <OfferDialog ref="customOfferDialog" :projectId="this.projectId" />
<div v-if="activeDid"> <div v-if="activeDid && isRegistered">
<div class="text-center"> <div class="text-center">
<p class="mt-2 mt-4 text-center">Record a contribution from:</p> <p class="mt-2 mt-4 text-center">Record a contribution from:</p>
</div> </div>
@ -467,6 +467,7 @@ export default class ProjectViewView extends Vue {
givesProvidedByThis: Array<GiveSummaryRecord> = []; givesProvidedByThis: Array<GiveSummaryRecord> = [];
givesProvidedByHitLimit = false; givesProvidedByHitLimit = false;
imageUrl = ""; imageUrl = "";
isRegistered = false;
issuer = ""; issuer = "";
latitude = 0; latitude = 0;
longitude = 0; longitude = 0;
@ -489,6 +490,7 @@ export default class ProjectViewView extends Vue {
this.activeDid = settings?.activeDid || ""; this.activeDid = settings?.activeDid || "";
this.apiServer = settings?.apiServer || ""; this.apiServer = settings?.apiServer || "";
this.allContacts = await db.contacts.toArray(); this.allContacts = await db.contacts.toArray();
this.isRegistered = !!settings?.isRegistered;
await accountsDB.open(); await accountsDB.open();
const accounts = accountsDB.accounts; const accounts = accountsDB.accounts;
@ -939,7 +941,11 @@ export default class ProjectViewView extends Vue {
claimType: "GiveAction", claimType: "GiveAction",
issuer: give.agentDid, issuer: give.agentDid,
}; };
return libsUtil.isGiveRecordTheUserCanConfirm(giveDetails, this.activeDid); return libsUtil.isGiveRecordTheUserCanConfirm(
this.isRegistered,
giveDetails,
this.activeDid,
);
} }
confirmConfirmClaim(give: GiveSummaryRecord) { confirmConfirmClaim(give: GiveSummaryRecord) {

12
src/views/ProjectsView.vue

@ -189,10 +189,14 @@
<InfiniteScroll v-if="showProjects" @reached-bottom="loadMoreProjectData"> <InfiniteScroll v-if="showProjects" @reached-bottom="loadMoreProjectData">
<div v-if="projects.length === 0" class="text-center py-4"> <div v-if="projects.length === 0" class="text-center py-4">
You have not announced any projects. You have not announced any projects.
<br /> <div v-if="isRegistered">
Hit the big Hit the big
<fa icon="plus" class="bg-blue-600 text-white px-1 py-1 rounded-full" /> <fa
button. You'll never know until you try. icon="plus"
class="bg-blue-600 text-white px-1 py-1 rounded-full"
/>
button. You'll never know until you try.
</div>
</div> </div>
<ul id="listProjects" class="border-t border-slate-300"> <ul id="listProjects" class="border-t border-slate-300">
<li <li

Loading…
Cancel
Save