-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NEW: CMS 5 upgrade. #102
NEW: CMS 5 upgrade. #102
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,7 @@ | ||
module.exports = require('@silverstripe/eslint-config/.eslintrc'); | ||
module.exports = { | ||
extends: '@silverstripe/eslint-config', | ||
// Allows null coalescing and optional chaining operators. | ||
parserOptions: { | ||
ecmaVersion: 2020 | ||
}, | ||
}; |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,18 +7,16 @@ import { connect } from 'react-redux'; | |
import i18n from 'i18n'; | ||
import { inject } from 'lib/Injector'; | ||
import { addMessage, showList } from 'state/historyviewer/HistoryViewerActions'; | ||
import { Tooltip } from 'reactstrap'; | ||
import { UncontrolledTooltip as Tooltip } from 'reactstrap'; | ||
|
||
class HistoryViewerToolbar extends Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.handleRevert = this.handleRevert.bind(this); | ||
this.handleToggleRevertTooltip = this.handleToggleRevertTooltip.bind(this); | ||
|
||
this.state = { | ||
isReverting: false, | ||
revertTooltipOpen: false, | ||
tooltipTimer: null, | ||
}; | ||
} | ||
|
@@ -40,12 +38,6 @@ class HistoryViewerToolbar extends Component { | |
} }).then(() => handler(versionId)); | ||
} | ||
|
||
handleToggleRevertTooltip() { | ||
this.setState(state => ({ | ||
revertTooltipOpen: !state.revertTooltipOpen, | ||
})); | ||
} | ||
|
||
render() { | ||
const { | ||
FormActionComponent, | ||
|
@@ -57,11 +49,14 @@ class HistoryViewerToolbar extends Component { | |
rollbackMessage, | ||
typeName, | ||
} = this.props; | ||
const { isReverting, revertTooltipOpen } = this.state; | ||
const { isReverting } = this.state; | ||
|
||
const revertButtonTitle = isReverting | ||
? i18n._t('HistoryViewerToolbar.REVERT_IN_PROGRESS', 'Revert in progress...') | ||
: i18n._t('HistoryViewerToolbar.REVERT_UNAVAILABLE', 'Unavailable for the current version'); | ||
let revertButtonTitle = ''; | ||
if (isReverting) { | ||
revertButtonTitle = i18n._t('HistoryViewerToolbar.REVERT_IN_PROGRESS', 'Revert in progress...'); | ||
} else if (isLatestVersion) { | ||
revertButtonTitle = i18n._t('HistoryViewerToolbar.REVERT_UNAVAILABLE', 'Unavailable for the current version'); | ||
} | ||
Comment on lines
-60
to
+59
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Without this, we end up with two tooltips when hovering over the revert button for the history details of a related child record. |
||
|
||
return ( | ||
<RollbackMutation typeName={typeName}> | ||
|
@@ -87,8 +82,6 @@ class HistoryViewerToolbar extends Component { | |
<Tooltip | ||
trigger="click hover focus" | ||
placement="top" | ||
isOpen={revertTooltipOpen} | ||
toggle={this.handleToggleRevertTooltip} | ||
target="HistoryRevertButton" | ||
> | ||
{rollbackMessage} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can't use hooks in a class component, so we need this little HOC to handle the hook for us. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React, { useEffect } from 'react'; | ||
import useResizeAware from 'react-resize-aware'; | ||
|
||
const ResizeAwareHoc = ({ children, className, onResize }) => { | ||
const [resizeListener, sizes] = useResizeAware(); | ||
|
||
useEffect(() => { | ||
onResize({ width: sizes?.width, height: sizes?.height }); | ||
}, [sizes?.width, sizes?.height]); | ||
|
||
return ( | ||
<div className={className}> | ||
{resizeListener} | ||
{children} | ||
</div> | ||
); | ||
}; | ||
|
||
export default ResizeAwareHoc; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
/* eslint-disable import/no-unresolved */ | ||
|
||
import i18n from 'i18n'; | ||
import moment from 'moment'; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
/* eslint-disable import/no-unresolved */ | ||
|
||
import i18n from 'i18n'; | ||
import jQuery from 'jquery'; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4297,7 +4297,7 @@ graphql-fragments@^0.1.0: | |
dependencies: | ||
graphql-anywhere "^0.2.4" | ||
|
||
graphql-tag@^2.10.0, graphql-tag@^2.12.6: | ||
graphql-tag@^2.12.6: | ||
version "2.12.6" | ||
resolved "https://registry.yarnpkg.com/graphql-tag/-/graphql-tag-2.12.6.tgz#d441a569c1d2537ef10ca3d1633b48725329b5f1" | ||
integrity sha512-FdSNcu2QQcWnM2VNvSCCDCVS5PpPqpzgFT8+GXzqJuoDd0CBncxCY278u4mhRO7tMgo2JjgJA5aZ+nWSQ/Z+xg== | ||
|
@@ -7077,10 +7077,10 @@ react-redux@^8.0.5: | |
react-is "^18.0.0" | ||
use-sync-external-store "^1.0.0" | ||
|
||
react-resize-aware@^3.1.2: | ||
version "3.1.2" | ||
resolved "https://registry.yarnpkg.com/react-resize-aware/-/react-resize-aware-3.1.2.tgz#a5e6fe4691a3ac8d3b0fadd37008339db2294c4f" | ||
integrity sha512-sBtMIEy/9oI+Xf2o7IdWdkTokpZSPo9TWn60gqWKPG3BXg44Rg3FCIMiIjmgvRUF4eQptw6pqYTUhYwkeVSxXA== | ||
react-resize-aware@^4.0.0: | ||
version "4.0.0" | ||
resolved "https://registry.yarnpkg.com/react-resize-aware/-/react-resize-aware-4.0.0.tgz#9a2e002c0a3d15285ccd81c2d3d17aff64e8a597" | ||
integrity sha512-42aoj3uGcqhsMQE7yssxuy0+YYNp38CSzoGxRXUV80WUm6uYJKhAwBlOSBltxTbdZSkJXZwgq43iyywjVI9ZgA== | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Had to update to 4.x because of FezVrasta/react-resize-aware#58 |
||
|
||
react-router-redux@^4.0.5: | ||
version "4.0.8" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The state control we were doing here was pointless - it was just toggling a boolean in state. No need for us to manage that directly.