fix(template): fixed disabled deploy button EE-812 (#5105)
parent
819faa3948
commit
6bfbf58cdb
|
@ -55,7 +55,7 @@
|
|||
<button
|
||||
type="button"
|
||||
class="btn btn-primary btn-sm"
|
||||
ng-disabled="$ctrl.state.actionInProgress || !$ctrl.formValues.name || $ctrl.state.provider !== $ctrl.template.Type"
|
||||
ng-disabled="$ctrl.state.actionInProgress || !$ctrl.formValues.name || !$ctrl.state.deployable"
|
||||
ng-click="$ctrl.createTemplate()"
|
||||
button-spinner="$ctrl.state.actionInProgress"
|
||||
>
|
||||
|
@ -64,7 +64,7 @@
|
|||
</button>
|
||||
<button type="button" class="btn btn-sm btn-default" ng-click="$ctrl.unselectTemplate($ctrl.template)">Hide</button>
|
||||
<div class="cols-sm-12 small text-danger" ng-if="$ctrl.state.formValidationError" style="margin-left: 5px; margin-top: 5px;">{{ $ctrl.state.formValidationError }}</div>
|
||||
<div class="cols-sm-12 small text-danger" ng-if="$ctrl.state.provider !== $ctrl.template.Type" style="margin-left: 5px; margin-top: 5px;"
|
||||
<div class="cols-sm-12 small text-danger" ng-if="!$ctrl.state.deployable" style="margin-left: 5px; margin-top: 5px;"
|
||||
>This template type cannot be deployed on this endpoint.</div
|
||||
>
|
||||
</div>
|
||||
|
|
|
@ -36,6 +36,9 @@ angular.module('portainer.app').controller('TemplatesController', [
|
|||
StackService,
|
||||
endpoint
|
||||
) {
|
||||
const DOCKER_STANDALONE = 'DOCKER_STANDALONE';
|
||||
const DOCKER_SWARM_MODE = 'DOCKER_SWARM_MODE';
|
||||
|
||||
$scope.state = {
|
||||
selectedTemplate: null,
|
||||
showAdvancedOptions: false,
|
||||
|
@ -240,9 +243,27 @@ angular.module('portainer.app').controller('TemplatesController', [
|
|||
|
||||
$scope.formValues.name = template.Name ? template.Name : '';
|
||||
$scope.state.selectedTemplate = template;
|
||||
$scope.state.deployable = isDeployable($scope.applicationState.endpoint, template.Type);
|
||||
$anchorScroll('view-top');
|
||||
};
|
||||
|
||||
function isDeployable(endpoint, templateType) {
|
||||
let deployable = false;
|
||||
switch (templateType) {
|
||||
case 1:
|
||||
deployable = endpoint.mode.provider === DOCKER_SWARM_MODE || endpoint.mode.provider === DOCKER_STANDALONE;
|
||||
break;
|
||||
case 2:
|
||||
deployable = endpoint.mode.provider === DOCKER_SWARM_MODE;
|
||||
break;
|
||||
case 3:
|
||||
deployable = endpoint.mode.provider === DOCKER_STANDALONE;
|
||||
break;
|
||||
}
|
||||
|
||||
return deployable;
|
||||
}
|
||||
|
||||
function createTemplateConfiguration(template) {
|
||||
var network = $scope.formValues.network;
|
||||
var name = $scope.formValues.name;
|
||||
|
@ -254,7 +275,6 @@ angular.module('portainer.app').controller('TemplatesController', [
|
|||
|
||||
var endpointMode = $scope.applicationState.endpoint.mode;
|
||||
var apiVersion = $scope.applicationState.endpoint.apiVersion;
|
||||
$scope.state.provider = endpointMode.provider === 'DOCKER_STANDALONE' ? 2 : 1;
|
||||
|
||||
$q.all({
|
||||
templates: TemplateService.templates(),
|
||||
|
|
Loading…
Reference in New Issue