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