[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
|
||||
hasExceededCharacterLimit={false}
|
||||
hasText={true}
|
||||
isMarkdownPreviewEnabled={false}
|
||||
previewMessageLink={
|
||||
<Memo(MemoizedFormattedMessage)
|
||||
defaultMessage="Edit"
|
||||
@@ -215,7 +214,6 @@ exports[`components/EditChannelHeaderModal error with intl message 1`] = `
|
||||
<TextboxLinks
|
||||
hasExceededCharacterLimit={false}
|
||||
hasText={true}
|
||||
isMarkdownPreviewEnabled={false}
|
||||
previewMessageLink={
|
||||
<Memo(MemoizedFormattedMessage)
|
||||
defaultMessage="Edit"
|
||||
@@ -364,7 +362,6 @@ exports[`components/EditChannelHeaderModal error without intl message 1`] = `
|
||||
<TextboxLinks
|
||||
hasExceededCharacterLimit={false}
|
||||
hasText={true}
|
||||
isMarkdownPreviewEnabled={false}
|
||||
previewMessageLink={
|
||||
<Memo(MemoizedFormattedMessage)
|
||||
defaultMessage="Edit"
|
||||
@@ -505,7 +502,6 @@ exports[`components/EditChannelHeaderModal should match snapshot, init 1`] = `
|
||||
<TextboxLinks
|
||||
hasExceededCharacterLimit={false}
|
||||
hasText={true}
|
||||
isMarkdownPreviewEnabled={false}
|
||||
previewMessageLink={
|
||||
<Memo(MemoizedFormattedMessage)
|
||||
defaultMessage="Edit"
|
||||
@@ -636,7 +632,6 @@ exports[`components/EditChannelHeaderModal submitted 1`] = `
|
||||
<TextboxLinks
|
||||
hasExceededCharacterLimit={false}
|
||||
hasText={true}
|
||||
isMarkdownPreviewEnabled={false}
|
||||
previewMessageLink={
|
||||
<Memo(MemoizedFormattedMessage)
|
||||
defaultMessage="Edit"
|
||||
|
||||
@@ -253,7 +253,6 @@ export class EditChannelHeaderModal extends React.PureComponent<Props, State> {
|
||||
</div>
|
||||
<div className='post-create-footer'>
|
||||
<TextboxLinks
|
||||
isMarkdownPreviewEnabled={this.props.markdownPreviewFeatureIsEnabled}
|
||||
showPreview={this.props.shouldShowPreview}
|
||||
updatePreview={this.setShowPreview}
|
||||
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 {showPreviewOnEditChannelHeaderModal} from 'selectors/views/textbox';
|
||||
|
||||
import {Constants} from 'utils/constants';
|
||||
import {isFeatureEnabled} from 'utils/utils';
|
||||
|
||||
import type {GlobalState} from 'types/store';
|
||||
|
||||
import EditChannelHeaderModal from './edit_channel_header_modal';
|
||||
|
||||
function mapStateToProps(state: GlobalState) {
|
||||
return {
|
||||
markdownPreviewFeatureIsEnabled: isFeatureEnabled(Constants.PRE_RELEASE_FEATURES.MARKDOWN_PREVIEW, state),
|
||||
shouldShowPreview: showPreviewOnEditChannelHeaderModal(state),
|
||||
ctrlSend: getBool(state, Preferences.CATEGORY_ADVANCED_SETTINGS, 'send_on_ctrl_enter'),
|
||||
};
|
||||
|
||||
@@ -12,7 +12,6 @@ type Props = {
|
||||
previewMessageLink?: ReactNode;
|
||||
hasText?: boolean;
|
||||
hasExceededCharacterLimit?: boolean;
|
||||
isMarkdownPreviewEnabled: boolean;
|
||||
updatePreview?: (showPreview: boolean) => void;
|
||||
};
|
||||
|
||||
@@ -21,7 +20,6 @@ function TextboxLinks({
|
||||
previewMessageLink,
|
||||
hasText = false,
|
||||
hasExceededCharacterLimit = false,
|
||||
isMarkdownPreviewEnabled,
|
||||
updatePreview,
|
||||
}: Props) {
|
||||
const togglePreview = (e: MouseEvent) => {
|
||||
@@ -48,25 +46,22 @@ function TextboxLinks({
|
||||
);
|
||||
}
|
||||
|
||||
let previewLink = null;
|
||||
if (isMarkdownPreviewEnabled) {
|
||||
previewLink = (
|
||||
<button
|
||||
id='previewLink'
|
||||
onClick={togglePreview}
|
||||
className='style--none textbox-preview-link color--link'
|
||||
>
|
||||
{showPreview ? (
|
||||
editHeader
|
||||
) : (
|
||||
<FormattedMessage
|
||||
id='textbox.preview'
|
||||
defaultMessage='Preview'
|
||||
/>
|
||||
)}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
const previewLink = (
|
||||
<button
|
||||
id='previewLink'
|
||||
onClick={togglePreview}
|
||||
className='style--none textbox-preview-link color--link'
|
||||
>
|
||||
{showPreview ? (
|
||||
editHeader
|
||||
) : (
|
||||
<FormattedMessage
|
||||
id='textbox.preview'
|
||||
defaultMessage='Preview'
|
||||
/>
|
||||
)}
|
||||
</button>
|
||||
);
|
||||
|
||||
const helpText = (
|
||||
<div
|
||||
|
||||
@@ -28,7 +28,8 @@ import PerformanceDebuggingSection from './performance_debugging_section';
|
||||
import SettingDesktopHeader from '../headers/setting_desktop_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 = {
|
||||
[key: string]: string | undefined;
|
||||
@@ -63,7 +64,7 @@ export type Props = {
|
||||
};
|
||||
|
||||
type State = {
|
||||
preReleaseFeatures: typeof PreReleaseFeatures;
|
||||
preReleaseFeatures: PreReleaseFeaturesType;
|
||||
settings: Settings;
|
||||
enabledFeatures: number;
|
||||
isSaving: boolean;
|
||||
@@ -92,7 +93,6 @@ export default class AdvancedSettingsDisplay extends React.PureComponent<Props,
|
||||
};
|
||||
|
||||
const PreReleaseFeaturesLocal = JSON.parse(JSON.stringify(PreReleaseFeatures));
|
||||
delete PreReleaseFeaturesLocal.MARKDOWN_PREVIEW;
|
||||
const preReleaseFeaturesKeys = Object.keys(PreReleaseFeaturesLocal);
|
||||
|
||||
let enabledFeatures = 0;
|
||||
@@ -709,7 +709,7 @@ export default class AdvancedSettingsDisplay extends React.PureComponent<Props,
|
||||
const inputs = [];
|
||||
|
||||
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(
|
||||
<div key={'advancedPreviewFeatures_' + feature.label}>
|
||||
<div className='checkbox'>
|
||||
|
||||
@@ -1971,12 +1971,7 @@ export const Constants = {
|
||||
COMMAND_SUGGESTION_USER: 'user',
|
||||
},
|
||||
FeatureTogglePrefix: 'feature_enabled_',
|
||||
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',
|
||||
},
|
||||
},
|
||||
PRE_RELEASE_FEATURES: {},
|
||||
OVERLAY_TIME_DELAY_SMALL: 100,
|
||||
OVERLAY_TIME_DELAY: 400,
|
||||
OVERLAY_DEFAULT_TRIGGER: ['hover', 'focus'],
|
||||
|
||||
Ссылка в новой задаче
Block a user