feature: implements mid trimming long text; implements repo length truncation

This commit is contained in:
ievgenii vdovenko 2026-01-06 17:54:17 +01:00
parent 1906b1960f
commit e0b2043c71
21 changed files with 311 additions and 96 deletions

View file

@ -17,8 +17,8 @@
%>
<div class="panel panel-default">
<div class="panel-heading" id="advanced-info" >
<h3 class="panel-title">${_('Repository: %s') % c.rhodecode_db_repo.repo_name} <a class="permalink" href="#advanced-info"> ¶</a></h3>
<div class="panel-heading truncate" id="advanced-info" >
<h3 class="panel-title" id="repo-name-title">${_('Repository: %s') % c.rhodecode_db_repo.repo_name} <a class="permalink" href="#advanced-info"> ¶</a></h3>
</div>
<div class="panel-body">
${base.dt_info_panel(elems)}
@ -241,7 +241,7 @@
<div class="field">
<button class="btn btn-small btn-danger" type="submit"
onclick="submitConfirm(event, this, _gettext('Confirm to delete this repository'), _gettext('Delete'), '${c.rhodecode_db_repo.repo_name}')"
onclick="submitConfirm(event, this, _gettext('Confirm to delete this repository'), _gettext('Delete'), '${h.truncate_middle(c.rhodecode_db_repo.repo_name, 50)}')"
>
${_('Delete this repository')}
</button>
@ -263,73 +263,72 @@
<script>
var currentRepoId = ${c.rhodecode_db_repo.repo_id};
var currentRepoId = ${c.rhodecode_db_repo.repo_id};
var repoTypeFilter = function(data) {
var results = [];
var repoTypeFilter = function(data) {
var results = [];
if (!data.results[0]) {
return data
}
if (!data.results[0]) {
return data
$.each(data.results[0].children, function() {
// filter out the SAME repo, it cannot be used as fork of itself
if (this.repo_id != currentRepoId) {
this.id = this.repo_id;
results.push(this)
}
});
data.results[0].children = results;
return data;
};
$("#id_fork_of").select2({
cachedDataSource: {},
minimumInputLength: 2,
placeholder: "${_('Change repository') if c.rhodecode_db_repo.fork else _('Pick repository')}",
dropdownAutoWidth: true,
containerCssClass: "drop-menu",
dropdownCssClass: "drop-menu-dropdown",
formatResult: formatRepoResult,
query: $.debounce(250, function(query){
self = this;
var cacheKey = query.term;
var cachedData = self.cachedDataSource[cacheKey];
if (cachedData) {
query.callback({results: cachedData.results});
} else {
$.ajax({
url: pyroutes.url('repo_list_data'),
data: {'query': query.term, repo_type: '${c.rhodecode_db_repo.repo_type}'},
dataType: 'json',
type: 'GET',
success: function(data) {
data = repoTypeFilter(data);
self.cachedDataSource[cacheKey] = data;
query.callback({results: data.results});
},
error: function(data, textStatus, errorThrown) {
alert("Error while fetching entries.\nError code {0} ({1}).".format(data.status, data.statusText));
}
})
}
})
});
// hide/show archive help field
const $checkbox = $('#backup');
const $helpField = $('#archive_help_field');
function syncHelpVisibility() {
$checkbox.val($checkbox.is(':checked') ? 'true' : 'false');
$helpField.toggle($checkbox.is(':checked'));
}
$.each(data.results[0].children, function() {
// filter out the SAME repo, it cannot be used as fork of itself
if (this.repo_id != currentRepoId) {
this.id = this.repo_id;
results.push(this)
}
});
data.results[0].children = results;
return data;
};
$("#id_fork_of").select2({
cachedDataSource: {},
minimumInputLength: 2,
placeholder: "${_('Change repository') if c.rhodecode_db_repo.fork else _('Pick repository')}",
dropdownAutoWidth: true,
containerCssClass: "drop-menu",
dropdownCssClass: "drop-menu-dropdown",
formatResult: formatRepoResult,
query: $.debounce(250, function(query){
self = this;
var cacheKey = query.term;
var cachedData = self.cachedDataSource[cacheKey];
if (cachedData) {
query.callback({results: cachedData.results});
} else {
$.ajax({
url: pyroutes.url('repo_list_data'),
data: {'query': query.term, repo_type: '${c.rhodecode_db_repo.repo_type}'},
dataType: 'json',
type: 'GET',
success: function(data) {
data = repoTypeFilter(data);
self.cachedDataSource[cacheKey] = data;
query.callback({results: data.results});
},
error: function(data, textStatus, errorThrown) {
alert("Error while fetching entries.\nError code {0} ({1}).".format(data.status, data.statusText));
}
})
}
})
});
// hide/show archive help field
const $checkbox = $('#backup');
const $helpField = $('#archive_help_field');
function syncHelpVisibility() {
$checkbox.val($checkbox.is(':checked') ? 'true' : 'false');
$helpField.toggle($checkbox.is(':checked'));
}
$checkbox.on('change', syncHelpVisibility)
syncHelpVisibility();
$checkbox.on('change', syncHelpVisibility)
syncHelpVisibility();
trimRepoTitleName();
</script>