diff --git a/CHANGELOG.md b/CHANGELOG.md index d1f0f887..74054319 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), #### Changed * [#191](https://github.com/shlinkio/shlink-web-client/issues/191) Created `ForServerVersion` helper component which dynamically renders children if current server conditions are met. +* [#189](https://github.com/shlinkio/shlink-web-client/issues/189) Simplified short url tags and short url deletion components and reducers, by removing redundant actions. #### Deprecated diff --git a/src/short-urls/helpers/DeleteShortUrlModal.js b/src/short-urls/helpers/DeleteShortUrlModal.js index 0a50d53f..a7a0affb 100644 --- a/src/short-urls/helpers/DeleteShortUrlModal.js +++ b/src/short-urls/helpers/DeleteShortUrlModal.js @@ -1,7 +1,7 @@ import React from 'react'; import { Modal, ModalBody, ModalFooter, ModalHeader } from 'reactstrap'; import PropTypes from 'prop-types'; -import { identity } from 'ramda'; +import { identity, pipe } from 'ramda'; import { shortUrlType } from '../reducers/shortUrlsList'; import { shortUrlDeletionType } from '../reducers/shortUrlDeletion'; @@ -15,21 +15,17 @@ export default class DeleteShortUrlModal extends React.Component { shortUrlDeletion: shortUrlDeletionType, deleteShortUrl: PropTypes.func, resetDeleteShortUrl: PropTypes.func, - shortUrlDeleted: PropTypes.func, }; state = { inputValue: '' }; handleDeleteUrl = (e) => { e.preventDefault(); - const { deleteShortUrl, shortUrl, toggle, shortUrlDeleted } = this.props; + const { deleteShortUrl, shortUrl, toggle } = this.props; const { shortCode } = shortUrl; deleteShortUrl(shortCode) - .then(() => { - shortUrlDeleted(shortCode); - toggle(); - }) + .then(toggle) .catch(identity); }; @@ -40,16 +36,17 @@ export default class DeleteShortUrlModal extends React.Component { } render() { - const { shortUrl, toggle, isOpen, shortUrlDeletion } = this.props; + const { shortUrl, toggle, isOpen, shortUrlDeletion, resetDeleteShortUrl } = this.props; const { error, errorData } = shortUrlDeletion; const errorCode = error && (errorData.type || errorData.error); const hasThresholdError = errorCode === THRESHOLD_REACHED; const hasErrorOtherThanThreshold = error && errorCode !== THRESHOLD_REACHED; + const close = pipe(resetDeleteShortUrl, toggle); return ( - +
- + Delete short URL @@ -77,7 +74,7 @@ export default class DeleteShortUrlModal extends React.Component { )} - + +