Added post limit warning (#26793)
* Renamed user limit API to app limit API * Added post warning limit * Added tests * Fixed types * Renamed AppLimits to ServerLimits * Fixed tests and review fixes * Updated generated code * Updated server i18n * Fixed TestCreateUserOrGuest test * Exclude deleted posts from post count for liims * Reduced limits for ease of testing * Restored original limts
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
4571c6e3a3
Коммит
b4a1b33d39
@@ -7,7 +7,7 @@ import type {Dispatch} from 'redux';
|
||||
|
||||
import {uploadLicense, removeLicense, getPrevTrialLicense} from 'mattermost-redux/actions/admin';
|
||||
import {getLicenseConfig} from 'mattermost-redux/actions/general';
|
||||
import {getUsersLimits} from 'mattermost-redux/actions/limits';
|
||||
import {getServerLimits} from 'mattermost-redux/actions/limits';
|
||||
import {getFilteredUsersStats} from 'mattermost-redux/actions/users';
|
||||
import {getConfig} from 'mattermost-redux/selectors/entities/general';
|
||||
import {getFilteredUsersStats as selectFilteredUserStats} from 'mattermost-redux/selectors/entities/users';
|
||||
@@ -43,7 +43,7 @@ function mapDispatchToProps(dispatch: Dispatch) {
|
||||
requestTrialLicense,
|
||||
openModal,
|
||||
getFilteredUsersStats,
|
||||
getUsersLimits,
|
||||
getServerLimits,
|
||||
}, dispatch),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ describe('components/admin_console/license_settings/LicenseSettings', () => {
|
||||
upgradeToE0Status: jest.fn().mockImplementation(() => Promise.resolve({percentage: 0, error: null})),
|
||||
openModal: jest.fn(),
|
||||
getFilteredUsersStats: jest.fn(),
|
||||
getUsersLimits: jest.fn(),
|
||||
getServerLimits: jest.fn(),
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import {FormattedMessage, defineMessages} from 'react-intl';
|
||||
import type {StatusOK} from '@mattermost/types/client4';
|
||||
import type {ClientLicense} from '@mattermost/types/config';
|
||||
import type {ServerError} from '@mattermost/types/errors';
|
||||
import type {UsersLimits} from '@mattermost/types/limits';
|
||||
import type {ServerLimits} from '@mattermost/types/limits';
|
||||
import type {GetFilteredUsersStatsOpts, UsersStats} from '@mattermost/types/users';
|
||||
|
||||
import type {ActionResult} from 'mattermost-redux/types/actions';
|
||||
@@ -55,7 +55,7 @@ type Props = {
|
||||
ping: () => Promise<{status: string}>;
|
||||
requestTrialLicense: (users: number, termsAccepted: boolean, receiveEmailsAccepted: boolean, featureName: string) => Promise<ActionResult>;
|
||||
openModal: <P>(modalData: ModalData<P>) => void;
|
||||
getUsersLimits: () => Promise<ActionResult<UsersLimits, ServerError>>;
|
||||
getServerLimits: () => Promise<ActionResult<ServerLimits, ServerError>>;
|
||||
getFilteredUsersStats: (filters: GetFilteredUsersStatsOpts) => Promise<{
|
||||
data?: UsersStats;
|
||||
error?: ServerError;
|
||||
@@ -196,7 +196,7 @@ export default class LicenseSettings extends React.PureComponent<Props, State> {
|
||||
this.props.actions.getLicenseConfig(),
|
||||
]);
|
||||
|
||||
await this.props.actions.getUsersLimits();
|
||||
await this.props.actions.getServerLimits();
|
||||
|
||||
this.setState({serverError: null, removing: false});
|
||||
};
|
||||
|
||||
@@ -6,6 +6,7 @@ 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 CloudAnnualRenewalAnnouncementBar from './cloud_annual_renewal';
|
||||
@@ -98,10 +99,22 @@ class AnnouncementBarController extends React.PureComponent<Props> {
|
||||
);
|
||||
}
|
||||
|
||||
// The component specified further down takes priority over the component above it.
|
||||
// For example, consider this-
|
||||
// {
|
||||
// Foo
|
||||
// Bar
|
||||
// Baz
|
||||
// }
|
||||
// Even if all Foo, Bar and Baz render, only Baz is visible as it's further down.
|
||||
return (
|
||||
<>
|
||||
{adminConfiguredAnnouncementBar}
|
||||
{errorBar}
|
||||
<PostLimitsAnnouncementBar
|
||||
license={this.props.license}
|
||||
userIsAdmin={this.props.userIsAdmin}
|
||||
/>
|
||||
<UsersLimitsAnnouncementBar
|
||||
license={this.props.license}
|
||||
userIsAdmin={this.props.userIsAdmin}
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
// 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);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,86 @@
|
||||
// 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;
|
||||
@@ -8,7 +8,7 @@ import {useSelector} from 'react-redux';
|
||||
import {AlertOutlineIcon} from '@mattermost/compass-icons/components';
|
||||
import type {ClientLicense} from '@mattermost/types/config';
|
||||
|
||||
import {getUsersLimits} from 'mattermost-redux/selectors/entities/limits';
|
||||
import {getServerLimits} from 'mattermost-redux/selectors/entities/limits';
|
||||
|
||||
import AnnouncementBar from 'components/announcement_bar/default_announcement_bar';
|
||||
|
||||
@@ -22,15 +22,15 @@ type Props = {
|
||||
const learnMoreExternalLink = 'https://mattermost.com/pl/error-code-error-safety-limits-exceeded';
|
||||
|
||||
function UsersLimitsAnnouncementBar(props: Props) {
|
||||
const usersLimits = useSelector(getUsersLimits);
|
||||
const serverLimits = useSelector(getServerLimits);
|
||||
|
||||
const handleCTAClick = useCallback(() => {
|
||||
window.open(learnMoreExternalLink, '_blank');
|
||||
}, []);
|
||||
|
||||
const isLicensed = props?.license?.IsLicensed === 'true';
|
||||
const maxUsersLimit = usersLimits?.maxUsersLimit ?? 0;
|
||||
const activeUserCount = usersLimits?.activeUserCount ?? 0;
|
||||
const maxUsersLimit = serverLimits?.maxUsersLimit ?? 0;
|
||||
const activeUserCount = serverLimits?.activeUserCount ?? 0;
|
||||
|
||||
if (!shouldShowUserLimitsAnnouncementBar({userIsAdmin: props.userIsAdmin, isLicensed, maxUsersLimit, activeUserCount})) {
|
||||
return null;
|
||||
@@ -43,7 +43,10 @@ function UsersLimitsAnnouncementBar(props: Props) {
|
||||
message={
|
||||
<FormattedMessage
|
||||
id='users_limits_announcement_bar.copyText'
|
||||
defaultMessage='User limits exceeded. Contact administrator with: ERROR_SAFETY_LIMITS_EXCEEDED'
|
||||
defaultMessage='User limits exceeded. Contact administrator with: {ErrorCode}'
|
||||
values={{
|
||||
ErrorCode: 'ERROR_SAFETY_LIMITS_EXCEEDED',
|
||||
}}
|
||||
/>
|
||||
}
|
||||
type={AnnouncementBarTypes.CRITICAL}
|
||||
|
||||
@@ -4584,6 +4584,7 @@
|
||||
"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",
|
||||
@@ -5850,7 +5851,7 @@
|
||||
"userGuideHelp.mattermostUserGuide": "Mattermost user guide",
|
||||
"userGuideHelp.reportAProblem": "Report a problem",
|
||||
"userGuideHelp.trainingResources": "Training resources",
|
||||
"users_limits_announcement_bar.copyText": "User limits exceeded. Contact administrator with: ERROR_SAFETY_LIMITS_EXCEEDED",
|
||||
"users_limits_announcement_bar.copyText": "User limits exceeded. Contact administrator with: {ErrorCode}",
|
||||
"users_limits_announcement_bar.ctaText": "Learn More",
|
||||
"userSettingsModal.pluginPreferences.header": "PLUGIN PREFERENCES",
|
||||
"version_bar.new": "A new version of Mattermost is available.",
|
||||
|
||||
@@ -4,5 +4,5 @@
|
||||
import keyMirror from 'mattermost-redux/utils/key_mirror';
|
||||
|
||||
export default keyMirror({
|
||||
RECIEVED_USERS_LIMITS: null,
|
||||
RECIEVED_APP_LIMITS: null,
|
||||
});
|
||||
|
||||
@@ -65,7 +65,7 @@ export default keyMirror({
|
||||
DISABLED_USER_ACCESS_TOKEN: null,
|
||||
ENABLED_USER_ACCESS_TOKEN: null,
|
||||
RECEIVED_USER_STATS: null,
|
||||
RECIEVED_USERS_LIMITS: null,
|
||||
RECIEVED_APP_LIMITS: null,
|
||||
RECEIVED_FILTERED_USER_STATS: null,
|
||||
PROFILE_NO_LONGER_VISIBLE: null,
|
||||
LOGIN: null,
|
||||
|
||||
@@ -26,7 +26,7 @@ import type {
|
||||
import type {DeepPartial} from '@mattermost/types/utilities';
|
||||
|
||||
import {AdminTypes} from 'mattermost-redux/action_types';
|
||||
import {getUsersLimits} from 'mattermost-redux/actions/limits';
|
||||
import {getServerLimits} from 'mattermost-redux/actions/limits';
|
||||
import {Client4} from 'mattermost-redux/client';
|
||||
import type {ActionFuncAsync} from 'mattermost-redux/types/actions';
|
||||
|
||||
@@ -386,7 +386,7 @@ export function removeLicense(): ActionFuncAsync<boolean> {
|
||||
return {error: error as ServerError};
|
||||
}
|
||||
|
||||
await dispatch(getUsersLimits());
|
||||
await dispatch(getServerLimits());
|
||||
|
||||
return {data: true};
|
||||
};
|
||||
|
||||
@@ -3,18 +3,22 @@
|
||||
|
||||
import nock from 'nock';
|
||||
|
||||
import type {ServerLimits} from '@mattermost/types/limits';
|
||||
|
||||
import * as Actions from 'mattermost-redux/actions/limits';
|
||||
import {Client4} from 'mattermost-redux/client';
|
||||
|
||||
import TestHelper from '../../test/test_helper';
|
||||
import configureStore from '../../test/test_store';
|
||||
|
||||
describe('getUsersLimits', () => {
|
||||
const URL_USERS_LIMITS = '/limits/users';
|
||||
describe('getServerLimits', () => {
|
||||
const URL_USERS_LIMITS = '/limits/server';
|
||||
|
||||
const defaultUserLimitsState = {
|
||||
const defaultServerLimitsState: ServerLimits = {
|
||||
activeUserCount: 0,
|
||||
maxUsersLimit: 0,
|
||||
maxPostLimit: 0,
|
||||
postCount: 0,
|
||||
};
|
||||
|
||||
let store = configureStore();
|
||||
@@ -62,26 +66,28 @@ describe('getUsersLimits', () => {
|
||||
},
|
||||
});
|
||||
|
||||
const {data} = await store.dispatch(Actions.getUsersLimits());
|
||||
expect(data).toEqual(defaultUserLimitsState);
|
||||
const {data} = await store.dispatch(Actions.getServerLimits());
|
||||
expect(data).toEqual(defaultServerLimitsState);
|
||||
});
|
||||
|
||||
test('should not return default state for non admin users', async () => {
|
||||
const {data} = await store.dispatch(Actions.getUsersLimits());
|
||||
expect(data).not.toEqual(defaultUserLimitsState);
|
||||
const {data} = await store.dispatch(Actions.getServerLimits());
|
||||
expect(data).not.toEqual(defaultServerLimitsState);
|
||||
});
|
||||
|
||||
test('should return data if user is admin', async () => {
|
||||
const userLimits = {
|
||||
const userLimits: ServerLimits = {
|
||||
activeUserCount: 600,
|
||||
maxUsersLimit: 10000,
|
||||
maxUsersLimit: 10_000,
|
||||
maxPostLimit: 5_000_000,
|
||||
postCount: 10_000,
|
||||
};
|
||||
|
||||
nock(Client4.getBaseRoute()).
|
||||
get(URL_USERS_LIMITS).
|
||||
reply(200, userLimits);
|
||||
|
||||
const {data} = await store.dispatch(Actions.getUsersLimits());
|
||||
const {data} = await store.dispatch(Actions.getServerLimits());
|
||||
expect(data).toEqual(userLimits);
|
||||
});
|
||||
|
||||
@@ -91,7 +97,7 @@ describe('getUsersLimits', () => {
|
||||
get(URL_USERS_LIMITS).
|
||||
reply(400, {message: errorMessage});
|
||||
|
||||
const {error} = await store.dispatch(Actions.getUsersLimits());
|
||||
const {error} = await store.dispatch(Actions.getServerLimits());
|
||||
console.log(error);
|
||||
expect(error.message).toEqual(errorMessage);
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import type {ServerError} from '@mattermost/types/errors';
|
||||
import type {UsersLimits} from '@mattermost/types/limits';
|
||||
import type {ServerLimits} from '@mattermost/types/limits';
|
||||
|
||||
import {LimitsTypes} from 'mattermost-redux/action_types';
|
||||
import {logError} from 'mattermost-redux/actions/errors';
|
||||
@@ -12,7 +12,7 @@ import {getCurrentUserRoles} from 'mattermost-redux/selectors/entities/users';
|
||||
import type {ActionFuncAsync} from 'mattermost-redux/types/actions';
|
||||
import {isAdmin} from 'mattermost-redux/utils/user_utils';
|
||||
|
||||
export function getUsersLimits(): ActionFuncAsync<UsersLimits> {
|
||||
export function getServerLimits(): ActionFuncAsync<ServerLimits> {
|
||||
return async (dispatch, getState) => {
|
||||
const roles = getCurrentUserRoles(getState());
|
||||
const amIAdmin = isAdmin(roles);
|
||||
@@ -21,26 +21,31 @@ export function getUsersLimits(): ActionFuncAsync<UsersLimits> {
|
||||
data: {
|
||||
activeUserCount: 0,
|
||||
maxUsersLimit: 0,
|
||||
postCount: 0,
|
||||
maxPostLimit: 0,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
let response;
|
||||
try {
|
||||
response = await Client4.getUsersLimits();
|
||||
response = await Client4.getServerLimits();
|
||||
} catch (err) {
|
||||
forceLogoutIfNecessary(err, dispatch, getState);
|
||||
dispatch(logError(err));
|
||||
return {error: err as ServerError};
|
||||
}
|
||||
|
||||
const data: UsersLimits = {
|
||||
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_USERS_LIMITS, data});
|
||||
dispatch({type: LimitsTypes.RECIEVED_APP_LIMITS, data});
|
||||
|
||||
return {data};
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import {UserTypes, AdminTypes} from 'mattermost-redux/action_types';
|
||||
import {logError} from 'mattermost-redux/actions/errors';
|
||||
import {setServerVersion, getClientConfig, getLicenseConfig} from 'mattermost-redux/actions/general';
|
||||
import {bindClientFunc, forceLogoutIfNecessary, debounce} from 'mattermost-redux/actions/helpers';
|
||||
import {getUsersLimits} from 'mattermost-redux/actions/limits';
|
||||
import {getServerLimits} from 'mattermost-redux/actions/limits';
|
||||
import {getMyPreferences} from 'mattermost-redux/actions/preferences';
|
||||
import {loadRolesIfNeeded} from 'mattermost-redux/actions/roles';
|
||||
import {getMyTeams, getMyTeamMembers, getMyTeamUnreads} from 'mattermost-redux/actions/teams';
|
||||
@@ -76,7 +76,7 @@ export function loadMe(): ActionFuncAsync<boolean> {
|
||||
const isCollapsedThreads = isCollapsedThreadsEnabled(getState());
|
||||
await dispatch(getMyTeamUnreads(isCollapsedThreads));
|
||||
|
||||
await dispatch(getUsersLimits());
|
||||
await dispatch(getServerLimits());
|
||||
} catch (error) {
|
||||
dispatch(logError(error as ServerError));
|
||||
return {error: error as ServerError};
|
||||
|
||||
@@ -6,13 +6,13 @@ import {combineReducers} from 'redux';
|
||||
|
||||
import {LimitsTypes} from 'mattermost-redux/action_types';
|
||||
|
||||
function usersLimits(state = {}, action: AnyAction) {
|
||||
function serverLimits(state = {}, action: AnyAction) {
|
||||
switch (action.type) {
|
||||
case LimitsTypes.RECIEVED_USERS_LIMITS: {
|
||||
const usersLimits = action.data;
|
||||
case LimitsTypes.RECIEVED_APP_LIMITS: {
|
||||
const serverLimits = action.data;
|
||||
return {
|
||||
...state,
|
||||
...usersLimits,
|
||||
...serverLimits,
|
||||
};
|
||||
}
|
||||
default:
|
||||
@@ -21,5 +21,5 @@ function usersLimits(state = {}, action: AnyAction) {
|
||||
}
|
||||
|
||||
export default combineReducers({
|
||||
usersLimits,
|
||||
serverLimits,
|
||||
});
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import type {UsersLimits} from '@mattermost/types/limits';
|
||||
import type {ServerLimits} from '@mattermost/types/limits';
|
||||
import type {GlobalState} from '@mattermost/types/store';
|
||||
|
||||
export function getUsersLimits(state: GlobalState): UsersLimits {
|
||||
return state.entities.limits.usersLimits;
|
||||
export function getServerLimits(state: GlobalState): ServerLimits {
|
||||
return state.entities.limits.serverLimits;
|
||||
}
|
||||
|
||||
@@ -36,9 +36,11 @@ const state: GlobalState = {
|
||||
dndEndTimes: {},
|
||||
},
|
||||
limits: {
|
||||
usersLimits: {
|
||||
serverLimits: {
|
||||
activeUserCount: 0,
|
||||
maxUsersLimit: 0,
|
||||
postCount: 0,
|
||||
maxPostLimit: 0,
|
||||
},
|
||||
},
|
||||
teams: {
|
||||
|
||||
@@ -103,7 +103,7 @@ import type {
|
||||
SubmitDialogResponse,
|
||||
} from '@mattermost/types/integrations';
|
||||
import type {Job, JobTypeBase} from '@mattermost/types/jobs';
|
||||
import type {UsersLimits} from '@mattermost/types/limits';
|
||||
import type {ServerLimits} from '@mattermost/types/limits';
|
||||
import type {
|
||||
MarketplaceApp,
|
||||
MarketplacePlugin,
|
||||
@@ -498,8 +498,8 @@ export default class Client4 {
|
||||
return `${this.getBaseRoute()}/limits`;
|
||||
}
|
||||
|
||||
getUsersLimitsRoute() {
|
||||
return `${this.getLimitsRoute()}/users`;
|
||||
getServerLimitsRoute() {
|
||||
return `${this.getLimitsRoute()}/server`;
|
||||
}
|
||||
|
||||
getCSRFFromCookie() {
|
||||
@@ -1220,9 +1220,9 @@ export default class Client4 {
|
||||
|
||||
// Limits Routes
|
||||
|
||||
getUsersLimits = () => {
|
||||
return this.doFetchWithResponse<UsersLimits>(
|
||||
`${this.getUsersLimitsRoute()}`,
|
||||
getServerLimits = () => {
|
||||
return this.doFetchWithResponse<ServerLimits>(
|
||||
`${this.getServerLimitsRoute()}`,
|
||||
{
|
||||
method: 'get',
|
||||
},
|
||||
|
||||
@@ -2,10 +2,13 @@
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
export type LimitsState = {
|
||||
usersLimits: UsersLimits;
|
||||
serverLimits: ServerLimits;
|
||||
};
|
||||
|
||||
export type UsersLimits = {
|
||||
export type ServerLimits = {
|
||||
activeUserCount: number;
|
||||
maxUsersLimit: number;
|
||||
|
||||
maxPostLimit: number;
|
||||
postCount: number;
|
||||
};
|
||||
|
||||
Ссылка в новой задаче
Block a user