diff --git a/app/portainer/components/forms/stack-from-template-form/stackFromTemplateForm.html b/app/portainer/components/forms/stack-from-template-form/stackFromTemplateForm.html
index 336ccb8a4..1f3907ee4 100644
--- a/app/portainer/components/forms/stack-from-template-form/stackFromTemplateForm.html
+++ b/app/portainer/components/forms/stack-from-template-form/stackFromTemplateForm.html
@@ -55,7 +55,7 @@
{{ $ctrl.state.formValidationError }}
- This template type cannot be deployed on this endpoint.
diff --git a/app/portainer/views/custom-templates/custom-templates-view/customTemplatesViewController.js b/app/portainer/views/custom-templates/custom-templates-view/customTemplatesViewController.js
index fa50213ba..224a33b9a 100644
--- a/app/portainer/views/custom-templates/custom-templates-view/customTemplatesViewController.js
+++ b/app/portainer/views/custom-templates/custom-templates-view/customTemplatesViewController.js
@@ -34,13 +34,16 @@ class CustomTemplatesViewController {
this.StateManager = StateManager;
this.StackService = StackService;
+ this.DOCKER_STANDALONE = 'DOCKER_STANDALONE';
+ this.DOCKER_SWARM_MODE = 'DOCKER_SWARM_MODE';
+
this.state = {
selectedTemplate: null,
showAdvancedOptions: false,
formValidationError: '',
actionInProgress: false,
isEditorVisible: false,
- provider: 0,
+ deployable: false,
};
this.currentUser = {
@@ -182,7 +185,8 @@ class CustomTemplatesViewController {
this.formValues.name = template.Title ? template.Title : '';
this.state.selectedTemplate = template;
this.$anchorScroll('view-top');
-
+ const applicationState = this.StateManager.getState();
+ this.state.deployable = this.isDeployable(applicationState.endpoint, template.Type);
const file = await this.CustomTemplateService.customTemplateFile(template.Id);
this.formValues.fileContent = file;
}
@@ -224,6 +228,21 @@ class CustomTemplatesViewController {
this.formValues.fileContent = cm.getValue();
}
+ isDeployable(endpoint, templateType) {
+ let deployable = false;
+ switch (templateType) {
+ case 1:
+ deployable = endpoint.mode.provider === this.DOCKER_SWARM_MODE;
+ break;
+ case 2:
+ deployable = endpoint.mode.provider === this.DOCKER_STANDALONE;
+ break;
+
+ }
+
+ return deployable;
+ }
+
$onInit() {
const applicationState = this.StateManager.getState();
@@ -232,7 +251,6 @@ class CustomTemplatesViewController {
apiVersion,
} = applicationState;
- this.state.provider = endpointMode.provider === 'DOCKER_STANDALONE' ? 2 : 1;
this.getTemplates(endpointMode);
this.getNetworks(endpointMode.provider, apiVersion);
diff --git a/app/portainer/views/templates/templatesController.js b/app/portainer/views/templates/templatesController.js
index cdf36a38a..f276b768e 100644
--- a/app/portainer/views/templates/templatesController.js
+++ b/app/portainer/views/templates/templatesController.js
@@ -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,26 @@ 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 +274,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(),