Skip to content

Commit

Permalink
Move proposals related files and fix notification roles selector (#377)
Browse files Browse the repository at this point in the history
* move proposals related files

* minor fixes

* fix pre-commit command
  • Loading branch information
Megha-Dev-19 authored Jun 12, 2024
1 parent 835abf6 commit 297fec3
Show file tree
Hide file tree
Showing 14 changed files with 164 additions and 90 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion apps/new/widget/page/activity/Index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ const config = {
},
},
proposals: {
path: "${alias_old}/widget/Proposals",
path: "${config_account}/widget/page.proposals.Index",
blockHeight: "final",
init: {
feedName: "Proposals",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ const cls = (c) => c.join(" ");
const YouVotedBadge = () => {
return (
<Widget
loading=""
src="nearui.near/widget/Element.Badge"
props={{
size: "sm",
Expand Down Expand Up @@ -268,6 +269,7 @@ function renderHeader({ typeName, id, status }) {
</div>
<div className="d-flex gap-2 flex-wrap align-items-center">
<Widget
loading=""
src="nearui.near/widget/Element.Badge"
props={{
children: `Proposal ID #${id}`,
Expand All @@ -278,6 +280,7 @@ function renderHeader({ typeName, id, status }) {
/>

<Widget
loading=""
src="nearui.near/widget/Element.Badge"
props={{
children: (
Expand All @@ -302,11 +305,13 @@ function renderHeader({ typeName, id, status }) {
{status === "InProgress" &&
parseInt(Big(expirationTime).div(1000000)) > Date.now() && (
<Widget
loading=""
src="nearui.near/widget/Element.Badge"
props={{
children: (
<div className="counter-text">
<Widget
loading=""
src="astraplusplus.ndctools.near/widget/Common.Layout.Countdown"
props={{
timeToCheck: parseInt(
Expand Down Expand Up @@ -342,6 +347,7 @@ function renderData({
</div>
<div className="secondary-text">
<Widget
loading=""
src="${alias_mob}/widget/Profile.ShortInlineBlock"
props={{ accountId: proposer, tooltip: true }}
/>
Expand All @@ -356,6 +362,7 @@ function renderData({
</div>

<Widget
loading=""
src="astraplusplus.ndctools.near/widget/Common.Modals.ProposalArguments"
props={{ daoId, proposal: proposalData }}
/>
Expand Down Expand Up @@ -681,10 +688,12 @@ function renderFooter({ totalVotes, votes, comments, daoId, proposal }) {
const renderModal = (item, index) => {
return (
<Widget
loading=""
src="astraplusplus.ndctools.near/widget/Layout.Modal"
props={{
content: (
<Widget
loading=""
src={`astraplusplus.ndctools.near/widget/${item.widget}`}
props={item.props}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { daos } = VM.require("${config_account}/widget/fetch.daos") || {
const { daos } = VM.require("${config_account}/widget/lib.daos") || {
daos: [],
};

Expand All @@ -7,7 +7,7 @@ if (!daos) {
}
const options = daos.map((dao) => dao.contract_id);

const { Modal, Button } = VM.require("${config_account}/widget/components") || {
const { Modal, Button } = VM.require("${alias_old}/widget/components") || {
Modal: () => <></>,
Button: () => <></>,
};
Expand Down Expand Up @@ -177,6 +177,7 @@ return (
{proposalTypeOptions[key].map((item) => {
return (
<Widget
loading=""
src="nearui.near/widget/Input.Checkbox"
props={{
checked: selectedTypes.includes(item.value) || false,
Expand All @@ -202,6 +203,7 @@ return (
{proposalStatusOptions.map((item) => {
return (
<Widget
loading=""
src="nearui.near/widget/Input.Checkbox"
props={{
checked: selectedStatus.includes(item.value) || false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const { Button, Modal } = VM.require("${config_account}/widget/components") || {
const { Button, Modal } = VM.require("${alias_old}/widget/components") || {
Button: <></>,
Modal: <></>,
};

const { Header } = VM.require("${config_account}/widget/components.Header") || {
const { Header } = VM.require("${alias_old}/widget/components.Header") || {
Header: () => <></>,
};
const DaoSDK = VM.require("sdks.near/widget/SDKs.Sputnik.DaoSDK") || (() => {});
Expand Down Expand Up @@ -157,7 +157,8 @@ const handleVote = ({ action, proposalId, proposer, showNotification }) => {
proposalId: proposalId,
},
type: "custom",
widget: "${config_account}/widget/Proposals",
widget:
"${config_account}/widget/Index?page=activity&tab=proposals",
},
},
]),
Expand Down Expand Up @@ -285,7 +286,8 @@ const proposalsComponent = useMemo(() => {

return (
<Widget
src="${config_account}/widget/components.ProposalCard"
loading=""
src="${config_account}/widget/page.proposals.Card"
props={{
proposalData: {
...item,
Expand Down Expand Up @@ -320,14 +322,16 @@ return (
<ThemeContainer>
<Container className="d-flex flex-column gap-4">
<Widget
src="${config_account}/widget/components.modals.CreateProposal"
loading=""
src="${config_account}/widget/page.proposals.create.Index"
props={{
showModal: showProposalModal,
toggleModal: () => setShowModal(!showProposalModal),
}}
/>
<Widget
src="${config_account}/widget/components.modals.ProposalsFilters"
loading=""
src="${config_account}/widget/page.proposals.Filters"
props={{
parentSelectedTypes: selectedTypes,
parentSelectedStatus: selectedStatus,
Expand Down Expand Up @@ -362,7 +366,8 @@ return (
{!proposalId && (
<div className="d-flex justify-content-center my-4">
<Widget
src={"${config_account}/widget/components.Pagination"}
loading=""
src={"${alias_old}/widget/components.Pagination"}
props={{
maxVisiblePages: 5,
totalPages:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const DaoSDK = VM.require("sdks.near/widget/SDKs.Sputnik.DaoSDK") || (() => {});

const { InputField } = VM.require("${config_account}/widget/components") || {
const { InputField } = VM.require("${alias_old}/widget/components") || {
InputField: <></>,
};

Expand All @@ -24,7 +24,9 @@ const group = sdk.getGroupsAndMembers();
if (group === null || !group.length) {
return;
}
setGroupsAndMembers(group);
if (!groupsAndMembers.length) {
setGroupsAndMembers(group);
}

const handleCheckboxChange = (role) => {
setSelectedRoles((prevRoles) => {
Expand All @@ -46,9 +48,11 @@ const ThemeContainer =
props.ThemeContainer ||
styled.div`
--primary-color: rgb(255, 175, 81);
--text-color: white;
`;

const Wrapper = styled.div`
color: var(--text-color) !important;
.checked > span:first-child {
background: var(--primary-color) !important;
border-color: var(--primary-color) !important;
Expand All @@ -64,6 +68,11 @@ const Wrapper = styled.div`
label {
font-size: 13px;
margin-bottom: 5px;
}
.text {
color: var(--text-color) !important;
}
`;

Expand Down Expand Up @@ -98,7 +107,8 @@ const createNotificationsData = () => {
page: "proposal",
},
type: "buildhub/custom",
widget: "${config_account}/widget/home",
widget:
"${config_account}/widget/Index?page=activity&tab=proposals",
},
};
}),
Expand Down Expand Up @@ -134,12 +144,13 @@ const groupList = useMemo(() => {
return null;
}
return (
<div key={group}>
<div key={group.name}>
<Widget
loading=""
src="nearui.near/widget/Input.Checkbox"
props={{
label: (
<div>
<div className="text">
{capitalizeFirstLetter(group.name)} ({membersLength} members)
</div>
),
Expand All @@ -159,13 +170,14 @@ return (
<div>Send notification to following roles: (Optional)</div>
<div>
<label htmlFor={"notifications-label" + daoId}>Custom Message</label>
<input
<textarea
name={"notifications-label" + daoId}
id={"notifications-label" + daoId}
className="form-control"
data-bs-theme={bootstrapTheme}
value={message}
onChange={(e) => setMessage(e.target.value)}
rows="2"
/>
</div>
<div>{groupList}</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { Button } = VM.require("${config_account}/widget/components") || {
const { Button } = VM.require("${alias_old}/widget/components") || {
Button: () => <></>,
};
const { Modal } = VM.require("${config_account}/widget/components.Modal") || {
const { Modal } = VM.require("${alias_old}/widget/components.Modal") || {
Modal: () => <></>,
};

Expand Down Expand Up @@ -79,7 +79,7 @@ const Content = styled.div`
padding: 0 20px;
`;
const url =
"${alias_gateway_url}/${config_account}/widget/app?page=feed&tab=proposals";
"${alias_gateway_url}/${config_account}/widget/Index?page=feed&tab=proposals";
const ProposalVisibilityInfoModal = ({ open, setInfoModalActive, sdkCall }) => {
const handleCopy = () => {
clipboard
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const { Button } = VM.require("${config_account}/widget/components") || {
const { Button } = VM.require("${alias_old}/widget/components") || {
Button: () => <></>,
};
const { ProposalVisibilityInfoModal } = VM.require(
"${config_account}/widget/components.modals.propose.ProposalVisibilityInfoModal",
"${config_account}/widget/page.proposals.VisibilityInfoModal",
) || {
ProposalVisibilityInfoModal: () => <></>,
};
Expand Down Expand Up @@ -186,6 +186,22 @@ const sdkCall = () => {
});
};

const NotificationSelector = useMemo(() => {
return (
<Widget
loading=""
src="${config_account}/widget/page.proposals.NotificationRolesSelector"
props={{
daoId: selectedDAO,
onUpdate: (v) => {
setNotificationData(v);
},
proposalType: "Add Member",
}}
/>
);
}, [selectedDAO]);

return (
<div className="d-flex flex-column">
<div className="form-group mb-3">
Expand Down Expand Up @@ -233,6 +249,7 @@ return (
key={memoizedKey}
>
<Widget
loading=""
src="${alias_mob}/widget/MarkdownEditorIframe"
props={{
initialText: text,
Expand All @@ -244,16 +261,7 @@ return (
/>
</TextareaWrapper>
</div>
<Widget
src="${config_account}/widget/Notification.NotificationRolesSelector"
props={{
daoId: selectedDAO,
onUpdate: (v) => {
setNotificationData(v);
},
proposalType: "Add Member",
}}
/>
{NotificationSelector}
<div className="w-100 d-flex">
<Button
className="ms-auto"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const { Button } = VM.require("${config_account}/widget/components") || {
const { Button } = VM.require("${alias_old}/widget/components") || {
Button: () => <></>,
};
const { ProposalVisibilityInfoModal } = VM.require(
"${config_account}/widget/components.modals.propose.ProposalVisibilityInfoModal",
"${config_account}/widget/page.proposals.VisibilityInfoModal",
) || {
ProposalVisibilityInfoModal: () => <></>,
};
Expand Down Expand Up @@ -188,6 +188,22 @@ const sdkCall = () => {
});
};

const NotificationSelector = useMemo(() => {
return (
<Widget
loading=""
src="${config_account}/widget/page.proposals.NotificationRolesSelector"
props={{
daoId: selectedDAO,
onUpdate: (v) => {
setNotificationData(v);
},
proposalType: "Function Call",
}}
/>
);
}, [selectedDAO]);

return (
<div className="d-flex flex-column">
<div className="form-group mb-3">
Expand Down Expand Up @@ -264,6 +280,7 @@ return (
key={memoizedKey}
>
<Widget
loading=""
src="${alias_mob}/widget/MarkdownEditorIframe"
props={{
initialText: text,
Expand All @@ -275,16 +292,8 @@ return (
/>
</TextareaWrapper>
</div>
<Widget
src="${config_account}/widget/Notification.NotificationRolesSelector"
props={{
daoId: selectedDAO,
onUpdate: (v) => {
setNotificationData(v);
},
proposalType: "Function Call",
}}
/>
{NotificationSelector}

<div className="w-100 d-flex">
<Button
disabled={!contract || !method || !validatedAddresss}
Expand Down
Loading

0 comments on commit 297fec3

Please sign in to comment.