1
0
mirror of https://github.com/mattermost/focalboard.git synced 2024-11-27 08:31:20 +02:00

Merge pull request #2761 from mattermost/gh-2337-hide-single-user-copy-link

fix: hide 'Copy link' for `single-user` installs
This commit is contained in:
Scott Bishel 2022-04-13 10:33:42 -06:00 committed by GitHub
commit cbd03bc612
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 88 additions and 39 deletions

View File

@ -119,21 +119,23 @@ const CardDialog = (props: Props): JSX.Element => {
onClick={handleDeleteButtonOnClick}
/>
</BoardPermissionGate>
<Menu.Text
icon={<LinkIcon/>}
id='copy'
name={intl.formatMessage({id: 'CardDialog.copyLink', defaultMessage: 'Copy link'})}
onClick={() => {
let cardLink = window.location.href
{me?.id !== 'single-user' &&
<Menu.Text
icon={<LinkIcon/>}
id='copy'
name={intl.formatMessage({id: 'CardDialog.copyLink', defaultMessage: 'Copy link'})}
onClick={() => {
let cardLink = window.location.href
if (!cardLink.includes(props.cardId)) {
cardLink += `/${props.cardId}`
}
if (!cardLink.includes(props.cardId)) {
cardLink += `/${props.cardId}`
}
Utils.copyTextToClipboard(cardLink)
sendFlashMessage({content: intl.formatMessage({id: 'CardDialog.copiedLink', defaultMessage: 'Copied!'}), severity: 'high'})
}}
/>
Utils.copyTextToClipboard(cardLink)
sendFlashMessage({content: intl.formatMessage({id: 'CardDialog.copiedLink', defaultMessage: 'Copied!'}), severity: 'high'})
}}
/>
}
{!isTemplate &&
<BoardPermissionGate permissions={[Permission.ManageBoardProperties]}>
<Menu.Text

View File

@ -58,6 +58,12 @@ describe('src/components/gallery/Gallery', () => {
comments: {
comments: {},
},
users: {
me: {
id: 'user_id_1',
props: {},
},
}
}
const store = mockStateStore([], state)
beforeEach(() => {

View File

@ -85,6 +85,12 @@ describe('src/components/gallery/GalleryCard', () => {
comments: {},
commentsByCard: {},
},
users: {
me: {
id: 'user_id_1',
props: {},
},
},
}
store = mockStateStore([], state)
})
@ -264,6 +270,12 @@ describe('src/components/gallery/GalleryCard', () => {
[board.id]: {userId: 'user_id_1', schemeAdmin: true},
},
},
users: {
me: {
id: 'user_id_1',
props: {},
},
},
}
store = mockStateStore([], state)
})
@ -330,6 +342,12 @@ describe('src/components/gallery/GalleryCard', () => {
[board.id]: {userId: 'user_id_1', schemeAdmin: true},
},
},
users: {
me: {
id: 'user_id_1',
props: {},
},
},
}
store = mockStateStore([], state)
})
@ -391,6 +409,12 @@ describe('src/components/gallery/GalleryCard', () => {
[board.id]: {userId: 'user_id_1', schemeAdmin: true},
},
},
users: {
me: {
id: 'user_id_1',
props: {},
},
},
}
store = mockStateStore([], state)
})
@ -471,6 +495,12 @@ describe('src/components/gallery/GalleryCard', () => {
[board.id]: {userId: 'user_id_1', schemeAdmin: true},
},
},
users: {
me: {
id: 'user_id_1',
props: {},
},
},
}
store = mockStateStore([], state)
})

View File

