From 27a4da126d56e5fd5c28fedc264c1d7be65c3110 Mon Sep 17 00:00:00 2001 From: Rajat Dabade Date: Tue, 23 Aug 2022 17:01:40 +0530 Subject: [PATCH] Added role so that the non-admin will not be able to unlink the board (#3703) Co-authored-by: Asaad Mahmood --- .../rhsChannelBoardItem.test.tsx.snap | 19 +- .../src/components/rhsChannelBoardItem.scss | 10 +- .../components/rhsChannelBoardItem.test.tsx | 14 +- .../src/components/rhsChannelBoardItem.tsx | 46 ++- .../src/components/rhsChannelBoards.scss | 7 +- .../addContentMenuItem.test.tsx.snap | 32 +- .../blockIconSelector.test.tsx.snap | 24 +- .../__snapshots__/cardDialog.test.tsx.snap | 32 +- .../__snapshots__/contentBlock.test.tsx.snap | 32 +- .../__snapshots__/viewMenu.test.tsx.snap | 128 ++++-- .../cardActionsMenu.test.tsx.snap | 80 +++- .../cardDetailContentsMenu.test.tsx.snap | 120 ++++-- .../cardDetailProperties.test.tsx.snap | 120 ++++-- .../__snapshots__/comment.test.tsx.snap | 32 +- .../__snapshots__/gallery.test.tsx.snap | 48 ++- .../__snapshots__/galleryCard.test.tsx.snap | 160 ++++++-- .../globalHeaderSettingsMenu.test.tsx.snap | 248 ++++++++--- .../__snapshots__/kanbanCard.test.tsx.snap | 96 +++-- .../kanbanColumnHeader.test.tsx.snap | 24 +- .../kanbanHiddenColumnItem.test.tsx.snap | 32 +- .../teamPermissionsRow.test.tsx.snap | 104 +++-- .../sidebarSettingsMenu.test.tsx.snap | 304 ++++++++++---- .../tableHeaderMenu.test.tsx.snap | 104 +++-- .../emptyCardButton.test.tsx.snap | 40 +- .../filterComponent.test.tsx.snap | 184 ++++++--- .../__snapshots__/filterEntry.test.tsx.snap | 384 +++++++++++++----- .../__snapshots__/filterValue.test.tsx.snap | 24 +- .../__snapshots__/newCardButton.test.tsx.snap | 72 +++- .../newCardButtonTemplateItem.test.tsx.snap | 168 ++++++-- .../viewHeaderActionsMenu.test.tsx.snap | 72 +++- .../viewHeaderGroupByMenu.test.tsx.snap | 216 +++++++--- .../viewHeaderPropertiesMenu.test.tsx.snap | 16 +- .../viewHeaderSortMenu.test.tsx.snap | 64 ++- webapp/src/styles/_typography.scss | 5 + .../__snapshots__/propertyMenu.test.tsx.snap | 136 +++++-- webapp/src/widgets/menu/menu.scss | 21 + webapp/src/widgets/menu/textOption.tsx | 16 +- webapp/src/widgets/menuWrapper.scss | 7 +- 38 files changed, 2440 insertions(+), 801 deletions(-) diff --git a/mattermost-plugin/webapp/src/components/__snapshots__/rhsChannelBoardItem.test.tsx.snap b/mattermost-plugin/webapp/src/components/__snapshots__/rhsChannelBoardItem.test.tsx.snap index 9e6b24490..6171f4f2c 100644 --- a/mattermost-plugin/webapp/src/components/__snapshots__/rhsChannelBoardItem.test.tsx.snap +++ b/mattermost-plugin/webapp/src/components/__snapshots__/rhsChannelBoardItem.test.tsx.snap @@ -69,7 +69,7 @@ exports[`components/rhsChannelBoardItem render board with menu open 1`] = ` /> +
{ it('render board', async () => { + const board = createBoard() const state = { teams: { current: { @@ -22,8 +23,12 @@ describe('components/rhsChannelBoardItem', () => { display_name: 'Team name', }, }, + boards: { + myBoardMemberships: { + [board.id]: {userId: 'user_id_1', schemeAdmin: true}, + }, + } } - const board = createBoard() board.updateAt = 1657311058157 board.title = 'Test board' @@ -37,6 +42,7 @@ describe('components/rhsChannelBoardItem', () => { }) it('render board with menu open', async () => { + const board = createBoard() const state = { teams: { current: { @@ -45,8 +51,12 @@ describe('components/rhsChannelBoardItem', () => { display_name: 'Team name', }, }, + boards: { + myBoardMemberships: { + [board.id]: {userId: 'user_id_1', schemeAdmin: true}, + }, + } } - const board = createBoard() board.updateAt = 1657311058157 board.title = 'Test board' diff --git a/mattermost-plugin/webapp/src/components/rhsChannelBoardItem.tsx b/mattermost-plugin/webapp/src/components/rhsChannelBoardItem.tsx index 542fe3a38..679f68e53 100644 --- a/mattermost-plugin/webapp/src/components/rhsChannelBoardItem.tsx +++ b/mattermost-plugin/webapp/src/components/rhsChannelBoardItem.tsx @@ -15,7 +15,10 @@ import Menu from '../../../../webapp/src/widgets/menu' import MenuWrapper from '../../../../webapp/src/widgets/menuWrapper' import {SuiteWindow} from '../../../../webapp/src/types/index' +import {Permission} from '../../../../webapp/src/constants' + import './rhsChannelBoardItem.scss' +import BoardPermissionGate from '../../../../webapp/src/components/permissions/boardPermissionGate' const windowAny = (window as SuiteWindow) @@ -55,18 +58,41 @@ const RHSChannelBoardItem = (props: Props) => { }/> - } - onClick={() => { - onUnlinkBoard(board) - }} - /> + + } + onClick={() => { + onUnlinkBoard(board) + }} + /> + + + } + onClick={() => { + onUnlinkBoard(board) + }} + subText={intl.formatMessage({id: 'rhs-board-non-admin-msg', defaultMessage:'You are not an admin of the board'})} + /> +
diff --git a/mattermost-plugin/webapp/src/components/rhsChannelBoards.scss b/mattermost-plugin/webapp/src/components/rhsChannelBoards.scss index c5fc1a014..856a2bc81 100644 --- a/mattermost-plugin/webapp/src/components/rhsChannelBoards.scss +++ b/mattermost-plugin/webapp/src/components/rhsChannelBoards.scss @@ -1,9 +1,9 @@ .RHSChannelBoards { - padding: 20px; + padding: 16px 24px; height: 100%; display: flex; flex-direction: column; - gap: 10px; + gap: 16px; &.empty { display: flex; @@ -45,7 +45,8 @@ overflow-y: auto; display: flex; flex-direction: column; - gap: 10px; + gap: 16px; + min-height: 100%; } .Button { diff --git a/webapp/src/components/__snapshots__/addContentMenuItem.test.tsx.snap b/webapp/src/components/__snapshots__/addContentMenuItem.test.tsx.snap index 8f010d0e3..4f243aa13 100644 --- a/webapp/src/components/__snapshots__/addContentMenuItem.test.tsx.snap +++ b/webapp/src/components/__snapshots__/addContentMenuItem.test.tsx.snap @@ -21,9 +21,13 @@ exports[`components/addContentMenuItem return a checkbox menu item 1`] = `
.menu-content { + display: block; + } + > .menu-name { overflow: hidden; text-overflow: ellipsis; @@ -98,6 +114,11 @@ text-align: left; } + > .menu-subtext { + font-size: 10px; + text-align: left; + } + > .SubmenuTriangleIcon { fill: rgba(var(--center-channel-color-rgb), 0.7); } diff --git a/webapp/src/widgets/menu/textOption.tsx b/webapp/src/widgets/menu/textOption.tsx index f0e5d2b43..93dd31c04 100644 --- a/webapp/src/widgets/menu/textOption.tsx +++ b/webapp/src/widgets/menu/textOption.tsx @@ -9,14 +9,23 @@ type TextOptionProps = MenuOptionProps & { icon?: React.ReactNode, rightIcon?: React.ReactNode, className?: string + subText?: string + disabled?: boolean } function TextOption(props:TextOptionProps): JSX.Element { - const {name, icon, rightIcon, check} = props + const {name, icon, rightIcon, check, subText, disabled} = props let className = 'MenuOption TextOption menu-option' if (props.className) { className += ' ' + props.className } + if (subText) { + className += ' menu-option--with-subtext' + } + if (disabled) { + className += ' menu-option--disabled' + } + return (
{icon ??
}
-
{name}
+
+
{name}
+ {subText &&
{subText}
} +
{rightIcon ??
}
) diff --git a/webapp/src/widgets/menuWrapper.scss b/webapp/src/widgets/menuWrapper.scss index 39324b4a5..410e44b5e 100644 --- a/webapp/src/widgets/menuWrapper.scss +++ b/webapp/src/widgets/menuWrapper.scss @@ -1,12 +1,13 @@ .MenuWrapper { position: relative; - + cursor: default; + &.disabled { cursor: default; } - - *:first-child { + + *:first-child { /* stylelint-disable property-no-vendor-prefix*/ -webkit-user-select: text; /* Chrome all / Safari all */ -moz-user-select: text; /* Firefox all */