Skip to content

Commit

Permalink
Add support for empty repos in GL
Browse files Browse the repository at this point in the history
  • Loading branch information
filiptronicek committed Jan 27, 2025
1 parent bc88cd7 commit 8b9e6db
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/button/button-contributions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,13 @@ export const buttonContributions: ButtonContributionParams[] = [
},
],
},
{
id: "gl-repo-empty",
exampleUrls: ["https://gitlab.com/filiptronicek/empty"],
selector: `xpath://*[@id="js-project-show-empty-page"]/div[1]/div[1]/div[2]`,
containerElement: { type: "div", props: { marginLeft: "8px" } },
application: "gitlab",
},
{
id: "gl-file",
exampleUrls: [
Expand Down Expand Up @@ -412,7 +419,8 @@ export const buttonContributions: ButtonContributionParams[] = [
],
selector: 'xpath://*[@id="main"]/div/div/div[1]/div/div/div/div[1]/div/div[2]/div/div[2]/div/div', // grandparent div of the "Request changes" and "Approve" buttons
containerElement: createElement("div", {}),
insertBefore: 'xpath:(//*[@id="main"]/div/div/div[1]/div/div/div/div[1]/div/div[2]/div/div[2]/div/div/div)[last()]', // note the [last()] to insert before the last child (the kebab menu)
insertBefore:
'xpath:(//*[@id="main"]/div/div/div[1]/div/div/div/div[1]/div/div[2]/div/div[2]/div/div/div)[last()]', // note the [last()] to insert before the last child (the kebab menu)
application: "bitbucket",
},
{
Expand Down
3 changes: 3 additions & 0 deletions src/contents/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ class ButtonContributionManager {
return this.buttons.get(this.getContainerId(this.active.contribution));
}

/**
* Checks if the contribution applies to the current page.
*/
private isActive(contrib: ButtonContributionParams) {
if (typeof contrib.match === "function" && !contrib.match()) {
return false;
Expand Down
12 changes: 10 additions & 2 deletions test/src/button-contributions-copy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,13 @@ export const buttonContributions: ButtonContributionParams[] = [
},
],
},
{
id: "gl-repo-empty",
exampleUrls: ["https://gitlab.com/filiptronicek/empty"],
selector: `xpath://*[@id="js-project-show-empty-page"]/div[1]/div[1]/div[2]`,
containerElement: { type: "div", props: { marginLeft: "8px" } },
application: "gitlab",
},
{
id: "gl-file",
exampleUrls: [
Expand Down Expand Up @@ -410,9 +417,10 @@ export const buttonContributions: ButtonContributionParams[] = [
exampleUrls: [
// "https://bitbucket.org/efftinge/browser-extension-test/pull-requests/1"
],
selector: 'xpath://*[@id="main"]/div/div/div[1]/div/div/div[1]/div/div[2]/div/div[2]/div/div', // grandparent div of the "Request changes" and "Approve" buttons
selector: 'xpath://*[@id="main"]/div/div/div[1]/div/div/div/div[1]/div/div[2]/div/div[2]/div/div', // grandparent div of the "Request changes" and "Approve" buttons
containerElement: createElement("div", {}),
insertBefore: 'xpath:(//*[@id="main"]/div/div/div[1]/div/div/div[1]/div/div[2]/div/div[2]/div/div/div)[last()]', // note the [last()] to insert before the last child (the kebab menu)
insertBefore:
'xpath:(//*[@id="main"]/div/div/div[1]/div/div/div/div[1]/div/div[2]/div/div[2]/div/div/div)[last()]', // note the [last()] to insert before the last child (the kebab menu)
application: "bitbucket",
},
{
Expand Down

0 comments on commit 8b9e6db

Please sign in to comment.