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

fix: validate the proposal creation form #524

Merged
merged 23 commits into from
Aug 2, 2024
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
419835d
fix: add limits to proposal's title, choices, and discussion
wa0x6e Jul 23, 2024
edd6235
fix: validate and show error on proposal body
wa0x6e Jul 23, 2024
251cd10
fix: revert changes, moved to later PR
wa0x6e Jul 23, 2024
1e6a506
fix: style composer textarea like s-box
wa0x6e Jul 23, 2024
7aa9f37
fix: improve CSS
wa0x6e Jul 23, 2024
ad42061
fix: remove unused class
wa0x6e Jul 23, 2024
dce38d9
fix(ui): add some padding
wa0x6e Jul 23, 2024
09917aa
fix(ui): add min height
wa0x6e Jul 23, 2024
232348e
fix(ui): make offset emulate border
wa0x6e Jul 23, 2024
15cbac2
fix: add maxLength/items validation to proposals fields
wa0x6e Jul 24, 2024
6b13b6e
fix: always show form error
wa0x6e Jul 24, 2024
8a730cb
Merge branch 'master' into fix-limit-proposal-fields-length
wa0x6e Jul 25, 2024
faa58c9
fix: always show composer error
wa0x6e Jul 25, 2024
3ab2f7b
fix: add validation to statement
wa0x6e Jul 25, 2024
4861c69
Merge branch 'master' into fix-validate-proposals-fields
wa0x6e Jul 25, 2024
465e590
Merge branch 'fix-limit-proposal-fields-length' into fix-validate-pro…
wa0x6e Jul 25, 2024
58ec889
Merge branch 'master' into fix-validate-proposals-fields
wa0x6e Aug 1, 2024
ccf78f4
revert: reverting unrelated changes
wa0x6e Aug 1, 2024
39a7222
feat: use different proposal body limit for trubo space
wa0x6e Aug 1, 2024
0683f6f
refactor: use camel case variable name
wa0x6e Aug 2, 2024
87d8c68
Merge branch 'master' into fix-validate-proposals-fields
wa0x6e Aug 2, 2024
40952e9
fix: revert changes, will be extracted to another dedicated PR
wa0x6e Aug 2, 2024
c1cd062
refactor: rename regular to default
wa0x6e Aug 2, 2024
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
27 changes: 17 additions & 10 deletions apps/ui/src/views/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,31 @@ type StrategyWithTreasury = SelectedStrategy & {
treasury: RequiredProperty<SpaceMetadataTreasury>;
};

const MAX_BODY_LENGTH = {
default: 10000,
turbo: 40000
} as const;

const TITLE_DEFINITION = {
type: 'string',
title: 'Title',
minLength: 1
minLength: 1,
maxLength: 256
};

const DISCUSSION_DEFINITION = {
type: 'string',
format: 'uri',
title: 'Discussion',
maxLength: 256,
examples: ['e.g. https://forum.balancer.fi/t/proposal…']
};

const BODY_DEFINITION = {
type: 'string',
format: 'long',
title: 'Body',
maxLength: 9600
};

const CHOICES_DEFINITION = {
type: 'array',
title: 'Choices',
minItems: 1,
maxItems: 500,
items: [{ type: 'string', minLength: 1, maxLength: 32 }],
additionalItems: { type: 'string', maxLength: 32 }
};
Expand Down Expand Up @@ -192,6 +193,12 @@ const extraContacts = computed(() => {

return space.value.treasuries as Contact[];
});
const bodyDefinition = computed(() => ({
type: 'string',
format: 'long',
title: 'Body',
maxLength: MAX_BODY_LENGTH[space.value?.turbo ? 'turbo' : 'default']
}));
const formErrors = computed(() => {
if (!proposal.value) return {};

Expand All @@ -203,7 +210,7 @@ const formErrors = computed(() => {
required: ['title', 'choices'],
properties: {
title: TITLE_DEFINITION,
body: BODY_DEFINITION,
body: bodyDefinition.value,
discussion: DISCUSSION_DEFINITION,
choices: CHOICES_DEFINITION
}
Expand Down Expand Up @@ -470,7 +477,7 @@ export default defineComponent({
<UiComposer
v-else
v-model="proposal.body"
:definition="BODY_DEFINITION"
:definition="bodyDefinition"
:error="formErrors.body"
/>
<div class="s-base mb-5">
Expand Down
Loading