Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 73 additions & 6 deletions public/js/actions/SegmentActions.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from 'react'
import {each, forEach, isUndefined} from 'lodash'
import {debounce} from 'lodash/function'
import $ from 'jquery'
Expand Down Expand Up @@ -28,7 +29,6 @@ import AlertModal from '../components/modals/AlertModal'
import ModalsActions from './ModalsActions'
import {getLocalWarnings} from '../api/getLocalWarnings'
import {getGlossaryCheck} from '../api/getGlossaryCheck'
import SearchUtils from '../components/header/cattol/search/searchUtils'
import CatToolStore from '../stores/CatToolStore'
import {toggleTagProjectionJob} from '../api/toggleTagProjectionJob'
import DraftMatecatUtils from '../components/segments/utils/DraftMatecatUtils'
Expand Down Expand Up @@ -1054,8 +1054,31 @@ const SegmentActions = {
deleteGlossaryItem: function (data) {
deleteGlossaryItem(data)
.then(() => {})
.catch(() => {
OfflineUtils.failedConnection()
.catch((errors) => {
if (errors.status === 403) {
const notification = {
title: 'Glossary edit failed',
text: (
<span>
This glossary is part of a resource that isn’t enabled for
updates.
<br />
To edit it, open the <b>Settings</b> panel, go to the{' '}
<b>Translation memory & glossary</b> tab, and enable the{' '}
<b>“Update”</b> checkbox next to the resource name.
</span>
),
type: 'warning',
position: 'bl',
}
CatToolActions.addNotification(notification)
} else {
OfflineUtils.failedConnection()
}

AppDispatcher.dispatch({
actionType: SegmentConstants.ERROR_CHANGE_GLOSSARY,
})
})
},

Expand Down Expand Up @@ -1089,7 +1112,24 @@ const SegmentActions = {
addGlossaryItem(data)
.then(() => {})
.catch((errors) => {
if (errors.length > 0) {
if (errors.status === 403) {
const notification = {
title: 'Glossary edit failed',
text: (
<span>
This glossary is part of a resource that isn’t enabled for
updates.
<br />
To edit it, open the <b>Settings</b> panel, go to the{' '}
<b>Translation memory & glossary</b> tab, and enable the{' '}
<b>“Update”</b> checkbox next to the resource name.
</span>
),
type: 'warning',
position: 'bl',
}
CatToolActions.addNotification(notification)
} else if (errors.length > 0) {
AppDispatcher.dispatch({
actionType: SegmentConstants.SHOW_FOOTER_MESSAGE,
sid: sid,
Expand All @@ -1098,6 +1138,10 @@ const SegmentActions = {
} else {
OfflineUtils.failedConnection()
}

AppDispatcher.dispatch({
actionType: SegmentConstants.ERROR_CHANGE_GLOSSARY,
})
})
},
addGlossaryItemToCache: (sid, payload) => {
Expand All @@ -1122,8 +1166,31 @@ const SegmentActions = {
updateGlossaryItem: function (data) {
updateGlossaryItem(data)
.then(() => {})
.catch(() => {
OfflineUtils.failedConnection()
.catch((errors) => {
if (errors.status === 403) {
const notification = {
title: 'Glossary edit failed',
text: (
<span>
This glossary is part of a resource that isn’t enabled for
updates.
<br />
To edit it, open the <b>Settings</b> panel, go to the{' '}
<b>Translation memory & glossary</b> tab, and enable the{' '}
<b>“Update”</b> checkbox next to the resource name.
</span>
),
type: 'warning',
position: 'bl',
}
CatToolActions.addNotification(notification)
} else {
OfflineUtils.failedConnection()
}

AppDispatcher.dispatch({
actionType: SegmentConstants.ERROR_CHANGE_GLOSSARY,
})
})
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ const NotificationItem = ({
NotificationItem.propTypes = {
position: PropTypes.string,
title: PropTypes.string.isRequired,
text: PropTypes.string.isRequired,
text: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired,
type: PropTypes.string,
autoDismiss: PropTypes.bool,
closeCallback: PropTypes.func,
Expand Down