Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for hibernated spaces #4350

Merged
merged 28 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b869e58
feat: disable proposal creation on hibernate spaces
wa0x6e Nov 13, 2023
2d7e090
fix: add button to reactivate space
wa0x6e Nov 13, 2023
33daf5d
fix: add link to hibernation doc
wa0x6e Nov 14, 2023
03d1fd7
fix: add translations
wa0x6e Nov 14, 2023
e113506
chore: fix formatting
wa0x6e Nov 14, 2023
5a164e2
refactor: extract hibernation warning message to its own component
wa0x6e Nov 15, 2023
e5b7d79
Merge branch 'master' into add-hibernation
wa0x6e Nov 15, 2023
fbd6cd9
feat: reactivate space via sequencer
wa0x6e Nov 15, 2023
6853ac4
Merge branch 'add-hibernation' of https://github.com/snapshot-labs/sn…
wa0x6e Nov 15, 2023
87e7592
chore: formatting fix
wa0x6e Nov 15, 2023
4f086f8
fix: show success message on space reactivation
wa0x6e Nov 15, 2023
ced757f
fix: add link to doc
wa0x6e Nov 15, 2023
4329589
chore: fix formatting
wa0x6e Nov 15, 2023
da65260
fix: use settings basic update to reactivate space
wa0x6e Nov 15, 2023
87a9199
chore: fix formatting
wa0x6e Nov 16, 2023
fff1e54
fix: redirect reactivate space CTA to settings page
wa0x6e Nov 16, 2023
c79d0f6
fix: update hibernated warning message
wa0x6e Nov 16, 2023
1d2540c
feat: add space reactivation message in space settings
wa0x6e Nov 16, 2023
ceb245d
Merge branch 'master' into add-hibernation
wa0x6e Nov 16, 2023
4f0b614
Update src/components/MessageWarningHibernated.vue
wa0x6e Nov 16, 2023
c730194
fix: increase warning level to red
wa0x6e Nov 16, 2023
3a3ead2
fix: remove title and change layout
wa0x6e Nov 16, 2023
d38b422
fix: "learn more" should only visible to admin/controller
wa0x6e Nov 16, 2023
1b669b2
refactor: extract message into its own components
wa0x6e Nov 16, 2023
f99f05d
Update src/locales/default.json
samuveth Nov 17, 2023
a5eb1dc
Fixes
samuveth Nov 17, 2023
d88e3b7
Update src/locales/default.json
samuveth Nov 17, 2023
b7f868e
Merge branch 'master' into add-hibernation
ChaituVR Nov 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions src/components/MessageWarningHibernated.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<script setup lang="ts">
import { ExtendedSpace } from '@/helpers/interfaces';

const props = defineProps<{
space: ExtendedSpace;
}>();

const { web3Account } = useWeb3();
const { loadSpaceController, isSpaceController } = useSpaceController();

const isAuthorized = computed(() => {
const admins = (props.space.admins || []).map(admin => admin.toLowerCase());
return (
admins.includes(web3Account.value?.toLowerCase()) || isSpaceController.value
);
});

onMounted(async () => {
await loadSpaceController();
});
</script>

<template>
<BaseMessageBlock v-if="space.hibernated" level="warning-red" is-responsive>
{{
isAuthorized
? $t('create.errorSpaceHibernatedAdmin')
: $t('create.errorSpaceHibernatedUsers')
}}
<BaseLink
v-if="isAuthorized"
link="https://docs.snapshot.org/user-guides/spaces/space-hibernation"
>
{{ $t('learnMore') }}
</BaseLink>

