[MM-66380] Only show playbook runs if enabled (#9252)
This commit is contained in:
parent
31556bfed6
commit
6cf1bb447b
3 changed files with 40 additions and 1 deletions
|
|
@ -38,6 +38,7 @@ type ChannelListProps = {
|
|||
scheduledPostHasError: boolean;
|
||||
lastChannelId?: string;
|
||||
scheduledPostsEnabled?: boolean;
|
||||
playbooksEnabled?: boolean;
|
||||
};
|
||||
|
||||
const getTabletWidth = (moreThanOneTeam: boolean) => {
|
||||
|
|
@ -56,6 +57,7 @@ const CategoriesList = ({
|
|||
scheduledPostHasError,
|
||||
lastChannelId,
|
||||
scheduledPostsEnabled,
|
||||
playbooksEnabled,
|
||||
}: ChannelListProps) => {
|
||||
const theme = useTheme();
|
||||
const styles = getStyleSheet(theme);
|
||||
|
|
@ -126,10 +128,14 @@ const CategoriesList = ({
|
|||
}, [activeScreen, draftsCount, isTablet, scheduledPostCount, scheduledPostHasError, scheduledPostsEnabled]);
|
||||
|
||||
const playbooksButtonComponent = useMemo(() => {
|
||||
if (!playbooksEnabled) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<PlaybooksButton/>
|
||||
);
|
||||
}, []);
|
||||
}, [playbooksEnabled]);
|
||||
|
||||
const content = useMemo(() => {
|
||||
if (!hasChannels) {
|
||||
|
|
|
|||
|
|
@ -170,4 +170,34 @@ describe('components/categories_list', () => {
|
|||
);
|
||||
expect(wrapper.queryByText('Drafts')).not.toBeTruthy();
|
||||
});
|
||||
|
||||
it('should not render channel list with Playbooks menu if playbooks feature is disabled', () => {
|
||||
const wrapper = renderWithEverything(
|
||||
<CategoriesList
|
||||
moreThanOneTeam={false}
|
||||
hasChannels={true}
|
||||
draftsCount={0}
|
||||
scheduledPostCount={0}
|
||||
scheduledPostHasError={false}
|
||||
playbooksEnabled={false}
|
||||
/>,
|
||||
{database},
|
||||
);
|
||||
expect(wrapper.queryByText('Playbook runs')).not.toBeTruthy();
|
||||
});
|
||||
|
||||
it('should render channel list with Playbooks menu if playbooks feature is enabled', () => {
|
||||
const wrapper = renderWithEverything(
|
||||
<CategoriesList
|
||||
moreThanOneTeam={false}
|
||||
hasChannels={true}
|
||||
draftsCount={0}
|
||||
scheduledPostCount={0}
|
||||
scheduledPostHasError={false}
|
||||
playbooksEnabled={true}
|
||||
/>,
|
||||
{database},
|
||||
);
|
||||
expect(wrapper.getByText('Playbook runs')).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import {withDatabase, withObservables} from '@nozbe/watermelondb/react';
|
|||
import {of} from 'rxjs';
|
||||
import {switchMap} from 'rxjs/operators';
|
||||
|
||||
import {observeIsPlaybooksEnabled} from '@playbooks/database/queries/version';
|
||||
import {observeDraftCount} from '@queries/servers/drafts';
|
||||
import {observeScheduledPostEnabled, observeScheduledPostsForTeam} from '@queries/servers/scheduled_post';
|
||||
import {observeCurrentTeamId} from '@queries/servers/system';
|
||||
|
|
@ -27,6 +28,7 @@ const enchanced = withObservables([], ({database}: WithDatabaseArgs) => {
|
|||
switchMap((scheduledPosts) => of(hasScheduledPostError(scheduledPosts))),
|
||||
);
|
||||
const scheduledPostsEnabled = observeScheduledPostEnabled(database);
|
||||
const playbooksEnabled = observeIsPlaybooksEnabled(database);
|
||||
|
||||
return {
|
||||
lastChannelId,
|
||||
|
|
@ -34,6 +36,7 @@ const enchanced = withObservables([], ({database}: WithDatabaseArgs) => {
|
|||
scheduledPostCount,
|
||||
scheduledPostHasError,
|
||||
scheduledPostsEnabled,
|
||||
playbooksEnabled,
|
||||
};
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue