Skip to content
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

Feature/integration GitHub project perspective + drafts - 2024 09 #275

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

ensemblebd
Copy link

@ensemblebd ensemblebd commented Sep 11, 2024

Implemented clockify small-button for GitHub's Project-perspective:

  • Kanban
  • Table
  • "My Items"
  • "Current Iteration"

Which by inference means it also now supports non-Issue tasks (GitHub's Project-pespective allows creation of tasks that are not tied to real GitHub Issues).
Also have code that enables pushing Labels from said tasks/issues, which works if Clockify already contains the associated Tag.

Let me know if any issues to help this PR along.
I believe my code on line 33 might be one area of improvement. Am using a hard internal to access the local storage of the extension, to procure the list of projects - for loose comparison to the Github Project view's Project-Name.
This is because on project view, there is no other reference to the Repository, anywhere.
And React internals (__reactRoot$*) are not possible to attain.

The only "volatile" change I believe is on line 125/126, which is now processed instead on line 115.
I don't believe it's possible that this negatively impacts backwards compatibility.
And additionally, it relies on the github html output to retain the class names for "test-id". I see no other way to reliably select the dom elements.
But humbly request your review to verify.

In short:

  • a new per-mutation (not per selector) function(class) scoped instance is created ScopedSingleton_GitHubProjectView, for code-reusability purposes.
  • This class scans for the singular h1 tag in the Project view. If present, it loosely matches against the localStorage of the plugin's known projects.
  • If it fails to locate one (expected on the Issue List, per original implementation), it instead falls back on:
    • The url of the page
    • The first found Issue-task in the dom elements on Project View,
    • or The first found slideout A href (original code for Issue List), if on the Issue List instead of a project view.

Appreciate your feedback.
My company just purchased Clockify, and we look forward to using it extensively within GitHub's Project-perspective.
But we need Clockify to work on non-issue tasks. Creating a GitHub issue for every task simply to project it into Clockify adds extreme clutter for us. And this solves that, and additionally gives users ability to initiate Clockify on GitHub Project-perspective views.

Thank you!

KanBan View

image

Table View

image


Initiation proof of concept, pulling both "repo" / "project" and Task title.

image

Warning:  Requires at least one task/card to be linked to an issue, to procure the Repository name to feed into the Project value of the new clockify task.

I do not see any other way to deduce it from the raw page content, nor localStorage of GitHub.com. Nor the url.
Fallback is to use the Name of the Project.

Note: This is not for the slideout, only the main card display of the Board.
Also need to work on Table view too.
For unknown reasons, the hidden internal dom property __reactProps will never exist unless chrome dev tools is open and you navigate to the DOM element, exposing the properties in the properties view.

I do not know why, and this was already a major hack.
I think it's time to look for a different approach.
Committing code which I will soon delete, for posterity.
… Project name.

So we'll fallback on the name of the Project.
I've extrapolated the common logic, to try and scan against the existing known projects of clockify, using a substring match. And fallback further against any detected available issue link.
It's the best we can do.

Also implemented table handler in full, testing good.
…nt upon manual page refresh).

when changing tabs, React is render cycling the entire document tree.

However it would appear that two issues are present:
a. webpack is transpiling the Class definition for our helper method into native, and it's already declared producing an error preventing execution.
b. import() statements are not permitted because the transpiled "integration" is not an esm module.

So it looks like I will have to rewrite my class helper into a const func, which degrades the async initializer/constructor approach.
Ugh.
… the error. I think webpack esm -> native , s happy now.

Tested good. Seeing fresh results whenever user switches tabs on github.
…table selector.

Was caused by comparison of zero-based index with a value of 0 to equivalency of false.
… to support non-issue tasks.

moving code order of ops, so we can reuse my helper class.
And next commit will contain the actual fix.
@milosfromcake
Copy link
Collaborator

Hello @ensemblebd.

We are happy that you tried to contribute to our project by enhancing the integration for Github.

After we review changes that you have made within our codebase, we'll give you feedback.

All the best.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants