Merge pull request !2951 from rhodecode-enterprise-ce feature/RCCE-386_add_ai_code_review_checkbox
feature: implements AI code review PR checkbox; adds AI PR settings
This commit is contained in:
commit
e1a67b7306
12 changed files with 184 additions and 48 deletions
|
|
@ -1,3 +1,9 @@
|
|||
<style>
|
||||
.field > .label {
|
||||
min-width: 300px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">${_('Ai Configuration')}</h3>
|
||||
|
|
@ -15,6 +21,16 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field" id="ai-default-review-toggle" >
|
||||
<div class="label label-checkbox">
|
||||
<label for="rhodecode_ai_default_code_review">${_('Turn on AI code review by default for new PRs')}:</label>
|
||||
<strong>Warning</strong>: can potentially spend a lot of tokens
|
||||
</div>
|
||||
<div class="checkboxes">
|
||||
${h.checkbox('rhodecode_ai_default_code_review',value=True, checked=c.ai_default_code_review==True)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field" id="model" style="display: flex;">
|
||||
<div class="label label">
|
||||
<label for="model">${_('Model')}</label>
|
||||
|
|
@ -79,6 +95,7 @@ import json
|
|||
const $model = $('#rhodecode_ai_model');
|
||||
const $slot = $('#model_version_slot');
|
||||
const $enable = $('#rhodecode_ai_features_enabled');
|
||||
const $codeReview = $('#rhodecode_ai_default_code_review');
|
||||
const $form = $('#ai_features_form');
|
||||
const $updateModelsBtn = $('#model_version_button_update');
|
||||
|
||||
|
|
@ -181,7 +198,8 @@ import json
|
|||
data: {
|
||||
'rhodecode_ai_model': $model.val(),
|
||||
'rhodecode_ai_api_key': $apiKey.val(),
|
||||
'rhodecode_ai_features_enabled': $enable.is(':checked')
|
||||
'rhodecode_ai_features_enabled': $enable.is(':checked'),
|
||||
'rhodecode_ai_default_code_review': $codeReview.is(':checked')
|
||||
},
|
||||
success: function (response) {
|
||||
$.Topic('/notifications').publish({
|
||||
|
|
|
|||
|
|
@ -279,6 +279,34 @@
|
|||
<span class="help-block">${_('When enabled, the security scan checkbox will be pre-selected when creating pull requests. This scans the PR diff for exposed secrets and credentials.')}</span>
|
||||
</div>
|
||||
%endif
|
||||
|
||||
%if hasattr(c, 'repo_vcs_settings') and c.repo_vcs_settings:
|
||||
|
||||
%if c.rhodecode_edition_id != 'EE':
|
||||
<div class="checkbox">
|
||||
<input type="checkbox" disabled>
|
||||
<label>${_('Enable AI review for pull requests')}</label>
|
||||
</div>
|
||||
<div class="label">
|
||||
<span class="help-block">${_('This feature is available in RhodeCode EE edition only. Contact {sales_email} to obtain a trial license.').format(sales_email='<a href="mailto:sales@rhodecode.com">sales@rhodecode.com</a>')|n}</span>
|
||||
</div>
|
||||
%else:
|
||||
<div class="checkbox">
|
||||
%if c.ai_features_enabled:
|
||||
${h.checkbox('rhodecode_ai_default_code_review' + suffix, 'True', checked=c.ai_default_code_review, **kwargs)}
|
||||
<label for="rhodecode_ai_default_code_review${suffix}">${_('Enable AI review for pull requests')}</label>
|
||||
%else:
|
||||
<span class="tooltip" title="${_('AI features disabled, enable AI features to activate this checkbox.')}">
|
||||
${h.checkbox('rhodecode_ai_default_code_review' + suffix, 'True', checked=c.ai_default_code_review, disabled=True, **kwargs)}
|
||||
<label for="rhodecode_ai_default_code_review${suffix}">${_('Enable AI review for pull requests')}</label>
|
||||
</span>
|
||||
%endif
|
||||
</div>
|
||||
<div class="label">
|
||||
<span class="help-block">${_('When enabled, the AI code review checkbox will be pre-selected when creating pull requests. This will schedule AI code review for the PR.')}</span>
|
||||
</div>
|
||||
%endif
|
||||
%endif
|
||||
</div>
|
||||
</div>
|
||||
% endif
|
||||
|
|
|
|||
|
|
@ -247,6 +247,31 @@
|
|||
</label>
|
||||
</div>
|
||||
% endif
|
||||
|
||||
% if c.ai_enabled and c.rhodecode_edition_id == 'EE':
|
||||
<div class="pull-request-settings" style="margin-left: 220px">
|
||||
${h.checkbox('run_ai_codereview', checked=c.ai_pr_review, value=True)}
|
||||
<label for="run_ai_codereview">
|
||||
${h.literal(_('Run run AI code review'))}
|
||||
</label>
|
||||
</div>
|
||||
% elif not c.ai_enabled:
|
||||
<div class="pull-request-settings" style="margin-left: 220px">
|
||||
${h.checkbox('run_ai_codereview', checked=False, value=True, disabled=True, **{'class': 'disabled-checkbox'})}
|
||||
<label for="run_ai_codereview" class="disabled-label">
|
||||
${h.literal(_('Run AI code review'))}
|
||||
<span class="tooltip" title="${_('Enable AI features to use this checkbox')}">[?]</span>
|
||||
</label>
|
||||
</div>
|
||||
% elif c.rhodecode_edition_id != 'EE':
|
||||
<div class="pull-request-settings" style="margin-left: 220px">
|
||||
${h.checkbox('run_ai_codereview', checked=False, value=True, disabled=True, **{'class': 'disabled-checkbox'})}
|
||||
<label for="run_ai_codereview" class="disabled-label">
|
||||
${h.literal(_('Run AI code review'))}
|
||||
<span class="ee-feature-label">[EE Only]</span>
|
||||
</label>
|
||||
</div>
|
||||
% endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue