mirror of
https://github.com/ansible/awx.git
synced 2026-05-09 02:17:37 -02:30
On JT form, Show credential tags from summary_fields if user
doesn't have view permission on the credential
This commit is contained in:
@@ -177,7 +177,7 @@ export default ['Rest', 'ProcessErrors', '$q', 'GetBasePath', function(Rest, Pro
|
|||||||
}, credTypes, credTypeOptions, credTags;
|
}, credTypes, credTypeOptions, credTags;
|
||||||
|
|
||||||
let credDefers = [];
|
let credDefers = [];
|
||||||
|
let job_template_obj = data;
|
||||||
// get machine credential
|
// get machine credential
|
||||||
if (data.related.credential) {
|
if (data.related.credential) {
|
||||||
Rest.setUrl(data.related.credential);
|
Rest.setUrl(data.related.credential);
|
||||||
@@ -186,6 +186,11 @@ export default ['Rest', 'ProcessErrors', '$q', 'GetBasePath', function(Rest, Pro
|
|||||||
selectedCredentials.machine = data;
|
selectedCredentials.machine = data;
|
||||||
})
|
})
|
||||||
.catch(({data, status}) => {
|
.catch(({data, status}) => {
|
||||||
|
if (status === 403) {
|
||||||
|
/* User doesn't have read access to the machine credential, so use summary_fields */
|
||||||
|
selectedCredentials.machine = job_template_obj.summary_fields.credential;
|
||||||
|
selectedCredentials.machine.credential_type = job_template_obj.summary_fields.credential.credential_type_id;
|
||||||
|
} else {
|
||||||
ProcessErrors(
|
ProcessErrors(
|
||||||
null, data, status, null,
|
null, data, status, null,
|
||||||
{
|
{
|
||||||
@@ -194,6 +199,7 @@ export default ['Rest', 'ProcessErrors', '$q', 'GetBasePath', function(Rest, Pro
|
|||||||
'Get returned status: ' +
|
'Get returned status: ' +
|
||||||
status
|
status
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,6 +210,11 @@ export default ['Rest', 'ProcessErrors', '$q', 'GetBasePath', function(Rest, Pro
|
|||||||
selectedCredentials.vault = data;
|
selectedCredentials.vault = data;
|
||||||
})
|
})
|
||||||
.catch(({data, status}) => {
|
.catch(({data, status}) => {
|
||||||
|
if (status === 403) {
|
||||||
|
/* User doesn't have read access to the vault credential, so use summary_fields */
|
||||||
|
selectedCredentials.vault = job_template_obj.summary_fields.vault_credential;
|
||||||
|
selectedCredentials.vault.credential_type = job_template_obj.summary_fields.vault_credential.credential_type_id;
|
||||||
|
} else {
|
||||||
ProcessErrors(
|
ProcessErrors(
|
||||||
null, data, status, null,
|
null, data, status, null,
|
||||||
{
|
{
|
||||||
@@ -212,6 +223,7 @@ export default ['Rest', 'ProcessErrors', '$q', 'GetBasePath', function(Rest, Pro
|
|||||||
'Get returned status: ' +
|
'Get returned status: ' +
|
||||||
status
|
status
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,6 +235,11 @@ export default ['Rest', 'ProcessErrors', '$q', 'GetBasePath', function(Rest, Pro
|
|||||||
selectedCredentials.extra = data.results;
|
selectedCredentials.extra = data.results;
|
||||||
})
|
})
|
||||||
.catch(({data, status}) => {
|
.catch(({data, status}) => {
|
||||||
|
if (status === 403) {
|
||||||
|
/* User doesn't have read access to the extra credentials, so use summary_fields */
|
||||||
|
selectedCredentials.extra = job_template_obj.summary_fields.extra_credentials;
|
||||||
|
_.map(selectedCredentials.extra, (cred) => {cred.credential_type = cred.credential_type_id;});
|
||||||
|
} else {
|
||||||
ProcessErrors(null, data, status, null,
|
ProcessErrors(null, data, status, null,
|
||||||
{
|
{
|
||||||
hdr: 'Error!',
|
hdr: 'Error!',
|
||||||
@@ -230,6 +247,7 @@ export default ['Rest', 'ProcessErrors', '$q', 'GetBasePath', function(Rest, Pro
|
|||||||
'Get returned status: ' +
|
'Get returned status: ' +
|
||||||
status
|
status
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user