Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Part 1]: Sidebar fixes #6640

Merged
merged 8 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions models/chunter/src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,4 @@ export function defineActions (builder: Builder): void {
target: notification.class.DocNotifyContext,
context: { mode: ['context', 'browser'], group: 'tools' }
})

createAction(builder, {
action: chunter.actionImpl.OpenInSidebarTab,
label: workbench.string.OpenInSidebarNewTab,
icon: view.icon.DetailsFilled,
input: 'focus',
category: chunter.category.Chunter,
target: notification.class.DocNotifyContext,
context: { mode: ['context', 'browser'], group: 'tools' }
})
}
3 changes: 1 addition & 2 deletions models/chunter/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ export default mergeIds(chunterId, chunter, {
ConvertDmToPrivateChannel: '' as ViewAction,
DeleteChatMessage: '' as ViewAction,
ReplyToThread: '' as ViewAction,
OpenInSidebar: '' as ViewAction,
OpenInSidebarTab: '' as ViewAction
OpenInSidebar: '' as ViewAction
},
category: {
Chunter: '' as Ref<ActionCategory>
Expand Down
2 changes: 2 additions & 0 deletions plugins/chunter-resources/src/components/ChannelHeader.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
export let withSearch: boolean = true
export let isAsideShown: boolean = false
export let filters: Ref<ActivityMessagesFilter>[] = []
export let canOpenInSidebar: boolean = false
const client = getClient()
const hierarchy = client.getHierarchy()
Expand Down Expand Up @@ -78,6 +79,7 @@
{withAside}
{isAsideShown}
{withSearch}
{canOpenInSidebar}
on:aside-toggled
on:close
>
Expand Down
29 changes: 15 additions & 14 deletions plugins/chunter-resources/src/components/ChannelSidebarView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,22 @@
</script>

{#if object}
{#key object._id}
<div class="channel" class:invisible={threadId !== undefined} style:height style:width>
<ChannelHeader
_id={object._id}
_class={object._class}
{object}
withAside={false}
withSearch={false}
canOpen={true}
allowClose={true}
on:close
/>
<div class="channel" class:invisible={threadId !== undefined} style:height style:width>
<ChannelHeader
_id={object._id}
_class={object._class}
{object}
withAside={false}
withSearch={false}
canOpen={true}
allowClose={true}
canOpenInSidebar={false}
on:close
/>
{#key object._id}
<Channel {object} {context} syncLocation={false} />
</div>
{/key}
{/key}
</div>
{/if}
{#if threadId}
<div class="thread" style:height style:width>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
canOpen={isDocChat}
allowClose={embedded}
{isAsideShown}
canOpenInSidebar={true}
on:close
on:select={handleMessageSelect}
on:aside-toggled={() => {
Expand Down
33 changes: 26 additions & 7 deletions plugins/chunter-resources/src/components/Header.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,24 @@
Breadcrumbs,
Button,
Icon,
IconDetails,
Label,
SearchInput,
Header,
HeaderAdaptive
HeaderAdaptive,
IconSettings,
IconDetailsFilled
} from '@hcengineering/ui'
import { createEventDispatcher } from 'svelte'
import view from '@hcengineering/view'
import { openDoc } from '@hcengineering/view-resources'
import { getClient } from '@hcengineering/presentation'
import { Doc, Ref } from '@hcengineering/core'
import { ActivityMessagesFilter } from '@hcengineering/activity'
import workbench from '@hcengineering/workbench'

import { userSearch } from '../index'
import { navigateToSpecial } from '../navigation'
import chunter from '../plugin'
import { navigateToSpecial, openChannelInSidebar } from '../navigation'
import ChannelMessagesFilter from './ChannelMessagesFilter.svelte'

export let object: Doc | undefined = undefined
Expand All @@ -53,6 +56,7 @@
export let filters: Ref<ActivityMessagesFilter>[] = []
export let adaptive: HeaderAdaptive = 'default'
export let hideActions: boolean = false
export let canOpenInSidebar: boolean = false

const client = getClient()
const dispatch = createEventDispatcher()
Expand Down Expand Up @@ -131,23 +135,38 @@
</svelte:fragment>
<svelte:fragment slot="actions" let:doubleRow>
<slot name="actions" {doubleRow} />
{#if canOpenInSidebar}
<Button
icon={IconDetailsFilled}
iconProps={{ size: 'small' }}
kind={'icon'}
showTooltip={{ label: workbench.string.OpenInSidebar }}
on:click={() => {
if (object !== undefined) {
void openChannelInSidebar(object._id, object._class, object, undefined, true)
}
}}
/>
{/if}
{#if canOpen && object}
<Button
icon={view.icon.Open}
iconProps={{ size: 'small' }}
kind={'icon'}
showTooltip={{ label: view.string.Open }}
on:click={() => {
if (object) {
openDoc(client.getHierarchy(), object)
if (object !== undefined) {
void openDoc(client.getHierarchy(), object)
}
}}
/>
{/if}
{#if withAside}
<Button
icon={IconDetails}
iconProps={{ size: 'medium', filled: isAsideShown }}
icon={IconSettings}
iconProps={{ size: 'medium' }}
kind={'icon'}
showTooltip={{ label: chunter.string.Settings }}
selected={isAsideShown}
on:click={() => dispatch('aside-toggled')}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@
</script>

{#if tab.data.thread}
{#key tab.data.thread}
<div class="root" style:height style:width>
<ThreadView _id={tab.data.thread} on:close />
</div>
{/key}
<div class="root" style:height style:width>
<ThreadView _id={tab.data.thread} on:close />
</div>
{/if}

<style lang="scss">
Expand Down
4 changes: 1 addition & 3 deletions plugins/chunter-resources/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ import {
getThreadLink,
openChannelInSidebar,
openChannelInSidebarAction,
openChannelInSidebarTabAction,
replyToThread
} from './navigation'
import {
Expand Down Expand Up @@ -206,7 +205,6 @@ export default async (): Promise<Resources> => ({
LeaveChannel: leaveChannelAction,
RemoveChannel: removeChannelAction,
ReplyToThread: replyToThread,
OpenInSidebar: openChannelInSidebarAction,
OpenInSidebarTab: openChannelInSidebarTabAction
OpenInSidebar: openChannelInSidebarAction
}
})
29 changes: 19 additions & 10 deletions plugins/chunter-resources/src/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,17 +276,9 @@ export async function openChannelInSidebar (
export async function openChannelInSidebarAction (
context: DocNotifyContext,
_: Event,
props?: { object?: Doc, newTab?: boolean }
): Promise<void> {
await openChannelInSidebar(context.objectId, context.objectClass, props?.object, undefined, props?.newTab ?? false)
}

export async function openChannelInSidebarTabAction (
context: DocNotifyContext,
event: Event,
props?: { object?: Doc }
): Promise<void> {
await openChannelInSidebarAction(context, event, { newTab: true, object: props?.object })
await openChannelInSidebar(context.objectId, context.objectClass, props?.object, undefined, true)
}

export async function openThreadInSidebarChannel (
Expand Down Expand Up @@ -326,12 +318,29 @@ export async function openThreadInSidebar (_id: Ref<ActivityMessage>, msg?: Acti
const name = (await getChannelName(object._id, object._class, object)) ?? (await translate(titleIntl, {}))
const tabName = await translate(chunter.string.ThreadIn, { name })
const loc = getCurrentLocation()
const allowedPath = loc.path.join('/')

const currentTAbs = get(sidebarStore).widgetsState.get(widget._id)?.tabs ?? []
const tabsToClose = currentTAbs
.filter((t) => t.isPinned !== true && t.allowedPath === allowedPath && (t as ChatWidgetTab).type === 'thread')
.map((t) => t.id)

if (tabsToClose.length > 0) {
sidebarStore.update((s) => {
const widgetState = s.widgetsState.get(widget._id)
if (widgetState === undefined) return s

const tabs = widgetState.tabs.filter((it) => !tabsToClose.includes(it.id))
s.widgetsState.set(widget._id, { ...widgetState, tabs })
return { ...s }
})
}

const tab: ChatWidgetTab = {
id: 'thread_' + _id,
name: tabName,
icon: chunter.icon.Thread,
allowedPath: loc.path.join('/'),
allowedPath,
type: 'thread',
data: {
_id: object?._id,
Expand Down
1 change: 1 addition & 0 deletions plugins/love-resources/src/components/VideoWidget.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@
flex: 1;
align-items: center;
background-color: var(--theme-statusbar-color);
overflow: hidden;
}
</style>
2 changes: 1 addition & 1 deletion plugins/workbench-resources/src/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ export function pinWidgetTab (widget: Widget, tabId: string): void {
if (widgetState === undefined) return

const tabs = widgetState.tabs
.map((it) => (it.id === tabId ? { ...it, isPinned: true } : it))
.map((it) => (it.id === tabId ? { ...it, isPinned: true, allowedPath: undefined } : it))
.sort((a, b) => (a.isPinned === b.isPinned ? 0 : a.isPinned === true ? -1 : 1))

widgetsState.set(widget._id, { ...widgetState, tabs })
Expand Down
Loading