diff --git a/src/main/resources/default/wiki.css b/src/main/resources/default/wiki.css index 0993574..22bce83 100644 --- a/src/main/resources/default/wiki.css +++ b/src/main/resources/default/wiki.css @@ -518,6 +518,7 @@ html { position: absolute !important; left: 0px; right: 0px; + background-color: #FFF; } .polarion-rpw-table-main { @@ -1056,6 +1057,8 @@ a:hover .polarion-cross-reference-label, height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; + top: -5px; + border-top-width: 8px; } .polarion-PlanProgressMacro-arrowTopLeft, .polarion-PlanProgressMacro-arrowTopRight, .polarion-PlansMacro-arrowTopLeft, .polarion-PlansMacro-arrowTopRight { @@ -1065,10 +1068,7 @@ a:hover .polarion-cross-reference-label, .polarion-PlanProgressMacro-arrowTopLeft, .polarion-PlanProgressMacro-arrowTopRight { top: -6px; -} - -.polarion-PlansMacro-arrowTopLeft, .polarion-PlansMacro-arrowTopRight { - top: -5px; + border-top-width: 11px; } .polarion-PlanProgressMacro-arrowBottomRight { @@ -1079,14 +1079,6 @@ a:hover .polarion-cross-reference-label, border-bottom-color: #3A7523; } -.polarion-PlanProgressMacro-arrowTopLeft, .polarion-PlanProgressMacro-arrowTopRight { - border-top-width: 11px; -} - -.polarion-PlansMacro-arrowTopLeft, .polarion-PlansMacro-arrowTopRight { - border-top-width: 8px; -} - .polarion-PlanProgressMacro-arrowBottomLeft, .polarion-PlanProgressMacro-arrowBottomLeftAligned, .polarion-PlanProgressMacro-arrowBottomRight { border-bottom-width: 11px; border-bottom-style: solid; @@ -1944,10 +1936,6 @@ a:hover .polarion-cross-reference-label, display: none; } -.polarion-HistoryTable-mainPanel { - background-color: #FFF; -} - .polarion-HistoryTable-table { width: 100%; } diff --git a/src/main/resources/webapp/pdf-exporter-admin/pages/localization.jsp b/src/main/resources/webapp/pdf-exporter-admin/pages/localization.jsp index d80c175..ff21bd2 100644 --- a/src/main/resources/webapp/pdf-exporter-admin/pages/localization.jsp +++ b/src/main/resources/webapp/pdf-exporter-admin/pages/localization.jsp @@ -42,11 +42,15 @@ display: none; } - td.action, div.action { + td.action, button.action { border: none !important; cursor: pointer; vertical-align: middle !important; text-align: center !important; + background: none; + min-width: 60px; + padding: 0 !important; + margin: 0 !important; } input.red-border { diff --git a/src/main/resources/webapp/pdf-exporter/js/export-pdf.js b/src/main/resources/webapp/pdf-exporter/js/export-pdf.js index 5ba47bb..f76e9c9 100644 --- a/src/main/resources/webapp/pdf-exporter/js/export-pdf.js +++ b/src/main/resources/webapp/pdf-exporter/js/export-pdf.js @@ -70,7 +70,7 @@ function stylePackageSelected(stylePackage) { displayIf("chapters", stylePackage.specificChapters); setCheckbox("localization", stylePackage.language); - setValue("language", (stylePackage.exposeSettings && !!stylePackage.language && documentLanguage) ? documentLanguage : stylePackage.language); + setValue("language", (stylePackage.exposeSettings && stylePackage.language && documentLanguage) ? documentLanguage : stylePackage.language); displayIf("language", stylePackage.language); setCheckbox("selected-roles", stylePackage.linkedWorkitemRoles); diff --git a/src/main/resources/webapp/pdf-exporter/js/pdf-exporter.js b/src/main/resources/webapp/pdf-exporter/js/pdf-exporter.js index 5b4503f..ed439b1 100644 --- a/src/main/resources/webapp/pdf-exporter/js/pdf-exporter.js +++ b/src/main/resources/webapp/pdf-exporter/js/pdf-exporter.js @@ -29,7 +29,7 @@ function ExportContext() { ? window.location.hash.substring(2, window.location.hash.indexOf("?")) : window.location.hash.substring(2) ); - const locationParts = locationHash.match("(project/[^/]+/).*wiki/(.*)") + const locationParts = new RegExp("(project/[^/]+/).*wiki/(.*)").exec(locationHash); if (locationParts) { this.scope = locationParts[1] @@ -49,7 +49,7 @@ function ExportContext() { } ExportContext.prototype.getProjectId = function() { - const foundValues = this.scope.match("project/(.*)/"); + const foundValues = new RegExp("project/(.*)/").exec(this.scope); return foundValues !== null ? foundValues[1] : null; } @@ -310,7 +310,7 @@ const PdfExporter = { this.setCheckbox("popup-localization", stylePackage.language); let languageValue; - if (stylePackage.exposeSettings && !!stylePackage.language && this.documentLanguage) { + if (stylePackage.exposeSettings && stylePackage.language && this.documentLanguage) { languageValue = this.documentLanguage; } else if (stylePackage.language) { languageValue = stylePackage.language; @@ -355,15 +355,16 @@ const PdfExporter = { }).then(({response}) => { this.actionInProgress({inProgress: false}); - const pages = response.invalidPages && response.invalidPages.length; + const pages = response.invalidPages?.length; if (pages && pages > 0) { + const pagesWord = 'page' + (pages === 1 ? '' : 's'); this.showValidationResult({ alertType: "error", message: pages > MAX_PAGE_PREVIEWS ? `Invalid pages found. First ${MAX_PAGE_PREVIEWS} of them:` - : `${MAX_PAGE_PREVIEWS} invalid page${pages === 1 ? '' : 's'} found:` + : `${MAX_PAGE_PREVIEWS} invalid ${pagesWord} found:` }); - this.createPreviews(result); + this.createPreviews(response); } else { this.showValidationResult({alertType: "success", message: "All pages are valid"}); } @@ -496,7 +497,7 @@ const PdfExporter = { body: requestBody, responseType: "json" }).then(({response}) => { - if (response && response.containsNestedLists) { + if (response?.containsNestedLists) { this.showNotification({alertType: "warning", message: "Document contains nested numbered lists which structures were not valid. We tried to fix this, but be aware of it."}); } }).catch((error) => { @@ -609,7 +610,7 @@ const PdfExporter = { setSelector: function (elementId, value) { const selector = document.getElementById(elementId); - selector.value = containsOption(selector, value) ? value : POPUP_DEFAULT_SETTING_NAME; + selector.value = this.containsOption(selector, value) ? value : POPUP_DEFAULT_SETTING_NAME; }, setCheckbox: function (elementId, value) { @@ -701,12 +702,11 @@ const PdfExporter = { getCookie: function (name) { const nameEQ = name + '='; const cookiesArray = document.cookie.split(';'); - for (let i = 0; i < cookiesArray.length; i++) { - let cookie = cookiesArray[i]; - while (cookie.charAt(0) === ' ') { + for (let cookie of cookiesArray) { + while (cookie.startsWith(' ')) { cookie = cookie.substring(1, cookie.length); } - if (cookie.indexOf(nameEQ) === 0) { + if (cookie.startsWith(nameEQ)) { return decodeURIComponent(cookie.substring(nameEQ.length, cookie.length)); } } diff --git a/src/main/resources/webapp/pdf-exporter/js/starter.js b/src/main/resources/webapp/pdf-exporter/js/starter.js index 65ab553..c2fdc2b 100644 --- a/src/main/resources/webapp/pdf-exporter/js/starter.js +++ b/src/main/resources/webapp/pdf-exporter/js/starter.js @@ -32,7 +32,7 @@ const PdfExporterStarter = { inject: function () { this.loadExtensionVersion() .then((response) => { - this.bundleTimestamp = response && response.bundleBuildTimestampDigitsOnly; + this.bundleTimestamp = response?.bundleBuildTimestampDigitsOnly; this.injectAll(this.bundleTimestamp ? `?bundle=${this.bundleTimestamp}` : ""); }).catch(() => { // Fallback to load resources without timestamp in case of error @@ -71,7 +71,7 @@ const PdfExporterStarter = { injectToolbar: function (params) { const bundleTimestampParam = this.bundleTimestamp ? `?bundle=${this.bundleTimestamp}` : ""; - if (params && params.alternate) { + if (params?.alternate) { const toolbarParent = top.document.querySelector('div.polarion-content-container div.polarion-Container div.polarion-dle-Container > div.polarion-dle-Wrapper > div.polarion-dle-RpcPanel > div.polarion-dle-MainDockPanel div.polarion-rte-ToolbarPanelWrapper table.polarion-dle-ToolbarPanel tr'); const toolbarContainer = document.createElement('td'); toolbarContainer.innerHTML = ALTERNATE_TOOLBAR_HTML.replaceAll("{BUNDLE_TIMESTAMP}", bundleTimestampParam); diff --git a/src/test/java/ch/sbb/polarion/extension/pdf/exporter/converter/PdfConverterTest.java b/src/test/java/ch/sbb/polarion/extension/pdf/exporter/converter/PdfConverterTest.java index 953433a..d7e369e 100644 --- a/src/test/java/ch/sbb/polarion/extension/pdf/exporter/converter/PdfConverterTest.java +++ b/src/test/java/ch/sbb/polarion/extension/pdf/exporter/converter/PdfConverterTest.java @@ -141,9 +141,9 @@ void shouldGetAndReplaceCss() { CssModel cssModel = CssModel.builder().css("my test css: {{ DOCUMENT_TITLE }} {{DOCUMENT_REVISION}} {{ REVISION }} {{ PRODUCT_NAME }} {{ PRODUCT_VERSION }} {{customField}}").build(); when(cssSettings.load("testProjectId", SettingId.fromName("testCssSetting"))).thenReturn(cssModel); - PlaceholderProcessor placeholderProcessor = new PlaceholderProcessor(pdfExporterPolarionService, liveDocHelper); + PlaceholderProcessor processor = new PlaceholderProcessor(pdfExporterPolarionService, liveDocHelper); when(velocityEvaluator.evaluateVelocityExpressions(eq(documentData), anyString())).thenAnswer(a -> a.getArguments()[1]); - PdfConverter pdfConverter = new PdfConverter(null, null, cssSettings, null, placeholderProcessor, velocityEvaluator, null, null, null, pdfTemplateProcessor); + PdfConverter pdfConverter = new PdfConverter(null, null, cssSettings, null, processor, velocityEvaluator, null, null, null, pdfTemplateProcessor); when(liveDocHelper.getDocumentStatus("testRevision", documentData)).thenReturn("testStatus"); when(pdfExporterPolarionService.getPolarionProductName()).thenReturn("testProductName"); diff --git a/src/test/java/ch/sbb/polarion/extension/pdf/exporter/weasyprint/BaseWeasyPrintTest.java b/src/test/java/ch/sbb/polarion/extension/pdf/exporter/weasyprint/BaseWeasyPrintTest.java index f2c07e4..f8bd486 100644 --- a/src/test/java/ch/sbb/polarion/extension/pdf/exporter/weasyprint/BaseWeasyPrintTest.java +++ b/src/test/java/ch/sbb/polarion/extension/pdf/exporter/weasyprint/BaseWeasyPrintTest.java @@ -80,7 +80,7 @@ protected List exportAndGetAsImages(String fileName, String html) if (pdfBytes != null) { return getAllPagesAsImagesAndLogAsReports(fileName, pdfBytes); } else { - logger.warn("No pdf file generated for name " + fileName); + logger.warn("No pdf file generated for name {}", fileName); return new ArrayList<>(); } } diff --git a/src/test/java/ch/sbb/polarion/extension/pdf/exporter/weasyprint/exporter/FileWaitStrategy.java b/src/test/java/ch/sbb/polarion/extension/pdf/exporter/weasyprint/exporter/FileWaitStrategy.java index e09b19f..ba81ec2 100644 --- a/src/test/java/ch/sbb/polarion/extension/pdf/exporter/weasyprint/exporter/FileWaitStrategy.java +++ b/src/test/java/ch/sbb/polarion/extension/pdf/exporter/weasyprint/exporter/FileWaitStrategy.java @@ -35,7 +35,7 @@ public void waitUntilReady(WaitStrategyTarget waitStrategyTarget) { .untilAsserted(() -> { logger.info("Check file existence..."); pdfFileData = waitStrategyTarget.copyFileFromContainer(filePath, InputStream::readAllBytes); - logger.info("Pdf file is ready, size = " + pdfFileData.length); + logger.info("Pdf file is ready, size = {}", pdfFileData.length); }); }