-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Refresh schedule phrase overlaps title (#3250)
- Loading branch information
Showing
7 changed files
with
82 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { react2angular } from 'react2angular'; | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import Tooltip from 'antd/lib/tooltip'; | ||
import { localizeTime, secondsToInterval } from '@/filters'; | ||
|
||
import './ScheduleDialog.css'; | ||
|
||
class SchedulePhrase extends React.Component { | ||
static propTypes = { | ||
// eslint-disable-next-line react/forbid-prop-types | ||
schedule: PropTypes.object.isRequired, | ||
isNew: PropTypes.bool.isRequired, | ||
isLink: PropTypes.bool, | ||
}; | ||
|
||
static defaultProps = { | ||
isLink: false, | ||
}; | ||
|
||
get content() { | ||
const { interval: seconds } = this.props.schedule; | ||
if (!seconds) { | ||
return ['Never']; | ||
} | ||
const { count, interval } = secondsToInterval(seconds); | ||
const short = `Every ${count} ${interval}`; | ||
let full = `Refreshes every ${count} ${interval}`; | ||
|
||
const { time, day_of_week: dayOfWeek } = this.props.schedule; | ||
if (time) { | ||
full += ` at ${localizeTime(time)}`; | ||
} | ||
if (dayOfWeek) { | ||
full += ` on ${dayOfWeek}`; | ||
} | ||
|
||
return [short, full]; | ||
} | ||
|
||
render() { | ||
if (this.props.isNew) { | ||
return 'Never'; | ||
} | ||
|
||
const [short, full] = this.content; | ||
const content = full ? <Tooltip title={full}>{short}</Tooltip> : short; | ||
|
||
return this.props.isLink | ||
? <a className="schedule-phrase">{content}</a> | ||
: content; | ||
} | ||
} | ||
|
||
export default function init(ngModule) { | ||
ngModule.component('schedulePhrase', react2angular(SchedulePhrase)); | ||
} | ||
|
||
init.init = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters