Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
mattermost-webapp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
sysadmin
mattermost
mattermost-webapp
Commits
eeff695d
Commit
eeff695d
authored
Dec 11, 2018
by
George Goldberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MM-13425: Fix set header option in DM/GM dropdown. (#2175)
Should not depend on permissions for these channel types.
parent
8b3fab7d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
116 additions
and
26 deletions
+116
-26
components/channel_header_dropdown/menu_items/set_channel_header.js
.../channel_header_dropdown/menu_items/set_channel_header.js
+30
-22
components/channel_header_dropdown/menu_items/set_channel_header.test.js
...nel_header_dropdown/menu_items/set_channel_header.test.js
+86
-4
No files found.
components/channel_header_dropdown/menu_items/set_channel_header.js
View file @
eeff695d
...
@@ -20,31 +20,39 @@ const SetChannelHeader = ({channel, isArchived, isReadonly}) => {
...
@@ -20,31 +20,39 @@ const SetChannelHeader = ({channel, isArchived, isReadonly}) => {
return
null
;
return
null
;
}
}
let
menuItem
=
(
<
li
role
=
'
presentation
'
>
<
ToggleModalButtonRedux
id
=
'
channelEditHeader
'
role
=
'
menuitem
'
modalId
=
{
ModalIdentifiers
.
EDIT_CHANNEL_HEADER
}
dialogType
=
{
EditChannelHeaderModal
}
dialogProps
=
{{
channel
}}
>
<
FormattedMessage
id
=
'
channel_header.setHeader
'
defaultMessage
=
'
Edit Channel Header
'
/>
<
/ToggleModalButtonRedux
>
<
/li
>
);
const
isPrivate
=
channel
.
type
===
Constants
.
PRIVATE_CHANNEL
;
const
isPrivate
=
channel
.
type
===
Constants
.
PRIVATE_CHANNEL
;
const
permission
=
isPrivate
?
Permissions
.
MANAGE_PRIVATE_CHANNEL_PROPERTIES
:
Permissions
.
MANAGE_PUBLIC_CHANNEL_PROPERTIES
;
const
permission
=
isPrivate
?
Permissions
.
MANAGE_PRIVATE_CHANNEL_PROPERTIES
:
Permissions
.
MANAGE_PUBLIC_CHANNEL_PROPERTIES
;
return
(
if
(
channel
.
type
!==
Constants
.
DM_CHANNEL
&&
channel
.
type
!==
Constants
.
GM_CHANNEL
)
{
<
ChannelPermissionGate
menuItem
=
(
channelId
=
{
channel
.
id
}
<
ChannelPermissionGate
teamId
=
{
channel
.
team_id
}
channelId
=
{
channel
.
id
}
permissions
=
{[
permission
]}
teamId
=
{
channel
.
team_id
}
>
permissions
=
{[
permission
]}
<
li
role
=
'
presentation
'
>
>
<
ToggleModalButtonRedux
{
menuItem
}
id
=
'
channelEditHeader
'
<
/ChannelPermissionGate
>
role
=
'
menuitem
'
);
modalId
=
{
ModalIdentifiers
.
EDIT_CHANNEL_HEADER
}
}
dialogType
=
{
EditChannelHeaderModal
}
dialogProps
=
{{
channel
}}
return
menuItem
;
>
<
FormattedMessage
id
=
'
channel_header.setHeader
'
defaultMessage
=
'
Edit Channel Header
'
/>
<
/ToggleModalButtonRedux
>
<
/li
>
<
/ChannelPermissionGate
>
);
};
};
SetChannelHeader
.
propTypes
=
{
SetChannelHeader
.
propTypes
=
{
...
...
components/channel_header_dropdown/menu_items/set_channel_header.test.js
View file @
eeff695d
...
@@ -46,18 +46,100 @@ describe('components/ChannelHeaderDropdown/MenuItem.SetChannelHeader', () => {
...
@@ -46,18 +46,100 @@ describe('components/ChannelHeaderDropdown/MenuItem.SetChannelHeader', () => {
expect
(
wrapper
.
isEmptyRender
()).
toBeTruthy
();
expect
(
wrapper
.
isEmptyRender
()).
toBeTruthy
();
});
});
it
(
'
should requires right permission level for channel type to manage header
'
,
()
=>
{
it
(
'
should not be permissions gated for a DM channel
'
,
()
=>
{
const
props
=
{
...
baseProps
,
channel
:
{
...
baseProps
.
channel
,
type
:
Constants
.
DM_CHANNEL
,
},
};
const
wrapper
=
shallow
(
<
SetChannelHeader
{...
props
}
/>
)
;
expect
(
wrapper
).
toMatchInlineSnapshot
(
`
<li
role="presentation"
>
<Connect(ModalToggleButtonRedux)
dialogProps={
Object {
"channel": Object {
"id": "channel_id",
"team_id": "team_id",
"type": "D",
},
}
}
dialogType={[Function]}
id="channelEditHeader"
modalId="edit_channel_header"
role="menuitem"
>
<FormattedMessage
defaultMessage="Edit Channel Header"
id="channel_header.setHeader"
values={Object {}}
/>
</Connect(ModalToggleButtonRedux)>
</li>
`
);
});
it
(
'
should not be permissions gated for a GM channel
'
,
()
=>
{
const
props
=
{
...
baseProps
,
channel
:
{
...
baseProps
.
channel
,
type
:
Constants
.
GM_CHANNEL
,
},
};
const
wrapper
=
shallow
(
<
SetChannelHeader
{...
props
}
/>
)
;
expect
(
wrapper
).
toMatchInlineSnapshot
(
`
<li
role="presentation"
>
<Connect(ModalToggleButtonRedux)
dialogProps={
Object {
"channel": Object {
"id": "channel_id",
"team_id": "team_id",
"type": "G",
},
}
}
dialogType={[Function]}
id="channelEditHeader"
modalId="edit_channel_header"
role="menuitem"
>
<FormattedMessage
defaultMessage="Edit Channel Header"
id="channel_header.setHeader"
values={Object {}}
/>
</Connect(ModalToggleButtonRedux)>
</li>
`
);
});
it
(
'
should requires right permission level for channel type to manage header in Public and Private channels
'
,
()
=>
{
const
props
=
{
const
props
=
{
...
baseProps
,
...
baseProps
,
channel
:
{...
baseProps
.
channel
},
channel
:
{...
baseProps
.
channel
},
};
};
const
makeWrapper
=
()
=>
shallow
(
<
SetChannelHeader
{...
props
}
/>
)
;
const
makeWrapper
=
()
=>
shallow
(
<
SetChannelHeader
{...
props
}
/>
)
;
// Public
, DM, GM (is this correct?)
// Public
Channel
props
.
channel
.
type
=
Constants
.
OPEN_CHANNEL
;
props
.
channel
.
type
=
Constants
.
OPEN_CHANNEL
;
expect
(
makeWrapper
().
prop
(
'
permissions
'
)[
0
]).
toBe
(
Permissions
.
MANAGE_PUBLIC_CHANNEL_PROPERTIES
);
expect
(
makeWrapper
().
prop
(
'
permissions
'
)[
0
]).
toBe
(
Permissions
.
MANAGE_PUBLIC_CHANNEL_PROPERTIES
);
props
.
channel
.
type
=
Constants
.
PRIVATE_CHANNEL
;
props
.
channel
.
type
=
Constants
.
PRIVATE_CHANNEL
;
expect
(
makeWrapper
().
prop
(
'
permissions
'
)[
0
]).
toBe
(
Permissions
.
MANAGE_PRIVATE_CHANNEL_PROPERTIES
);
expect
(
makeWrapper
().
prop
(
'
permissions
'
)[
0
]).
toBe
(
Permissions
.
MANAGE_PRIVATE_CHANNEL_PROPERTIES
);
});
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment