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

Added description for add/remove member proposal type #40

Merged
merged 1 commit into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ State.init({
role: state.role,
error: undefined,
rolesOptions: [],
description: null,
notificationsData: {}
});

Expand Down Expand Up @@ -44,9 +45,19 @@ const processPolicy = (policy) => {
return roles;
};

function isEmpty(value) {
return !value || value === "";
}

const allowedRoles = processPolicy(policy);

const handleProposal = () => {
if (isEmpty(state.description)) {
State.update({
error: "Please enter a description"
});
return;
}
if (
!state.member_id ||
state.member_id === "" ||
Expand All @@ -72,7 +83,7 @@ const handleProposal = () => {
methodName: "add_proposal",
args: {
proposal: {
description: "Potential member",
description: state.description,
kind: {
AddMemberToRole: {
member_id: state.member_id ?? accountId,
Expand Down Expand Up @@ -106,6 +117,15 @@ const onChangeRole = (role) => {
});
};

const onChangeDescription = (description) => {
State.update({
description,
error: undefined
});
};

const defaultDescription = "Potential member";

if (allowedRoles === null) {
return <> </>;
}
Expand All @@ -132,6 +152,17 @@ return (
}}
/>
</div>
<div className="mb-3">
<h5>Proposal Description</h5>
<Widget
src="sking.near/widget/Common.Inputs.Markdown"
props={{
onChange: (value) => onChangeDescription(value),
height: "270px",
initialText: defaultDescription
}}
/>
</div>
<Widget
src="/*__@appAccount__*//widget/DAO.Proposal.Common.NotificationRolesSelector"
props={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ State.init({
role: state.role,
error: undefined,
rolesOptions: [],
description: null,
notificationsData: {}
});

Expand All @@ -25,6 +26,10 @@ function isNearAddress(address) {
);
}

function isEmpty(value) {
return !value || value === "";
}

if (policy === null) {
return <></>;
}
Expand All @@ -47,6 +52,12 @@ const processPolicy = (policy) => {
const allowedRoles = processPolicy(policy);

const handleProposal = () => {
if (isEmpty(state.description)) {
State.update({
error: "Please enter a description"
});
return;
}
if (
!state.member_id ||
state.member_id === "" ||
Expand All @@ -72,7 +83,7 @@ const handleProposal = () => {
methodName: "add_proposal",
args: {
proposal: {
description: "Remove member",
description: state.description,
kind: {
RemoveMemberFromRole: {
member_id: state.member_id ?? accountId,
Expand Down Expand Up @@ -106,6 +117,15 @@ const onChangeRole = (role) => {
});
};

const onChangeDescription = (description) => {
State.update({
description,
error: undefined
});
};

const defaultDescription = "Remove member";

return (
<>
<div className="mb-3">
Expand All @@ -128,6 +148,17 @@ return (
}}
/>
</div>
<div className="mb-3">
<h5>Proposal Description</h5>
<Widget
src="sking.near/widget/Common.Inputs.Markdown"
props={{
onChange: (value) => onChangeDescription(value),
height: "270px",
initialText: defaultDescription
}}
/>
</div>
<Widget
src="/*__@appAccount__*//widget/DAO.Proposal.Common.NotificationRolesSelector"
props={{
Expand Down
Loading