Sys Aud can see CG forms, Adds correct CG form link, Disables CodeMirror

This allows the System Auditor to see the container groups form in a disabled state.
If the pod_spec_override has been changed that field will be open when the page renders
but it will be disabled. It also greys out all code mirror text area fields for System Auditor.
It adds the correct url for the Container Groups message bar to inform users of possible
pitfalls associated with that feature.
This commit is contained in:
Alex Corey 2019-10-11 12:03:17 -04:00
parent 31c14b005c
commit 5cf84ddb60
4 changed files with 32 additions and 13 deletions

View File

@ -52,6 +52,11 @@
height: calc(~"100vh - 80px");
}
textarea[disabled] + div .CodeMirror-code{
background-color: #ebebeb;
cursor: not-allowed;
}
@media screen and (min-width: 768px){
.NetworkingExtraVars .modal-dialog{

View File

@ -1,5 +1,5 @@
<div ui-view="credentials"></div>
<a class="containerGroups-messageBar-link"href="https://docs.ansible.com/ansible-tower/latest/html/userguide/instance_groups.html" target="_blank" style="color: white">
<a class="containerGroups-messageBar-link" href="https://docs.ansible.com/ansible-tower/latest/html/administration/external_execution_envs.html#container-group-considerations" target="_blank" style="color: white">
<div class="Section-messageBar">
<i class="Section-messageBar-warning fa fa-warning"></i>
<span class="Section-messageBar-text">This feature is tech preview, and is subject to change in a future release. Click here for documentation.</span>
@ -21,13 +21,15 @@
{{ vm.form.extraVars.toggleLabel }}
</span>
</label>
<div ng-class="{'ContainerGroups-codeMirror': vm.form.extraVars.isOpen }">
<at-switch on-toggle="vm.toggle(instance)" switch-on="vm.form.extraVars.isOpen"
switch-disabled="vm.rowAction.toggle._disabled"></at-switch>
<div ng-disabled="{{vm.form.extraVars.disabled}}" ng-class="{'ContainerGroups-codeMirror': vm.form.extraVars.isOpen }">
<at-switch on-toggle="vm.toggle(instance)" switch-on="vm.form.extraVars.isOpen"
switch-disabled="vm.switchDisabled"></at-switch>
</div>
<at-code-mirror
ng-disabled="{{vm.form.extraVars.disabled}}"
ng-if="vm.form.extraVars.isOpen"
col="4" tab="3"
ng-class="{'containerGroups-codeMirror-disabled': vm.form.extraVars.disabled}"
class="Form-formGroup--fullWidth"
variables="vm.form.extraVars.value"
label="{{ vm.form.extraVars.label }}"

View File

@ -4,7 +4,7 @@ function EditContainerGroupController($rootScope, $scope, $state, models, string
instanceGroup,
credential
} = models;
const canEdit = instanceGroup.model.OPTIONS.actions.PUT;
if (!instanceGroup.get('is_containerized')) {
return $state.go(
'instanceGroups.edit',
@ -21,6 +21,8 @@ function EditContainerGroupController($rootScope, $scope, $state, models, string
vm.lookUpTitle = strings.get('container.LOOK_UP_TITLE');
vm.form = instanceGroup.createFormSchema('post');
vm.switchDisabled = false;
vm.form.disabled = !instanceGroup.has('options', 'actions.PUT');
vm.form.name.required = true;
vm.form.credential = {
type: 'field',
@ -48,14 +50,23 @@ function EditContainerGroupController($rootScope, $scope, $state, models, string
_go: 'instanceGroups.containerGroupJobs',
_params: { instance_group_id: instanceGroup.get('id') }
}
};
vm.form.extraVars = {
label: strings.get('container.POD_SPEC_LABEL'),
value: EditContainerGroupDataset.data.pod_spec_override || instanceGroup.model.OPTIONS.actions.PUT.pod_spec_override.default,
name: 'extraVars',
toggleLabel: strings.get('container.POD_SPEC_TOGGLE')
};
if (!canEdit) {
vm.form.extraVars = {
label: strings.get('container.POD_SPEC_LABEL'),
value: EditContainerGroupDataset.data.pod_spec_override || "---",
name: 'extraVars',
disabled: true
};
vm.switchDisabled = true;
} else {
vm.form.extraVars = {
label: strings.get('container.POD_SPEC_LABEL'),
value: EditContainerGroupDataset.data.pod_spec_override || instanceGroup.model.OPTIONS.actions.PUT.pod_spec_override.default,
name: 'extraVars',
toggleLabel: strings.get('container.POD_SPEC_TOGGLE')
};
}
function sanitizeVars (str) {
// Quick function to test if the host vars are a json-object-string,
@ -90,7 +101,7 @@ function EditContainerGroupController($rootScope, $scope, $state, models, string
}
const podSpecValue = sanitizeVars(EditContainerGroupDataset.data.pod_spec_override);
const defaultPodSpecValue = sanitizeVars(instanceGroup.model.OPTIONS.actions.PUT.pod_spec_override.default);
const defaultPodSpecValue = canEdit ? sanitizeVars(instanceGroup.model.OPTIONS.actions.PUT.pod_spec_override.default) : '---';
if ((podSpecValue !== '---') && podSpecValue && podSpecValue.trim() !== defaultPodSpecValue.trim()) {
vm.form.extraVars.isOpen = true;

View File

@ -100,6 +100,7 @@
.at-Row-container{
flex-wrap: wrap;
}
.containerGroups-messageBar-link:hover{
text-decoration: underline;
}