jomarko commented on code in PR #2126:
URL:
https://github.com/apache/incubator-kie-tools/pull/2126#discussion_r1463167627
##########
packages/chrome-extension/src/index.ts:
##########
@@ -91,37 +91,66 @@ function init(globals: Globals) {
const fileInfo = extractFileInfoFromUrl();
const pageType = discoverCurrentGitHubPageType();
+ if (!globals.dependencies.all.octiconMarkGitHub()) {
+ globals.logger.warn("This is not the GitHub web page.");
+ return;
+ }
+
if (pageType === GitHubPageType.ANY) {
- globals.logger.log(`This GitHub page is not supported.`);
+ globals.logger.log(`This GitHub web page is not supported.`);
return;
}
if (pageType === GitHubPageType.EDIT) {
renderSingleEditorApp({ ...globals, fileInfo });
} else if (pageType === GitHubPageType.VIEW) {
- renderSingleEditorReadonlyApp({
- ...globals,
- pageType,
- className: "btn ml-2 d-none d-md-block",
- container: () =>
globals.dependencies.openRepoInExternalEditor.buttonContainerOnRepoFilesList()!,
- fileInfo,
- });
+ if
(!globals.dependencies.openRepoInExternalEditor.buttonContainerOnRepoFilesList())
{
+ globals.logger.warn(
+ "The extension can not display all buttons properly. Please be sure
you use the extension with the latest GitHub instance."
+ );
Review Comment:
here and bellow I added 4 similar `if` statements. that I feel is not ideal.
however I was not able to do it differently.
My original idea was to iterate all
`globals.dependencies.openRepoInExternalEditor` locators in single place and
check if some of them does not exist. in such case I wanted to inform user,
some features may be not available.
but for example `buttonContainerOnRepoFilesList` doesn't exist until proper
page is opened.
So in final I added 4 checks, where I check only locator required by given
page view.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]