Skip to content

Commit

Permalink
Dialog for users to submit proposals (#4503)
Browse files Browse the repository at this point in the history
  • Loading branch information
megrogan authored Oct 6, 2023
1 parent f4e5c02 commit a54c02f
Show file tree
Hide file tree
Showing 33 changed files with 972 additions and 59 deletions.
4 changes: 4 additions & 0 deletions backend/canisters/local_user_index/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [[2.0.872](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.872-local_user_index)] - 2023-10-05

### Added

- Add a welcome message to help new users discover communities ([#4484](https://github.com/open-chat-labs/open-chat/pull/4484))

### Changed

- Store `proposals_bot_canister_id` in user canisters ([#4485](https://github.com/open-chat-labs/open-chat/pull/4485))
Expand Down
22 changes: 18 additions & 4 deletions frontend/app/src/components/TextArea.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
export let minlength: number = 0;
export let maxlength: number = Number.MAX_VALUE;
export let rows: number = 4;
export let margin: boolean = true;
export let scroll: boolean = false;
export let outerHeight: number = 0;
export let innerHeight: number = 0;
onMount(() => {
if (autofocus) {
Expand All @@ -20,8 +24,8 @@
$: warn = remaining <= 5;
</script>

<div class="outer-wrapper">
<div class="input-wrapper">
<div class="outer-wrapper" class:margin bind:clientHeight={outerHeight}>
<div class="input-wrapper" bind:clientHeight={innerHeight}>
<textarea
bind:this={inp}
{rows}
Expand All @@ -32,7 +36,8 @@
{maxlength}
{placeholder}
bind:value
class={"textbox"} />
class="textbox"
class:scroll />
</div>
{#if !disabled && maxlength < Number.MAX_VALUE}
<div class:warn class="countdown">{value.length}/{maxlength}</div>
Expand All @@ -42,7 +47,11 @@

<style lang="scss">
.outer-wrapper {
margin-bottom: $sp3;
margin: 0;
&.margin {
margin-bottom: $sp3;
}
}
.input-wrapper {
Expand All @@ -68,6 +77,11 @@
@include input(normal);
&.scroll {
resize: none;
@include nice-scrollbar();
}
&.invalid {
border: 1px solid var(--error);
box-shadow: 0 0 5px 1px var(--error);
Expand Down
8 changes: 7 additions & 1 deletion frontend/app/src/components/home/AccountInfo.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@

<div class="account-info">
<QRCode text={account} size={qrSize} logo={tokenDetails.logo} {border} />
<p class:centered>{$_("tokenTransfer.yourAccount", { values: { token: symbol } })}</p>
<p class="your-account" class:centered>
{$_("tokenTransfer.yourAccount", { values: { token: symbol } })}
</p>
<div class="receiver" class:centered>
<div class="account">
{collapseAccount(account)}
Expand Down Expand Up @@ -85,4 +87,8 @@
width: 30px;
}
}
.your-account {
margin-top: $sp4;
}
</style>
7 changes: 1 addition & 6 deletions frontend/app/src/components/home/CurrentChat.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,6 @@
closeNotificationsForChat(chat.id);
}
function onMarkAllRead() {
client.markAllRead(chat);
}
function createPoll() {
if (!client.canCreatePolls(chat.id)) return;
Expand Down Expand Up @@ -288,10 +284,10 @@
{:else if showChatHeader}
<CurrentChatHeader
on:clearSelection
on:markAllRead={onMarkAllRead}
on:toggleMuteNotifications
on:showInviteGroupUsers
on:showProposalFilters
on:makeProposal
on:showGroupMembers
on:leaveGroup
on:upgrade
Expand All @@ -301,7 +297,6 @@
on:importToCommunity={importToCommunity}
{blocked}
{readonly}
{unreadMessages}
selectedChatSummary={chat}
hasPinned={$currentChatPinnedMessages.size > 0} />
{/if}
Expand Down
4 changes: 1 addition & 3 deletions frontend/app/src/components/home/CurrentChatHeader.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
export let selectedChatSummary: ChatSummary;
export let blocked: boolean;
export let readonly: boolean;
export let unreadMessages: number;
export let hasPinned: boolean;
let showSuspendUserModal = false;
Expand Down Expand Up @@ -164,7 +163,6 @@
<CurrentChatMenu
bind:showSuspendUserModal
{hasPinned}
{unreadMessages}
{selectedChatSummary}
{blocked}
on:convertGroupToCommunity
Expand All @@ -173,9 +171,9 @@
on:showGroupDetails={showGroupDetails}
on:searchChat
on:showProposalFilters
on:makeProposal
on:showGroupMembers
on:createPoll
on:markAllRead
on:upgrade
on:showInviteGroupUsers
on:leaveGroup />
Expand Down
41 changes: 20 additions & 21 deletions frontend/app/src/components/home/CurrentChatMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import AccountMultiplePlus from "svelte-material-icons/AccountMultiplePlus.svelte";
import Import from "svelte-material-icons/Import.svelte";
import AccountMultiple from "svelte-material-icons/AccountMultiple.svelte";
import CheckboxMultipleMarked from "svelte-material-icons/CheckboxMultipleMarked.svelte";
import LocationExit from "svelte-material-icons/LocationExit.svelte";
import ConvertToCommunity from "../icons/ConvertToCommunity.svelte";
import Tune from "svelte-material-icons/Tune.svelte";
Expand All @@ -15,6 +14,7 @@
import Bell from "svelte-material-icons/Bell.svelte";
import BellOff from "svelte-material-icons/BellOff.svelte";
import FileDocument from "svelte-material-icons/FileDocument.svelte";
import ChatQuestionIcon from "svelte-material-icons/ChatQuestion.svelte";
import MenuIcon from "../MenuIcon.svelte";
import HoverIcon from "../HoverIcon.svelte";
import Menu from "../Menu.svelte";
Expand All @@ -31,6 +31,7 @@
import HeartMinus from "../icons/HeartMinus.svelte";
import HeartPlus from "../icons/HeartPlus.svelte";
import { interpolateLevel } from "../../utils/i18n";
import { OC_GOVERNANCE_CANISTER_ID } from "../../utils/sns";
const client = getContext<OpenChat>("client");
const dispatch = createEventDispatcher();
Expand All @@ -39,12 +40,15 @@
export let blocked: boolean;
export let showSuspendUserModal = false;
export let hasPinned: boolean;
export let unreadMessages: number;
$: isDiamond = client.isDiamond;
$: favouritesStore = client.favouritesStore;
$: messagesRead = client.messagesRead;
$: isProposalGroup = client.isProposalGroup;
$: isChatProposalsGroup =
selectedChatSummary.kind !== "direct_chat" &&
selectedChatSummary.subtype?.kind === "governance_proposals" &&
selectedChatSummary.subtype.governanceCanisterId === OC_GOVERNANCE_CANISTER_ID;
$: userId = selectedChatSummary.kind === "direct_chat" ? selectedChatSummary.them.userId : "";
$: userStore = client.userStore;
$: isBot = $userStore[userId]?.kind === "bot";
Expand Down Expand Up @@ -113,10 +117,6 @@
dispatch("showGroupMembers", true);
}
function markAllRead() {
dispatch("markAllRead");
}
function blockUser() {
if (selectedChatSummary.kind === "direct_chat") {
client.blockUserFromDirectChat(selectedChatSummary.them.userId).then((success) => {
Expand Down Expand Up @@ -203,6 +203,10 @@
}
});
}
function makeProposal() {
dispatch("makeProposal");
}
</script>

{#if desktop}
Expand Down Expand Up @@ -364,13 +368,16 @@
</MenuItem>
{/if}
{/if}
<MenuItem disabled={unreadMessages === 0} on:click={markAllRead}>
<CheckboxMultipleMarked
size={$iconSize}
color={"var(--icon-inverted-txt)"}
slot="icon" />
<div slot="text">{$_("markAllRead")}</div>
</MenuItem>

{#if isChatProposalsGroup}
<MenuItem on:click={makeProposal}>
<ChatQuestionIcon
size={$iconSize}
color={"var(--icon-inverted-txt)"}
slot="icon" />
<div slot="text">{$_("proposal.makeProposal")}</div>
</MenuItem>
{/if}

{#if client.user.isPlatformModerator}
{#if client.isFrozen(selectedChatSummary.id)}
Expand Down Expand Up @@ -439,14 +446,6 @@
</MenuItem>
{/if}
{/if}
<MenuItem disabled={unreadMessages === 0} on:click={markAllRead}>
<CheckboxMultipleMarked
size={$iconSize}
color={"var(--icon-inverted-txt)"}
slot="icon" />
<div slot="text">{$_("markAllRead")}</div>
</MenuItem>

{#if blocked}
<MenuItem on:click={unblockUser}>
<CancelIcon
Expand Down
24 changes: 23 additions & 1 deletion frontend/app/src/components/home/Home.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
import GateCheckFailed from "./AccessGateCheckFailed.svelte";
import HallOfFame from "./HallOfFame.svelte";
import LeftNav from "./nav/LeftNav.svelte";
import MakeProposalModal from "./MakeProposalModal.svelte";
import { createCandidateCommunity } from "../../stores/community";
import { interpolateLevel } from "../../utils/i18n";
import Convert from "./communities/Convert.svelte";
Expand Down Expand Up @@ -140,6 +141,7 @@
GateCheckFailed,
HallOfFame,
EditCommunity,
MakeProposal,
}
let modal = ModalType.None;
Expand All @@ -163,6 +165,14 @@
$: currentCommunityRules = client.currentCommunityRules;
$: globalUnreadCount = client.globalUnreadCount;
$: communities = client.communities;
$: selectedMultiUserChat =
$selectedChatStore?.kind === "group_chat" || $selectedChatStore?.kind === "channel"
? $selectedChatStore
: undefined;
$: governanceCanisterId =
selectedMultiUserChat !== undefined
? selectedMultiUserChat.subtype?.governanceCanisterId
: undefined;
$: {
document.title =
Expand Down Expand Up @@ -695,6 +705,10 @@
}
}
function showMakeProposalModal() {
modal = ModalType.MakeProposal;
}
async function joinGroup(
ev: CustomEvent<{ group: MultiUserChat; select: boolean }>
): Promise<void> {
Expand Down Expand Up @@ -993,6 +1007,7 @@
on:replyPrivatelyTo={replyPrivatelyTo}
on:showInviteGroupUsers={showInviteGroupUsers}
on:showProposalFilters={showProposalFilters}
on:makeProposal={showMakeProposalModal}
on:showGroupMembers={showGroupMembers}
on:joinGroup={joinGroup}
on:upgrade={upgrade}
Expand Down Expand Up @@ -1057,7 +1072,9 @@

{#if modal !== ModalType.None}
<Overlay
dismissible={modal !== ModalType.SelectChat && modal !== ModalType.Wallet}
dismissible={modal !== ModalType.SelectChat &&
modal !== ModalType.Wallet &&
modal !== ModalType.MakeProposal}
alignLeft={modal === ModalType.SelectChat}
on:close={closeModal}>
{#if modal === ModalType.SelectChat}
Expand All @@ -1079,6 +1096,11 @@
<AccountsModal on:close={closeModal} />
{:else if modal === ModalType.HallOfFame}
<HallOfFame on:close={closeModal} />
{:else if modal === ModalType.MakeProposal && selectedMultiUserChat !== undefined && governanceCanisterId !== undefined}
<MakeProposalModal
{selectedMultiUserChat}
{governanceCanisterId}
on:close={closeModal} />
{/if}
</Overlay>
{/if}
Expand Down
Loading

0 comments on commit a54c02f

Please sign in to comment.