<p v-if="isAuthorized" class="mt-3">
<router-link :to="{ name: 'spaceSettings' }">
<BaseButton> Go to Settings </BaseButton>
</router-link>
</p>
</BaseMessageBlock>
</template>
4 changes: 3 additions & 1 deletion src/components/SpaceCreateWarnings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ const strategySymbolsString = computed(() => {

<template>
<div class="mb-4 space-y-2">
<MessageWarningHibernated v-if="space.hibernated" :space="space" />

<MessageWarningGnosisNetwork
v-if="isGnosisAndNotSpaceNetwork"
v-else-if="isGnosisAndNotSpaceNetwork"
:space="space"
action="create"
is-responsive
Expand Down
37 changes: 37 additions & 0 deletions src/components/SpaceSettingsMessageHibernated.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<script setup lang="ts">
import { ExtendedSpace } from '@/helpers/interfaces';

defineProps<{
space: ExtendedSpace;
isSending: boolean;
isValid: boolean;
}>();

const emit = defineEmits(['showErrors', 'reactivateSpace']);

onMounted(() => {
emit('showErrors');
});
</script>

<template>
<BaseMessageBlock level="warning-red" is-responsive>
<div v-if="isValid">
{{ $t('settings.reactivatingHibernatedSpace.information') }}
</div>

<div v-else>
{{ $t('settings.reactivatingHibernatedSpace.disabledInformation') }}
</div>

<BaseButton
primary
:loading="isSending"
:disabled="!isValid"
class="mt-3 whitespace-nowrap"
@click="emit('reactivateSpace')"
>
{{ $t('reactivateSpace') }}
</BaseButton>
</BaseMessageBlock>
</template>
14 changes: 14 additions & 0 deletions src/composables/useClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,20 @@ export function useClient() {
proposalId: payload.proposal.id
});

return receipt;
} else if (type === 'reactivate-space') {
const receipt = await client.reactivateSpace(
auth.web3,
web3.value.account,
{
space: space.id
}
);

mixpanel.track('Reactivate space', {
space: space.id
});

return receipt;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/composables/useFormSpaceSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export function useFormSpaceSettings(context: 'setup' | 'settings') {
delete formData.followersCount;
delete formData.verified;
delete formData.flagged;
delete formData.hibernated;

if (formData.filters.invalids) delete formData.filters.invalids;
}
Expand Down
2 changes: 2 additions & 0 deletions src/helpers/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export interface Space {
activeProposals: number;
followersCount: number;
flagged: boolean;
hibernated: boolean;
terms: string;
}

Expand Down Expand Up @@ -165,6 +166,7 @@ export interface ExtendedSpace {
guidelines: string;
verified: boolean;
flagged: boolean;
hibernated: boolean;
voting: {
delay: number | null;
hideAbstain: boolean;
Expand Down
2 changes: 2 additions & 0 deletions src/helpers/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ export const SPACES_QUERY = gql`
followersCount
terms
flagged
hibernated
}
}
`;
Expand Down Expand Up @@ -452,6 +453,7 @@ export const SPACE_QUERY = gql`
guidelines
verified
flagged
hibernated
parent {
id
name
Expand Down
12 changes: 10 additions & 2 deletions src/locales/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
"createASpace": "Create a space",
"getStarted": "Get started",
"skip": "Skip",
"reactivateSpace": "Reactivate space",
"newSpaceNotice": {
"header": "Your space is live!",
"mainText": "You can change how voting power is calculated via strategies in your {settings}. Changes to your settings will only affect new proposals, existing proposals can not be changed.",
Expand Down Expand Up @@ -235,7 +236,9 @@
"uploading": "Uploading image",
"markdown": "Styling with Markdown is supported",
"errorGettingSnapshot": "We encountered an error while fetching the snapshot block number which is needed to calculate your voting power. Please try again later.",
"errorTimeInPast": "Entered time is in the past. Please select a future time."
"errorTimeInPast": "Entered time is in the past. Please select a future time.",
"errorSpaceHibernatedAdmin": "Admins your attention is required. This space has been hibernated due to a lack of activity, and as a result, proposal creation is currently disabled. To re-enable your space, please go to the settings page and click \"Reactivate\".",
"errorSpaceHibernatedUsers": "This space has been hibernated due to a lack of activity. As a result, the creation of proposals has been temporarily disabled. To resume your ability to create proposals, the space needs to be reactivated by an admin. Please check back later or contact your space admin for further information."
},
"delegates": {
"header": "Delegates",
Expand Down Expand Up @@ -534,6 +537,10 @@
"delegationPortal": {
"title": "Delegation portal",
"information": "Please ensure your token adheres to a compatible delegation standard to enable delegate discovery and activity within your Snapshot space."
},
"reactivatingHibernatedSpace": {
"information": "Your space is currently in hibernation due to six months of inactivity. To re-enable proposal creation, please click the button below to reactivate your space. There are no penalties for hibernation, but the space will remain inactive for proposal creation until reactivation by an admin.",
"disabledInformation": "Your space contains invalid settings since your last update. Fix the errors below and your space will be reactivated automatically upon save."
}
},
"setup": {
Expand Down Expand Up @@ -652,7 +659,8 @@
"ensSet": "ENS text record was successfully set",
"transactionSent": "Transaction sent",
"emailPreferencesUpdated": "Email preferences updated",
"delegationAdded": "Well done. Delegate was successfully added"
"delegationAdded": "Well done. Delegate was successfully added",
"spaceReactivated": "The space has been reactivated"
},
"explore": {
"createStrategy": "Create strategy",
Expand Down
3 changes: 2 additions & 1 deletion src/views/SpaceCreate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,8 @@ onBeforeRouteLeave(async () => {
web3.authLoading ||
hasAuthorValidationFailed ||
validationLoading ||
isGnosisAndNotSpaceNetwork
isGnosisAndNotSpaceNetwork ||
space.hibernated
wa0x6e marked this conversation as resolved.
Show resolved Hide resolved
"
primary
:data-testid="
Expand Down
23 changes: 16 additions & 7 deletions src/views/SpaceSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,6 @@ async function handleSubmit() {
}
}

onMounted(async () => {
populateForm(props.space);
await loadEnsOwner();
await loadSpaceController();
loaded.value = true;
});

const {
isRevealed: isConfirmLeaveOpen,
reveal: openConfirmLeave,
Expand All @@ -172,6 +165,13 @@ const isViewOnly = computed(() => {
return !(isSpaceController.value || isSpaceAdmin.value);
});

onMounted(async () => {
populateForm(props.space);
await loadEnsOwner();
await loadSpaceController();
loaded.value = true;
});

onBeforeRouteLeave(async () => {
if (hasFormChanged.value && !isViewOnly.value) {
const { data } = await openConfirmLeave();
Expand All @@ -190,6 +190,15 @@ onBeforeRouteLeave(async () => {

<template v-else>
<div class="mt-3 space-y-3 sm:mt-0">
<SpaceSettingsMessageHibernated
v-if="space.hibernated && !isViewOnly"
:space="space"
:is-sending="isSending"
:is-valid="isValid"
@show-errors="showFormErrors = true"
@reactivate-space="handleSubmit"
/>

<BaseMessageBlock
v-if="showFormErrors && Object.keys(validationErrors).length"
level="warning-red"
Expand Down