Do not show the playbooks item on DMs/GMs (#9098)
Co-authored-by: Mattermost Build <build@mattermost.com>
This commit is contained in:
parent
303dbf3367
commit
82c7787dc4
6 changed files with 64 additions and 5 deletions
|
|
@ -4,6 +4,7 @@
|
|||
import React, {type ComponentProps} from 'react';
|
||||
|
||||
import NavigationHeader from '@components/navigation_header';
|
||||
import {General} from '@constants';
|
||||
import {useServerUrl} from '@context/server';
|
||||
import {fetchPlaybookRunsForChannel} from '@playbooks/actions/remote/runs';
|
||||
import {goToPlaybookRun, goToPlaybookRuns} from '@playbooks/screens/navigation';
|
||||
|
|
@ -75,6 +76,45 @@ describe('ChannelHeader', () => {
|
|||
);
|
||||
});
|
||||
|
||||
it('does not show playbook button when is DM or GM', () => {
|
||||
const props = getBaseProps();
|
||||
props.hasPlaybookRuns = true;
|
||||
props.playbooksActiveRuns = 1;
|
||||
props.channelType = General.DM_CHANNEL;
|
||||
const {getByTestId, rerender} = renderWithIntl(<ChannelHeader {...props}/>);
|
||||
const navHeader = getByTestId('navigation-header');
|
||||
let rightButtons = navHeader.props.rightButtons;
|
||||
expect(rightButtons).not.toEqual(expect.arrayContaining(
|
||||
[
|
||||
expect.objectContaining({
|
||||
iconName: 'product-playbooks',
|
||||
}),
|
||||
]),
|
||||
);
|
||||
|
||||
props.channelType = General.GM_CHANNEL;
|
||||
rerender(<ChannelHeader {...props}/>);
|
||||
rightButtons = navHeader.props.rightButtons;
|
||||
expect(rightButtons).not.toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
iconName: 'product-playbooks',
|
||||
}),
|
||||
]),
|
||||
);
|
||||
|
||||
props.channelType = General.OPEN_CHANNEL;
|
||||
rerender(<ChannelHeader {...props}/>);
|
||||
rightButtons = navHeader.props.rightButtons;
|
||||
expect(rightButtons).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
iconName: 'product-playbooks',
|
||||
}),
|
||||
]),
|
||||
);
|
||||
});
|
||||
|
||||
it('shows playbook button with count when there are active runs', () => {
|
||||
const props = getBaseProps();
|
||||
props.playbooksActiveRuns = 3;
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@ const ChannelHeader = ({
|
|||
if (callsAvailable && !isDMorGM) {
|
||||
items += 1;
|
||||
}
|
||||
if (hasPlaybookRuns) {
|
||||
if (hasPlaybookRuns && !isDMorGM) {
|
||||
items += 1;
|
||||
}
|
||||
let height = CHANNEL_ACTIONS_OPTIONS_HEIGHT + SEPARATOR_HEIGHT + MARGIN + (items * ITEM_HEIGHT);
|
||||
|
|
@ -224,7 +224,7 @@ const ChannelHeader = ({
|
|||
|
||||
const rightButtons = useMemo(() => {
|
||||
const buttons: HeaderRightButton[] = [];
|
||||
if (playbooksActiveRuns) {
|
||||
if (playbooksActiveRuns && !isDMorGM) {
|
||||
buttons.push({
|
||||
iconName: 'product-playbooks',
|
||||
onPress: openPlaybooksRuns,
|
||||
|
|
@ -250,7 +250,7 @@ const ChannelHeader = ({
|
|||
});
|
||||
|
||||
return buttons;
|
||||
}, [playbooksActiveRuns, onChannelQuickAction, openPlaybooksRuns]);
|
||||
}, [playbooksActiveRuns, isDMorGM, onChannelQuickAction, openPlaybooksRuns]);
|
||||
|
||||
let title = displayName;
|
||||
if (isOwnDirectMessage) {
|
||||
|
|
|
|||
|
|
@ -54,4 +54,12 @@ describe('ChannelQuickAction', () => {
|
|||
expect(playbookRunsOption.props.channelId).toBe('channel-id');
|
||||
expect(playbookRunsOption.props.location).toBe('quick_actions');
|
||||
});
|
||||
|
||||
it('does not show playbook runs option when is DM or GM', () => {
|
||||
const props = getBaseProps();
|
||||
props.isDMorGM = true;
|
||||
props.hasPlaybookRuns = true;
|
||||
const {queryByTestId} = renderWithEverything(<ChannelQuickAction {...props}/>, {database});
|
||||
expect(queryByTestId('playbook-runs-option')).toBeNull();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ const ChannelQuickAction = ({
|
|||
showAsLabel={true}
|
||||
testID='channel.quick_actions.channel_info.action'
|
||||
/>
|
||||
{hasPlaybookRuns &&
|
||||
{hasPlaybookRuns && !isDMorGM &&
|
||||
<PlaybookRunsOption
|
||||
channelId={channelId}
|
||||
location='quick_actions'
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
import React, {type ComponentProps} from 'react';
|
||||
|
||||
import {General} from '@constants';
|
||||
import DatabaseManager from '@database/manager';
|
||||
import PlaybookRunsOption from '@playbooks/components/channel_actions/playbook_runs_option';
|
||||
import {renderWithEverything} from '@test/intl-test-helper';
|
||||
|
|
@ -46,4 +47,14 @@ describe('ChannelInfoOptions', () => {
|
|||
rerender(<ChannelInfoOptions {...props}/>);
|
||||
expect(getByTestId('playbook-runs-option')).toHaveProp('channelId', 'channel-id-2');
|
||||
});
|
||||
it('should not show playbook runs option when is DM or GM', () => {
|
||||
const props = getBaseProps();
|
||||
props.type = General.DM_CHANNEL;
|
||||
const {queryByTestId, rerender} = renderWithEverything(<ChannelInfoOptions {...props}/>, {database});
|
||||
expect(queryByTestId('playbook-runs-option')).toBeNull();
|
||||
|
||||
props.type = General.GM_CHANNEL;
|
||||
rerender(<ChannelInfoOptions {...props}/>);
|
||||
expect(queryByTestId('playbook-runs-option')).toBeNull();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ const Options = ({
|
|||
<NotificationPreference channelId={channelId}/>
|
||||
<PinnedMessages channelId={channelId}/>
|
||||
<ChannelFiles channelId={channelId}/>
|
||||
{isPlaybooksEnabled &&
|
||||
{isPlaybooksEnabled && !isDMorGM &&
|
||||
<PlaybookRunsOption
|
||||
channelId={channelId}
|
||||
location='channel_actions'
|
||||
|
|
|
|||
Loading…
Reference in a new issue