@ -8,6 +8,8 @@ import {Card} from '../../blocks/card'
import {ContentBlock} from '../../blocks/contentBlock'
import {useSortable} from '../../hooks/sortable'
import mutator from '../../mutator'
import {IUser} from '../../user'
import {getMe} from '../../store/users'
import {getCardContents} from '../../store/contents'
import {useAppSelector} from '../../store/hooks'
import TelemetryClient, {TelemetryActions, TelemetryCategory} from '../../telemetry/telemetryClient'
@ -49,6 +51,7 @@ const GalleryCard = (props: Props) => {
const intl = useIntl()
const [isDragging, isOver, cardRef] = useSortable('card', card, props.isManualSort && !props.readonly, props.onDrop)
const contents = useAppSelector(getCardContents(card.id))
const me = useAppSelector<IUser|null>(getMe)
const visiblePropertyTemplates = props.visiblePropertyTemplates || []
@ -99,21 +102,23 @@ const GalleryCard = (props: Props) => {
}}
/>
</BoardPermissionGate>
<Menu.Text
icon={<LinkIcon/>}
id='copy'
name={intl.formatMessage({id: 'GalleryCard.copyLink', defaultMessage: 'Copy link'})}
onClick={() => {
let cardLink = window.location.href
{me?.id !== 'single-user' &&
<Menu.Text
icon={<LinkIcon/>}
id='copy'
name={intl.formatMessage({id: 'GalleryCard.copyLink', defaultMessage: 'Copy link'})}
onClick={() => {
let cardLink = window.location.href
if (!cardLink.includes(card.id)) {
cardLink += `/${card.id}`
}
if (!cardLink.includes(card.id)) {
cardLink += `/${card.id}`
}
Utils.copyTextToClipboard(cardLink)
sendFlashMessage({content: intl.formatMessage({id: 'GalleryCard.copiedLink', defaultMessage: 'Copied!'}), severity: 'high'})
}}
/>
Utils.copyTextToClipboard(cardLink)
sendFlashMessage({content: intl.formatMessage({id: 'GalleryCard.copiedLink', defaultMessage: 'Copied!'}), severity: 'high'})
}}
/>
}
</Menu>
</MenuWrapper>
}

View File

@ -21,6 +21,9 @@ import Tooltip from '../../widgets/tooltip'
import {Permission} from '../../constants'
import {sendFlashMessage} from '../flashMessages'
import PropertyValueElement from '../propertyValueElement'
import {IUser} from '../../user'
import {getMe} from '../../store/users'
import {useAppSelector} from '../../store/hooks'
import BoardPermissionGate from '../permissions/boardPermissionGate'
@ -51,6 +54,7 @@ const KanbanCard = (props: Props) => {
const [isDragging, isOver, cardRef] = useSortable('card', card, !props.readonly, props.onDrop)
const visiblePropertyTemplates = props.visiblePropertyTemplates || []
const match = useRouteMatch<{boardId: string, viewId: string, cardId?: string}>()
const me = useAppSelector<IUser|null>(getMe)
let className = props.isSelected ? 'KanbanCard selected' : 'KanbanCard'
if (props.isManualSort && isOver) {
className += ' dragover'
@ -142,21 +146,23 @@ const KanbanCard = (props: Props) => {
}}
/>
</BoardPermissionGate>
<Menu.Text
icon={<LinkIcon/>}
id='copy'
name={intl.formatMessage({id: 'KanbanCard.copyLink', defaultMessage: 'Copy link'})}
onClick={() => {
let cardLink = window.location.href
{me?.id !== 'single-user' &&
<Menu.Text
icon={<LinkIcon/>}
id='copy'
name={intl.formatMessage({id: 'KanbanCard.copyLink', defaultMessage: 'Copy link'})}
onClick={() => {
let cardLink = window.location.href
if (!cardLink.includes(card.id)) {
cardLink += `/${card.id}`
}
if (!cardLink.includes(card.id)) {
cardLink += `/${card.id}`
}
Utils.copyTextToClipboard(cardLink)
sendFlashMessage({content: intl.formatMessage({id: 'KanbanCard.copiedLink', defaultMessage: 'Copied!'}), severity: 'high'})
}}
/>
Utils.copyTextToClipboard(cardLink)
sendFlashMessage({content: intl.formatMessage({id: 'KanbanCard.copiedLink', defaultMessage: 'Copied!'}), severity: 'high'})
}}
/>
}
</Menu>
</MenuWrapper>
}