Search Apps Documentation Source Content File Folder Download Copy Actions Download

view_proposal_history_page.gno

1.21 Kb · 37 lines
 1package basedao
 2
 3import (
 4	"gno.land/p/moul/md"
 5	"gno.land/p/nt/ufmt/v0"
 6	"gno.land/p/samcrew/daokit"
 7)
 8
 9func (d *DAOPrivate) ProposalHistoryPageView(path string) string {
10	return d.ProposalHistoryHeaderView() +
11		d.ProposalHistoryView(path)
12}
13
14func (d *DAOPrivate) ProposalHistoryHeaderView() string {
15	pkgPath := d.Realm.PkgPath()
16	linkPath := getLinkPath(pkgPath)
17	name := d.GetProfileString(d.Realm.Address(), "DisplayName", "DAO")
18	s := ""
19	s += ufmt.Sprintf("# %s - Proposal History\n\n", name)
20	s += md.Link("> Go to the active Proposals 📃", ufmt.Sprintf("%s:%s", linkPath, PROPOSALS_PATH)) + "\n\n"
21	s += md.Link("Add a new proposal 🗳️", ufmt.Sprintf("%s$help", linkPath)) + "\n\n"
22	s += ufmt.Sprintf("\n--------------------------------\n")
23	return s
24}
25
26func (d *DAOPrivate) ProposalHistoryView(path string) string {
27	inactiveProposals := d.Core.Proposals.GetProposals(
28		func(p daokit.Proposal) bool {
29			return p.Status != daokit.ProposalStatusOpen && p.Status != daokit.ProposalStatusPassed
30		},
31	)
32	s := ""
33	s += ufmt.Sprintf("## Inactive Proposals 🗳️ (%d)\n\n", inactiveProposals.Tree.Size())
34	s += d.RenderProposalsTable(path, inactiveProposals)
35	s += ufmt.Sprintf("\n--------------------------------\n")
36	return s
37}