clockify / browser-extension

Clockify Browser Extension
https://clockify.me/chrome-time-tracking
BSD 3-Clause "New" or "Revised" License
185 stars 172 forks source link

Button parameters as functions #88

Closed dpoetzsch closed 4 years ago

dpoetzsch commented 4 years ago

Before #80 broke it, integrations were able to pass time entry description as function.

As I've noted in https://github.com/clockify/browser-extension/pull/82#issuecomment-630841085, this allows for dynamic evaluation of the properties at time of button click. As possible use case would be the following: If I am in an gitlab issue, change the tags of that issue and then start logging my time I want my new tag to be synced without reloading the page.

This PR fixes and generalizes this feature or all parameters, including for example the tags. I also took the freedom to remove the code duplication between normal and small button.

Finally, I implemented the aforementioned behavior for gitlab tags.

dpoetzsch commented 4 years ago

Ok, I made a mistake with the small button.. This is still WIP

dpoetzsch commented 4 years ago

Ok, now this should do what it's supposed to :)

My basic idea was to go towards only a single createButton with an options object that allows configuration such as small. The createSmallButton is now merely a short cut for passing the small flag. This allows for a unified code base which I believe is less prone to accidental behavioral differences between the two button options.

aleksandar-olic commented 4 years ago

Great, everything seems to work fine. So you can now pass additional argument small, eg:

    link = clockifyButton.createButton({
        description: description,
        projectName: projectElem.textContent.trim(),
        taskName: description,
        small: true
    });

Thanks!