Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
BykhovDenis committed Aug 28, 2024
2 parents cf53ac2 + 86c69b4 commit 702e8b4
Show file tree
Hide file tree
Showing 33 changed files with 373 additions and 463 deletions.
1 change: 1 addition & 0 deletions dev/tool/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"_phase:docker-staging": "rushx docker:staging",
"bundle": "mkdir -p bundle && esbuild src/__start.ts --bundle --minify --platform=node --define:process.env.MODEL_VERSION=$(node ../../common/scripts/show_version.js) --define:process.env.GIT_REVISION=$(../../common/scripts/git_version.sh) > bundle/bundle.js",
"docker:build": "../../common/scripts/docker_build.sh hardcoreeng/tool",
"docker:tbuild": "docker build -t hardcoreeng/tool . --platform=linux/amd64 && ../../common/scripts/docker_tag_push.sh hardcoreeng/tool",
"docker:staging": "../../common/scripts/docker_tag.sh hardcoreeng/tool staging",
"docker:push": "../../common/scripts/docker_tag.sh hardcoreeng/tool",
"run-local": "rush bundle --to @hcengineering/tool >/dev/null && cross-env SERVER_SECRET=secret ACCOUNTS_URL=http://localhost:3000 TRANSACTOR_URL=ws://localhost:3333 MINIO_ACCESS_KEY=minioadmin MINIO_SECRET_KEY=minioadmin MINIO_ENDPOINT=localhost MONGO_URL=mongodb://localhost:27017 TELEGRAM_DATABASE=telegram-service ELASTIC_URL=http://localhost:9200 REKONI_URL=http://localhost:4004 MODEL_VERSION=$(node ../../common/scripts/show_version.js) GIT_REVISION=$(git describe --all --long) node --max-old-space-size=18000 ./bundle/bundle.js",
Expand Down
8 changes: 4 additions & 4 deletions dev/tool/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1300,19 +1300,19 @@ export function devTool (
await withDatabase(mongodbUri, async (db, client) => {
await withStorage(mongodbUri, async (adapter) => {
const workspaces = await listWorkspacesPure(db)
let index = 0
for (const workspace of workspaces) {
if (cmd.workspace !== '' && workspace.workspace !== cmd.workspace) {
continue
}

const wsId = getWorkspaceId(workspace.workspace)
const endpoint = await getTransactorEndpoint(generateToken(systemAccountEmail, wsId), 'external')
console.log('processing workspace', workspace.workspace, index, workspaces.length)

console.log('processing workspace', workspace.workspace)

await migrateMarkup(toolCtx, adapter, wsId, client, endpoint, parseInt(cmd.concurrency))
await migrateMarkup(toolCtx, adapter, wsId, client, mongodbUri, parseInt(cmd.concurrency))

console.log('...done', workspace.workspace)
index++
}
})
})
Expand Down
52 changes: 22 additions & 30 deletions dev/tool/src/markup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import core, {
} from '@hcengineering/core'
import { getMongoClient, getWorkspaceDB } from '@hcengineering/mongo'
import { type StorageAdapter } from '@hcengineering/server-core'
import { connect } from '@hcengineering/server-tool'
import { connect, fetchModelFromMongo } from '@hcengineering/server-tool'
import { jsonToText, markupToYDoc } from '@hcengineering/text'
import { type Db, type FindCursor, type MongoClient } from 'mongodb'

Expand Down Expand Up @@ -120,47 +120,39 @@ export async function migrateMarkup (
storageAdapter: StorageAdapter,
workspaceId: WorkspaceId,
client: MongoClient,
transactorUrl: string,
mongodbUri: string,
concurrency: number
): Promise<void> {
const connection = (await connect(transactorUrl, workspaceId, undefined, {
mode: 'backup'
})) as unknown as CoreClient

const hierarchy = connection.getHierarchy()
const { hierarchy } = await fetchModelFromMongo(ctx, mongodbUri, workspaceId)

const workspaceDb = client.db(workspaceId.name)

try {
const classes = hierarchy.getDescendants(core.class.Doc)
for (const _class of classes) {
const domain = hierarchy.findDomain(_class)
if (domain === undefined) continue
const classes = hierarchy.getDescendants(core.class.Doc)
for (const _class of classes) {
const domain = hierarchy.findDomain(_class)
if (domain === undefined) continue

const allAttributes = hierarchy.getAllAttributes(_class)
const attributes = Array.from(allAttributes.values()).filter((attribute) => {
return hierarchy.isDerived(attribute.type._class, 'core:class:TypeCollaborativeMarkup' as Ref<Class<Doc>>)
})
const allAttributes = hierarchy.getAllAttributes(_class)
const attributes = Array.from(allAttributes.values()).filter((attribute) => {
return hierarchy.isDerived(attribute.type._class, 'core:class:TypeCollaborativeMarkup' as Ref<Class<Doc>>)
})

if (attributes.length === 0) continue
if (hierarchy.isMixin(_class) && attributes.every((p) => p.attributeOf !== _class)) continue
if (attributes.length === 0) continue
if (hierarchy.isMixin(_class) && attributes.every((p) => p.attributeOf !== _class)) continue

const collection = workspaceDb.collection(domain)
const collection = workspaceDb.collection(domain)

const filter = hierarchy.isMixin(_class) ? { [_class]: { $exists: true } } : { _class }
const filter = hierarchy.isMixin(_class) ? { [_class]: { $exists: true } } : { _class }

const count = await collection.countDocuments(filter)
const iterator = collection.find<Doc>(filter)
const count = await collection.countDocuments(filter)
const iterator = collection.find<Doc>(filter)

try {
console.log('processing', _class, '->', count)
await processMigrateMarkupFor(ctx, hierarchy, storageAdapter, workspaceId, attributes, iterator, concurrency)
} finally {
await iterator.close()
}
try {
console.log('processing', _class, '->', count)
await processMigrateMarkupFor(ctx, hierarchy, storageAdapter, workspaceId, attributes, iterator, concurrency)
} finally {
await iterator.close()
}
} finally {
await connection.close()
}
}

Expand Down
4 changes: 3 additions & 1 deletion packages/theme/styles/prose.scss
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,10 @@ table.proseTable {
padding: .5rem;
user-select: text;
cursor: auto;
}

pre { white-space: pre-wrap; }
pre.proseCodeBlock {
white-space: pre-wrap;
}

// Fixes for MessageViewer
Expand Down
42 changes: 20 additions & 22 deletions plugins/chunter-resources/src/components/chat/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,31 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
import notification, { type DocNotifyContext } from '@hcengineering/notification'
import attachment, { type SavedAttachments } from '@hcengineering/attachment'
import { type DirectMessage } from '@hcengineering/chunter'
import contact, { type PersonAccount } from '@hcengineering/contact'
import core, {
type Account,
AccountRole,
generateId,
type Ref,
SortingOrder,
type WithLookup,
hasAccountRole,
getCurrentAccount,
AccountRole,
hasAccountRole,
type IdMap,
type Account,
type UserStatus
type Ref,
SortingOrder,
type UserStatus,
type WithLookup
} from '@hcengineering/core'
import notification, { type DocNotifyContext } from '@hcengineering/notification'
import { InboxNotificationsClientImpl } from '@hcengineering/notification-resources'
import { createQuery, getClient, MessageBox } from '@hcengineering/presentation'
import { get, writable } from 'svelte/store'
import { type Action, showPopup } from '@hcengineering/ui'
import view from '@hcengineering/view'
import workbench, { type SpecialNavModel } from '@hcengineering/workbench'
import attachment, { type SavedAttachments } from '@hcengineering/attachment'
import { InboxNotificationsClientImpl } from '@hcengineering/notification-resources'
import { type Action, showPopup } from '@hcengineering/ui'
import contact, { type PersonAccount } from '@hcengineering/contact'
import { type DirectMessage } from '@hcengineering/chunter'
import { get, writable } from 'svelte/store'

import { type ChatNavGroupModel, type ChatNavItemModel, type SortFnOptions } from './types'
import chunter from '../../plugin'
import { type ChatNavGroupModel, type ChatNavItemModel, type SortFnOptions } from './types'

const navigatorStateStorageKey = 'chunter.navigatorState'

Expand Down Expand Up @@ -356,14 +356,12 @@ function archiveActivityChannels (contexts: DocNotifyContext[]): void {
MessageBox,
{
label: chunter.string.ArchiveActivityConfirmationTitle,
message: chunter.string.ArchiveActivityConfirmationMessage
},
'top',
(result?: boolean) => {
if (result === true) {
void removeActivityChannels(contexts)
message: chunter.string.ArchiveActivityConfirmationMessage,
action: async () => {
await removeActivityChannels(contexts)
}
}
},
'top'
)
}

Expand Down
130 changes: 58 additions & 72 deletions plugins/chunter-resources/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,115 +13,101 @@
// limitations under the License.
//

import { writable } from 'svelte/store'
import { type ActivityMessage } from '@hcengineering/activity'
import chunter, { type Channel, type ChatMessage, type DirectMessage } from '@hcengineering/chunter'
import { type Resources } from '@hcengineering/platform'
import { MessageBox, getClient } from '@hcengineering/presentation'
import { getLocation, navigate, showPopup } from '@hcengineering/ui'
import { type ActivityMessage } from '@hcengineering/activity'
import { writable } from 'svelte/store'

import ChannelPresenter from './components/ChannelPresenter.svelte'
import ChannelCreatedMessage from './components/activity/ChannelCreatedMessage.svelte'
import MembersChangedMessage from './components/activity/MembersChangedMessage.svelte'
import ChannelHeader from './components/ChannelHeader.svelte'
import ChannelIcon from './components/ChannelIcon.svelte'
import ChannelPanel from './components/ChannelPanel.svelte'
import ChunterBrowser from './components/chat/specials/ChunterBrowser.svelte'
import ConvertDmToPrivateChannelModal from './components/ConvertDmToPrivateChannel.svelte'
import CreateChannel from './components/chat/create/CreateChannel.svelte'
import CreateDirectChat from './components/chat/create/CreateDirectChat.svelte'
import DmHeader from './components/DmHeader.svelte'
import DmPresenter from './components/DmPresenter.svelte'
import EditChannel from './components/EditChannel.svelte'
import ChannelPresenter from './components/ChannelPresenter.svelte'
import ChannelPreview from './components/ChannelPreview.svelte'
import ThreadView from './components/threads/ThreadView.svelte'
import ThreadViewPanel from './components/threads/ThreadViewPanel.svelte'
import ChatMessagePresenter from './components/chat-message/ChatMessagePresenter.svelte'
import ChatMessageInput from './components/chat-message/ChatMessageInput.svelte'
import ChatMessagePresenter from './components/chat-message/ChatMessagePresenter.svelte'
import ChatMessagePreview from './components/chat-message/ChatMessagePreview.svelte'
import ChatMessagesPresenter from './components/chat-message/ChatMessagesPresenter.svelte'
import Chat from './components/chat/Chat.svelte'
import ThreadMessagePresenter from './components/threads/ThreadMessagePresenter.svelte'
import ThreadParentPresenter from './components/threads/ThreadParentPresenter.svelte'
import ChannelHeader from './components/ChannelHeader.svelte'
import ChatAside from './components/chat/ChatAside.svelte'
import CreateChannel from './components/chat/create/CreateChannel.svelte'
import CreateDirectChat from './components/chat/create/CreateDirectChat.svelte'
import ChunterBrowser from './components/chat/specials/ChunterBrowser.svelte'
import SavedMessages from './components/chat/specials/SavedMessages.svelte'
import Threads from './components/threads/Threads.svelte'
import ConvertDmToPrivateChannelModal from './components/ConvertDmToPrivateChannel.svelte'
import DirectIcon from './components/DirectIcon.svelte'
import ChannelIcon from './components/ChannelIcon.svelte'
import ThreadNotificationPresenter from './components/notification/ThreadNotificationPresenter.svelte'
import DmHeader from './components/DmHeader.svelte'
import DmPresenter from './components/DmPresenter.svelte'
import EditChannel from './components/EditChannel.svelte'
import ChatMessageNotificationLabel from './components/notification/ChatMessageNotificationLabel.svelte'
import ChatAside from './components/chat/ChatAside.svelte'
import ThreadMessagePreview from './components/threads/ThreadMessagePreview.svelte'
import ChatMessagePreview from './components/chat-message/ChatMessagePreview.svelte'
import ChannelCreatedMessage from './components/activity/ChannelCreatedMessage.svelte'
import MembersChangedMessage from './components/activity/MembersChangedMessage.svelte'
import JoinChannelNotificationPresenter from './components/notification/JoinChannelNotificationPresenter.svelte'
import ThreadNotificationPresenter from './components/notification/ThreadNotificationPresenter.svelte'
import ThreadMessagePresenter from './components/threads/ThreadMessagePresenter.svelte'
import ThreadMessagePreview from './components/threads/ThreadMessagePreview.svelte'
import ThreadParentPresenter from './components/threads/ThreadParentPresenter.svelte'
import Threads from './components/threads/Threads.svelte'
import ThreadView from './components/threads/ThreadView.svelte'
import ThreadViewPanel from './components/threads/ThreadViewPanel.svelte'

import {
chunterSpaceLinkFragmentProvider,
getMessageLink,
getMessageLocation,
getThreadLink,
replyToThread
} from './navigation'
import {
ChannelTitleProvider,
DirectTitleProvider,
canCopyMessageLink,
canDeleteMessage,
canReplyToThread,
dmIdentifierProvider,
getDmName,
getTitle,
getUnreadThreadsCount,
canCopyMessageLink,
leaveChannelAction,
removeChannelAction,
canReplyToThread
removeChannelAction
} from './utils'
import {
chunterSpaceLinkFragmentProvider,
getThreadLink,
getMessageLink,
replyToThread,
getMessageLocation
} from './navigation'

export { default as ChatMessagesPresenter } from './components/chat-message/ChatMessagesPresenter.svelte'
export { default as ChatMessagePopup } from './components/chat-message/ChatMessagePopup.svelte'
export { default as ChatMessageInput } from './components/chat-message/ChatMessageInput.svelte'
export { default as ChatMessagePopup } from './components/chat-message/ChatMessagePopup.svelte'
export { default as ChatMessagesPresenter } from './components/chat-message/ChatMessagesPresenter.svelte'
export { default as Header } from './components/Header.svelte'
export { default as ThreadView } from './components/threads/ThreadView.svelte'

export async function ArchiveChannel (channel: Channel, evt: any, afterArchive?: () => void): Promise<void> {
showPopup(
MessageBox,
{
label: chunter.string.ArchiveChannel,
message: chunter.string.ArchiveConfirm
},
undefined,
(result: boolean) => {
if (result) {
const client = getClient()

// eslint-disable-next-line @typescript-eslint/no-floating-promises
client.update(channel, { archived: true })
if (afterArchive != null) afterArchive()

const loc = getLocation()
if (loc.path[3] === channel._id) {
loc.path.length = 3
navigate(loc)
}
showPopup(MessageBox, {
label: chunter.string.ArchiveChannel,
message: chunter.string.ArchiveConfirm,
action: async () => {
const client = getClient()

// eslint-disable-next-line @typescript-eslint/no-floating-promises
await client.update(channel, { archived: true })
if (afterArchive != null) afterArchive()

const loc = getLocation()
if (loc.path[3] === channel._id) {
loc.path.length = 3
navigate(loc)
}
}
)
})
}

async function UnarchiveChannel (channel: Channel): Promise<void> {
showPopup(
MessageBox,
{
label: chunter.string.UnarchiveChannel,
message: chunter.string.UnarchiveConfirm
},
undefined,
(result: boolean) => {
if (result) {
const client = getClient()

// eslint-disable-next-line @typescript-eslint/no-floating-promises
client.update(channel, { archived: false })
}
showPopup(MessageBox, {
label: chunter.string.UnarchiveChannel,
message: chunter.string.UnarchiveConfirm,
action: async () => {
const client = getClient()
await client.update(channel, { archived: false })
}
)
})
}

async function ConvertDmToPrivateChannel (dm: DirectMessage): Promise<void> {
Expand Down
25 changes: 8 additions & 17 deletions plugins/contact-resources/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,25 +272,16 @@ async function kickEmployee (doc: Person): Promise<void> {
if (accounts.length === 0) {
await client.update(employee, { active: false })
} else {
showPopup(
MessageBox,
{
label: contact.string.KickEmployee,
message: contact.string.KickEmployeeDescr
},
undefined,
(res?: boolean) => {
if (res === true) {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
const p = getResource(login.function.LeaveWorkspace)
for (const i of accounts) {
void p.then(async (f) => {
await f(i.email)
})
}
showPopup(MessageBox, {
label: contact.string.KickEmployee,
message: contact.string.KickEmployeeDescr,
action: async () => {
const leaveWorkspace = await getResource(login.function.LeaveWorkspace)
for (const i of accounts) {
await leaveWorkspace(i.email)
}
}
)
})
}
}
async function openChannelURL (doc: Channel): Promise<void> {
Expand Down
Loading

0 comments on commit 702e8b4

Please sign in to comment.