Skip to content

Commit 981daa8

Browse files
[MM-66380] Only show playbook runs if enabled (#9252) (#9263)
(cherry picked from commit 6cf1bb4) Co-authored-by: Daniel Espino García <[email protected]>
1 parent 97e49ac commit 981daa8

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

app/screens/home/channel_list/categories_list/categories_list.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ type ChannelListProps = {
3838
scheduledPostHasError: boolean;
3939
lastChannelId?: string;
4040
scheduledPostsEnabled?: boolean;
41+
playbooksEnabled?: boolean;
4142
};
4243

4344
const getTabletWidth = (moreThanOneTeam: boolean) => {
@@ -56,6 +57,7 @@ const CategoriesList = ({
5657
scheduledPostHasError,
5758
lastChannelId,
5859
scheduledPostsEnabled,
60+
playbooksEnabled,
5961
}: ChannelListProps) => {
6062
const theme = useTheme();
6163
const styles = getStyleSheet(theme);
@@ -126,10 +128,14 @@ const CategoriesList = ({
126128
}, [activeScreen, draftsCount, isTablet, scheduledPostCount, scheduledPostHasError, scheduledPostsEnabled]);
127129

128130
const playbooksButtonComponent = useMemo(() => {
131+
if (!playbooksEnabled) {
132+
return null;
133+
}
134+
129135
return (
130136
<PlaybooksButton/>
131137
);
132-
}, []);
138+
}, [playbooksEnabled]);
133139

134140
const content = useMemo(() => {
135141
if (!hasChannels) {

app/screens/home/channel_list/categories_list/index.test.tsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,4 +170,34 @@ describe('components/categories_list', () => {
170170
);
171171
expect(wrapper.queryByText('Drafts')).not.toBeTruthy();
172172
});
173+
174+
it('should not render channel list with Playbooks menu if playbooks feature is disabled', () => {
175+
const wrapper = renderWithEverything(
176+
<CategoriesList
177+
moreThanOneTeam={false}
178+
hasChannels={true}
179+
draftsCount={0}
180+
scheduledPostCount={0}
181+
scheduledPostHasError={false}
182+
playbooksEnabled={false}
183+
/>,
184+
{database},
185+
);
186+
expect(wrapper.queryByText('Playbook runs')).not.toBeTruthy();
187+
});
188+
189+
it('should render channel list with Playbooks menu if playbooks feature is enabled', () => {
190+
const wrapper = renderWithEverything(
191+
<CategoriesList
192+
moreThanOneTeam={false}
193+
hasChannels={true}
194+
draftsCount={0}
195+
scheduledPostCount={0}
196+
scheduledPostHasError={false}
197+
playbooksEnabled={true}
198+
/>,
199+
{database},
200+
);
201+
expect(wrapper.getByText('Playbook runs')).toBeTruthy();
202+
});
173203
});

app/screens/home/channel_list/categories_list/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {withDatabase, withObservables} from '@nozbe/watermelondb/react';
55
import {of} from 'rxjs';
66
import {switchMap} from 'rxjs/operators';
77

8+
import {observeIsPlaybooksEnabled} from '@playbooks/database/queries/version';
89
import {observeDraftCount} from '@queries/servers/drafts';
910
import {observeScheduledPostEnabled, observeScheduledPostsForTeam} from '@queries/servers/scheduled_post';
1011
import {observeCurrentTeamId} from '@queries/servers/system';
@@ -27,13 +28,15 @@ const enchanced = withObservables([], ({database}: WithDatabaseArgs) => {
2728
switchMap((scheduledPosts) => of(hasScheduledPostError(scheduledPosts))),
2829
);
2930
const scheduledPostsEnabled = observeScheduledPostEnabled(database);
31+
const playbooksEnabled = observeIsPlaybooksEnabled(database);
3032

3133
return {
3234
lastChannelId,
3335
draftsCount,
3436
scheduledPostCount,
3537
scheduledPostHasError,
3638
scheduledPostsEnabled,
39+
playbooksEnabled,
3740
};
3841
});
3942

0 commit comments

Comments
 (0)