Code cleanup
This commit is contained in:
@@ -28,7 +28,6 @@ html {
|
||||
flex: 0 0 48px;
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
|
||||
}
|
||||
|
||||
h1 {
|
||||
@@ -66,7 +65,6 @@ html {
|
||||
flex: 0 0 42px;
|
||||
color: white;
|
||||
background-color: #eee;
|
||||
|
||||
}
|
||||
|
||||
&.moco-bx-calendar__day--filled {
|
||||
@@ -89,6 +87,15 @@ html {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.moco-bx-timer-view {
|
||||
text-align: center;
|
||||
margin-top: 4rem;
|
||||
|
||||
.btn-stop-timer {
|
||||
margin-top: 3rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.moco-bx-error-container {
|
||||
|
||||
@@ -6,6 +6,20 @@ import { tabUpdated, settingsChanged, togglePopup } from "utils/messageHandlers"
|
||||
|
||||
const messenger = new BackgroundMessenger()
|
||||
|
||||
function resetBubble({ tab, apiClient, service }) {
|
||||
messenger.postMessage(tab, { type: "closePopup" })
|
||||
apiClient.activitiesStatus(service).then(({ data }) => {
|
||||
messenger.postMessage(tab, {
|
||||
type: "showBubble",
|
||||
payload: {
|
||||
bookedHours: parseFloat(data.hours),
|
||||
timedActivity: data.timed_activity,
|
||||
service,
|
||||
},
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
messenger.on("togglePopup", () => {
|
||||
getCurrentTab().then(tab => {
|
||||
if (tab && !isBrowserTab(tab)) {
|
||||
@@ -31,19 +45,7 @@ chrome.runtime.onMessage.addListener(action => {
|
||||
const apiClient = new ApiClient(settings)
|
||||
apiClient
|
||||
.createActivity(activity)
|
||||
.then(() => {
|
||||
messenger.postMessage(tab, { type: "closePopup" })
|
||||
apiClient.activitiesStatus(service).then(({ data }) => {
|
||||
messenger.postMessage(tab, {
|
||||
type: "showBubble",
|
||||
payload: {
|
||||
bookedHours: parseFloat(data.hours),
|
||||
timedActivity: data.timed_activity,
|
||||
service,
|
||||
},
|
||||
})
|
||||
})
|
||||
})
|
||||
.then(() => resetBubble({ tab, apiClient, service }))
|
||||
.catch(error => {
|
||||
if (error.response?.status === 422) {
|
||||
chrome.runtime.sendMessage({
|
||||
|
||||
@@ -22,19 +22,9 @@ import InvalidConfigurationError from "components/Errors/InvalidConfigurationErr
|
||||
import UpgradeRequiredError from "components/Errors/UpgradeRequiredError"
|
||||
import UnknownError from "components/Errors/UnknownError"
|
||||
import Header from "./shared/Header"
|
||||
import { head, isNil } from "lodash"
|
||||
import { head } from "lodash"
|
||||
import TimeInputParser from "utils/TimeInputParser"
|
||||
|
||||
const findTimedActivity = (activities, service) => {
|
||||
if (!service) {
|
||||
return null
|
||||
}
|
||||
|
||||
return activities.find(
|
||||
activity => activity.remote_id === service.id && !isNil(activity.timer_started_at),
|
||||
)
|
||||
}
|
||||
|
||||
@observer
|
||||
class App extends Component {
|
||||
static propTypes = {
|
||||
@@ -181,7 +171,6 @@ class App extends Component {
|
||||
schedules,
|
||||
fromDate,
|
||||
toDate,
|
||||
service,
|
||||
errorType,
|
||||
errorMessage,
|
||||
} = this.props
|
||||
@@ -222,7 +211,6 @@ class App extends Component {
|
||||
<Form
|
||||
changeset={this.changesetWithDefaults}
|
||||
projects={projects}
|
||||
timedActivity={findTimedActivity(activities, service)}
|
||||
errors={this.formErrors}
|
||||
onChange={this.handleChange}
|
||||
onSubmit={this.handleSubmit}
|
||||
|
||||
@@ -10,6 +10,7 @@ class Form extends Component {
|
||||
billable: PropTypes.bool.isRequired,
|
||||
date: PropTypes.string.isRequired,
|
||||
task_id: PropTypes.number.isRequired,
|
||||
description: PropTypes.string,
|
||||
remote_id: PropTypes.string,
|
||||
remote_service: PropTypes.string,
|
||||
remote_url: PropTypes.string,
|
||||
@@ -41,7 +42,7 @@ class Form extends Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
const { projects, changeset, timedActivity, errors, onChange, onSubmit } = this.props
|
||||
const { projects, changeset, errors, onChange, onSubmit } = this.props
|
||||
const project = Select.findOptionByValue(projects, changeset.assignment_id)
|
||||
|
||||
return (
|
||||
|
||||
@@ -101,8 +101,4 @@ chrome.runtime.onConnect.addListener(function(port) {
|
||||
messenger.on("closePopup", () => {
|
||||
closePopup()
|
||||
})
|
||||
|
||||
messenger.on("activityCreated", () => {
|
||||
closePopup()
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user