Skip to content

Commit

Permalink
feat: TipTap Tasks add new line for jira tasks (#10530)
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Krick <[email protected]>
  • Loading branch information
mattkrick authored Nov 27, 2024
1 parent 6a05e4b commit a8cfa03
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
4 changes: 4 additions & 0 deletions packages/client/shared/tiptap/splitTipTapContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import {serverTipTapExtensions} from './serverTipTapExtensions'
export const splitTipTapContent = (doc: JSONContent, maxLength = 256) => {
const [firstBlock, ...bodyBlocks] = doc.content!
const fullTitle = generateText({...doc, content: [firstBlock!]}, serverTipTapExtensions)
// Remove newlines from the title
.split(/\s/)
.filter((s) => s.length)
.join(' ')
if (fullTitle.length < maxLength) {
const bodyText = generateText({...doc, content: bodyBlocks}, serverTipTapExtensions)
const content = bodyText.trim().length > 0 ? bodyBlocks : doc.content!
Expand Down
14 changes: 1 addition & 13 deletions packages/server/graphql/mutations/changeTaskTeam.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import {GraphQLID, GraphQLNonNull} from 'graphql'
import {SubscriptionChannel} from 'parabol-client/types/constEnums'
import {removeMentionKeepText} from '../../../client/shared/tiptap/removeMentionKeepText'
import getKysely from '../../postgres/getKysely'
import {AtlassianAuth} from '../../postgres/queries/getAtlassianAuthByUserIdTeamId'
import {GitHubAuth} from '../../postgres/queries/getGitHubAuthByUserIdTeamId'
import upsertAtlassianAuths from '../../postgres/queries/upsertAtlassianAuths'
import upsertGitHubAuth from '../../postgres/queries/upsertGitHubAuth'
import {getUserId, isTeamMember} from '../../utils/authorization'
import {convertToTipTap} from '../../utils/convertToTipTap'
import publish from '../../utils/publish'
import standardError from '../../utils/standardError'
import {GQLContext} from '../graphql'
Expand Down Expand Up @@ -46,7 +44,7 @@ export default {
if (!task) {
return standardError(new Error('Task not found'), {userId: viewerId})
}
const {content, tags, teamId: oldTeamId} = task
const {tags, teamId: oldTeamId} = task
if (!isTeamMember(authToken, oldTeamId)) {
return standardError(new Error('Team not found'), {userId: viewerId})
}
Expand Down Expand Up @@ -122,15 +120,6 @@ export default {
).filter(isValid)
const oldTeamMembers = teamMemberRes[0]!
const newTeamMembers = teamMemberRes[1]!
const oldTeamUserIds = oldTeamMembers.map(({userId}) => userId)
const newTeamUserIds = newTeamMembers.map(({userId}) => userId)
const userIdsOnlyOnOldTeam = oldTeamUserIds.filter((oldTeamUserId) => {
return !newTeamUserIds.find((newTeamUserId) => newTeamUserId === oldTeamUserId)
})
const rawContent = convertToTipTap(content)
const eqFn = (userId: string) => userIdsOnlyOnOldTeam.includes(userId)
const {rawContent: nextRawContent} = removeMentionKeepText(rawContent, eqFn)

// If there is a task with the same integration hash in the new team, then delete it first.
// This is done so there are no duplicates and also solves the issue of the conflicting task being
// private or archived.
Expand All @@ -155,7 +144,6 @@ export default {
await pg
.updateTable('Task')
.set({
content: rawContent === nextRawContent ? undefined : JSON.stringify(nextRawContent),
teamId,
integration: JSON.stringify(integration)
})
Expand Down

0 comments on commit a8cfa03

Please sign in to comment.