Skip to content

Commit

Permalink
UBERF-8288: Fix archiving a channel (#6750)
Browse files Browse the repository at this point in the history
Signed-off-by: Kristina Fefelova <[email protected]>
  • Loading branch information
kristina-fefelova authored Sep 26, 2024
1 parent d284414 commit b359d08
Show file tree
Hide file tree
Showing 28 changed files with 235 additions and 76 deletions.
2 changes: 2 additions & 0 deletions models/chunter/src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ function defineChannelActions (builder: Builder): void {
query: {
archived: false
},
override: [view.action.Archive],
visibilityTester: view.function.CanArchiveSpace,
context: {
mode: 'context',
group: 'remove'
Expand Down
2 changes: 1 addition & 1 deletion models/core/src/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ export const coreOperation: MigrateOperation = {
func: migrateAllSpaceToTyped
},
{
state: 'add-spaces-owner',
state: 'add-spaces-owner-v1',
func: migrateSpacesOwner
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
export let hoverable = true
export let hoverStyles: 'borderedHover' | 'filledHover' = 'borderedHover'
export let hideLink = false
export let readonly: boolean = false
export let onClick: (() => void) | undefined = undefined
$: personAccount = $personAccountByIdStore.get((value.createdBy ?? value.modifiedBy) as Ref<PersonAccount>)
Expand Down Expand Up @@ -74,6 +75,7 @@
{hoverable}
{hoverStyles}
viewlet={undefined}
{readonly}
{onClick}
>
<svelte:fragment slot="icon">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
export let videoPreload = true
export let hideLink = false
export let compact = false
export let readonly = false
export let onClick: (() => void) | undefined = undefined
const client = getClient()
Expand Down Expand Up @@ -72,6 +73,7 @@
hideLink,
type,
compact,
readonly,
onClick
}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
export let type: ActivityMessageViewType = 'default'
export let inlineActions: MessageInlineAction[] = []
export let excludedActions: Ref<ViewAction>[] = []
export let readonly: boolean = false
export let onClick: (() => void) | undefined = undefined
export let socialIcon: Asset | undefined = undefined
Expand Down Expand Up @@ -107,8 +108,7 @@
$: isHidden = !!viewlet?.onlyWithParent && parentMessage === undefined
$: withActionMenu = withActions && !embedded && (actions.length > 0 || menuActionIds.length > 0)
let readonly: boolean = false
$: readonly = $restrictionStore.disableComments
$: readonly = readonly || $restrictionStore.disableComments
function canDisplayShort (type: ActivityMessageViewType, isSaved: boolean): boolean {
return type === 'short' && !isSaved && (message.replies ?? 0) === 0
Expand Down Expand Up @@ -143,6 +143,7 @@
}
function handleContextMenu (event: MouseEvent): void {
if (readonly) return
const showCustomPopup = !isTextClicked(event.target as HTMLElement, event.clientX, event.clientY)
if (showCustomPopup) {
showMenu(event, { object: message, baseMenuClass: activity.class.ActivityMessage }, () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
export let hoverStyles: 'borderedHover' | 'filledHover' = 'borderedHover'
export let hideLink = false
export let compact = false
export let readonly: boolean = false
export let onClick: (() => void) | undefined = undefined
const client = getClient()
Expand Down Expand Up @@ -96,6 +97,7 @@

<ActivityMessageTemplate
message={value}
{readonly}
{person}
{showNotify}
{isHighlighted}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
export let hoverStyles: 'borderedHover' | 'filledHover' = 'borderedHover'
export let hideLink = false
export let type: ActivityMessageViewType = 'default'
export let readonly = false
export let space: Ref<Space> | undefined = undefined
export let onClick: (() => void) | undefined = undefined
Expand Down Expand Up @@ -195,6 +196,7 @@
{skipLabel}
{hoverable}
{hoverStyles}
{readonly}
type={viewlet?.label || getIsTextType(attributeModel) ? 'default' : type}
showDatePreposition={hideLink}
{onClick}
Expand Down
6 changes: 4 additions & 2 deletions plugins/chunter-assets/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"Settings": "Settings",
"ArchiveChannel": "Archive channel",
"UnarchiveChannel": "Unarchive channel",
"ArchiveConfirm": "Do you want to archive channel?",
"ArchiveConfirm": "When you archive a channel, it’s archived for everyone.<br/><br/>No one will be able to send messages, but they’ll still have access to the channel’s history.<br/><br/>You’ll still be able to find the channel’s contents via search.<br/>And you can always unarchive the channel in the future, if needed.\n",
"UnarchiveConfirm": "Do you want to unarchive channel?",
"AddToSaved": "Add to saved",
"RemoveFromSaved": "Remove from saved",
Expand Down Expand Up @@ -127,6 +127,8 @@
"Translate": "Translate",
"ShowOriginal": "Show original",
"Translating": "Translating...",
"StartConversation": "Start conversation"
"StartConversation": "Start conversation",
"ViewingThreadFromArchivedChannel": "You are viewing a thread from an archived channel",
"ViewingArchivedChannel": "You are viewing an archived channel"
}
}
6 changes: 4 additions & 2 deletions plugins/chunter-assets/lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"Settings": "Ajustes",
"ArchiveChannel": "Archivar canal",
"UnarchiveChannel": "Desarchivar canal",
"ArchiveConfirm": "¿Quieres archivar el canal?",
"ArchiveConfirm": "Cuando archivas un canal, se archiva para todos.<br/><br/>Nadie podrá enviar mensajes, pero seguirán teniendo acceso al historial del canal.<br/><br/>Todavía podrás encontrar el contenido del canal a través de la búsqueda.<br/>Y siempre puedes desarchivar el canal en el futuro, si es necesario.\n",
"UnarchiveConfirm": "¿Quieres desarchivar el canal?",
"AddToSaved": "Añadir a guardados",
"RemoveFromSaved": "Eliminar de guardados",
Expand Down Expand Up @@ -127,6 +127,8 @@
"Translate": "Traducir",
"ShowOriginal": "Mostrar original",
"Translating": "Traduciendo...",
"StartConversation": "Iniciar conversación"
"StartConversation": "Iniciar conversación",
"ViewingThreadFromArchivedChannel": "Estás viendo un hilo de un canal archivado",
"ViewingArchivedChannel": "Estás viendo un canal archivado"
}
}
6 changes: 4 additions & 2 deletions plugins/chunter-assets/lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"Settings": "Paramètres",
"ArchiveChannel": "Archiver le canal",
"UnarchiveChannel": "Désarchiver le canal",
"ArchiveConfirm": "Voulez-vous archiver le canal ?",
"ArchiveConfirm": "Lorsque vous archivez un canal, il est archivé pour tout le monde.<br/><br/>Personne ne pourra envoyer de messages, mais ils auront toujours accès à l'historique du canal.<br/><br/>Vous pourrez toujours trouver le contenu du canal via la recherche.<br/>Et vous pourrez toujours désarchiver le canal à l'avenir, si nécessaire.\n",
"UnarchiveConfirm": "Voulez-vous désarchiver le canal ?",
"AddToSaved": "Ajouter aux favoris",
"RemoveFromSaved": "Retirer des favoris",
Expand Down Expand Up @@ -127,6 +127,8 @@
"Translate": "Traduire",
"ShowOriginal": "Afficher l'original",
"Translating": "Traduction en cours...",
"StartConversation": "Démarrer la conversation"
"StartConversation": "Démarrer la conversation",
"ViewingThreadFromArchivedChannel": "Vous consultez un fil de discussion d'un canal archivé",
"ViewingArchivedChannel": "Vous consultez un canal archivé"
}
}
6 changes: 4 additions & 2 deletions plugins/chunter-assets/lang/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"Settings": "Definições",
"ArchiveChannel": "Arquivar canal",
"UnarchiveChannel": "Desarquivar canal",
"ArchiveConfirm": "Deseja arquivar o canal?",
"ArchiveConfirm": "Quando arquivar um canal, ele é arquivado para todos.<br/><br/>Ninguém poderá enviar mensagens, mas ainda terão acesso ao histórico do canal.<br/><br/>Ainda poderá encontrar o conteúdo do canal através da pesquisa.<br/>E poderá sempre desarquivar o canal no futuro, se necessário.\n",
"UnarchiveConfirm": "Deseja desarquivar o canal?",
"AddToSaved": "Adicionar aos guardados",
"RemoveFromSaved": "Remover dos guardados",
Expand Down Expand Up @@ -127,6 +127,8 @@
"Translate": "Traduzir",
"ShowOriginal": "Mostrar original",
"Translating": "A traduzir...",
"StartConversation": "Iniciar conversa"
"StartConversation": "Iniciar conversa",
"ViewingThreadFromArchivedChannel": "Está a visualizar uma conversa em cadeia de um canal arquivado",
"ViewingArchivedChannel": "Está a visualizar um canal arquivado"
}
}
6 changes: 4 additions & 2 deletions plugins/chunter-assets/lang/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"Settings": "Настройки",
"ArchiveChannel": "Архивировать канал",
"UnarchiveChannel": "Разархивировать канал",
"ArchiveConfirm": "Вы действительно хотите архивировать канал?",
"ArchiveConfirm": "При архивации канала он архивируется для всех.<br/><br/>Никто не сможет отправлять сообщения, но у них все равно будет доступ к истории канала.<br/><br/>Вы все равно сможете найти содержимое канала через поиск.<br/>И вы всегда сможете разархивировать канал в будущем, если это понадобится.\n",
"UnarchiveConfirm": "Вы действительно хотите разархивировать канал?",
"AddToSaved": "Добавить в сохраненные",
"RemoveFromSaved": "Удалить из сохраненных",
Expand Down Expand Up @@ -127,6 +127,8 @@
"Translate": "Перевести",
"ShowOriginal": "Показать оригинал",
"Translating": "Перевод...",
"StartConversation": "Начать диалог"
"StartConversation": "Начать диалог",
"ViewingThreadFromArchivedChannel": "Вы просматриваете обсуждение из архивированного канала",
"ViewingArchivedChannel": "Вы просматриваете архивированный канал"
}
}
6 changes: 4 additions & 2 deletions plugins/chunter-assets/lang/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"Settings": "设置",
"ArchiveChannel": "归档频道",
"UnarchiveChannel": "取消归档频道",
"ArchiveConfirm": "你想要归档频道吗?",
"ArchiveConfirm": "当你归档频道时,它会对所有人进行归档。<br/><br/>没有人能够发送消息,但他们仍然可以访问频道的历史记录。<br/><br/>你仍然可以通过搜索找到频道的内容。<br/>如果需要,你可以随时取消归档频道。\n",
"UnarchiveConfirm": "你想要取消归档频道吗?",
"AddToSaved": "添加到已保存",
"RemoveFromSaved": "从已保存中移除",
Expand Down Expand Up @@ -127,6 +127,8 @@
"Translate": "翻译",
"ShowOriginal": "显示原文",
"Translating": "翻译中...",
"StartConversation": "开始对话"
"StartConversation": "开始对话",
"ViewingThreadFromArchivedChannel": "你正在查看已归档频道的线程",
"ViewingArchivedChannel": "你正在查看已归档频道"
}
}
1 change: 1 addition & 0 deletions plugins/chunter-resources/src/components/Channel.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
{#if dataProvider}
<ChannelScrollView
{object}
channel={object}
skipLabels={!isDocChannel}
selectedFilters={filters}
startFromBottom
Expand Down
118 changes: 118 additions & 0 deletions plugins/chunter-resources/src/components/ChannelInput.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
<!--
// Copyright © 2024 Hardcore Engineering Inc.
//
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. You may
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
-->
<script lang="ts">
import { ActivityExtension as ActivityExtensionComponent } from '@hcengineering/activity-resources'
import { Class, Doc, Ref } from '@hcengineering/core'
import activity, { ActivityExtension } from '@hcengineering/activity'
import { getClient } from '@hcengineering/presentation'
import { AnySvelteComponent, Icon, Label } from '@hcengineering/ui'
import { Asset, getResource, translate } from '@hcengineering/platform'
import view from '@hcengineering/view'
import { getChannelName, getObjectIcon } from '../utils'
import chunter from '../plugin'
export let object: Doc
export let readonly = false
export let boundary: HTMLElement | undefined | null = undefined
export let collection: string | undefined
export let isThread = false
const client = getClient()
const hierarchy = client.getHierarchy()
let extensions: ActivityExtension[] = []
$: extensions = client.getModel().findAllSync(activity.class.ActivityExtension, { ofClass: object._class })
let icon: Asset | AnySvelteComponent | undefined = undefined
let name: string | undefined = undefined
$: void updateIcon(object._class)
$: void updateName(object)
async function updateIcon (_class: Ref<Class<Doc>>): Promise<void> {
if (isThread) {
return
}
const iconMixin = hierarchy.classHierarchyMixin(_class, view.mixin.ObjectIcon)
let result: AnySvelteComponent | Asset | undefined = undefined
if (iconMixin?.component) {
result = await getResource(iconMixin.component)
} else {
result = getObjectIcon(_class)
}
icon = result
}
async function updateName (object: Doc): Promise<void> {
const titleIntl = client.getHierarchy().getClass(object._class).label
name = (await getChannelName(object._id, object._class, object)) ?? (await translate(titleIntl, {}))
}
</script>

{#if !readonly}
<div class="ref-input flex-col">
<ActivityExtensionComponent
kind="input"
{extensions}
props={{ object, boundary, collection, autofocus: true, withTypingInfo: true }}
/>
</div>
{:else}
<div class="message">
{#if isThread}
<Label label={chunter.string.ViewingThreadFromArchivedChannel} />
{:else}
<Label label={chunter.string.ViewingArchivedChannel} />
<span class="info">
{#if icon}
<Icon {icon} size="x-small" />
{/if}
{#if name}
{name}
{/if}
</span>
{/if}
</div>
{/if}

<style lang="scss">
.ref-input {
flex-shrink: 0;
margin: 1.25rem 1rem 0;
max-height: 18.75rem;
}
.message {
display: flex;
align-items: center;
justify-content: center;
margin: 1rem;
padding: 0.5rem 0;
color: var(--global-primary-TextColor);
background: var(--global-ui-BorderColor);
border-radius: 0.5rem;
}
.info {
display: flex;
align-items: center;
justify-content: center;
margin-left: 0.25rem;
gap: 0.125rem;
font-weight: 600;
}
</style>
27 changes: 15 additions & 12 deletions plugins/chunter-resources/src/components/ChannelMembers.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
export let ids: Ref<Person>[] = []
export let disableRemoveFor: Ref<Person>[] = []
export let readonly = false
const dispatch = createEventDispatcher()
Expand All @@ -36,22 +37,24 @@
</script>

<div class="root">
<div class="item" style:padding="var(--spacing-1_5)" class:withoutBorder={persons.length === 0}>
<ModernButton
label={chunter.string.AddMembers}
icon={IconAddMember}
iconSize="small"
kind="secondary"
size="small"
on:click={() => dispatch('add')}
/>
</div>
{#if !readonly}
<div class="item" style:padding="var(--spacing-1_5)" class:withoutBorder={persons.length === 0}>
<ModernButton
label={chunter.string.AddMembers}
icon={IconAddMember}
iconSize="small"
kind="secondary"
size="small"
on:click={() => dispatch('add')}
/>
</div>
{/if}
<Scroller>
{#each persons as person, index (person._id)}
<div class="item" class:withoutBorder={index === persons.length - 1}>
<div class="item__content" class:disabled={disableRemoveFor.includes(person._id)}>
<div class="item__content" class:disabled={readonly || disableRemoveFor.includes(person._id)}>
<UserDetails {person} showStatus />
{#if !disableRemoveFor.includes(person._id)}
{#if !readonly && !disableRemoveFor.includes(person._id)}
<div class="item__action">
<ButtonIcon
icon={IconDelete}
Expand Down
Loading

0 comments on commit b359d08

Please sign in to comment.