* Remove mattermost-redux * Move mm-redux files into app/redux * Add @redux path to tsconfig.json * Fix imports * Install missing dependencies * Fix tsc errors * Fix i18n_utils test * Fix more imports * Remove redux websocket * Fix tests * Rename @redux * Apply changes from mattermost-redux PR 1103 * Remove mattermost-redux mention in template * Add missing imports * Rename app/redux/ to app/mm-redux/ * Remove test file * Fix fetching Sidebar GM profiles Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
76 lines
2.9 KiB
TypeScript
76 lines
2.9 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
import {createSelector} from 'reselect';
|
|
import {isMinimumServerVersion} from '@mm-redux/utils/helpers';
|
|
import {General} from '../../constants';
|
|
import {GlobalState} from '@mm-redux/types/store';
|
|
import {Config} from '@mm-redux/types/config';
|
|
|
|
export function getConfig(state: GlobalState): Partial<Config> {
|
|
return state.entities.general.config;
|
|
}
|
|
|
|
export function getLicense(state: GlobalState): any {
|
|
return state.entities.general.license;
|
|
}
|
|
|
|
export function getSupportedTimezones(state: GlobalState): Array<string> {
|
|
return state.entities.general.timezones;
|
|
}
|
|
|
|
export function getCurrentUrl(state: GlobalState): string {
|
|
return state.entities.general.credentials.url;
|
|
}
|
|
|
|
export function isCompatibleWithJoinViewTeamPermissions(state: GlobalState): boolean {
|
|
const version = state.entities.general.serverVersion;
|
|
return isMinimumServerVersion(version, 5, 10, 0) ||
|
|
(version.indexOf('dev') !== -1 && isMinimumServerVersion(version, 5, 8, 0)) ||
|
|
(version.match(/^5.8.\d.\d\d\d\d.*$/) !== null && isMinimumServerVersion(version, 5, 8, 0));
|
|
}
|
|
|
|
export function hasNewPermissions(state: GlobalState): boolean {
|
|
const version = state.entities.general.serverVersion;
|
|
|
|
// FIXME This must be changed to 4, 9, 0 before we generate the 4.9.0 release
|
|
return isMinimumServerVersion(version, 4, 9, 0) ||
|
|
(version.indexOf('dev') !== -1 && isMinimumServerVersion(version, 4, 8, 0)) ||
|
|
(version.match(/^4.8.\d.\d\d\d\d.*$/) !== null && isMinimumServerVersion(version, 4, 8, 0));
|
|
}
|
|
|
|
export const canUploadFilesOnMobile: (a: GlobalState) => boolean = createSelector(
|
|
getConfig,
|
|
getLicense,
|
|
(config: Config, license: any): boolean => {
|
|
// Defaults to true if either setting doesn't exist
|
|
return config.EnableFileAttachments !== 'false' &&
|
|
(license.IsLicensed === 'false' || license.Compliance === 'false' || config.EnableMobileFileUpload !== 'false');
|
|
}
|
|
);
|
|
|
|
export const canDownloadFilesOnMobile: (a: GlobalState) => boolean = createSelector(
|
|
getConfig,
|
|
getLicense,
|
|
(config: Config, license: any): boolean => {
|
|
// Defaults to true if the setting doesn't exist
|
|
return license.IsLicensed === 'false' || license.Compliance === 'false' || config.EnableMobileFileDownload !== 'false';
|
|
}
|
|
);
|
|
|
|
export const getAutolinkedUrlSchemes: (a: GlobalState) => string[] = createSelector(
|
|
getConfig,
|
|
(config: Config): string[] => {
|
|
if (!config.CustomUrlSchemes) {
|
|
return General.DEFAULT_AUTOLINKED_URL_SCHEMES;
|
|
}
|
|
|
|
return [
|
|
...General.DEFAULT_AUTOLINKED_URL_SCHEMES,
|
|
...config.CustomUrlSchemes.split(','),
|
|
];
|
|
}
|
|
);
|
|
|
|
export const getServerVersion = (state: GlobalState): string => {
|
|
return state.entities.general.serverVersion;
|
|
};
|