diff --git a/apps/meteor/client/views/teams/contextualBar/info/TeamsInfo.tsx b/apps/meteor/client/views/teams/contextualBar/info/TeamsInfo.tsx
index 12e092b48763..5a38722cfc42 100644
--- a/apps/meteor/client/views/teams/contextualBar/info/TeamsInfo.tsx
+++ b/apps/meteor/client/views/teams/contextualBar/info/TeamsInfo.tsx
@@ -17,18 +17,10 @@ import RetentionPolicyCallout from '../../../../components/InfoPanel/RetentionPo
import MarkdownText from '../../../../components/MarkdownText';
import type { Action } from '../../../hooks/useActionSpread';
import { useActionSpread } from '../../../hooks/useActionSpread';
-
-type RetentionPolicy = {
- retentionPolicyEnabled: boolean;
- maxAgeDefault: number;
- retentionEnabledDefault: boolean;
- excludePinnedDefault: boolean;
- filesOnlyDefault: boolean;
-};
+import { useRetentionPolicy } from '../../../room/hooks/useRetentionPolicy';
type TeamsInfoProps = {
room: IRoom;
- retentionPolicy: RetentionPolicy;
onClickHide: () => void;
onClickClose: () => void;
onClickLeave: () => void;
@@ -40,7 +32,6 @@ type TeamsInfoProps = {
const TeamsInfo = ({
room,
- retentionPolicy,
onClickHide,
onClickClose,
onClickLeave,
@@ -51,7 +42,7 @@ const TeamsInfo = ({
}: TeamsInfoProps): ReactElement => {
const t = useTranslation();
- const { retentionPolicyEnabled, filesOnlyDefault, excludePinnedDefault, maxAgeDefault } = retentionPolicy;
+ const retentionPolicy = useRetentionPolicy(room);
const memoizedActions = useMemo(
() => ({
@@ -199,8 +190,12 @@ const TeamsInfo = ({
)}
- {retentionPolicyEnabled && (
-
+ {retentionPolicy?.isActive && (
+
)}
diff --git a/apps/meteor/client/views/teams/contextualBar/info/TeamsInfoWithData.js b/apps/meteor/client/views/teams/contextualBar/info/TeamsInfoWithData.js
index f5cb4a44c5d2..0b2f84a339ed 100644
--- a/apps/meteor/client/views/teams/contextualBar/info/TeamsInfoWithData.js
+++ b/apps/meteor/client/views/teams/contextualBar/info/TeamsInfoWithData.js
@@ -3,7 +3,6 @@ import {
useSetModal,
useToastMessageDispatch,
useUserId,
- useSetting,
usePermission,
useMethod,
useTranslation,
@@ -23,33 +22,12 @@ import ConvertToChannelModal from '../../ConvertToChannelModal';
import LeaveTeam from './LeaveTeam';
import TeamsInfo from './TeamsInfo';
-const retentionPolicyMaxAge = {
- c: 'RetentionPolicy_MaxAge_Channels',
- p: 'RetentionPolicy_MaxAge_Groups',
- d: 'RetentionPolicy_MaxAge_DMs',
-};
-
-const retentionPolicyAppliesTo = {
- c: 'RetentionPolicy_AppliesToChannels',
- p: 'RetentionPolicy_AppliesToGroups',
- d: 'RetentionPolicy_AppliesToDMs',
-};
-
const TeamsInfoWithLogic = ({ openEditing }) => {
const room = useRoom();
const { openTab, closeTab } = useRoomToolbox();
const t = useTranslation();
const userId = useUserId();
- const retentionPolicyEnabled = useSetting('RetentionPolicy_Enabled');
- const retentionPolicy = {
- retentionPolicyEnabled,
- maxAgeDefault: useSetting(retentionPolicyMaxAge[room.t]) || 30,
- retentionEnabledDefault: useSetting(retentionPolicyAppliesTo[room.t]),
- excludePinnedDefault: useSetting('RetentionPolicy_DoNotPrunePinned'),
- filesOnlyDefault: useSetting('RetentionPolicy_FilesOnly'),
- };
-
const dontAskHideRoom = useDontAskAgain('hideRoom');
const dispatchToastMessage = useToastMessageDispatch();
@@ -153,7 +131,6 @@ const TeamsInfoWithLogic = ({ openEditing }) => {
return (
{
let poHomeChannel: HomeChannel;
let targetChannel: string;
+ let targetTeam: string;
let targetGroup: string;
test.beforeAll(async ({ api }) => {
targetChannel = await createTargetChannel(api);
targetGroup = await createTargetPrivateChannel(api);
+ targetTeam = await createTargetTeam(api);
})
test.beforeEach(async ({ page }) => {
@@ -28,6 +30,12 @@ test.describe.serial('retention-policy', () => {
await expect(poHomeChannel.content.channelRetentionPolicyWarning).not.toBeVisible();
});
+ test('should not show prune banner in team', async () => {
+ await poHomeChannel.sidenav.openChat(targetTeam);
+
+ await expect(poHomeChannel.content.channelRetentionPolicyWarning).not.toBeVisible();
+ });
+
test('should not show prune section on edit channel', async () => {
await poHomeChannel.sidenav.openChat(targetChannel);
await poHomeChannel.tabs.btnRoomInfo.click();
@@ -53,6 +61,9 @@ test.describe.serial('retention-policy', () => {
await poHomeChannel.sidenav.openChat(targetChannel);
await expect(poHomeChannel.content.channelRetentionPolicyWarning).not.toBeVisible();
+ await poHomeChannel.sidenav.openChat(targetTeam);
+ await expect(poHomeChannel.content.channelRetentionPolicyWarning).not.toBeVisible();
+
await poHomeChannel.sidenav.openChat(targetGroup);
await expect(poHomeChannel.content.channelRetentionPolicyWarning).not.toBeVisible();
@@ -85,6 +96,16 @@ test.describe.serial('retention-policy', () => {
await expect(poHomeChannel.tabs.room.checkboxPruneMessages).toBeChecked();
});
+ test('should prune old messages checkbox enabled by default in team and show retention policy banner', async () => {
+ await poHomeChannel.sidenav.openChat(targetTeam);
+ await expect(poHomeChannel.content.channelRetentionPolicyWarning).toBeVisible();
+
+ await poHomeChannel.tabs.btnRoomInfo.click();
+ await poHomeChannel.tabs.room.btnEdit.click();
+ await poHomeChannel.tabs.room.pruneAccordion.click();
+ await expect(poHomeChannel.tabs.room.checkboxPruneMessages).toBeChecked();
+ });
+
test('should prune old messages checkbox enabled by default in group and show retention policy banner', async () => {
await poHomeChannel.sidenav.openChat(targetGroup);
await expect(poHomeChannel.content.channelRetentionPolicyWarning).toBeVisible();