Relax post action requirements to allow undefined name (#33612) (#33767)

Automatic Merge
Этот коммит содержится в:
Mattermost Build
2025-08-21 13:04:04 +03:00
коммит произвёл GitHub
родитель 4c718c4b9a
Коммит 2a35a97a18
6 изменённых файлов: 16 добавлений и 19 удалений

Просмотреть файл

@@ -331,7 +331,9 @@ function shouldSkipNotification(
if (attachment.fields) {
for (const field of attachment.fields) {
appendText(field.title);
appendText(field.value);
if (typeof field.value === 'string') {
appendText(field.value);
}
}
}
}

Просмотреть файл

@@ -56,6 +56,8 @@ const ActionButton = ({
(action.style.match('^#(?:[0-9a-fA-F]{3}){1,2}$') && action.style);
}
const name = action.name || action.id || '';
return (
<ActionBtn
data-action-id={action.id}
@@ -71,7 +73,7 @@ const ActionButton = ({
text={actionExecutingMessage}
>
<Markdown
message={action.name}
message={name}
options={markdownOptions}
/>
</LoadingWrapper>

Просмотреть файл

@@ -99,6 +99,7 @@ export default class ActionMenu extends React.PureComponent<Props, State> {
render() {
const {action, disabled} = this.props;
const name = action.name || action.id || '';
return (
<PostContext.Consumer>
@@ -106,7 +107,7 @@ export default class ActionMenu extends React.PureComponent<Props, State> {
<AutocompleteSelector
providers={this.providers}
onSelected={this.handleSelected}
placeholder={action.name}
placeholder={name}
inputClassName='post-attachment-dropdown'
value={this.state.value}
toggleFocus={handlePopupOpened}

Просмотреть файл

@@ -5,7 +5,7 @@ import truncate from 'lodash/truncate';
import React from 'react';
import type {KeyboardEvent, MouseEvent, CSSProperties} from 'react';
import type {PostAction, PostActionOption} from '@mattermost/types/integration_actions';
import type {PostActionOption} from '@mattermost/types/integration_actions';
import type {
MessageAttachment as MessageAttachmentType,
} from '@mattermost/types/message_attachments';
@@ -144,7 +144,7 @@ export default class MessageAttachment extends React.PureComponent<Props, State>
const content = [] as JSX.Element[];
actions.forEach((action: PostAction) => {
actions.forEach((action) => {
if (!action.id || !action.name) {
return;
}

Просмотреть файл

@@ -4,9 +4,9 @@
import {isArrayOf} from './utilities';
export type PostAction = {
id: string;
id?: string;
type?: string;
name: string;
name?: string;
disabled?: boolean;
style?: string;
data_source?: string;
@@ -20,19 +20,11 @@ export function isPostAction(v: unknown): v is PostAction {
return false;
}
if (!('id' in v)) {
if ('id' in v && typeof v.id !== 'string') {
return false;
}
if (typeof v.id !== 'string') {
return false;
}
if (!('name' in v)) {
return false;
}
if (typeof v.name !== 'string') {
if ('name' in v && typeof v.name !== 'string') {
return false;
}

Просмотреть файл

@@ -103,8 +103,8 @@ function isMessageAttachment(v: unknown): v is MessageAttachment {
}
export type MessageAttachmentField = {
title: string;
value: any;
title?: string;
value?: unknown;
short?: boolean;
}