[MM-59059] Re enable markdown preview for channel header in user advanced settings (#27440)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
926c7aeac8
Коммит
12ad9f3fe2
@@ -84,7 +84,6 @@ exports[`components/EditChannelHeaderModal edit direct message channel 1`] = `
|
|||||||
<TextboxLinks
|
<TextboxLinks
|
||||||
hasExceededCharacterLimit={false}
|
hasExceededCharacterLimit={false}
|
||||||
hasText={true}
|
hasText={true}
|
||||||
isMarkdownPreviewEnabled={false}
|
|
||||||
previewMessageLink={
|
previewMessageLink={
|
||||||
<Memo(MemoizedFormattedMessage)
|
<Memo(MemoizedFormattedMessage)
|
||||||
defaultMessage="Edit"
|
defaultMessage="Edit"
|
||||||
@@ -215,7 +214,6 @@ exports[`components/EditChannelHeaderModal error with intl message 1`] = `
|
|||||||
<TextboxLinks
|
<TextboxLinks
|
||||||
hasExceededCharacterLimit={false}
|
hasExceededCharacterLimit={false}
|
||||||
hasText={true}
|
hasText={true}
|
||||||
isMarkdownPreviewEnabled={false}
|
|
||||||
previewMessageLink={
|
previewMessageLink={
|
||||||
<Memo(MemoizedFormattedMessage)
|
<Memo(MemoizedFormattedMessage)
|
||||||
defaultMessage="Edit"
|
defaultMessage="Edit"
|
||||||
@@ -364,7 +362,6 @@ exports[`components/EditChannelHeaderModal error without intl message 1`] = `
|
|||||||
<TextboxLinks
|
<TextboxLinks
|
||||||
hasExceededCharacterLimit={false}
|
hasExceededCharacterLimit={false}
|
||||||
hasText={true}
|
hasText={true}
|
||||||
isMarkdownPreviewEnabled={false}
|
|
||||||
previewMessageLink={
|
previewMessageLink={
|
||||||
<Memo(MemoizedFormattedMessage)
|
<Memo(MemoizedFormattedMessage)
|
||||||
defaultMessage="Edit"
|
defaultMessage="Edit"
|
||||||
@@ -505,7 +502,6 @@ exports[`components/EditChannelHeaderModal should match snapshot, init 1`] = `
|
|||||||
<TextboxLinks
|
<TextboxLinks
|
||||||
hasExceededCharacterLimit={false}
|
hasExceededCharacterLimit={false}
|
||||||
hasText={true}
|
hasText={true}
|
||||||
isMarkdownPreviewEnabled={false}
|
|
||||||
previewMessageLink={
|
previewMessageLink={
|
||||||
<Memo(MemoizedFormattedMessage)
|
<Memo(MemoizedFormattedMessage)
|
||||||
defaultMessage="Edit"
|
defaultMessage="Edit"
|
||||||
@@ -636,7 +632,6 @@ exports[`components/EditChannelHeaderModal submitted 1`] = `
|
|||||||
<TextboxLinks
|
<TextboxLinks
|
||||||
hasExceededCharacterLimit={false}
|
hasExceededCharacterLimit={false}
|
||||||
hasText={true}
|
hasText={true}
|
||||||
isMarkdownPreviewEnabled={false}
|
|
||||||
previewMessageLink={
|
previewMessageLink={
|
||||||
<Memo(MemoizedFormattedMessage)
|
<Memo(MemoizedFormattedMessage)
|
||||||
defaultMessage="Edit"
|
defaultMessage="Edit"
|
||||||
|
|||||||
@@ -253,7 +253,6 @@ export class EditChannelHeaderModal extends React.PureComponent<Props, State> {
|
|||||||
</div>
|
</div>
|
||||||
<div className='post-create-footer'>
|
<div className='post-create-footer'>
|
||||||
<TextboxLinks
|
<TextboxLinks
|
||||||
isMarkdownPreviewEnabled={this.props.markdownPreviewFeatureIsEnabled}
|
|
||||||
showPreview={this.props.shouldShowPreview}
|
showPreview={this.props.shouldShowPreview}
|
||||||
updatePreview={this.setShowPreview}
|
updatePreview={this.setShowPreview}
|
||||||
hasText={this.state.header ? this.state.header.length > 0 : false}
|
hasText={this.state.header ? this.state.header.length > 0 : false}
|
||||||
|
|||||||
@@ -13,16 +13,12 @@ import {getBool} from 'mattermost-redux/selectors/entities/preferences';
|
|||||||
import {setShowPreviewOnEditChannelHeaderModal} from 'actions/views/textbox';
|
import {setShowPreviewOnEditChannelHeaderModal} from 'actions/views/textbox';
|
||||||
import {showPreviewOnEditChannelHeaderModal} from 'selectors/views/textbox';
|
import {showPreviewOnEditChannelHeaderModal} from 'selectors/views/textbox';
|
||||||
|
|
||||||
import {Constants} from 'utils/constants';
|
|
||||||
import {isFeatureEnabled} from 'utils/utils';
|
|
||||||
|
|
||||||
import type {GlobalState} from 'types/store';
|
import type {GlobalState} from 'types/store';
|
||||||
|
|
||||||
import EditChannelHeaderModal from './edit_channel_header_modal';
|
import EditChannelHeaderModal from './edit_channel_header_modal';
|
||||||
|
|
||||||
function mapStateToProps(state: GlobalState) {
|
function mapStateToProps(state: GlobalState) {
|
||||||
return {
|
return {
|
||||||
markdownPreviewFeatureIsEnabled: isFeatureEnabled(Constants.PRE_RELEASE_FEATURES.MARKDOWN_PREVIEW, state),
|
|
||||||
shouldShowPreview: showPreviewOnEditChannelHeaderModal(state),
|
shouldShowPreview: showPreviewOnEditChannelHeaderModal(state),
|
||||||
ctrlSend: getBool(state, Preferences.CATEGORY_ADVANCED_SETTINGS, 'send_on_ctrl_enter'),
|
ctrlSend: getBool(state, Preferences.CATEGORY_ADVANCED_SETTINGS, 'send_on_ctrl_enter'),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ type Props = {
|
|||||||
previewMessageLink?: ReactNode;
|
previewMessageLink?: ReactNode;
|
||||||
hasText?: boolean;
|
hasText?: boolean;
|
||||||
hasExceededCharacterLimit?: boolean;
|
hasExceededCharacterLimit?: boolean;
|
||||||
isMarkdownPreviewEnabled: boolean;
|
|
||||||
updatePreview?: (showPreview: boolean) => void;
|
updatePreview?: (showPreview: boolean) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -21,7 +20,6 @@ function TextboxLinks({
|
|||||||
previewMessageLink,
|
previewMessageLink,
|
||||||
hasText = false,
|
hasText = false,
|
||||||
hasExceededCharacterLimit = false,
|
hasExceededCharacterLimit = false,
|
||||||
isMarkdownPreviewEnabled,
|
|
||||||
updatePreview,
|
updatePreview,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
const togglePreview = (e: MouseEvent) => {
|
const togglePreview = (e: MouseEvent) => {
|
||||||
@@ -48,9 +46,7 @@ function TextboxLinks({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let previewLink = null;
|
const previewLink = (
|
||||||
if (isMarkdownPreviewEnabled) {
|
|
||||||
previewLink = (
|
|
||||||
<button
|
<button
|
||||||
id='previewLink'
|
id='previewLink'
|
||||||
onClick={togglePreview}
|
onClick={togglePreview}
|
||||||
@@ -66,7 +62,6 @@ function TextboxLinks({
|
|||||||
)}
|
)}
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
const helpText = (
|
const helpText = (
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ import PerformanceDebuggingSection from './performance_debugging_section';
|
|||||||
import SettingDesktopHeader from '../headers/setting_desktop_header';
|
import SettingDesktopHeader from '../headers/setting_desktop_header';
|
||||||
import SettingMobileHeader from '../headers/setting_mobile_header';
|
import SettingMobileHeader from '../headers/setting_mobile_header';
|
||||||
|
|
||||||
const PreReleaseFeatures = Constants.PRE_RELEASE_FEATURES;
|
type PreReleaseFeaturesType = Record<string, {label: string; description: string}>;
|
||||||
|
const PreReleaseFeatures: PreReleaseFeaturesType = Constants.PRE_RELEASE_FEATURES;
|
||||||
|
|
||||||
type Settings = {
|
type Settings = {
|
||||||
[key: string]: string | undefined;
|
[key: string]: string | undefined;
|
||||||
@@ -63,7 +64,7 @@ export type Props = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
preReleaseFeatures: typeof PreReleaseFeatures;
|
preReleaseFeatures: PreReleaseFeaturesType;
|
||||||
settings: Settings;
|
settings: Settings;
|
||||||
enabledFeatures: number;
|
enabledFeatures: number;
|
||||||
isSaving: boolean;
|
isSaving: boolean;
|
||||||
@@ -92,7 +93,6 @@ export default class AdvancedSettingsDisplay extends React.PureComponent<Props,
|
|||||||
};
|
};
|
||||||
|
|
||||||
const PreReleaseFeaturesLocal = JSON.parse(JSON.stringify(PreReleaseFeatures));
|
const PreReleaseFeaturesLocal = JSON.parse(JSON.stringify(PreReleaseFeatures));
|
||||||
delete PreReleaseFeaturesLocal.MARKDOWN_PREVIEW;
|
|
||||||
const preReleaseFeaturesKeys = Object.keys(PreReleaseFeaturesLocal);
|
const preReleaseFeaturesKeys = Object.keys(PreReleaseFeaturesLocal);
|
||||||
|
|
||||||
let enabledFeatures = 0;
|
let enabledFeatures = 0;
|
||||||
@@ -709,7 +709,7 @@ export default class AdvancedSettingsDisplay extends React.PureComponent<Props,
|
|||||||
const inputs = [];
|
const inputs = [];
|
||||||
|
|
||||||
this.state.preReleaseFeaturesKeys.forEach((key) => {
|
this.state.preReleaseFeaturesKeys.forEach((key) => {
|
||||||
const feature = this.state.preReleaseFeatures[key as keyof typeof PreReleaseFeatures];
|
const feature = this.state.preReleaseFeatures[key as keyof PreReleaseFeaturesType];
|
||||||
inputs.push(
|
inputs.push(
|
||||||
<div key={'advancedPreviewFeatures_' + feature.label}>
|
<div key={'advancedPreviewFeatures_' + feature.label}>
|
||||||
<div className='checkbox'>
|
<div className='checkbox'>
|
||||||
|
|||||||
@@ -1971,12 +1971,7 @@ export const Constants = {
|
|||||||
COMMAND_SUGGESTION_USER: 'user',
|
COMMAND_SUGGESTION_USER: 'user',
|
||||||
},
|
},
|
||||||
FeatureTogglePrefix: 'feature_enabled_',
|
FeatureTogglePrefix: 'feature_enabled_',
|
||||||
PRE_RELEASE_FEATURES: {
|
PRE_RELEASE_FEATURES: {},
|
||||||
MARKDOWN_PREVIEW: {
|
|
||||||
label: 'markdown_preview', // github issue: https://github.com/mattermost/platform/pull/1389
|
|
||||||
description: 'Show markdown preview option in message input box',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
OVERLAY_TIME_DELAY_SMALL: 100,
|
OVERLAY_TIME_DELAY_SMALL: 100,
|
||||||
OVERLAY_TIME_DELAY: 400,
|
OVERLAY_TIME_DELAY: 400,
|
||||||
OVERLAY_DEFAULT_TRIGGER: ['hover', 'focus'],
|
OVERLAY_DEFAULT_TRIGGER: ['hover', 'focus'],
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user