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

url shortening, use GitHub octokit.js to show issue/pull status. #1895

Open
Carreau opened this issue Jun 20, 2024 · 0 comments
Open

url shortening, use GitHub octokit.js to show issue/pull status. #1895

Carreau opened this issue Jun 20, 2024 · 0 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed impact: block-release Should block a release from happening. Only use if this is a critical problem we don't want to ship kind: enhancement New feature or request needs: discussion Needs discussion before an implementation can be made tag: CSS CSS and SCSS related issues tag: javascript Pull requests that update Javascript code tag: UX Issues or improvements related to user experience

Comments

@Carreau
Copy link
Collaborator

Carreau commented Jun 20, 2024

currently we are shortening github/gitlab url at build time,

It should be possible to use ocktokit js to run all all link on a page matching a specific pattern and mark the issue/PRs as closed/opened/merged,
for example, the following fetch a open|close issue of IPython and a closed|opened|merged PR.

<script type="module">
import { Octokit, App } from "https://esm.sh/octokit";
const octokit = new Octokit();


for(var ni of [14454,14453,14464,14462,14460]){

    const res = await octokit.request('GET /repos/ipython/ipython/issues/'+ni, {
      //owner: 'OWNER',
      //repo: 'REPO',
      //issue_number: 'ISSUE_NUMBER',
      headers: {
        'X-GitHub-Api-Version': '2022-11-28'
      }
    })

    //console.info('res', ni, res.data)
    if (res.data.pull_request != undefined){
        console.info('is pull', res.data.pull_request.merged_at != null ? 'merged': res.data.state ); 
    } else {
        console.info('is issue',res.data.state);

    }
}

mixed with something like :

var anchorTags = document.querySelectorAll('a');

// Regular expression to match the desired GitHub issue URL pattern
var regex = /^https:\/\/github\.com\/[^\/]+\/[^\/]+\/issues\/\d+$/;

// Filter <a> tags that match the pattern
var githubIssueLinks = Array.prototype.filter.call(anchorTags, function(element) {
    return regex.test(element.href);
});

We should be able to find all links to Pulls/issues, and then I suggest adding a given class to the a (pst-github-[issue|pr|unknown]-[open|close|merged|unknonw]) that can be later targeted by css to either add a :before icon or change the styling.

@Carreau Carreau added kind: enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers tag: CSS CSS and SCSS related issues needs: discussion Needs discussion before an implementation can be made impact: block-release Should block a release from happening. Only use if this is a critical problem we don't want to ship tag: javascript Pull requests that update Javascript code tag: UX Issues or improvements related to user experience labels Jun 20, 2024
Carreau added a commit to Carreau/pydata-sphinx-theme that referenced this issue Jun 20, 2024
See pydata#1895.

Not that I heve the right skills and am good at desing, just show what
could be done.

Need to be pulled into a separate JS file and properely desinged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed impact: block-release Should block a release from happening. Only use if this is a critical problem we don't want to ship kind: enhancement New feature or request needs: discussion Needs discussion before an implementation can be made tag: CSS CSS and SCSS related issues tag: javascript Pull requests that update Javascript code tag: UX Issues or improvements related to user experience
Projects
None yet
Development

No branches or pull requests

1 participant