* Added scaffolding for unrevealed BoR post * Displayed reveal UI * Displayed expiry timer * WIP * Displayed own post indicator and blur text * restored button * Ungrouped BoR posts * WIP * WIP * DIsplayed error message on revealing * Added last run check on mobile app cleanup job * Cleanup * lint fix * i18n-fix * Added tests * test: add test suite for revealBoRPost function * test: add unrevealed burn on read post test file * feat: add tests for UnrevealedBurnOnReadPost component * test: update UnrevealedBurnOnReadPost test with PostModel type * test: replace toBeTruthy with toBeVisible for component visibility assertions * test: add initial test file for expiry timer component * test: add comprehensive tests for ExpiryCountdown component * refactor: clean up test formatting and remove redundant test case * fix: adjust test timing for ExpiryCountdown onExpiry callback * test: fix timer test by advancing timers in smaller increments * Added tests * Updated tests * fixed accidental change * restored package.resolved * WIP review fixes * Review fixes * Review fixes * Fixed tests * restored package.resolved * WIP * test: add test for skipping BoR post cleanup within 15 minutes * test: add comprehensive test cases for expiredBoRPostCleanup * WIP * WIP * test: add bor.test.ts placeholder file * test: add comprehensive tests for BoR utility functions * test: add comprehensive tests for formatTime function * WIP * test: add comprehensive tests for getLastBoRPostCleanupRun function * Added tests * removed a commented code * post list optimization * test: add test case for updating unrevealed burn-on-read post * fix: handle error logging in expiredBoRPostCleanup test * test: add test case for updateLastBoRCleanupRun error handling * review fixes * lint fixes * Added WS event handling (#9320) * Added WS event handling * test: add burn on read websocket action test * test: add tests for handleBoRPostRevealedEvent in burn_on_read * Added tests * test: add comprehensive error handling test cases for burn on read * Added tests and error handling * BoR post - restricted actions (#9315) * Restricted post actions for BoR post type * Prevent opening thread fr nBoR post * WIP * fix: remove redundant observable wrapping in post options * fixed a change * removed broken * restored package.resolved * Added tests * Awaiting for last run to be set * Added tests for validating expiry timer behaviour (#9338) * Added tests for validating expiry timer behaviour * No need of use event setup * Bor ux fixes (#9336) * WIP * UI and delete fixes * lint fixes * fixed tests * Improved mocking * Improved test
236 lines
6.5 KiB
TypeScript
236 lines
6.5 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import {defineMessages, type MessageDescriptor} from 'react-intl';
|
|
|
|
import keyMirror from '@utils/key_mirror';
|
|
|
|
export const SNACK_BAR_TYPE = keyMirror({
|
|
ADD_CHANNEL_MEMBERS: null,
|
|
AGENT_STOP_ERROR: null,
|
|
AGENT_REGENERATE_ERROR: null,
|
|
AGENT_TOOL_APPROVAL_ERROR: null,
|
|
CODE_COPIED: null,
|
|
FAVORITE_CHANNEL: null,
|
|
FOLLOW_THREAD: null,
|
|
INFO_COPIED: null,
|
|
LINK_COPIED: null,
|
|
LINK_COPY_FAILED: null,
|
|
MESSAGE_COPIED: null,
|
|
MUTE_CHANNEL: null,
|
|
REMOVE_CHANNEL_USER: null,
|
|
TEXT_COPIED: null,
|
|
UNFAVORITE_CHANNEL: null,
|
|
UNMUTE_CHANNEL: null,
|
|
UNFOLLOW_THREAD: null,
|
|
CREATE_POST_ERROR: null,
|
|
CONNECTION_ERROR: null,
|
|
SCHEDULED_POST_CREATION_ERROR: null,
|
|
RESCHEDULED_POST: null,
|
|
DELETE_SCHEDULED_POST_ERROR: null,
|
|
PLAYBOOK_ERROR: null,
|
|
BOR_POST_EXPIRED: null,
|
|
});
|
|
|
|
export const MESSAGE_TYPE = {
|
|
SUCCESS: 'success',
|
|
ERROR: 'error',
|
|
DEFAULT: 'default',
|
|
};
|
|
|
|
export type SnackBarConfig = {
|
|
message: MessageDescriptor;
|
|
iconName: string;
|
|
canUndo: boolean;
|
|
type?: typeof MESSAGE_TYPE[keyof typeof MESSAGE_TYPE];
|
|
};
|
|
|
|
const messages = defineMessages({
|
|
ADD_CHANNEL_MEMBERS: {
|
|
id: 'snack.bar.channel.members.added',
|
|
defaultMessage: '{numMembers, number} {numMembers, plural, one {member} other {members}} added',
|
|
},
|
|
AGENT_STOP_ERROR: {
|
|
id: 'snack.bar.agent.stop.error',
|
|
defaultMessage: 'Failed to stop generation',
|
|
},
|
|
AGENT_REGENERATE_ERROR: {
|
|
id: 'snack.bar.agent.regenerate.error',
|
|
defaultMessage: 'Failed to regenerate response',
|
|
},
|
|
AGENT_TOOL_APPROVAL_ERROR: {
|
|
id: 'snack.bar.agent.tool.approval.error',
|
|
defaultMessage: 'Failed to submit tool approval',
|
|
},
|
|
CODE_COPIED: {
|
|
id: 'snack.bar.code.copied',
|
|
defaultMessage: 'Code copied to clipboard',
|
|
},
|
|
FAVORITE_CHANNEL: {
|
|
id: 'snack.bar.favorited.channel',
|
|
defaultMessage: 'This channel was favorited',
|
|
},
|
|
FOLLOW_THREAD: {
|
|
id: 'snack.bar.following.thread',
|
|
defaultMessage: 'Thread followed',
|
|
},
|
|
INFO_COPIED: {
|
|
id: 'snack.bar.info.copied',
|
|
defaultMessage: 'Info copied to clipboard',
|
|
},
|
|
LINK_COPIED: {
|
|
id: 'snack.bar.link.copied',
|
|
defaultMessage: 'Link copied to clipboard',
|
|
},
|
|
LINK_COPY_FAILED: {
|
|
id: 'gallery.copy_link.failed',
|
|
defaultMessage: 'Failed to copy link to clipboard',
|
|
},
|
|
MESSAGE_COPIED: {
|
|
id: 'snack.bar.message.copied',
|
|
defaultMessage: 'Text copied to clipboard',
|
|
},
|
|
MUTE_CHANNEL: {
|
|
id: 'snack.bar.mute.channel',
|
|
defaultMessage: 'This channel was muted',
|
|
},
|
|
REMOVE_CHANNEL_USER: {
|
|
id: 'snack.bar.remove.user',
|
|
defaultMessage: '1 member was removed from the channel',
|
|
},
|
|
TEXT_COPIED: {
|
|
id: 'snack.bar.text.copied',
|
|
defaultMessage: 'Copied to clipboard',
|
|
},
|
|
UNFAVORITE_CHANNEL: {
|
|
id: 'snack.bar.unfavorite.channel',
|
|
defaultMessage: 'This channel was unfavorited',
|
|
},
|
|
UNMUTE_CHANNEL: {
|
|
id: 'snack.bar.unmute.channel',
|
|
defaultMessage: 'This channel was unmuted',
|
|
},
|
|
UNFOLLOW_THREAD: {
|
|
id: 'snack.bar.unfollow.thread',
|
|
defaultMessage: 'Thread unfollowed',
|
|
},
|
|
PLAYBOOK_ERROR: {
|
|
id: 'snack.bar.playbook.error',
|
|
defaultMessage: 'Unable to perform action. Please try again later.',
|
|
},
|
|
BOR_POST_EXPIRED: {
|
|
id: 'snack.bar.bor_post_expired.error',
|
|
defaultMessage: 'This burn-on-read post has expired and can no longer be revealed.',
|
|
},
|
|
});
|
|
|
|
export const SNACK_BAR_CONFIG: Record<string, SnackBarConfig> = {
|
|
ADD_CHANNEL_MEMBERS: {
|
|
message: messages.ADD_CHANNEL_MEMBERS,
|
|
iconName: 'check',
|
|
canUndo: false,
|
|
},
|
|
AGENT_STOP_ERROR: {
|
|
message: messages.AGENT_STOP_ERROR,
|
|
iconName: 'alert-outline',
|
|
canUndo: false,
|
|
type: MESSAGE_TYPE.ERROR,
|
|
},
|
|
AGENT_REGENERATE_ERROR: {
|
|
message: messages.AGENT_REGENERATE_ERROR,
|
|
iconName: 'alert-outline',
|
|
canUndo: false,
|
|
type: MESSAGE_TYPE.ERROR,
|
|
},
|
|
AGENT_TOOL_APPROVAL_ERROR: {
|
|
message: messages.AGENT_TOOL_APPROVAL_ERROR,
|
|
iconName: 'alert-outline',
|
|
canUndo: false,
|
|
type: MESSAGE_TYPE.ERROR,
|
|
},
|
|
CODE_COPIED: {
|
|
message: messages.CODE_COPIED,
|
|
iconName: 'content-copy',
|
|
canUndo: false,
|
|
},
|
|
FAVORITE_CHANNEL: {
|
|
message: messages.FAVORITE_CHANNEL,
|
|
iconName: 'star',
|
|
canUndo: true,
|
|
},
|
|
FOLLOW_THREAD: {
|
|
message: messages.FOLLOW_THREAD,
|
|
iconName: 'check',
|
|
canUndo: true,
|
|
},
|
|
INFO_COPIED: {
|
|
message: messages.INFO_COPIED,
|
|
iconName: 'content-copy',
|
|
canUndo: false,
|
|
},
|
|
LINK_COPIED: {
|
|
message: messages.LINK_COPIED,
|
|
iconName: 'link-variant',
|
|
canUndo: false,
|
|
type: MESSAGE_TYPE.SUCCESS,
|
|
},
|
|
LINK_COPY_FAILED: {
|
|
message: messages.LINK_COPY_FAILED,
|
|
iconName: 'link-variant',
|
|
canUndo: false,
|
|
type: MESSAGE_TYPE.ERROR,
|
|
},
|
|
MESSAGE_COPIED: {
|
|
message: messages.MESSAGE_COPIED,
|
|
iconName: 'content-copy',
|
|
canUndo: false,
|
|
},
|
|
MUTE_CHANNEL: {
|
|
message: messages.MUTE_CHANNEL,
|
|
iconName: 'bell-off-outline',
|
|
canUndo: true,
|
|
},
|
|
REMOVE_CHANNEL_USER: {
|
|
message: messages.REMOVE_CHANNEL_USER,
|
|
iconName: 'check',
|
|
canUndo: true,
|
|
},
|
|
TEXT_COPIED: {
|
|
message: messages.TEXT_COPIED,
|
|
iconName: 'content-copy',
|
|
canUndo: false,
|
|
type: MESSAGE_TYPE.SUCCESS,
|
|
},
|
|
UNFAVORITE_CHANNEL: {
|
|
message: messages.UNFAVORITE_CHANNEL,
|
|
iconName: 'star-outline',
|
|
canUndo: true,
|
|
},
|
|
UNMUTE_CHANNEL: {
|
|
message: messages.UNMUTE_CHANNEL,
|
|
iconName: 'bell-outline',
|
|
canUndo: true,
|
|
},
|
|
UNFOLLOW_THREAD: {
|
|
message: messages.UNFOLLOW_THREAD,
|
|
iconName: 'check',
|
|
canUndo: true,
|
|
},
|
|
PLAYBOOK_ERROR: {
|
|
message: messages.PLAYBOOK_ERROR,
|
|
iconName: 'alert-outline',
|
|
canUndo: false,
|
|
type: MESSAGE_TYPE.ERROR,
|
|
},
|
|
BOR_POST_EXPIRED: {
|
|
message: messages.BOR_POST_EXPIRED,
|
|
iconName: 'alert-outline',
|
|
canUndo: false,
|
|
type: MESSAGE_TYPE.ERROR,
|
|
},
|
|
};
|
|
|
|
export default {
|
|
SNACK_BAR_TYPE,
|
|
SNACK_BAR_CONFIG,
|
|
};
|