Skip to content

Commit

Permalink
Add join overlay for public channels (#5630)
Browse files Browse the repository at this point in the history
Signed-off-by: Kristina Fefelova <[email protected]>
  • Loading branch information
kristina-fefelova committed May 21, 2024
1 parent 66a8fbe commit f956b8d
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 9 deletions.
4 changes: 3 additions & 1 deletion plugins/chunter-assets/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@
"StarChannel": "Star channel",
"StarConversation": "Star conversation",
"UnstarChannel": "Unstar channel",
"UnstarConversation": "Unstar conversation"
"UnstarConversation": "Unstar conversation",
"JoinChannelHeader": "Click \"Join\" to get started.",
"JoinChannelText": "Once you've joined, you'll be able to read all messages and contribute to the discussion."
}
}
4 changes: 3 additions & 1 deletion plugins/chunter-assets/lang/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@
"StarChannel": "Добавить в избранное",
"StarConversation": "Добавить в избранное",
"UnstarChannel": "Удалить из избранного",
"UnstarConversation": "Удалить из избранного"
"UnstarConversation": "Удалить из избранного",
"JoinChannelHeader": "Нажмите \"Присоединиться\", чтобы начать.",
"JoinChannelText": "Присоединившись, вы сможете читать все сообщения и участвовать в обсуждении."
}
}
75 changes: 69 additions & 6 deletions plugins/chunter-resources/src/components/ChannelView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,20 @@
// limitations under the License.
-->
<script lang="ts">
import { Doc, Ref } from '@hcengineering/core'
import { defineSeparators, location as locationStore, panelSeparators, Separator } from '@hcengineering/ui'
import core, { Doc, getCurrentAccount, Ref, Space } from '@hcengineering/core'
import {
defineSeparators,
Label,
location as locationStore,
ModernButton,
panelSeparators,
Separator
} from '@hcengineering/ui'
import { DocNotifyContext } from '@hcengineering/notification'
import { ActivityMessagesFilter } from '@hcengineering/activity'
import { getClient } from '@hcengineering/presentation'
import { Channel } from '@hcengineering/chunter'
import view from '@hcengineering/view'
import ChannelComponent from './Channel.svelte'
import ChannelHeader from './ChannelHeader.svelte'
Expand All @@ -33,6 +41,7 @@
const client = getClient()
const hierarchy = client.getHierarchy()
const me = getCurrentAccount()._id
let isThreadOpened = false
let isAsideShown = false
Expand All @@ -43,11 +52,27 @@
isThreadOpened = newLocation.path[4] != null
})
$: showJoinOverlay = shouldShowJoinOverlay(object)
$: isDocChat = !hierarchy.isDerived(object._class, chunter.class.ChunterSpace)
$: withAside = !embedded && !isThreadOpened && !hierarchy.isDerived(object._class, chunter.class.DirectMessage)
$: withAside =
!embedded && !isThreadOpened && !hierarchy.isDerived(object._class, chunter.class.DirectMessage) && !showJoinOverlay
function toChannel (object?: Doc): Channel | undefined {
return object as Channel | undefined
function toChannel (object: Doc): Channel {
return object as Channel
}
function shouldShowJoinOverlay (object: Doc): boolean {
if (hierarchy.isDerived(object._class, core.class.Space)) {
const space = object as Space
return !space.members.includes(me)
}
return false
}
async function join (): Promise<void> {
await client.update(object as Space, { $push: { members: me } })
}
defineSeparators('aside', panelSeparators)
Expand All @@ -72,7 +97,27 @@
<div class="popupPanel-body" class:asideShown={withAside && isAsideShown}>
<div class="popupPanel-body__main">
{#key object._id}
<ChannelComponent {context} {object} {filters} isAsideOpened={(withAside && isAsideShown) || isThreadOpened} />
{#if shouldShowJoinOverlay(object)}
<div class="body h-full w-full clear-mins flex-center">
<div class="joinOverlay">
<div class="an-element__label header">
<Label label={chunter.string.JoinChannelHeader} />
</div>
<span class="an-element__label">
<Label label={chunter.string.JoinChannelText} />
</span>
<span class="mt-4"> </span>
<ModernButton label={view.string.Join} kind="primary" on:click={join} />
</div>
</div>
{:else}
<ChannelComponent
{context}
{object}
{filters}
isAsideOpened={(withAside && isAsideShown) || isThreadOpened}
/>
{/if}
{/key}
</div>

Expand All @@ -91,3 +136,21 @@
{/if}
</div>
</div>

<style lang="scss">
.joinOverlay {
display: flex;
align-self: center;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
height: inherit;
width: 35rem;
}
.header {
font-weight: 600;
margin: 1rem;
}
</style>
4 changes: 3 additions & 1 deletion plugins/chunter-resources/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ export default mergeIds(chunterId, chunter, {
LoadingHistory: '' as IntlString,
UnpinChannels: '' as IntlString,
ArchiveActivityConfirmationTitle: '' as IntlString,
ArchiveActivityConfirmationMessage: '' as IntlString
ArchiveActivityConfirmationMessage: '' as IntlString,
JoinChannelHeader: '' as IntlString,
JoinChannelText: '' as IntlString
}
})

0 comments on commit f956b8d

Please sign in to comment.