Skip to content

Commit

Permalink
[PLA-1454] [PLA-1479] add revoke confirmation (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
zlayine authored Dec 6, 2023
1 parent c50799b commit 6072db7
Show file tree
Hide file tree
Showing 39 changed files with 76 additions and 50 deletions.
12 changes: 5 additions & 7 deletions resources/js/components/ConfirmModal.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
<template>
<Modal :is-open="isOpen" :close="closeModal">
<DialogTitle as="h3" class="text-lg font-medium leading-6 text-gray-900"> Disclaimer </DialogTitle>
<DialogTitle as="h3" class="text-lg font-medium leading-6 text-gray-900"> {{ title }} </DialogTitle>
<div class="mt-2">
<p class="text-sm text-gray-500">
Retries transactions that have failed or otherwise not been included on-chain after some time. Use with
caution and ensure the transactions really aren't yet on-chain (or likely to be) to make sure they are
not accidentally included twice.
{{ description }}
</p>
</div>

<div class="flex space-x-4 mt-4">
<div class="flex space-x-4 mt-6">
<Btn @click="closeModal">Cancel</Btn>
<Btn primary @click="confirm">Retry transaction</Btn>
<Btn primary @click="confirm">Confirm</Btn>
</div>
</Modal>
</template>
Expand All @@ -21,7 +19,7 @@ import { DialogTitle } from '@headlessui/vue';
import Btn from '~/components/Btn.vue';
import Modal from '~/components/Modal.vue';
defineProps<{ isOpen: boolean }>();
defineProps<{ isOpen: boolean; title: string; description: string }>();
const emit = defineEmits(['closed', 'confirm']);
Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/batch/BatchMint.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
>
Cancel
</RouterLink>
<Btn :loading="isLoading" primary is-submit>Batch Mint</Btn>
<Btn :loading="isLoading" :disabled="isLoading" primary is-submit>Batch Mint</Btn>
</div>
</div>
</Form>
Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/batch/BatchSetAttribute.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
>
Cancel
</RouterLink>
<Btn :loading="isLoading" primary is-submit>Batch Set Attribute</Btn>
<Btn :loading="isLoading" :disabled="isLoading" primary is-submit>Batch Set Attribute</Btn>
</div>
</Form>
</div>
Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/batch/BatchTransfer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
>
Cancel
</RouterLink>
<Btn :loading="isLoading" primary is-submit>Batch Transfer</Btn>
<Btn :loading="isLoading" :disabled="isLoading" primary is-submit>Batch Transfer</Btn>
</div>
</div>
</Form>
Expand Down
32 changes: 27 additions & 5 deletions resources/js/components/pages/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@
/>
</span>
</div>
<Btn :id="`revoke-api-button__${token.name}`" error @click="revokeToken(token.name)">Revoke</Btn>
<Btn :id="`revoke-api-button__${token.name}`" error @click="confirmRevoke(token.name)">
Revoke
</Btn>
</div>
</div>
</div>
Expand All @@ -90,6 +92,13 @@
</div>
</template>
</div>
<ConfirmModal
:is-open="confirmModal"
title="Revoke API Token"
description="Do you want to revoke this API token?"
@closed="confirmModal = false"
@confirm="revokeToken"
/>
</div>
</template>

Expand All @@ -105,6 +114,7 @@ import FormInput from '../FormInput.vue';
import { shortString, snackbarErrors } from '~/util';
import CopyTextIcon from '../CopyTextIcon.vue';
import LoadingCircle from '../LoadingCircle.vue';
import ConfirmModal from '../ConfirmModal.vue';

const router = useRouter();
const appStore = useAppStore();
Expand All @@ -114,6 +124,8 @@ const tokenName = ref();
const enableTokenCreate = ref(false);
const loading = ref(appStore.user || !appStore.hasMultiTenantPackage ? false : true);
const creating = ref(false);
const confirmModal = ref(false);
const confirmModalName = ref();

const tokens = computed(() => appStore.user?.apiTokens);

Expand All @@ -138,17 +150,27 @@ const createApiToken = async () => {
}
};

const revokeToken = async (name: string) => {
if (!name) return;
const revokeToken = async () => {
if (!confirmModalName.value) return;

try {
await appStore.revokeToken(name);
snackbar.info({ title: 'Token revoked', text: `Your token ${name} has been revoked.` });
await appStore.revokeToken(confirmModalName.value);
snackbar.info({ title: 'Token revoked', text: `Your token ${confirmModalName.value} has been revoked.` });
confirmModalName.value = null;
} catch (e: any) {
if (snackbarErrors(e)) return;
snackbar.error({ title: 'Token revocation failed' });
} finally {
confirmModal.value = false;
confirmModalName.value = null;
}
};

const confirmRevoke = (name: string) => {
confirmModal.value = true;
confirmModalName.value = name;
};

const logout = async () => {
await appStore.logout();
router.push({ name: 'platform.auth.login' });
Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/pages/create/CreateBeam.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
>
Cancel
</RouterLink>
<Btn :loading="isLoading" primary is-submit>Create</Btn>
<Btn :loading="isLoading" :disabled="isLoading" primary is-submit>Create</Btn>
</div>
</div>
</Form>
Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/pages/create/CreateCollection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@
>
Cancel
</RouterLink>
<Btn :loading="isLoading" primary is-submit>Create</Btn>
<Btn :loading="isLoading" :disabled="isLoading" primary is-submit>Create</Btn>
</div>
</Form>
</div>
Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/pages/create/CreateFuelTank.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
>
Cancel
</RouterLink>
<Btn :loading="isLoading" primary is-submit>Create</Btn>
<Btn :loading="isLoading" :disabled="isLoading" primary is-submit>Create</Btn>
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/pages/create/CreateListing.vue
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
>
Cancel
</RouterLink>
<Btn :loading="isLoading" primary is-submit>Create</Btn>
<Btn :loading="isLoading" :disabled="isLoading" primary is-submit>Create</Btn>
</div>
</Form>
</div>
Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/pages/create/CreateToken.vue
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@
>
Cancel
</RouterLink>
<Btn :loading="isLoading" primary is-submit>Create</Btn>
<Btn :loading="isLoading" :disabled="isLoading" primary is-submit>Create</Btn>
</div>
</Form>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</div>
<div class="flex space-x-3 flex-shrink-0 justify-end px-4 py-4">
<Btn @click="closeSlide">Cancel</Btn>
<Btn :loading="isLoading" primary is-submit>Delete</Btn>
<Btn :loading="isLoading" :disabled="isLoading" primary is-submit>Delete</Btn>
</div>
</Form>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</div>
<div class="flex space-x-3 flex-shrink-0 justify-end px-4 py-4">
<Btn @click="closeSlide">Cancel</Btn>
<Btn :loading="isLoading" primary is-submit>Expire</Btn>
<Btn :loading="isLoading" :disabled="isLoading" primary is-submit>Expire</Btn>
</div>
</Form>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
</div>
<div class="flex space-x-3 flex-shrink-0 justify-end px-4 py-4">
<Btn @click="closeSlide">Cancel</Btn>
<Btn :loading="isLoading" primary is-submit>Update</Btn>
<Btn :loading="isLoading" :disabled="isLoading" primary is-submit>Update</Btn>
</div>
</Form>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
</div>
<div class="flex space-x-3 flex-shrink-0 justify-end px-4 py-4">
<Btn @click="closeSlide">Cancel</Btn>
<Btn :loading="isLoading" primary is-submit>Approve</Btn>
<Btn :loading="isLoading" :disabled="isLoading" primary is-submit>Approve</Btn>
</div>
</Form>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
</div>
<div class="flex space-x-3 flex-shrink-0 justify-end px-4 py-4">
<Btn @click="closeSlide">Cancel</Btn>
<Btn :loading="isLoading" primary is-submit>
<Btn :loading="isLoading" :disabled="isLoading" primary is-submit>
{{ attributeActions.find((a) => a.value === attributeAction)?.btnText }}
</Btn>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
</div>
<div class="flex space-x-3 flex-shrink-0 justify-end px-4 py-4">
<Btn @click="closeSlide">Cancel</Btn>
<Btn :loading="isLoading" primary is-submit>Destroy</Btn>
<Btn :loading="isLoading" :disabled="isLoading" primary is-submit>Destroy</Btn>
</div>
</Form>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
</div>
<div class="flex space-x-3 flex-shrink-0 justify-end px-4 py-4">
<Btn @click="closeSlide">Cancel</Btn>
<Btn :loading="isLoading" primary is-submit>Mutate</Btn>
<Btn :loading="isLoading" :disabled="isLoading" primary is-submit>Mutate</Btn>
</div>
</Form>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
</div>
<div class="flex space-x-3 flex-shrink-0 justify-end px-4 py-4">
<Btn @click="closeSlide">Cancel</Btn>
<Btn :loading="isLoading" primary is-submit>Unapprove</Btn>
<Btn :loading="isLoading" :disabled="isLoading" primary is-submit>Unapprove</Btn>
</div>
</Form>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
</div>
<div class="flex space-x-3 flex-shrink-0 justify-end px-4 py-4">
<Btn @click="closeSlide">Cancel</Btn>
<Btn :loading="isLoading" primary is-submit>Freeze</Btn>
<Btn :loading="isLoading" :disabled="isLoading" primary is-submit>Freeze</Btn>
</div>
</Form>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,16 @@
</div>
<div class="flex space-x-3 flex-shrink-0 justify-end px-4 py-4">
<Btn @click="closeSlide">Cancel</Btn>
<Btn :loading="isLoading" primary is-submit>Retry</Btn>
<Btn :loading="isLoading" :disabled="isLoading" primary is-submit>Retry</Btn>
</div>
</Form>
<ConfirmModal :is-open="modal" @closed="modal = false" @confirm="retryTransaction" />
<ConfirmModal
:is-open="modal"
title="Disclaimer"
description="Retries transactions that have failed or otherwise not been included on-chain after some time. Use with caution and ensure the transactions really aren't yet on-chain (or likely to be) to make sure they are not accidentally included twice."
@closed="modal = false"
@confirm="retryTransaction"
/>
</template>

<script setup lang="ts">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
</div>
<div class="flex space-x-3 flex-shrink-0 justify-end px-4 py-4">
<Btn @click="closeSlide">Cancel</Btn>
<Btn :loading="isLoading" primary is-submit>Thaw</Btn>
<Btn :loading="isLoading" :disabled="isLoading" primary is-submit>Thaw</Btn>
</div>
</Form>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
</div>
<div class="flex space-x-3 flex-shrink-0 justify-end px-4 py-4" v-if="actionType !== 'list'">
<Btn @click="closeSlide">Cancel</Btn>
<Btn :loading="isLoading" primary is-submit>
<Btn :loading="isLoading" :disabled="isLoading" primary is-submit>
{{ actionType === 'add' ? 'Add' : 'Remove' }}
</Btn>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
</div>
<div class="flex space-x-3 flex-shrink-0 justify-end px-4 py-4">
<Btn @click="closeSlide">Cancel</Btn>
<Btn :loading="isLoading" primary is-submit>Set consumption</Btn>
<Btn :loading="isLoading" :disabled="isLoading" primary is-submit>Set consumption</Btn>
</div>
</Form>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</div>
<div class="flex space-x-3 flex-shrink-0 justify-end px-4 py-4">
<Btn @click="closeSlide">Cancel</Btn>
<Btn :loading="isLoading" primary is-submit>Destroy</Btn>
<Btn :loading="isLoading" :disabled="isLoading" primary is-submit>Destroy</Btn>
</div>
</Form>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
</div>
<div class="flex space-x-3 flex-shrink-0 justify-end px-4 py-4">
<Btn @click="closeSlide">Cancel</Btn>
<Btn :loading="isLoading" primary is-submit>Dispatch</Btn>
<Btn :loading="isLoading" :disabled="isLoading" primary is-submit>Dispatch</Btn>
</div>
</Form>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</div>
<div class="flex space-x-3 flex-shrink-0 justify-end px-4 py-4">
<Btn @click="closeSlide">Cancel</Btn>
<Btn :loading="isLoading" primary is-submit>Freeze</Btn>
<Btn :loading="isLoading" :disabled="isLoading" primary is-submit>Freeze</Btn>
</div>
</Form>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
</div>
<div class="flex space-x-3 flex-shrink-0 justify-end px-4 py-4">
<Btn @click="closeSlide">Cancel</Btn>
<Btn :loading="isLoading" primary is-submit>Mutate</Btn>
<Btn :loading="isLoading" :disabled="isLoading" primary is-submit>Mutate</Btn>
</div>
</Form>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
</div>
<div class="flex space-x-3 flex-shrink-0 justify-end px-4 py-4" v-if="actionType !== 'list'">
<Btn @click="closeSlide">Cancel</Btn>
<Btn :loading="isLoading" primary is-submit>
<Btn :loading="isLoading" :disabled="isLoading" primary is-submit>
{{ actionType === 'add' ? 'Add' : 'Remove' }}
</Btn>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</div>
<div class="flex space-x-3 flex-shrink-0 justify-end px-4 py-4">
<Btn @click="closeSlide">Close</Btn>
<Btn :loading="isLoading" primary is-submit>Cancel Listing</Btn>
<Btn :loading="isLoading" :disabled="isLoading" primary is-submit>Cancel Listing</Btn>
</div>
</Form>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
</div>
<div class="flex space-x-3 flex-shrink-0 justify-end px-4 py-4">
<Btn @click="closeSlide">Close</Btn>
<Btn :loading="isLoading" primary is-submit>Fill</Btn>
<Btn :loading="isLoading" :disabled="isLoading" primary is-submit>Fill</Btn>
</div>
</Form>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</div>
<div class="flex space-x-3 flex-shrink-0 justify-end px-4 py-4">
<Btn @click="closeSlide">Close</Btn>
<Btn :loading="isLoading" primary is-submit>Finalize Auction</Btn>
<Btn :loading="isLoading" :disabled="isLoading" primary is-submit>Finalize Auction</Btn>
</div>
</Form>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
</div>
<div class="flex space-x-3 flex-shrink-0 justify-end px-4 py-4">
<Btn @click="closeSlide">Close</Btn>
<Btn :loading="isLoading" primary is-submit>Place Bid</Btn>
<Btn :loading="isLoading" :disabled="isLoading" primary is-submit>Place Bid</Btn>
</div>
</Form>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
</div>
<div class="flex space-x-3 flex-shrink-0 justify-end px-4 py-4">
<Btn @click="closeSlide">Cancel</Btn>
<Btn :loading="isLoading" primary is-submit>Approve</Btn>
<Btn :loading="isLoading" :disabled="isLoading" primary is-submit>Approve</Btn>
</div>
</Form>
</template>
Expand Down
Loading

0 comments on commit 6072db7

Please sign in to comment.