Skip to content

Commit

Permalink
re-add osnap modal
Browse files Browse the repository at this point in the history
Signed-off-by: ryanwolhuter <[email protected]>
  • Loading branch information
ryanwolhuter committed Oct 5, 2023
1 parent 9d5bf72 commit d79bc0f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
File renamed without changes.
27 changes: 27 additions & 0 deletions src/components/SettingsTreasuriesBlock.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ const treasuryObj = {
};
const modalTreasuryOpen = ref(false);
const modalOsnapOpen = ref(false);
const currentTreasuryIndex = ref<number | null>(null);
const currentTreasury = ref<TreasuryWallet>(clone(treasuryObj));
const hasOsnapPlugin = computed(() => {
return Object.keys(props.space.plugins).includes('oSnap');
});
const isOsnapEnabledOnCurrentTreasury = ref(false);
function handleRemoveTreasury(i: number) {
form.value.treasuries = form.value.treasuries.filter(
Expand Down Expand Up @@ -51,6 +53,22 @@ function handleSubmitTreasury(treasury: TreasuryWallet) {
form.value.treasuries = form.value.treasuries.concat(treasury);
}
}
function handleOpenConfigureOsnapModal(
treasuryIndex: number,
isEnabled: boolean
) {
if (props.isViewOnly || !hasOsnapPlugin.value) return;
currentTreasuryIndex.value = treasuryIndex;
currentTreasury.value = clone(form.value.treasuries[treasuryIndex]);
isOsnapEnabledOnCurrentTreasury.value = isEnabled;
modalOsnapOpen.value = true;
}
function handleCloseConfigureOsnapModal() {
modalOsnapOpen.value = false;
isOsnapEnabledOnCurrentTreasury.value = false;
}
</script>

<template>
Expand All @@ -62,6 +80,7 @@ function handleSubmitTreasury(treasury: TreasuryWallet) {
:has-osnap-plugin="hasOsnapPlugin"
@edit-treasury="i => handleEditTreasury(i)"
@remove-treasury="i => handleRemoveTreasury(i)"
@configure-osnap="handleOpenConfigureOsnapModal"
/>
</div>

Expand All @@ -79,6 +98,14 @@ function handleSubmitTreasury(treasury: TreasuryWallet) {
@close="modalTreasuryOpen = false"
@add="handleSubmitTreasury"
/>
<ModalOsnap
v-if="hasOsnapPlugin"
:open="modalOsnapOpen"
:treasury="currentTreasury"
:space-name="form.name"
:is-osnap-enabled="isOsnapEnabledOnCurrentTreasury"
@close="handleCloseConfigureOsnapModal"
/>
</teleport>
</BaseBlock>
</template>

0 comments on commit d79bc0f

Please sign in to comment.