11import { Settings } from '../interfaces/settings.interface' ;
2+ import { Environment } from '../interfaces/environment.interface' ;
23
34import { URLHelper } from './url.helper' ;
45import { GitHubHelper } from './github.helper' ;
@@ -25,7 +26,7 @@ export class DomHelper {
2526
2627 this . subscribeToStorageChanges ( ) ;
2728
28- if ( this . settings && this . isMatchingOwnerAndRepo ( ) ) {
29+ if ( this . settings && this . isMatchingOwnerAndRepo ( ) && URLHelper . isDeployableURL ( ) ) {
2930 this . showDisplayBtn ( ) ;
3031 this . refreshEnvironmentButtonList ( ) ;
3132 }
@@ -36,9 +37,9 @@ export class DomHelper {
3637 return document . querySelector ( '#branch-select-menu' ) as HTMLElement ;
3738 }
3839
39- private getSHARef ( ) {
40+ private getSHARef ( environment : Environment ) {
4041 if ( URLHelper . isDeployableURL ( ) && this . getContainer ( ) ) {
41- const anchor : HTMLAnchorElement = document . querySelector ( '.commit-tease-sha' ) ;
42+ const anchor : HTMLAnchorElement = document . querySelector ( `.Box-header a[href^="/ ${ environment . repoOwner } / ${ environment . repoName } /commit/"]` ) ;
4243 return anchor . href . split ( '/commit/' ) [ 1 ] ;
4344 }
4445 }
@@ -84,7 +85,7 @@ export class DomHelper {
8485
8586 private createDropDownBtn ( ) {
8687 const dropDownBtn = document . createElement ( 'summary' ) ;
87- dropDownBtn . classList . add ( 'select-menu-button' , 'btn' , 'btn-sm' , 'btn- primary', 'ml-2' ) ;
88+ dropDownBtn . classList . add ( 'select-menu-button' , 'btn' , 'btn-primary' , 'ml-2' ) ;
8889 dropDownBtn . innerHTML = '<span> Deploy </span>' ;
8990 return dropDownBtn ;
9091 }
@@ -124,7 +125,7 @@ export class DomHelper {
124125
125126 private removeAllEnvironmentButtons ( ) {
126127 if ( this . environmentsButtonList ) {
127- this . showDisplayBtn ( ) ;
128+ this . hideDisplayBtn ( ) ;
128129 while ( this . environmentsButtonList . firstChild ) {
129130 this . environmentsButtonList . removeChild ( this . environmentsButtonList . lastChild ) ;
130131 }
@@ -133,7 +134,7 @@ export class DomHelper {
133134
134135 private refreshEnvironmentButtonList ( ) {
135136 this . removeAllEnvironmentButtons ( ) ;
136- if ( ! this . settings . environments . length || ! this . isMatchingOwnerAndRepo ( ) ) {
137+ if ( ! this . settings . environments . length || ! this . isMatchingOwnerAndRepo ( ) || ! URLHelper . isDeployableURL ( ) ) {
137138 return ;
138139 }
139140 for ( const environment of this . settings . environments ) {
@@ -174,7 +175,7 @@ export class DomHelper {
174175 this . closeDropDown ( ) ;
175176
176177 const environment = this . settings . environments . find ( ( env ) => env . id === button . id ) ;
177- const sha = this . getSHARef ( ) ;
178+ const sha = this . getSHARef ( environment ) ;
178179
179180 const gitHubHelper = new GitHubHelper ( this . settings . token , environment . repoOwner , environment . repoName ) ;
180181 await gitHubHelper . actionDispatch ( sha , environment . event ) ;
0 commit comments