diff --git a/webapp/src/main/java/com/box/l10n/mojito/entity/BranchSource.java b/webapp/src/main/java/com/box/l10n/mojito/entity/BranchSource.java new file mode 100644 index 0000000000..61c8537478 --- /dev/null +++ b/webapp/src/main/java/com/box/l10n/mojito/entity/BranchSource.java @@ -0,0 +1,39 @@ +package com.box.l10n.mojito.entity; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.ForeignKey; +import jakarta.persistence.Index; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; + +@Entity +@Table( + name = "branch_source", + indexes = {@Index(name = "I__BRANCH_SOURCE__BRANCH_ID", columnList = "branch_id")}) +public class BranchSource extends BaseEntity { + + @ManyToOne + @JoinColumn(name = "branch_id", foreignKey = @ForeignKey(name = "FK__BRANCH_SOURCE__BRANCH_ID")) + private Branch branch; + + @Column(name = "url") + private String url; + + public Branch getBranch() { + return branch; + } + + public void setBranch(Branch branch) { + this.branch = branch; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } +} diff --git a/webapp/src/main/java/com/box/l10n/mojito/entity/TMTextUnitToBranch.java b/webapp/src/main/java/com/box/l10n/mojito/entity/TMTextUnitToBranch.java new file mode 100644 index 0000000000..914f6a9816 --- /dev/null +++ b/webapp/src/main/java/com/box/l10n/mojito/entity/TMTextUnitToBranch.java @@ -0,0 +1,44 @@ +package com.box.l10n.mojito.entity; + +import jakarta.persistence.Entity; +import jakarta.persistence.ForeignKey; +import jakarta.persistence.Index; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; + +@Entity +@Table( + name = "tm_text_unit_to_branch", + indexes = { + @Index(name = "I__TEXT_UNIT_TO_BRANCH__TEXT_UNIT_ID", columnList = "tm_text_unit_id") + }) +public class TMTextUnitToBranch extends BaseEntity { + @ManyToOne + @JoinColumn( + name = "tm_text_unit_id", + foreignKey = @ForeignKey(name = "FK__TM_TEXT_UNIT_TO_BRANCH__TM_TEXT_UNIT_ID")) + private TMTextUnit tmTextUnit; + + @ManyToOne + @JoinColumn( + name = "branch_id", + foreignKey = @ForeignKey(name = "FK__TM_TEXT_UNIT_TO_BRANCH__BRANCH_ID")) + private Branch branch; + + public TMTextUnit getTmTextUnit() { + return tmTextUnit; + } + + public void setTmTextUnit(TMTextUnit tmTextUnit) { + this.tmTextUnit = tmTextUnit; + } + + public Branch getBranch() { + return branch; + } + + public void setBranch(Branch branch) { + this.branch = branch; + } +} diff --git a/webapp/src/main/java/com/box/l10n/mojito/service/assetExtraction/AssetExtractionService.java b/webapp/src/main/java/com/box/l10n/mojito/service/assetExtraction/AssetExtractionService.java index dc8fc316c6..a77136cdc3 100644 --- a/webapp/src/main/java/com/box/l10n/mojito/service/assetExtraction/AssetExtractionService.java +++ b/webapp/src/main/java/com/box/l10n/mojito/service/assetExtraction/AssetExtractionService.java @@ -17,6 +17,7 @@ import com.box.l10n.mojito.entity.PushRun; import com.box.l10n.mojito.entity.Repository; import com.box.l10n.mojito.entity.TMTextUnit; +import com.box.l10n.mojito.entity.TMTextUnitToBranch; import com.box.l10n.mojito.entity.security.user.User; import com.box.l10n.mojito.json.ObjectMapper; import com.box.l10n.mojito.localtm.merger.AssetExtractorTextUnitsToMultiBranchStateConverter; @@ -51,6 +52,7 @@ import com.box.l10n.mojito.service.tm.TMRepository; import com.box.l10n.mojito.service.tm.TMService; import com.box.l10n.mojito.service.tm.TMTextUnitRepository; +import com.box.l10n.mojito.service.tm.TMTextUnitToBranchRepository; import com.box.l10n.mojito.service.tm.search.StatusFilter; import com.box.l10n.mojito.service.tm.search.TextUnitDTO; import com.box.l10n.mojito.service.tm.textunitdtocache.TextUnitDTOsCacheService; @@ -172,6 +174,8 @@ public class AssetExtractionService { @Autowired(required = false) AITranslationService aiTranslationService; + @Autowired TMTextUnitToBranchRepository tmTextUnitToBranchRepository; + private RepositoryStatisticsJobScheduler repositoryStatisticsJobScheduler; @Value("${l10n.assetExtraction.quartz.schedulerName:" + DEFAULT_SCHEDULER_NAME + "}") @@ -215,6 +219,9 @@ public PollableFuture processAsset( updateBranchAssetExtraction( assetContent, createdTextUnitsResult.getUpdatedState(), filterOptions, currentTask); + + updateTextUnitsToBranch(createdTextUnitsResult.getCreatedTextUnits(), assetContent.getBranch()); + updateLastSuccessfulAssetExtraction( asset, createdTextUnitsResult.getUpdatedState(), currentTask); updatePushRun(asset, createdTextUnitsResult.getUpdatedState(), pushRunId, currentTask); @@ -1290,4 +1297,24 @@ public AssetTextUnit createAssetTextUnit( return assetTextUnit; } + + public void updateTextUnitsToBranch(ImmutableList textUnits, Branch branch) { + // Map the text units to their branch + textUnits.forEach( + textUnit -> { + TMTextUnitToBranch textUnitToBranch = new TMTextUnitToBranch(); + textUnitToBranch.setBranch(branch); + textUnitToBranch.setTmTextUnit( + tmTextUnitRepository.findById(textUnit.getTmTextUnitId()).get()); + try { + tmTextUnitToBranchRepository.save(textUnitToBranch); + } catch (Exception e) { + logger.error( + "Failed to save text unit with id '{}' to text unit to branch table with branch id '{}'", + textUnit.getTmTextUnitId(), + branch.getId(), + e); + } + }); + } } diff --git a/webapp/src/main/java/com/box/l10n/mojito/service/branch/BranchService.java b/webapp/src/main/java/com/box/l10n/mojito/service/branch/BranchService.java index 521827c9b0..168475947b 100644 --- a/webapp/src/main/java/com/box/l10n/mojito/service/branch/BranchService.java +++ b/webapp/src/main/java/com/box/l10n/mojito/service/branch/BranchService.java @@ -4,13 +4,18 @@ import static org.slf4j.LoggerFactory.getLogger; import com.box.l10n.mojito.entity.Branch; +import com.box.l10n.mojito.entity.BranchSource; import com.box.l10n.mojito.entity.Repository; import com.box.l10n.mojito.entity.security.user.User; import com.box.l10n.mojito.quartz.QuartzJobInfo; import com.box.l10n.mojito.quartz.QuartzPollableTaskScheduler; import com.box.l10n.mojito.service.pollableTask.PollableFuture; +import com.box.l10n.mojito.service.tm.BranchSourceRepository; +import com.google.common.base.Strings; +import com.google.common.collect.ImmutableMap; import java.text.MessageFormat; import java.util.Set; +import org.apache.commons.lang.text.StrSubstitutor; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -33,6 +38,10 @@ public class BranchService { @Autowired QuartzPollableTaskScheduler quartzPollableTaskScheduler; + @Autowired BranchSourceRepository branchSourceRepository; + + @Autowired BranchSourceConfig branchSourceConfig; + @Value("${l10n.branchService.quartz.schedulerName:" + DEFAULT_SCHEDULER_NAME + "}") String schedulerName; @@ -48,6 +57,8 @@ public Branch createBranch( branch.setNotifiers(branchNotifierIds); branch = branchRepository.save(branch); + addBranchSource(branch); + return branch; } @@ -87,4 +98,29 @@ public PollableFuture asyncDeleteBranch(Long repositoryId, Long branchId) .build(); return quartzPollableTaskScheduler.scheduleJob(quartzJobInfo); } + + public void addBranchSource(Branch branch) { + // Mojito push links text unit extractions to empty branch, don't attempt to update the source + if (branch.getName() == null) return; + + com.box.l10n.mojito.service.branch.BranchSource branchSource = + branchSourceConfig.getRepoOverride().get(branch.getRepository().getName()); + + String sourceUrl = (branchSource != null) ? branchSource.getUrl() : branchSourceConfig.getUrl(); + if (Strings.isNullOrEmpty(sourceUrl)) return; + + String url = + StrSubstitutor.replace( + sourceUrl, ImmutableMap.of("branchName", branch.getName()), "{", "}"); + + BranchSource bSource = new BranchSource(); + bSource.setBranch(branch); + bSource.setUrl(url); + try { + branchSourceRepository.save(bSource); + } catch (Exception e) { + logger.error( + "Failed to save branch source for branch '{}' with url '{}'", branch.getName(), url, e); + } + } } diff --git a/webapp/src/main/java/com/box/l10n/mojito/service/branch/BranchSource.java b/webapp/src/main/java/com/box/l10n/mojito/service/branch/BranchSource.java new file mode 100644 index 0000000000..8ffa1f6754 --- /dev/null +++ b/webapp/src/main/java/com/box/l10n/mojito/service/branch/BranchSource.java @@ -0,0 +1,14 @@ +package com.box.l10n.mojito.service.branch; + +public class BranchSource { + + String url; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } +} diff --git a/webapp/src/main/java/com/box/l10n/mojito/service/branch/BranchSourceConfig.java b/webapp/src/main/java/com/box/l10n/mojito/service/branch/BranchSourceConfig.java new file mode 100644 index 0000000000..31d85c7659 --- /dev/null +++ b/webapp/src/main/java/com/box/l10n/mojito/service/branch/BranchSourceConfig.java @@ -0,0 +1,39 @@ +package com.box.l10n.mojito.service.branch; + +import java.util.HashMap; +import java.util.Map; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +@Component +@ConfigurationProperties("l10n.branch-sources") +public class BranchSourceConfig { + + String url; + String notFound = "-"; + Map repoOverride = new HashMap<>(); + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getNotFound() { + return notFound; + } + + public void setNotFound(String notFound) { + this.notFound = notFound; + } + + public Map getRepoOverride() { + return repoOverride; + } + + public void setRepoOverride(Map repoOverride) { + this.repoOverride = repoOverride; + } +} diff --git a/webapp/src/main/java/com/box/l10n/mojito/service/gitblame/GitBlameService.java b/webapp/src/main/java/com/box/l10n/mojito/service/gitblame/GitBlameService.java index a1858d6aff..adad87e447 100644 --- a/webapp/src/main/java/com/box/l10n/mojito/service/gitblame/GitBlameService.java +++ b/webapp/src/main/java/com/box/l10n/mojito/service/gitblame/GitBlameService.java @@ -1,17 +1,22 @@ package com.box.l10n.mojito.service.gitblame; import com.box.l10n.mojito.entity.AssetTextUnit; +import com.box.l10n.mojito.entity.BranchSource; import com.box.l10n.mojito.entity.GitBlame; import com.box.l10n.mojito.entity.Screenshot; import com.box.l10n.mojito.entity.ThirdPartyTextUnit; import com.box.l10n.mojito.quartz.QuartzPollableTaskScheduler; +import com.box.l10n.mojito.react.LinkConfig; import com.box.l10n.mojito.service.asset.AssetRepository; import com.box.l10n.mojito.service.assetTextUnit.AssetTextUnitRepository; +import com.box.l10n.mojito.service.branch.BranchRepository; +import com.box.l10n.mojito.service.branch.BranchSourceConfig; import com.box.l10n.mojito.service.pollableTask.Pollable; import com.box.l10n.mojito.service.pollableTask.PollableFuture; import com.box.l10n.mojito.service.pollableTask.PollableFutureTaskResult; import com.box.l10n.mojito.service.screenshot.ScreenshotService; import com.box.l10n.mojito.service.thirdparty.ThirdPartyTextUnitRepository; +import com.box.l10n.mojito.service.tm.BranchSourceRepository; import com.box.l10n.mojito.service.tm.TMTextUnitRepository; import com.box.l10n.mojito.service.tm.search.TextUnitDTO; import com.box.l10n.mojito.service.tm.search.TextUnitSearcher; @@ -55,6 +60,13 @@ public class GitBlameService { @Autowired ThirdPartyTextUnitRepository thirdPartyTextUnitRepository; + @Autowired BranchRepository branchRepository; + + @Autowired LinkConfig linkConfig; + @Autowired private BranchSourceRepository branchSourceRepository; + + @Autowired private BranchSourceConfig branchSourceConfig; + /** * Gets the {@link GitBlameWithUsage} information that matches the search parameters. * @@ -111,6 +123,15 @@ List convertTextUnitsDTOsToGitBlameWithUsages(List screenshots = new HashSet<>(); + @JsonView(View.GitBlameWithUsage.class) + String introducedBy; + @JsonView(View.GitBlameWithUsage.class) boolean isVirtual; @@ -152,4 +155,16 @@ public boolean getVirtual() { public void setVirtual(boolean isVirtual) { this.isVirtual = isVirtual; } + + public String getIntroducedBy() { + return introducedBy; + } + + public void setIntroducedBy(String introducedBy) { + this.introducedBy = introducedBy; + } + + public boolean isVirtual() { + return isVirtual; + } } diff --git a/webapp/src/main/java/com/box/l10n/mojito/service/tm/BranchSourceRepository.java b/webapp/src/main/java/com/box/l10n/mojito/service/tm/BranchSourceRepository.java new file mode 100644 index 0000000000..c048f304ea --- /dev/null +++ b/webapp/src/main/java/com/box/l10n/mojito/service/tm/BranchSourceRepository.java @@ -0,0 +1,16 @@ +package com.box.l10n.mojito.service.tm; + +import com.box.l10n.mojito.entity.BranchSource; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; + +public interface BranchSourceRepository extends JpaRepository { + @Query( + value = + "SELECT bs.*" + + " FROM branch_source bs" + + " JOIN tm_text_unit_to_branch tutb ON tutb.branch_id = bs.branch_id" + + " WHERE tutb.tm_text_unit_id = :textUnitId", + nativeQuery = true) + BranchSource findByTextUnitId(Long textUnitId); +} diff --git a/webapp/src/main/java/com/box/l10n/mojito/service/tm/TMTextUnitToBranchRepository.java b/webapp/src/main/java/com/box/l10n/mojito/service/tm/TMTextUnitToBranchRepository.java new file mode 100644 index 0000000000..0e9d34aa2e --- /dev/null +++ b/webapp/src/main/java/com/box/l10n/mojito/service/tm/TMTextUnitToBranchRepository.java @@ -0,0 +1,6 @@ +package com.box.l10n.mojito.service.tm; + +import com.box.l10n.mojito.entity.TMTextUnitToBranch; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface TMTextUnitToBranchRepository extends JpaRepository {} diff --git a/webapp/src/main/resources/db/migration/V72__Add_branch_source.sql b/webapp/src/main/resources/db/migration/V72__Add_branch_source.sql new file mode 100644 index 0000000000..fced4bfdf7 --- /dev/null +++ b/webapp/src/main/resources/db/migration/V72__Add_branch_source.sql @@ -0,0 +1,25 @@ +CREATE TABLE tm_text_unit_to_branch( + id BIGINT AUTO_INCREMENT PRIMARY KEY, + tm_text_unit_id BIGINT NOT NULL, + branch_id BIGINT NOT NULL +); + +ALTER TABLE tm_text_unit_to_branch +ADD CONSTRAINT FK__TM_TEXT_UNIT_TO_BRANCH__TM_TEXT_UNIT_ID FOREIGN KEY (tm_text_unit_id) REFERENCES tm_text_unit(id); + +ALTER TABLE tm_text_unit_to_branch +ADD CONSTRAINT FK__TM_TEXT_UNIT_TO_BRANCH__BRANCH_ID FOREIGN KEY (branch_id) REFERENCES branch(id); + +create index I__TEXT_UNIT_TO_BRANCH__TEXT_UNIT_ID on tm_text_unit_to_branch (tm_text_unit_id); + +CREATE TABLE branch_source( + id BIGINT AUTO_INCREMENT PRIMARY KEY, + branch_id BIGINT NOT NULL, + url VARCHAR(255) NOT NULL +); + +ALTER TABLE branch_source +ADD CONSTRAINT FK__BRANCH_SOURCE__BRANCH_ID FOREIGN KEY (branch_id) REFERENCES branch(id); + +create index I__BRANCH_SOURCE__BRANCH_ID on branch_source (branch_id); + diff --git a/webapp/src/main/resources/properties/be.properties b/webapp/src/main/resources/properties/be.properties index ecc5f4ebdc..87451992f8 100644 --- a/webapp/src/main/resources/properties/be.properties +++ b/webapp/src/main/resources/properties/be.properties @@ -687,6 +687,9 @@ textUnit.gitBlameModal.commitDate=Commit date # Label for code location in git-blame modal textUnit.gitBlameModal.location=Location +# Label for introduced by in git-blame modal +textUnit.gitBlameModal.introducedBy=Introduced By + # Label for third party system in git-blame modal textUnit.gitBlameModal.thirdPartyTMS=Third party TMS diff --git a/webapp/src/main/resources/properties/de.properties b/webapp/src/main/resources/properties/de.properties index e80c8176d8..5058c5666d 100644 --- a/webapp/src/main/resources/properties/de.properties +++ b/webapp/src/main/resources/properties/de.properties @@ -705,6 +705,9 @@ textUnit.gitBlameModal.commitDate=Commit date # Label for code location in git-blame modal textUnit.gitBlameModal.location=Location +# Label for introduced by in git-blame modal +textUnit.gitBlameModal.introducedBy=Introduced By + # Label for third party system in git-blame modal textUnit.gitBlameModal.thirdPartyTMS=Third party TMS diff --git a/webapp/src/main/resources/properties/el.properties b/webapp/src/main/resources/properties/el.properties index b21eb1cb11..6045c69e7d 100644 --- a/webapp/src/main/resources/properties/el.properties +++ b/webapp/src/main/resources/properties/el.properties @@ -687,6 +687,9 @@ textUnit.gitBlameModal.commitDate=Commit date # Label for code location in git-blame modal textUnit.gitBlameModal.location=Location +# Label for introduced by in git-blame modal +textUnit.gitBlameModal.introducedBy=Introduced By + # Label for third party system in git-blame modal textUnit.gitBlameModal.thirdPartyTMS=Third party TMS diff --git a/webapp/src/main/resources/properties/en.properties b/webapp/src/main/resources/properties/en.properties index e809162bb8..e8350c6c1b 100644 --- a/webapp/src/main/resources/properties/en.properties +++ b/webapp/src/main/resources/properties/en.properties @@ -758,6 +758,9 @@ textUnit.gitBlameModal.commitDate=Commit date # Label for code location in git-blame modal textUnit.gitBlameModal.location=Location +# Label for introduced by in git-blame modal +textUnit.gitBlameModal.introducedBy=Introduced By + # Label for third party system in git-blame modal textUnit.gitBlameModal.thirdPartyTMS=Third party TMS diff --git a/webapp/src/main/resources/properties/es.properties b/webapp/src/main/resources/properties/es.properties index 9d3a24338e..c77c49ae3b 100644 --- a/webapp/src/main/resources/properties/es.properties +++ b/webapp/src/main/resources/properties/es.properties @@ -687,6 +687,9 @@ textUnit.gitBlameModal.commitDate=Commit date # Label for code location in git-blame modal textUnit.gitBlameModal.location=Location +# Label for introduced by in git-blame modal +textUnit.gitBlameModal.introducedBy=Introduced By + # Label for third party system in git-blame modal textUnit.gitBlameModal.thirdPartyTMS=Third party TMS diff --git a/webapp/src/main/resources/properties/fr.properties b/webapp/src/main/resources/properties/fr.properties index 91ae593f27..49af15886f 100644 --- a/webapp/src/main/resources/properties/fr.properties +++ b/webapp/src/main/resources/properties/fr.properties @@ -687,6 +687,9 @@ textUnit.gitBlameModal.commitDate=Commit date # Label for code location in git-blame modal textUnit.gitBlameModal.location=Location +# Label for introduced by in git-blame modal +textUnit.gitBlameModal.introducedBy=Introduced By + # Label for third party system in git-blame modal textUnit.gitBlameModal.thirdPartyTMS=Third party TMS diff --git a/webapp/src/main/resources/properties/id.properties b/webapp/src/main/resources/properties/id.properties index b21eb1cb11..6045c69e7d 100644 --- a/webapp/src/main/resources/properties/id.properties +++ b/webapp/src/main/resources/properties/id.properties @@ -687,6 +687,9 @@ textUnit.gitBlameModal.commitDate=Commit date # Label for code location in git-blame modal textUnit.gitBlameModal.location=Location +# Label for introduced by in git-blame modal +textUnit.gitBlameModal.introducedBy=Introduced By + # Label for third party system in git-blame modal textUnit.gitBlameModal.thirdPartyTMS=Third party TMS diff --git a/webapp/src/main/resources/properties/it.properties b/webapp/src/main/resources/properties/it.properties index 3a96e60980..e2bc945461 100644 --- a/webapp/src/main/resources/properties/it.properties +++ b/webapp/src/main/resources/properties/it.properties @@ -687,6 +687,9 @@ textUnit.gitBlameModal.commitDate=Commit date # Label for code location in git-blame modal textUnit.gitBlameModal.location=Location +# Label for introduced by in git-blame modal +textUnit.gitBlameModal.introducedBy=Introduced By + # Label for third party system in git-blame modal textUnit.gitBlameModal.thirdPartyTMS=Third party TMS diff --git a/webapp/src/main/resources/properties/ja.properties b/webapp/src/main/resources/properties/ja.properties index c64733186a..6b68aee127 100644 --- a/webapp/src/main/resources/properties/ja.properties +++ b/webapp/src/main/resources/properties/ja.properties @@ -687,6 +687,9 @@ textUnit.gitBlameModal.commitDate=Commit date # Label for code location in git-blame modal textUnit.gitBlameModal.location=Location +# Label for introduced by in git-blame modal +textUnit.gitBlameModal.introducedBy=Introduced By + # Label for third party system in git-blame modal textUnit.gitBlameModal.thirdPartyTMS=Third party TMS diff --git a/webapp/src/main/resources/properties/ko.properties b/webapp/src/main/resources/properties/ko.properties index 3fa3b511c9..d85ba9120f 100644 --- a/webapp/src/main/resources/properties/ko.properties +++ b/webapp/src/main/resources/properties/ko.properties @@ -687,6 +687,9 @@ textUnit.gitBlameModal.commitDate=Commit date # Label for code location in git-blame modal textUnit.gitBlameModal.location=Location +# Label for introduced by in git-blame modal +textUnit.gitBlameModal.introducedBy=Introduced By + # Label for third party system in git-blame modal textUnit.gitBlameModal.thirdPartyTMS=Third party TMS diff --git a/webapp/src/main/resources/properties/ms.properties b/webapp/src/main/resources/properties/ms.properties index b21eb1cb11..6045c69e7d 100644 --- a/webapp/src/main/resources/properties/ms.properties +++ b/webapp/src/main/resources/properties/ms.properties @@ -687,6 +687,9 @@ textUnit.gitBlameModal.commitDate=Commit date # Label for code location in git-blame modal textUnit.gitBlameModal.location=Location +# Label for introduced by in git-blame modal +textUnit.gitBlameModal.introducedBy=Introduced By + # Label for third party system in git-blame modal textUnit.gitBlameModal.thirdPartyTMS=Third party TMS diff --git a/webapp/src/main/resources/properties/nl.properties b/webapp/src/main/resources/properties/nl.properties index 202f8a6e89..8db7f45a59 100644 --- a/webapp/src/main/resources/properties/nl.properties +++ b/webapp/src/main/resources/properties/nl.properties @@ -687,6 +687,9 @@ textUnit.gitBlameModal.commitDate=Commit date # Label for code location in git-blame modal textUnit.gitBlameModal.location=Location +# Label for introduced by in git-blame modal +textUnit.gitBlameModal.introducedBy=Introduced By + # Label for third party system in git-blame modal textUnit.gitBlameModal.thirdPartyTMS=Third party TMS diff --git a/webapp/src/main/resources/properties/pl.properties b/webapp/src/main/resources/properties/pl.properties index b21eb1cb11..6045c69e7d 100644 --- a/webapp/src/main/resources/properties/pl.properties +++ b/webapp/src/main/resources/properties/pl.properties @@ -687,6 +687,9 @@ textUnit.gitBlameModal.commitDate=Commit date # Label for code location in git-blame modal textUnit.gitBlameModal.location=Location +# Label for introduced by in git-blame modal +textUnit.gitBlameModal.introducedBy=Introduced By + # Label for third party system in git-blame modal textUnit.gitBlameModal.thirdPartyTMS=Third party TMS diff --git a/webapp/src/main/resources/properties/pt.properties b/webapp/src/main/resources/properties/pt.properties index 221ea9b160..c2aeb3fb09 100644 --- a/webapp/src/main/resources/properties/pt.properties +++ b/webapp/src/main/resources/properties/pt.properties @@ -687,6 +687,9 @@ textUnit.gitBlameModal.commitDate=Commit date # Label for code location in git-blame modal textUnit.gitBlameModal.location=Location +# Label for introduced by in git-blame modal +textUnit.gitBlameModal.introducedBy=Introduced By + # Label for third party system in git-blame modal textUnit.gitBlameModal.thirdPartyTMS=Third party TMS diff --git a/webapp/src/main/resources/properties/ru.properties b/webapp/src/main/resources/properties/ru.properties index 8e4a7c72f4..2e11a7055b 100644 --- a/webapp/src/main/resources/properties/ru.properties +++ b/webapp/src/main/resources/properties/ru.properties @@ -687,6 +687,9 @@ textUnit.gitBlameModal.commitDate=Commit date # Label for code location in git-blame modal textUnit.gitBlameModal.location=Location +# Label for introduced by in git-blame modal +textUnit.gitBlameModal.introducedBy=Introduced By + # Label for third party system in git-blame modal textUnit.gitBlameModal.thirdPartyTMS=Third party TMS diff --git a/webapp/src/main/resources/properties/tr.properties b/webapp/src/main/resources/properties/tr.properties index b21eb1cb11..138c0fa73d 100644 --- a/webapp/src/main/resources/properties/tr.properties +++ b/webapp/src/main/resources/properties/tr.properties @@ -445,8 +445,8 @@ drops.status.importing=Importing # Status label for drop when being sent drops.status.sending=Sending -# Status label for drop when translation request -drops.status.inTranslation=In Translation +# Label for introduced by in git-blame modal +textUnit.gitBlameModal.introducedBy=Introduced By # Status label for drop when review request drops.status.inReview=In Review @@ -687,6 +687,9 @@ textUnit.gitBlameModal.commitDate=Commit date # Label for code location in git-blame modal textUnit.gitBlameModal.location=Location +# Label for introduced in git-blame modal +textUnit.gitBlameModal.introducedIn=Introduced In + # Label for third party system in git-blame modal textUnit.gitBlameModal.thirdPartyTMS=Third party TMS diff --git a/webapp/src/main/resources/properties/vi.properties b/webapp/src/main/resources/properties/vi.properties index b21eb1cb11..138c0fa73d 100644 --- a/webapp/src/main/resources/properties/vi.properties +++ b/webapp/src/main/resources/properties/vi.properties @@ -445,8 +445,8 @@ drops.status.importing=Importing # Status label for drop when being sent drops.status.sending=Sending -# Status label for drop when translation request -drops.status.inTranslation=In Translation +# Label for introduced by in git-blame modal +textUnit.gitBlameModal.introducedBy=Introduced By # Status label for drop when review request drops.status.inReview=In Review @@ -687,6 +687,9 @@ textUnit.gitBlameModal.commitDate=Commit date # Label for code location in git-blame modal textUnit.gitBlameModal.location=Location +# Label for introduced in git-blame modal +textUnit.gitBlameModal.introducedIn=Introduced In + # Label for third party system in git-blame modal textUnit.gitBlameModal.thirdPartyTMS=Third party TMS diff --git a/webapp/src/main/resources/public/js/components/workbench/GitBlameInfoModal.js b/webapp/src/main/resources/public/js/components/workbench/GitBlameInfoModal.js index 57c9340c4f..46da11bebf 100644 --- a/webapp/src/main/resources/public/js/components/workbench/GitBlameInfoModal.js +++ b/webapp/src/main/resources/public/js/components/workbench/GitBlameInfoModal.js @@ -101,6 +101,7 @@ class GitBlameInfoModal extends React.Component { {this.displayInfoWithId("textUnit.gitBlameModal.location", this.getLocationLinks())} {this.shouldShowThirdPartyTMS() && this.displayInfoWithId("textUnit.gitBlameModal.thirdPartyTMS", this.getThirdPartyLink())} {this.shouldShowCustomMd5() && this.displayInfoWithId("textUnit.gitBlameModal.customMd5", this.getCustomMd5Link())} + {this.displayInfoWithId("textUnit.gitBlameModal.introducedBy", this.getIntroducedByLink())} ); }; @@ -221,6 +222,14 @@ class GitBlameInfoModal extends React.Component { } }; + getIntroducedBy = () => { + try { + return this.props.gitBlameWithUsage.introducedBy.toString(); + } catch (e) { + return "-"; + } + } + /** * Base params are just a subset of text unit properties that can be used inside templates. * @@ -282,6 +291,15 @@ class GitBlameInfoModal extends React.Component { this.getParamsForLinks()); }; + getIntroducedByLink = () => { + try { + const parsedUrl = new URL(this.getIntroducedBy()); + return {parsedUrl.toString()}; + } catch (error) { + return this.getIntroducedBy(); + } + }; + getCustomMd5 = (baseParams) => { let renderedTemplate = TemplateHelper.renderTemplate(this.getCustomMd5Template(), baseParams); return md5(renderedTemplate);