diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000000..8573da1b539 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "focalboard", + "lockfileVersion": 3, + "requires": true, + "packages": {} +} diff --git a/webapp/src/components/boardsSwitcher/boardsSwitcher.tsx b/webapp/src/components/boardsSwitcher/boardsSwitcher.tsx index b129bdff54e..4590e6c2afd 100644 --- a/webapp/src/components/boardsSwitcher/boardsSwitcher.tsx +++ b/webapp/src/components/boardsSwitcher/boardsSwitcher.tsx @@ -99,38 +99,6 @@ const BoardsSwitcher = (props: Props): JSX.Element => { {shouldViewSearchForBoardsTour &&
} - { - Utils.isFocalboardPlugin() && !props.userIsGuest && - - } - title={'Add Board Dropdown'} - /> - - } - onClick={props.onBoardTemplateSelectorOpen} - name='Create new board' - /> - - } - onClick={handleCreateNewCategory} - /> - - - } - { showSwitcher && setShowSwitcher(false)}/> diff --git a/webapp/src/components/cardDialog.tsx b/webapp/src/components/cardDialog.tsx index ec484e66825..eb92babfc4d 100644 --- a/webapp/src/components/cardDialog.tsx +++ b/webapp/src/components/cardDialog.tsx @@ -23,11 +23,6 @@ import ConfirmationDialogBox, {ConfirmationDialogBoxProps} from '../components/c import Button from '../widgets/buttons/button' -import {getUserBlockSubscriptionList} from '../store/initialLoad' -import {getClientConfig} from '../store/clientConfig' - -import {IUser} from '../user' -import {getMe} from '../store/users' import {Permission} from '../constants' import {Block, createBlock} from '../blocks/block' import {AttachmentBlock, createAttachmentBlock} from '../blocks/attachmentBlock' @@ -57,10 +52,8 @@ const CardDialog = (props: Props): JSX.Element => { const contents = useAppSelector(getCardContents(props.cardId)) const comments = useAppSelector(getCardComments(props.cardId)) const attachments = useAppSelector(getCardAttachments(props.cardId)) - const clientConfig = useAppSelector(getClientConfig) const intl = useIntl() const dispatch = useAppDispatch() - const me = useAppSelector(getMe) const isTemplate = card && card.fields.isTemplate const [showConfirmationDialogBox, setShowConfirmationDialogBox] = useState(false) @@ -159,36 +152,31 @@ const CardDialog = (props: Props): JSX.Element => { const attachmentBlock = createAttachmentBlock(uploadingBlock) attachmentBlock.isUploading = true dispatch(updateAttachments([attachmentBlock])) - if (attachment.size > clientConfig.maxFileSize && Utils.isFocalboardPlugin()) { - removeUploadingAttachment(uploadingBlock) - sendFlashMessage({content: intl.formatMessage({id: 'AttachmentBlock.failed', defaultMessage: 'Unable to upload the file. Attachment size limit reached.'}), severity: 'normal'}) - } else { - sendFlashMessage({content: intl.formatMessage({id: 'AttachmentBlock.upload', defaultMessage: 'Attachment uploading.'}), severity: 'normal'}) - const xhr = await octoClient.uploadAttachment(boardId, attachment) - if (xhr) { - xhr.upload.onprogress = (event) => { - const percent = Math.floor((event.loaded / event.total) * 100) - dispatch(updateUploadPrecent({ - blockId: attachmentBlock.id, - uploadPercent: percent, - })) - } + sendFlashMessage({content: intl.formatMessage({id: 'AttachmentBlock.upload', defaultMessage: 'Attachment uploading.'}), severity: 'normal'}) + const xhr = await octoClient.uploadAttachment(boardId, attachment) + if (xhr) { + xhr.upload.onprogress = (event) => { + const percent = Math.floor((event.loaded / event.total) * 100) + dispatch(updateUploadPrecent({ + blockId: attachmentBlock.id, + uploadPercent: percent, + })) + } - xhr.onload = () => { - if (xhr.status === 200 && xhr.readyState === 4) { - const json = JSON.parse(xhr.response) - const fileId = json.fileId - if (fileId) { - removeUploadingAttachment(uploadingBlock) - const block = createAttachmentBlock() - block.fields.fileId = fileId || '' - block.title = attachment.name - sendFlashMessage({content: intl.formatMessage({id: 'AttachmentBlock.uploadSuccess', defaultMessage: 'Attachment uploaded successfull.'}), severity: 'normal'}) - resolve(block) - } else { - removeUploadingAttachment(uploadingBlock) - sendFlashMessage({content: intl.formatMessage({id: 'AttachmentBlock.failed', defaultMessage: 'Unable to upload the file. Attachment size limit reached.'}), severity: 'normal'}) - } + xhr.onload = () => { + if (xhr.status === 200 && xhr.readyState === 4) { + const json = JSON.parse(xhr.response) + const fileId = json.fileId + if (fileId) { + removeUploadingAttachment(uploadingBlock) + const block = createAttachmentBlock() + block.fields.fileId = fileId || '' + block.title = attachment.name + sendFlashMessage({content: intl.formatMessage({id: 'AttachmentBlock.uploadSuccess', defaultMessage: 'Attachment uploaded successfull.'}), severity: 'normal'}) + resolve(block) + } else { + removeUploadingAttachment(uploadingBlock) + sendFlashMessage({content: intl.formatMessage({id: 'AttachmentBlock.failed', defaultMessage: 'Unable to upload the file. Attachment size limit reached.'}), severity: 'normal'}) } } } @@ -236,42 +224,11 @@ const CardDialog = (props: Props): JSX.Element => { ) } - const followActionButton = (following: boolean): React.ReactNode => { - const followBtn = ( - <> - - - ) - - const unfollowBtn = ( - <> - - - ) - - if (!isTemplate && Utils.isFocalboardPlugin() && !card?.limited) { - return (<>{attachBtn()}{following ? unfollowBtn : followBtn}) - } + const followActionButton = (): React.ReactNode => { return (<>{attachBtn()}) } - const followingCards = useAppSelector(getUserBlockSubscriptionList) - const isFollowingCard = Boolean(followingCards.find((following) => following.blockId === props.cardId)) - const toolbar = followActionButton(isFollowingCard) + const toolbar = followActionButton() return ( <> diff --git a/webapp/src/components/kanban/kanbanCard.tsx b/webapp/src/components/kanban/kanbanCard.tsx index a1fc303e700..1c4bf4cc5ef 100644 --- a/webapp/src/components/kanban/kanbanCard.tsx +++ b/webapp/src/components/kanban/kanbanCard.tsx @@ -1,7 +1,6 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import React, {useState, useCallback, useMemo} from 'react' -import {useRouteMatch} from 'react-router-dom' import {useIntl} from 'react-intl' import {Board, IPropertyTemplate} from '../../blocks/board' @@ -16,8 +15,6 @@ import PropertyValueElement from '../propertyValueElement' import ConfirmationDialogBox, {ConfirmationDialogBoxProps} from '../confirmationDialogBox' import './kanbanCard.scss' import CardBadges from '../cardBadges' -import OpenCardTourStep from '../onboardingTour/openCard/open_card' -import CopyLinkTourStep from '../onboardingTour/copyLink/copy_link' import CardActionsMenu from '../cardActionsMenu/cardActionsMenu' import CardActionsMenuIcon from '../cardActionsMenu/cardActionsMenuIcon' @@ -41,7 +38,6 @@ const KanbanCard = (props: Props) => { const intl = useIntl() const [isDragging, isOver, cardRef] = useSortable('card', card, !props.readonly, props.onDrop) const visiblePropertyTemplates = props.visiblePropertyTemplates || [] - const match = useRouteMatch<{boardId: string, viewId: string, cardId?: string}>() let className = props.isSelected ? 'KanbanCard selected' : 'KanbanCard' if (props.isManualSort && isOver) { className += ' dragover' @@ -85,21 +81,18 @@ const KanbanCard = (props: Props) => { } }, [props.onClick, card]) - const isOnboardingCard = card.title === 'Create a new card' - const showOnboarding = isOnboardingCard && !match.params.cardId && !board.isTemplate && Utils.isFocalboardPlugin() - return ( <>
null : cardRef} - className={`${className} ${showOnboarding && OnboardingCardClassName}`} + className={`${className}`} draggable={!props.readonly} style={{opacity: isDragging ? 0.5 : 1}} onClick={handleOnClick} > {!props.readonly && @@ -152,8 +145,6 @@ const KanbanCard = (props: Props) => { ))} {props.visibleBadges && } - {showOnboarding && !match.params.cardId && } - {showOnboarding && !match.params.cardId && }
{showConfirmationDialogBox && } diff --git a/webapp/src/components/shareBoard/channelPermissionsRow.tsx b/webapp/src/components/shareBoard/channelPermissionsRow.tsx index 1b29915b8bb..8287c2f8fec 100644 --- a/webapp/src/components/shareBoard/channelPermissionsRow.tsx +++ b/webapp/src/components/shareBoard/channelPermissionsRow.tsx @@ -14,7 +14,6 @@ import {getBoardUsers} from '../../store/users' import {Channel} from '../../store/channels' import {Utils} from '../../utils' import mutator from '../../mutator' -import octoClient from '../../octoClient' import {Permission} from '../../constants' import PrivateIcon from '../../widgets/icons/lockOutline' @@ -44,20 +43,7 @@ const ChannelPermissionsRow = (props: Props): JSX.Element => { } useEffect(() => { - if (!Utils.isFocalboardPlugin() || !board.channelId) { - setLinkedChannel(null) - return - } - const unknownChannel = { - id: board.channelId, - type: 'P', - name: 'unknown', - display_name: intl.formatMessage({ - id: 'shareBoard.unknown-channel-display-name', - defaultMessage: 'Unknown channel', - }), - } as Channel - octoClient.getChannel(board.teamId, board.channelId).then((c) => setLinkedChannel(c || unknownChannel)) + setLinkedChannel(null) }, [board.channelId]) if (!linkedChannel) { diff --git a/webapp/src/components/shareBoard/shareBoard.tsx b/webapp/src/components/shareBoard/shareBoard.tsx index 3c0199d581e..5427ee5917c 100644 --- a/webapp/src/components/shareBoard/shareBoard.tsx +++ b/webapp/src/components/shareBoard/shareBoard.tsx @@ -10,7 +10,7 @@ import {CSSObject} from '@emotion/serialize' import {useAppSelector} from '../../store/hooks' import {getCurrentBoard, getCurrentBoardMembers} from '../../store/boards' -import {Channel, ChannelTypeOpen, ChannelTypePrivate} from '../../store/channels' +import {Channel} from '../../store/channels' import {getMe, getBoardUsersList} from '../../store/users' import {ClientConfig} from '../../config/clientConfig' @@ -40,8 +40,6 @@ import {getSelectBaseStyle} from '../../theme' import CompassIcon from '../../widgets/icons/compassIcon' import IconButton from '../../widgets/buttons/iconButton' import SearchIcon from '../../widgets/icons/search' -import PrivateIcon from '../../widgets/icons/lockOutline' -import PublicIcon from '../../widgets/icons/globe' import BoardPermissionGate from '../permissions/boardPermissionGate' @@ -301,12 +299,6 @@ export default function ShareBoardDialog(props: Props): JSX.Element { const user = userOrChannel as IUser return (
- {Utils.isFocalboardPlugin() && - - }
{Utils.getUserDisplayName(user, clientConfig.teammateNameDisplay)} {`@${user.username}`} @@ -317,20 +309,7 @@ export default function ShareBoardDialog(props: Props): JSX.Element { ) } - if (!Utils.isFocalboardPlugin()) { - return null - } - - const channel = userOrChannel as Channel - return ( -
- {channel.type === ChannelTypePrivate && } - {channel.type === ChannelTypeOpen && } -
- {channel.display_name} -
-
- ) + return null } let confirmSubtext @@ -380,22 +359,8 @@ export default function ShareBoardDialog(props: Props): JSX.Element { }} loadOptions={async (inputValue: string) => { const result = [] - if (Utils.isFocalboardPlugin()) { - const excludeBots = true - const users = await client.searchTeamUsers(inputValue, excludeBots) - if (users) { - result.push({label: intl.formatMessage({id: 'shareBoard.members-select-group', defaultMessage: 'Members'}), options: users || []}) - } - if (!board.isTemplate) { - const channels = await client.searchUserChannels(match.params.teamId || '', inputValue) - if (channels) { - result.push({label: intl.formatMessage({id: 'shareBoard.channels-select-group', defaultMessage: 'Channels'}), options: channels || []}) - } - } - } else { - const users = await client.searchTeamUsers(inputValue) || [] - result.push(...users) - } + const users = await client.searchTeamUsers(inputValue) || [] + result.push(...users) return result }} components={{DropdownIndicator: () => null, IndicatorSeparator: () => null}} @@ -404,9 +369,7 @@ export default function ShareBoardDialog(props: Props): JSX.Element { getOptionValue={(u) => u.id} getOptionLabel={(u: IUser|Channel) => (u as IUser).username || (u as Channel).display_name} isMulti={false} - placeholder={board.isTemplate ? - intl.formatMessage({id: 'ShareTemplate.searchPlaceholder', defaultMessage: 'Search for people'}) : - intl.formatMessage({id: 'ShareBoard.searchPlaceholder', defaultMessage: 'Search for people and channels'}) + placeholder={board.isTemplate ? intl.formatMessage({id: 'ShareTemplate.searchPlaceholder', defaultMessage: 'Search for people'}) : intl.formatMessage({id: 'ShareBoard.searchPlaceholder', defaultMessage: 'Search for people and channels'}) } onChange={(newValue) => { if (newValue && (newValue as IUser).username) { diff --git a/webapp/src/components/shareBoard/teamPermissionsRow.tsx b/webapp/src/components/shareBoard/teamPermissionsRow.tsx index 7f16f8e1d5f..46366ceb4fd 100644 --- a/webapp/src/components/shareBoard/teamPermissionsRow.tsx +++ b/webapp/src/components/shareBoard/teamPermissionsRow.tsx @@ -15,7 +15,6 @@ import {useAppSelector} from '../../store/hooks' import {getCurrentTeam} from '../../store/teams' import {getCurrentBoard} from '../../store/boards' import {Permission} from '../../constants' -import {Utils} from '../../utils' import BoardPermissionGate from '../permissions/boardPermissionGate' import ConfirmationDialogBox from '../confirmationDialogBox' @@ -93,12 +92,6 @@ const TeamPermissionsRow = (): JSX.Element => {
{changeRoleConfirmation && confirmationDialog}
- {Utils.isFocalboardPlugin() && - - }
{intl.formatMessage({id: 'ShareBoard.teamPermissionsText', defaultMessage: 'Everyone at {teamName} Team'}, {teamName: team?.title})}
diff --git a/webapp/src/components/shareBoard/userPermissionsRow.tsx b/webapp/src/components/shareBoard/userPermissionsRow.tsx index 303308d6f4b..42dd8bb734a 100644 --- a/webapp/src/components/shareBoard/userPermissionsRow.tsx +++ b/webapp/src/components/shareBoard/userPermissionsRow.tsx @@ -55,12 +55,6 @@ const UserPermissionsRow = (props: Props): JSX.Element => { ref={menuWrapperRef} >
- {Utils.isFocalboardPlugin() && - - }
{Utils.getUserDisplayName(user, teammateNameDisplay)} {`@${user.username}`} diff --git a/webapp/src/components/sidebar/sidebar.tsx b/webapp/src/components/sidebar/sidebar.tsx index bd50edfdc2a..81fde5b8c15 100644 --- a/webapp/src/components/sidebar/sidebar.tsx +++ b/webapp/src/components/sidebar/sidebar.tsx @@ -345,41 +345,25 @@ const Sidebar = (props: Props) => { return (
- {!Utils.isFocalboardPlugin() && -
-
- -
+
+
+ +
-
-
- { - setUserHidden(true) - setHidden(true) - }} - icon={} - /> -
-
} +
+
+ { + setUserHidden(true) + setHidden(true) + }} + icon={} + /> +
+
{team && team.id !== Constants.globalTeamId && -
- {Utils.isFocalboardPlugin() && - <> -
-
- { - setUserHidden(true) - setHidden(true) - }} - icon={} - /> -
- - } -
+
} {
- { - (!Utils.isFocalboardPlugin()) && -
- -
- } +
+ +
- {!Utils.isFocalboardPlugin() && - } +
) } diff --git a/webapp/src/components/sidebar/sidebarUserMenu.tsx b/webapp/src/components/sidebar/sidebarUserMenu.tsx index 622e09a32bd..8627bcb6589 100644 --- a/webapp/src/components/sidebar/sidebarUserMenu.tsx +++ b/webapp/src/components/sidebar/sidebarUserMenu.tsx @@ -13,7 +13,6 @@ import Menu from '../../widgets/menu' import MenuWrapper from '../../widgets/menuWrapper' import {getMe, setMe} from '../../store/users' import {useAppSelector, useAppDispatch} from '../../store/hooks' -import {Utils} from '../../utils' import ModalWrapper from '../modalWrapper' @@ -32,9 +31,6 @@ const SidebarUserMenu = () => { const user = useAppSelector(getMe) const intl = useIntl() - if (Utils.isFocalboardPlugin()) { - return <> - } return (
diff --git a/webapp/src/components/topBar.tsx b/webapp/src/components/topBar.tsx index 97b4f4e56ad..37d299fa8cc 100644 --- a/webapp/src/components/topBar.tsx +++ b/webapp/src/components/topBar.tsx @@ -7,39 +7,9 @@ import './topBar.scss' import {FormattedMessage} from 'react-intl' import HelpIcon from '../widgets/icons/help' -import {Utils} from '../utils' import {Constants} from '../constants' const TopBar = (): JSX.Element => { - if (Utils.isFocalboardPlugin()) { - const feedbackUrl = 'https://www.focalboard.com/fwlink/feedback-boards.html?v=' + Constants.versionString - return ( -
- - - -
-
- {`v${Constants.versionString}`} -
-
-
- ) - } - const focalboardFeedbackUrl = 'https://www.focalboard.com/fwlink/feedback-focalboard.html?v=' + Constants.versionString return (
{ return } - if (!Utils.isFocalboardPlugin()) { - const token = localStorage.getItem('focalboardSessionId') || queryString.get('r') || '' - if (token) { - wsClient.authenticate(token) - } - wsClient.open() - return - } - - if (!props.webSocketClient) { - Utils.logWarn('Trying to initialise Boards websocket in plugin mode without base connection. Aborting') - return - } - - if (!props.manifest?.id || !props.manifest?.version) { - Utils.logError('Trying to initialise Boards websocket in plugin mode with an incomplete manifest. Aborting') - return + const token = localStorage.getItem('focalboardSessionId') || queryString.get('r') || '' + if (token) { + wsClient.authenticate(token) } - - wsClient.initPlugin(props.manifest?.id, props.manifest?.version, props.webSocketClient) wsClient.open() }, [props.webSocketClient]) useEffect(() => { // if we're running on a plugin instance or we don't have a // user yet, do nothing - if (Utils.isFocalboardPlugin() || !props.userId) { + if (!props.userId) { return } diff --git a/webapp/src/pages/boardPage/boardPage.tsx b/webapp/src/pages/boardPage/boardPage.tsx index a2b4e953b76..72fcaca2201 100644 --- a/webapp/src/pages/boardPage/boardPage.tsx +++ b/webapp/src/pages/boardPage/boardPage.tsx @@ -37,7 +37,6 @@ import {updateComments} from '../../store/comments' import {updateAttachments} from '../../store/attachments' import {updateContents} from '../../store/contents' import { - fetchUserBlockSubscriptions, getMe, followBlock, unfollowBlock, @@ -88,17 +87,6 @@ const BoardPage = (props: Props): JSX.Element => { window.location.href = window.location.href.replace('/plugins/focalboard', '/boards') } - // Load user's block subscriptions when workspace changes - // block subscriptions are relevant only in plugin mode. - if (Utils.isFocalboardPlugin()) { - useEffect(() => { - if (!me) { - return - } - dispatch(fetchUserBlockSubscriptions(me!.id)) - }, [me?.id]) - } - // TODO: Make this less brittle. This only works because this is the root render function useEffect(() => { UserSettings.lastTeamId = teamId diff --git a/webapp/src/pages/boardPage/setWindowTitleAndIcon.tsx b/webapp/src/pages/boardPage/setWindowTitleAndIcon.tsx index 2253714302a..fbada1471d5 100644 --- a/webapp/src/pages/boardPage/setWindowTitleAndIcon.tsx +++ b/webapp/src/pages/boardPage/setWindowTitleAndIcon.tsx @@ -22,8 +22,6 @@ const SetWindowTitleAndIcon = (): null => { title += ` | ${activeView.title}` } document.title = title - } else if (Utils.isFocalboardPlugin()) { - document.title = 'Boards - Mattermost' } else { document.title = 'Focalboard' } diff --git a/webapp/src/pages/errorPage.tsx b/webapp/src/pages/errorPage.tsx index 37504544b47..d8d6c472c8e 100644 --- a/webapp/src/pages/errorPage.tsx +++ b/webapp/src/pages/errorPage.tsx @@ -10,7 +10,6 @@ import Button from '../widgets/buttons/button' import './errorPage.scss' import {errorDefFromId, ErrorId} from '../errors' -import {Utils} from '../utils' const ErrorPage = () => { const history = useHistory() @@ -46,7 +45,7 @@ const ErrorPage = () => { ) }) - if (!Utils.isFocalboardPlugin() && errid === ErrorId.NotLoggedIn) { + if (errid === ErrorId.NotLoggedIn) { handleButtonClick(errorDef.button1Redirect) } diff --git a/webapp/src/route.tsx b/webapp/src/route.tsx index 46063b700ef..e6d6cbc73e9 100644 --- a/webapp/src/route.tsx +++ b/webapp/src/route.tsx @@ -7,12 +7,8 @@ import { } from 'react-router-dom' import {Utils} from './utils' -import {getLoggedIn, getMe, getMyConfig} from './store/users' +import {getLoggedIn} from './store/users' import {useAppSelector} from './store/hooks' -import {UserSettingKey} from './userSettings' -import {IUser} from './user' -import {getClientConfig} from './store/clientConfig' -import {ClientConfig} from './config/clientConfig' type RouteProps = { path: string|string[] @@ -26,31 +22,8 @@ type RouteProps = { function FBRoute(props: RouteProps) { const loggedIn = useAppSelector(getLoggedIn) - const me = useAppSelector(getMe) - const myConfig = useAppSelector(getMyConfig) - const clientConfig = useAppSelector(getClientConfig) - let redirect: React.ReactNode = null - // No FTUE for guests - const disableTour = me?.is_guest || clientConfig?.featureFlags?.disableTour || false - - const showWelcomePage = !disableTour && - Utils.isFocalboardPlugin() && - (me?.id !== 'single-user') && - props.path !== '/welcome' && - loggedIn === true && - !myConfig[UserSettingKey.WelcomePageViewed] - - if (showWelcomePage) { - redirect = ({match}: any) => { - if (props.getOriginalPath) { - return - } - return - } - } - if (redirect === null && loggedIn === false && props.loginRequired) { redirect = ({match}: any) => { if (props.getOriginalPath) { diff --git a/webapp/src/router.tsx b/webapp/src/router.tsx index 01b67f1ee7e..2421a8f4d71 100644 --- a/webapp/src/router.tsx +++ b/webapp/src/router.tsx @@ -3,7 +3,6 @@ import React, {useEffect, useMemo} from 'react' import { Router, - Redirect, Switch, useRouteMatch, useHistory, @@ -12,10 +11,8 @@ import { } from 'react-router-dom' import {createBrowserHistory, History} from 'history' -import {IAppWindow} from './types' import BoardPage from './pages/boardPage/boardPage' import ChangePasswordPage from './pages/changePasswordPage' -import WelcomePage from './pages/welcome/welcomePage' import ErrorPage from './pages/errorPage' import LoginPage from './pages/loginPage' import RegisterPage from './pages/registerPage' @@ -23,52 +20,10 @@ import {Utils} from './utils' import octoClient from './octoClient' import {setGlobalError, getGlobalError} from './store/globalError' import {useAppSelector, useAppDispatch} from './store/hooks' -import {getFirstTeam, fetchTeams, Team} from './store/teams' -import {UserSettings} from './userSettings' import FBRoute from './route' -declare let window: IAppWindow - const UUID_REGEX = new RegExp(/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/) -function HomeToCurrentTeam(props: {path: string, exact: boolean}) { - return ( - { - const firstTeam = useAppSelector(getFirstTeam) - const dispatch = useAppDispatch() - useEffect(() => { - dispatch(fetchTeams()) - }, []) - - let teamID = (window.getCurrentTeamId && window.getCurrentTeamId()) || '' - const lastTeamID = UserSettings.lastTeamId - if (!teamID && !firstTeam && !lastTeamID) { - return <> - } - teamID = teamID || lastTeamID || firstTeam?.id || '' - - if (UserSettings.lastBoardId) { - const lastBoardID = UserSettings.lastBoardId[teamID] - const lastViewID = UserSettings.lastViewId[lastBoardID] - - if (lastBoardID && lastViewID) { - return - } - if (lastBoardID) { - return - } - } - - return - }} - /> - ) -} - function WorkspaceToTeamRedirect() { const match = useRouteMatch<{boardId: string, viewId: string, cardId?: string, workspaceId?: string}>() const queryParams = new URLSearchParams(useLocation().search) @@ -112,8 +67,6 @@ type Props = { } const FocalboardRouter = (props: Props): JSX.Element => { - const isPlugin = Utils.isFocalboardPlugin() - let browserHistory: History if (props.history) { browserHistory = props.history @@ -123,47 +76,23 @@ const FocalboardRouter = (props: Props): JSX.Element => { }, []) } - if (isPlugin) { - useEffect(() => { - if (window.frontendBaseURL) { - browserHistory.replace(window.location.pathname.replace(window.frontendBaseURL, '')) - } - }, []) - } - return ( - {isPlugin && - } - {isPlugin && - - - } - - {!isPlugin && - - - } - {!isPlugin && - - - } - {!isPlugin && - - - } + + + + + + + + + @@ -195,20 +124,19 @@ const FocalboardRouter = (props: Props): JSX.Element => { - {!isPlugin && - { - const boardIdIsValidUUIDV4 = UUID_REGEX.test(boardId || '') - if (boardIdIsValidUUIDV4) { - return `/${Utils.buildOriginalPath('', boardId, viewId, cardId)}` - } - return '' - }} - > - - } + { + const boardIdIsValidUUIDV4 = UUID_REGEX.test(boardId || '') + if (boardIdIsValidUUIDV4) { + return `/${Utils.buildOriginalPath('', boardId, viewId, cardId)}` + } + return '' + }} + > + + ) diff --git a/webapp/src/store/users.ts b/webapp/src/store/users.ts index cb5a71a0a13..6446c6ae63a 100644 --- a/webapp/src/store/users.ts +++ b/webapp/src/store/users.ts @@ -6,8 +6,6 @@ import {createSlice, createAsyncThunk, PayloadAction, createSelector} from '@red import {default as client} from '../octoClient' import {IUser, parseUserProps, UserPreference} from '../user' -import {Utils} from '../utils' - import {Subscription} from '../wsclient' import {initialLoad} from './initialLoad' @@ -37,7 +35,7 @@ type UsersStatus = { export const fetchUserBlockSubscriptions = createAsyncThunk( 'user/blockSubscriptions', - async (userId: string) => (Utils.isFocalboardPlugin() ? client.getUserBlockSubscriptions(userId) : []), + async () => ([]), ) const initialState = { diff --git a/webapp/src/theme.ts b/webapp/src/theme.ts index f4616098186..160931d9db3 100644 --- a/webapp/src/theme.ts +++ b/webapp/src/theme.ts @@ -5,8 +5,6 @@ import {CSSObject} from '@emotion/serialize' import isEqual from 'lodash/isEqual' import color from 'color' -import {Utils} from './utils' - let activeThemeName: string import {UserSettings} from './userSettings' @@ -124,67 +122,20 @@ export function setTheme(theme: Theme | null): Theme { setActiveThemeName(consolidatedTheme, theme) - if (Utils.isFocalboardPlugin()) { - // in plugin mode, Focalbaord reuses Mattermost's color pallet, so we don't really need to - // set the color variables here because in the app, Mattermost webapp would have already - // declared them. - // But, - // when testing the plugin mode in Jest unit test, - // since there is no Mattermost webapp, we need to ensure someone declares the variables. - // So here we set the variable if it wasn't already declared. - // In plugins, since Mattermost webapp renders always before the plugin/product, - // the variables are guaranteed to be set there. - // - // Fun fact - in a Jest test suite, if there are some non-plugin tests and a few plugin tests, - // if a non-plugin test ran first, it creates the variables in document, which is somehow - // shared to other tests as well. That's why the tests don't fail unless you run ONLY - // a plugin test. - - const style = document.documentElement.style - - style.setProperty('--center-channel-bg-rgb', style.getPropertyValue('--center-channel-bg-rgb') || consolidatedTheme.mainBg) - style.setProperty('--center-channel-color-rgb', style.getPropertyValue('--center-channel-color-rgb') || consolidatedTheme.mainBg) - style.setProperty('--button-bg-rgb', style.getPropertyValue('--button-bg-rgb') || consolidatedTheme.mainBg) - style.setProperty('--button-color-rgb', style.getPropertyValue('--button-color-rgb') || consolidatedTheme.mainBg) - style.setProperty('--sidebar-bg-rgb', style.getPropertyValue('--sidebar-bg-rgb') || consolidatedTheme.mainBg) - style.setProperty('--sidebar-text-rgb', style.getPropertyValue('--sidebar-text-rgb') || consolidatedTheme.mainBg) - style.setProperty('--link-color-rgb', style.getPropertyValue('--link-color-rgb') || consolidatedTheme.mainBg) - style.setProperty('--sidebar-text-active-border-rgb', style.getPropertyValue('--sidebar-text-active-border-rgb') || consolidatedTheme.mainBg) - } else { - // for personal server and desktop, Focalboard is responsible for managing the theme, - // so we set all the color variables here. - document.documentElement.style.setProperty('--center-channel-bg-rgb', consolidatedTheme.mainBg) - document.documentElement.style.setProperty('--center-channel-color-rgb', consolidatedTheme.mainFg) - document.documentElement.style.setProperty('--button-bg-rgb', consolidatedTheme.buttonBg) - document.documentElement.style.setProperty('--button-color-rgb', consolidatedTheme.buttonFg) - document.documentElement.style.setProperty('--sidebar-bg-rgb', consolidatedTheme.sidebarBg) - document.documentElement.style.setProperty('--sidebar-text-rgb', consolidatedTheme.sidebarFg) - document.documentElement.style.setProperty('--link-color-rgb', consolidatedTheme.link) - document.documentElement.style.setProperty('--sidebar-text-active-border-rgb', consolidatedTheme.sidebarTextActiveBorder) - } + // for personal server and desktop, Focalboard is responsible for managing the theme, + // so we set all the color variables here. + document.documentElement.style.setProperty('--center-channel-bg-rgb', consolidatedTheme.mainBg) + document.documentElement.style.setProperty('--center-channel-color-rgb', consolidatedTheme.mainFg) + document.documentElement.style.setProperty('--button-bg-rgb', consolidatedTheme.buttonBg) + document.documentElement.style.setProperty('--button-color-rgb', consolidatedTheme.buttonFg) + document.documentElement.style.setProperty('--sidebar-bg-rgb', consolidatedTheme.sidebarBg) + document.documentElement.style.setProperty('--sidebar-text-rgb', consolidatedTheme.sidebarFg) + document.documentElement.style.setProperty('--link-color-rgb', consolidatedTheme.link) + document.documentElement.style.setProperty('--sidebar-text-active-border-rgb', consolidatedTheme.sidebarTextActiveBorder) document.documentElement.style.setProperty('--sidebar-white-logo', consolidatedTheme.sidebarWhiteLogo) document.documentElement.style.setProperty('--link-visited-color-rgb', consolidatedTheme.linkVisited) - const mainBgColor = color(`rgb(${getComputedStyle(document.documentElement).getPropertyValue('--center-channel-bg-rgb')})`) - - if (Utils.isFocalboardPlugin()) { - let fixedTheme = lightTheme - if (mainBgColor.isDark()) { - fixedTheme = darkTheme - } - consolidatedTheme.propDefault = fixedTheme.propDefault - consolidatedTheme.propGray = fixedTheme.propGray - consolidatedTheme.propBrown = fixedTheme.propBrown - consolidatedTheme.propOrange = fixedTheme.propOrange - consolidatedTheme.propYellow = fixedTheme.propYellow - consolidatedTheme.propGreen = fixedTheme.propGreen - consolidatedTheme.propBlue = fixedTheme.propBlue - consolidatedTheme.propPurple = fixedTheme.propPurple - consolidatedTheme.propPink = fixedTheme.propPink - consolidatedTheme.propRed = fixedTheme.propRed - } - document.documentElement.style.setProperty('--prop-default', consolidatedTheme.propDefault) document.documentElement.style.setProperty('--prop-gray', consolidatedTheme.propGray) document.documentElement.style.setProperty('--prop-brown', consolidatedTheme.propBrown) diff --git a/webapp/src/utils.ts b/webapp/src/utils.ts index 3a2954d180f..d3779911128 100644 --- a/webapp/src/utils.ts +++ b/webapp/src/utils.ts @@ -424,11 +424,6 @@ class Utils { // favicon static setFavicon(icon?: string): void { - if (Utils.isFocalboardPlugin()) { - // Do not change the icon from focalboard plugin - return - } - if (!icon) { document.querySelector("link[rel*='icon']")?.remove() return @@ -583,11 +578,6 @@ class Utils { } static buildURL(path: string, absolute?: boolean): string { - /* eslint-disable no-process-env */ - if (!Utils.isFocalboardPlugin() || process.env.TARGET_IS_PRODUCT) { - return path - } - const baseURL = Utils.getBaseURL() let finalPath = baseURL + path if (path.indexOf('/') !== 0) { @@ -606,10 +596,6 @@ class Utils { return Math.round(num * Math.pow(10, decimalPlaces)) / Math.pow(10, decimalPlaces) } - static isFocalboardPlugin(): boolean { - return Boolean(window.isFocalboardPlugin) - } - // this is a temporary solution while we're using legacy routes // for shared boards as a way to check if we're accessing the // legacy routes inside the plugin