Merge branch 'edits-confirmation' into 'develop'

Use different confirmation modal/snackbar messages for post editing

See merge request soapbox-pub/soapbox-fe!1701
environments/review-develop-3zknud/deployments/701
marcin mikołajczak 2022-08-04 22:45:36 +00:00
commit 89cb1432dd
5 zmienionych plików z 15 dodań i 7 usunięć

Wyświetl plik

@ -92,6 +92,7 @@ const messages = defineMessages({
exceededVideoDurationLimit: { id: 'upload_error.video_duration_limit', defaultMessage: 'Video exceeds the current duration limit ({limit} seconds)' },
scheduleError: { id: 'compose.invalid_schedule', defaultMessage: 'You must schedule a post at least 5 minutes out.' },
success: { id: 'compose.submit_success', defaultMessage: 'Your post was sent' },
editSuccess: { id: 'compose.edit_success', defaultMessage: 'Your post was edited' },
uploadErrorLimit: { id: 'upload_error.limit', defaultMessage: 'File upload limit exceeded.' },
uploadErrorPoll: { id: 'upload_error.poll', defaultMessage: 'File upload not allowed with polls.' },
view: { id: 'snackbar.view', defaultMessage: 'View' },
@ -203,12 +204,12 @@ const directComposeById = (accountId: string) =>
dispatch(openModal('COMPOSE'));
};
const handleComposeSubmit = (dispatch: AppDispatch, getState: () => RootState, data: APIEntity, status: string) => {
const handleComposeSubmit = (dispatch: AppDispatch, getState: () => RootState, data: APIEntity, status: string, edit?: boolean) => {
if (!dispatch || !getState) return;
dispatch(insertIntoTagHistory(data.tags || [], status));
dispatch(submitComposeSuccess({ ...data }));
dispatch(snackbar.success(messages.success, messages.view, `/@${data.account.acct}/posts/${data.id}`));
dispatch(snackbar.success(edit ? messages.editSuccess : messages.success, messages.view, `/@${data.account.acct}/posts/${data.id}`));
};
const needsDescriptions = (state: RootState) => {
@ -287,7 +288,7 @@ const submitCompose = (routerHistory?: History, force = false) =>
if (!statusId && data.visibility === 'direct' && getState().conversations.mounted <= 0 && routerHistory) {
routerHistory.push('/messages');
}
handleComposeSubmit(dispatch, getState, data, status);
handleComposeSubmit(dispatch, getState, data, status, !!statusId);
}).catch(function(error) {
dispatch(submitComposeFail(error));
});

Wyświetl plik

@ -11,6 +11,7 @@ import ComposeFormContainer from '../../compose/containers/compose_form_containe
const messages = defineMessages({
close: { id: 'lightbox.close', defaultMessage: 'Close' },
confirm: { id: 'confirmations.delete.confirm', defaultMessage: 'Delete' },
cancelEditing: { id: 'confirmations.cancel_editing.confirm', defaultMessage: 'Cancel editing' },
});
interface IComposeModal {
@ -31,9 +32,13 @@ const ComposeModal: React.FC<IComposeModal> = ({ onClose }) => {
if (composeText) {
dispatch(openModal('CONFIRM', {
icon: require('@tabler/icons/trash.svg'),
heading: <FormattedMessage id='confirmations.delete.heading' defaultMessage='Delete post' />,
message: <FormattedMessage id='confirmations.delete.message' defaultMessage='Are you sure you want to delete this post?' />,
confirm: intl.formatMessage(messages.confirm),
heading: statusId
? <FormattedMessage id='confirmations.cancel_editing.heading' defaultMessage='Cancel post editing' />
: <FormattedMessage id='confirmations.delete.heading' defaultMessage='Delete post' />,
message: statusId
? <FormattedMessage id='confirmations.cancel_editing.message' defaultMessage='Are you sure you want to cancel editing this post? All changes will be lost.' />
: <FormattedMessage id='confirmations.delete.message' defaultMessage='Are you sure you want to delete this post?' />,
confirm: intl.formatMessage(statusId ? messages.cancelEditing : messages.confirm),
onConfirm: () => {
dispatch(closeModal('COMPOSE'));
dispatch(cancelReplyCompose());

Wyświetl plik

@ -283,6 +283,7 @@
"compare_history_modal.header": "Historia edycji",
"compose.character_counter.title": "Wykorzystano {chars} z {maxChars} znaków",
"compose.invalid_schedule": "Musisz zaplanować wpis przynajmniej 5 minut wcześniej.",
"compose.edit_success": "Twój wpis został zedytowany",
"compose.submit_success": "Twój wpis został wysłany",
"compose_form.direct_message_warning": "Ten wpis będzie widoczny tylko dla wszystkich wspomnianych użytkowników.",
"compose_form.hashtag_warning": "Ten wpis nie będzie widoczny pod podanymi hashtagami, ponieważ jest oznaczony jako niewidoczny. Tylko publiczne wpisy mogą zostać znalezione z użyciem hashtagów.",

Wyświetl plik

@ -44,6 +44,7 @@ describe('compose reducer', () => {
type: actions.COMPOSE_SET_STATUS,
status: normalizeStatus(fromJS(require('soapbox/__fixtures__/pleroma-status-deleted.json'))),
v: { software: 'Pleroma' },
withRedraft: true,
};
const result = reducer(undefined, action);

Wyświetl plik

@ -444,7 +444,7 @@ export default function compose(state = ReducerRecord({ idempotencyKey: uuid(),
map.set('content_type', action.contentType || 'text/plain');
map.set('quote', action.status.get('quote'));
if (action.v?.software === PLEROMA && !action.withRedraft && hasIntegerMediaIds(action.status)) {
if (action.v?.software === PLEROMA && action.withRedraft && hasIntegerMediaIds(action.status)) {
map.set('media_attachments', ImmutableList());
} else {
map.set('media_attachments', action.status.media_attachments);