Removed post limit warning banner (#27036)
Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
cef7826fa8
Коммит
13d9a9b6cc
@@ -6,7 +6,6 @@ import React from 'react';
|
||||
import type {ClientLicense, ClientConfig, WarnMetricStatus} from '@mattermost/types/config';
|
||||
|
||||
import {ToPaidPlanBannerDismissable} from 'components/admin_console/billing/billing_subscriptions/to_paid_plan_nudge_banner';
|
||||
import PostLimitsAnnouncementBar from 'components/announcement_bar/post_limits_announcement_bar';
|
||||
import withGetCloudSubscription from 'components/common/hocs/cloud/with_get_cloud_subscription';
|
||||
|
||||
import CloudTrialAnnouncementBar from './cloud_trial_announcement_bar';
|
||||
@@ -102,10 +101,6 @@ class AnnouncementBarController extends React.PureComponent<Props> {
|
||||
<>
|
||||
{adminConfiguredAnnouncementBar}
|
||||
{errorBar}
|
||||
<PostLimitsAnnouncementBar
|
||||
license={this.props.license}
|
||||
userIsAdmin={this.props.userIsAdmin}
|
||||
/>
|
||||
<UsersLimitsAnnouncementBar
|
||||
license={this.props.license}
|
||||
userIsAdmin={this.props.userIsAdmin}
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import type {
|
||||
ShouldShowingPostLimitsAnnouncementBarProps} from 'components/announcement_bar/post_limits_announcement_bar/index';
|
||||
import {shouldShowPostLimitsAnnouncementBar,
|
||||
} from 'components/announcement_bar/post_limits_announcement_bar/index';
|
||||
|
||||
describe('shouldShowPostLimitsAnnouncementBar', () => {
|
||||
const defaultProps: ShouldShowingPostLimitsAnnouncementBarProps = {
|
||||
userIsAdmin: true,
|
||||
isLicensed: false,
|
||||
maxPostLimit: 10,
|
||||
postCount: 5,
|
||||
};
|
||||
|
||||
test('should not show when user is not admin', () => {
|
||||
const props: ShouldShowingPostLimitsAnnouncementBarProps = {
|
||||
...defaultProps,
|
||||
userIsAdmin: false,
|
||||
};
|
||||
expect(shouldShowPostLimitsAnnouncementBar(props)).toBe(false);
|
||||
});
|
||||
|
||||
test('should not show when post count is 0', () => {
|
||||
const props: ShouldShowingPostLimitsAnnouncementBarProps = {
|
||||
...defaultProps,
|
||||
postCount: 0,
|
||||
};
|
||||
expect(shouldShowPostLimitsAnnouncementBar(props)).toBe(false);
|
||||
});
|
||||
|
||||
test('should not show when max post limit is 0', () => {
|
||||
const props: ShouldShowingPostLimitsAnnouncementBarProps = {
|
||||
...defaultProps,
|
||||
maxPostLimit: 0,
|
||||
};
|
||||
expect(shouldShowPostLimitsAnnouncementBar(props)).toBe(false);
|
||||
});
|
||||
|
||||
test('should not show when post count is less than max users limit', () => {
|
||||
const props: ShouldShowingPostLimitsAnnouncementBarProps = {
|
||||
...defaultProps,
|
||||
maxPostLimit: 10,
|
||||
postCount: 5,
|
||||
};
|
||||
expect(shouldShowPostLimitsAnnouncementBar(props)).toBe(false);
|
||||
});
|
||||
|
||||
test('should show when post count is equal to max post limit', () => {
|
||||
const props: ShouldShowingPostLimitsAnnouncementBarProps = {
|
||||
...defaultProps,
|
||||
maxPostLimit: 10,
|
||||
postCount: 10,
|
||||
};
|
||||
expect(shouldShowPostLimitsAnnouncementBar(props)).toBe(true);
|
||||
});
|
||||
|
||||
test('should show for non licensed servers with post count is greater than max post limit', () => {
|
||||
const props: ShouldShowingPostLimitsAnnouncementBarProps = {
|
||||
...defaultProps,
|
||||
isLicensed: false,
|
||||
maxPostLimit: 5,
|
||||
postCount: 10,
|
||||
};
|
||||
expect(shouldShowPostLimitsAnnouncementBar(props)).toBe(true);
|
||||
});
|
||||
|
||||
test('should not show for licensed server', () => {
|
||||
const props: ShouldShowingPostLimitsAnnouncementBarProps = {
|
||||
...defaultProps,
|
||||
isLicensed: true,
|
||||
maxPostLimit: 0,
|
||||
postCount: 0,
|
||||
};
|
||||
|
||||
expect(shouldShowPostLimitsAnnouncementBar(props)).toBe(false);
|
||||
});
|
||||
|
||||
test('should not show for licensed server even if post count is greater than max post limit', () => {
|
||||
const props: ShouldShowingPostLimitsAnnouncementBarProps = {
|
||||
...defaultProps,
|
||||
isLicensed: true,
|
||||
maxPostLimit: 10,
|
||||
postCount: 11,
|
||||
};
|
||||
|
||||
expect(shouldShowPostLimitsAnnouncementBar(props)).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -1,86 +0,0 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import React, {useCallback} from 'react';
|
||||
import {FormattedMessage} from 'react-intl';
|
||||
import {useSelector} from 'react-redux';
|
||||
|
||||
import {AlertOutlineIcon} from '@mattermost/compass-icons/components';
|
||||
import type {ClientLicense} from '@mattermost/types/config';
|
||||
|
||||
import {getServerLimits} from 'mattermost-redux/selectors/entities/limits';
|
||||
|
||||
import AnnouncementBar from 'components/announcement_bar/default_announcement_bar';
|
||||
|
||||
import {AnnouncementBarTypes} from 'utils/constants';
|
||||
|
||||
type Props = {
|
||||
license?: ClientLicense;
|
||||
userIsAdmin: boolean;
|
||||
};
|
||||
|
||||
const learnMoreExternalLink = 'https://mattermost.com/pl/error-code-error-safety-limits-exceeded';
|
||||
|
||||
function PostLimitsAnnouncementBar(props: Props) {
|
||||
const serverLimits = useSelector(getServerLimits);
|
||||
|
||||
const handleCTAClick = useCallback(() => {
|
||||
window.open(learnMoreExternalLink, '_blank');
|
||||
}, []);
|
||||
|
||||
const isLicensed = props?.license?.IsLicensed === 'true';
|
||||
const maxPostLimit = serverLimits?.maxPostLimit ?? 0;
|
||||
const postCount = serverLimits?.postCount ?? 0;
|
||||
|
||||
if (!shouldShowPostLimitsAnnouncementBar({userIsAdmin: props.userIsAdmin, isLicensed, maxPostLimit, postCount})) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<AnnouncementBar
|
||||
id='post_limits_announcement_bar'
|
||||
showCloseButton={false}
|
||||
message={
|
||||
<FormattedMessage
|
||||
id='post_limits_announcement_bar.copyText'
|
||||
defaultMessage='Message limits exceeded. Contact administrator with: {ErrorCode}'
|
||||
values={{
|
||||
ErrorCode: 'ERROR_SAFETY_LIMITS_EXCEEDED',
|
||||
}}
|
||||
/>
|
||||
}
|
||||
type={AnnouncementBarTypes.CRITICAL}
|
||||
icon={<AlertOutlineIcon size={16}/>}
|
||||
showCTA={true}
|
||||
showLinkAsButton={true}
|
||||
ctaText={
|
||||
<FormattedMessage
|
||||
id='users_limits_announcement_bar.ctaText'
|
||||
defaultMessage='Learn More'
|
||||
/>
|
||||
}
|
||||
onButtonClick={handleCTAClick}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export type ShouldShowingPostLimitsAnnouncementBarProps = {
|
||||
userIsAdmin: boolean;
|
||||
isLicensed: boolean;
|
||||
maxPostLimit: number;
|
||||
postCount: number;
|
||||
};
|
||||
|
||||
export function shouldShowPostLimitsAnnouncementBar({userIsAdmin, isLicensed, maxPostLimit, postCount}: ShouldShowingPostLimitsAnnouncementBarProps) {
|
||||
if (!userIsAdmin) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (maxPostLimit === 0 || postCount === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !isLicensed && postCount >= maxPostLimit;
|
||||
}
|
||||
|
||||
export default PostLimitsAnnouncementBar;
|
||||
@@ -4472,7 +4472,6 @@
|
||||
"post_info.tooltip.add_reactions": "Add Reaction",
|
||||
"post_info.unpin": "Unpin from Channel",
|
||||
"post_info.unread": "Mark as Unread",
|
||||
"post_limits_announcement_bar.copyText": "Message limits exceeded. Contact administrator with: {ErrorCode}",
|
||||
"post_message_preview.channel": "Only visible to users in ~{channel}",
|
||||
"post_message_view.edited": "Edited",
|
||||
"post_message_view.view_post_edit_history": "Click to view history",
|
||||
|
||||
@@ -17,8 +17,6 @@ describe('getServerLimits', () => {
|
||||
const defaultServerLimitsState: ServerLimits = {
|
||||
activeUserCount: 0,
|
||||
maxUsersLimit: 0,
|
||||
maxPostLimit: 0,
|
||||
postCount: 0,
|
||||
};
|
||||
|
||||
let store = configureStore();
|
||||
@@ -79,8 +77,6 @@ describe('getServerLimits', () => {
|
||||
const userLimits: ServerLimits = {
|
||||
activeUserCount: 600,
|
||||
maxUsersLimit: 10_000,
|
||||
maxPostLimit: 5_000_000,
|
||||
postCount: 10_000,
|
||||
};
|
||||
|
||||
nock(Client4.getBaseRoute()).
|
||||
|
||||
@@ -21,8 +21,6 @@ export function getServerLimits(): ActionFuncAsync<ServerLimits> {
|
||||
data: {
|
||||
activeUserCount: 0,
|
||||
maxUsersLimit: 0,
|
||||
postCount: 0,
|
||||
maxPostLimit: 0,
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -39,8 +37,6 @@ export function getServerLimits(): ActionFuncAsync<ServerLimits> {
|
||||
const data: ServerLimits = {
|
||||
activeUserCount: response?.data?.activeUserCount ?? 0,
|
||||
maxUsersLimit: response?.data?.maxUsersLimit ?? 0,
|
||||
postCount: response?.data?.postCount ?? 0,
|
||||
maxPostLimit: response?.data?.maxPostLimit ?? 0,
|
||||
};
|
||||
|
||||
dispatch({type: LimitsTypes.RECIEVED_APP_LIMITS, data});
|
||||
|
||||
@@ -38,8 +38,6 @@ const state: GlobalState = {
|
||||
serverLimits: {
|
||||
activeUserCount: 0,
|
||||
maxUsersLimit: 0,
|
||||
postCount: 0,
|
||||
maxPostLimit: 0,
|
||||
},
|
||||
},
|
||||
teams: {
|
||||
|
||||
@@ -8,7 +8,4 @@ export type LimitsState = {
|
||||
export type ServerLimits = {
|
||||
activeUserCount: number;
|
||||
maxUsersLimit: number;
|
||||
|
||||
maxPostLimit: number;
|
||||
postCount: number;
|
||||
};
|
||||
|
||||
Ссылка в новой задаче
Block a user