mirror of
https://github.com/ansible/awx.git
synced 2026-05-08 18:07:36 -02:30
@@ -54,6 +54,18 @@ module.exports = {
|
|||||||
'no-multiple-empty-lines': ['error', { max: 1 }],
|
'no-multiple-empty-lines': ['error', { max: 1 }],
|
||||||
'object-curly-newline': 'off',
|
'object-curly-newline': 'off',
|
||||||
'space-before-function-paren': ['error', 'always'],
|
'space-before-function-paren': ['error', 'always'],
|
||||||
'no-trailing-spaces': ['error']
|
'no-trailing-spaces': ['error'],
|
||||||
}
|
'prefer-destructuring': ['error', {
|
||||||
|
'VariableDeclarator': {
|
||||||
|
'array': false,
|
||||||
|
'object': true
|
||||||
|
},
|
||||||
|
'AssignmentExpression': {
|
||||||
|
'array': false,
|
||||||
|
'object': true
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
'enforceForRenamedProperties': false
|
||||||
|
}]
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,10 +3,8 @@ function AddApplicationsController (models, $state, strings) {
|
|||||||
|
|
||||||
const { application, me, organization } = models;
|
const { application, me, organization } = models;
|
||||||
const omit = [
|
const omit = [
|
||||||
'authorization_grant_type',
|
|
||||||
'client_id',
|
'client_id',
|
||||||
'client_secret',
|
'client_secret',
|
||||||
'client_type',
|
|
||||||
'created',
|
'created',
|
||||||
'modified',
|
'modified',
|
||||||
'related',
|
'related',
|
||||||
@@ -44,7 +42,7 @@ function AddApplicationsController (models, $state, strings) {
|
|||||||
vm.form.organization._resource = 'organization';
|
vm.form.organization._resource = 'organization';
|
||||||
vm.form.organization._route = 'applications.add.organization';
|
vm.form.organization._route = 'applications.add.organization';
|
||||||
vm.form.organization._model = organization;
|
vm.form.organization._model = organization;
|
||||||
vm.form.organization._placeholder = strings.get('SELECT AN ORGANIZATION');
|
vm.form.organization._placeholder = strings.get('inputs.ORGANIZATION_PLACEHOLDER');
|
||||||
|
|
||||||
vm.form.name.required = true;
|
vm.form.name.required = true;
|
||||||
vm.form.organization.required = true;
|
vm.form.organization.required = true;
|
||||||
@@ -54,9 +52,7 @@ function AddApplicationsController (models, $state, strings) {
|
|||||||
|
|
||||||
vm.form.save = data => {
|
vm.form.save = data => {
|
||||||
const hiddenData = {
|
const hiddenData = {
|
||||||
authorization_grant_type: 'implicit',
|
user: me.get('id')
|
||||||
user: me.get('id'),
|
|
||||||
client_type: 'public'
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const payload = _.merge(data, hiddenData);
|
const payload = _.merge(data, hiddenData);
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
<at-input-lookup col="4" tab="3" state="vm.form.organization"></at-input-lookup>
|
<at-input-lookup col="4" tab="3" state="vm.form.organization"></at-input-lookup>
|
||||||
<at-divider></at-divider>
|
<at-divider></at-divider>
|
||||||
<at-input-text col="4" tab="4" state="vm.form.redirect_uris"></at-input-text>
|
<at-input-text col="4" tab="4" state="vm.form.redirect_uris"></at-input-text>
|
||||||
|
<at-input-select col="4" tab="5" state="vm.form.client_type"></at-input-select>
|
||||||
|
<at-input-select col="4" tab="6" state="vm.form.authorization_grant_type"></at-input-select>
|
||||||
|
|
||||||
<at-action-group col="12" pos="right">
|
<at-action-group col="12" pos="right">
|
||||||
<at-form-action type="cancel" to="applications"></at-form-action>
|
<at-form-action type="cancel" to="applications"></at-form-action>
|
||||||
|
|||||||
@@ -25,6 +25,10 @@ function ApplicationsStrings (BaseString) {
|
|||||||
ROW_ITEM_LABEL_ORGANIZATION: t.s('ORG'),
|
ROW_ITEM_LABEL_ORGANIZATION: t.s('ORG'),
|
||||||
ROW_ITEM_LABEL_MODIFIED: t.s('LAST MODIFIED')
|
ROW_ITEM_LABEL_MODIFIED: t.s('LAST MODIFIED')
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ns.inputs = {
|
||||||
|
ORGANIZATION_PLACEHOLDER: t.s('SELECT AN ORGANIZATION')
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
ApplicationsStrings.$inject = ['BaseStringService'];
|
ApplicationsStrings.$inject = ['BaseStringService'];
|
||||||
|
|||||||
@@ -4,10 +4,8 @@ function EditApplicationsController (models, $state, strings, $scope) {
|
|||||||
const { me, application, organization } = models;
|
const { me, application, organization } = models;
|
||||||
|
|
||||||
const omit = [
|
const omit = [
|
||||||
'authorization_grant_type',
|
|
||||||
'client_id',
|
'client_id',
|
||||||
'client_secret',
|
'client_secret',
|
||||||
'client_type',
|
|
||||||
'created',
|
'created',
|
||||||
'modified',
|
'modified',
|
||||||
'related',
|
'related',
|
||||||
@@ -54,45 +52,31 @@ function EditApplicationsController (models, $state, strings, $scope) {
|
|||||||
|
|
||||||
vm.form.disabled = !isEditable;
|
vm.form.disabled = !isEditable;
|
||||||
|
|
||||||
|
vm.form.name.required = true;
|
||||||
|
vm.form.redirect_uris.required = true;
|
||||||
|
|
||||||
const isOrgAdmin = _.some(me.get('related.admin_of_organizations.results'), (org) => org.id === organization.get('id'));
|
const isOrgAdmin = _.some(me.get('related.admin_of_organizations.results'), (org) => org.id === organization.get('id'));
|
||||||
const isSuperuser = me.get('is_superuser');
|
const isSuperuser = me.get('is_superuser');
|
||||||
const isCurrentAuthor = Boolean(application.get('summary_fields.created_by.id') === me.get('id'));
|
const isCurrentAuthor = Boolean(application.get('summary_fields.created_by.id') === me.get('id'));
|
||||||
|
|
||||||
vm.form.organization = {
|
|
||||||
type: 'field',
|
|
||||||
label: 'Organization',
|
|
||||||
id: 'organization'
|
|
||||||
};
|
|
||||||
vm.form.description = {
|
|
||||||
type: 'String',
|
|
||||||
label: 'Description',
|
|
||||||
id: 'description'
|
|
||||||
};
|
|
||||||
|
|
||||||
vm.form.organization._resource = 'organization';
|
|
||||||
vm.form.organization._route = 'applications.edit.organization';
|
|
||||||
vm.form.organization._model = organization;
|
|
||||||
vm.form.organization._placeholder = strings.get('SELECT AN ORGANIZATION');
|
|
||||||
|
|
||||||
// TODO: org not returned via api endpoint, check on this
|
|
||||||
vm.form.organization._value = application.get('organization');
|
|
||||||
|
|
||||||
vm.form.organization._disabled = true;
|
vm.form.organization._disabled = true;
|
||||||
|
|
||||||
if (isSuperuser || isOrgAdmin || (application.get('organization') === null && isCurrentAuthor)) {
|
if (isSuperuser || isOrgAdmin || (application.get('organization') === null && isCurrentAuthor)) {
|
||||||
vm.form.organization._disabled = false;
|
vm.form.organization._disabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
vm.form.name.required = true;
|
vm.form.organization._resource = 'organization';
|
||||||
|
vm.form.organization._model = organization;
|
||||||
|
vm.form.organization._route = 'applications.edit.organization';
|
||||||
|
vm.form.organization._value = application.get('summary_fields.organization.id');
|
||||||
|
vm.form.organization._displayValue = application.get('summary_fields.organization.name');
|
||||||
|
vm.form.organization._placeholder = strings.get('inputs.ORGANIZATION_PLACEHOLDER');
|
||||||
vm.form.organization.required = true;
|
vm.form.organization.required = true;
|
||||||
vm.form.redirect_uris.required = true;
|
|
||||||
|
|
||||||
delete vm.form.name.help_text;
|
delete vm.form.name.help_text;
|
||||||
|
|
||||||
vm.form.save = data => {
|
vm.form.save = data => {
|
||||||
const hiddenData = {
|
const hiddenData = {
|
||||||
authorization_grant_type: 'implicit',
|
user: me.get('id')
|
||||||
user: me.get('id'),
|
|
||||||
client_type: 'public'
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const payload = _.merge(data, hiddenData);
|
const payload = _.merge(data, hiddenData);
|
||||||
|
|||||||
@@ -62,8 +62,7 @@ function ApplicationsRun ($stateExtender, strings) {
|
|||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
activityStream: true,
|
activityStream: true,
|
||||||
// TODO: double-check activity stream works
|
activityStreamTarget: 'o_auth2_application'
|
||||||
activityStreamTarget: 'application'
|
|
||||||
},
|
},
|
||||||
views: {
|
views: {
|
||||||
'@': {
|
'@': {
|
||||||
@@ -111,8 +110,7 @@ function ApplicationsRun ($stateExtender, strings) {
|
|||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
activityStream: true,
|
activityStream: true,
|
||||||
// TODO: double-check activity stream works
|
activityStreamTarget: 'o_auth2_application'
|
||||||
activityStreamTarget: 'application'
|
|
||||||
},
|
},
|
||||||
views: {
|
views: {
|
||||||
'add@applications': {
|
'add@applications': {
|
||||||
@@ -134,7 +132,7 @@ function ApplicationsRun ($stateExtender, strings) {
|
|||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
activityStream: true,
|
activityStream: true,
|
||||||
activityStreamTarget: 'application',
|
activityStreamTarget: 'o_auth2_application',
|
||||||
activityStreamId: 'application_id'
|
activityStreamId: 'application_id'
|
||||||
},
|
},
|
||||||
views: {
|
views: {
|
||||||
@@ -264,8 +262,7 @@ function ApplicationsRun ($stateExtender, strings) {
|
|||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
activityStream: true,
|
activityStream: true,
|
||||||
// TODO: double-check activity stream works
|
activityStreamTarget: 'o_auth2_application'
|
||||||
activityStreamTarget: 'application'
|
|
||||||
},
|
},
|
||||||
views: {
|
views: {
|
||||||
'userList@applications.edit': {
|
'userList@applications.edit': {
|
||||||
|
|||||||
@@ -76,7 +76,9 @@ function AtFormController (eventService, strings) {
|
|||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (component.state._key && typeof component.state._value === 'object') {
|
if (component.state._format === 'selectFromOptions') {
|
||||||
|
values[component.state.id] = component.state._value[0];
|
||||||
|
} else if (component.state._key && typeof component.state._value === 'object') {
|
||||||
values[component.state.id] = component.state._value[component.state._key];
|
values[component.state.id] = component.state._value[component.state._key];
|
||||||
} else if (component.state._group) {
|
} else if (component.state._group) {
|
||||||
values[component.state._key] = values[component.state._key] || {};
|
values[component.state._key] = values[component.state._key] || {};
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ function BaseInputController (strings) {
|
|||||||
scope.state._required = scope.state.required || false;
|
scope.state._required = scope.state.required || false;
|
||||||
scope.state._isValid = scope.state._isValid || false;
|
scope.state._isValid = scope.state._isValid || false;
|
||||||
scope.state._disabled = scope.state._disabled || false;
|
scope.state._disabled = scope.state._disabled || false;
|
||||||
scope.state._activeModel = '_value';
|
scope.state._activeModel = scope.state._activeModel || '_value';
|
||||||
|
|
||||||
if (scope.state.ask_at_runtime) {
|
if (scope.state.ask_at_runtime) {
|
||||||
scope.state._displayPromptOnLaunch = true;
|
scope.state._displayPromptOnLaunch = true;
|
||||||
@@ -49,7 +49,8 @@ function BaseInputController (strings) {
|
|||||||
scope.state._touched = true;
|
scope.state._touched = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scope.state._required && !scope.state._value && !scope.state._displayValue) {
|
if (scope.state._required && (!scope.state._value || !scope.state._value[0]) &&
|
||||||
|
!scope.state._displayValue) {
|
||||||
isValid = false;
|
isValid = false;
|
||||||
message = vm.strings.get('message.REQUIRED_INPUT_MISSING');
|
message = vm.strings.get('message.REQUIRED_INPUT_MISSING');
|
||||||
} else if (scope.state._validate) {
|
} else if (scope.state._validate) {
|
||||||
|
|||||||
@@ -59,7 +59,9 @@ function AtInputSelectController (baseInputController, eventService) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
vm.updateDisplayModel = () => {
|
vm.updateDisplayModel = () => {
|
||||||
if (scope.state._format === 'array') {
|
if (scope.state._format === 'selectFromOptions') {
|
||||||
|
scope.displayModel = scope.state._value[1];
|
||||||
|
} else if (scope.state._format === 'array') {
|
||||||
scope.displayModel = scope.state._value;
|
scope.displayModel = scope.state._value;
|
||||||
} else if (scope.state._format === 'objects') {
|
} else if (scope.state._format === 'objects') {
|
||||||
scope.displayModel = scope.state._value[scope.state._display];
|
scope.displayModel = scope.state._value[scope.state._display];
|
||||||
|
|||||||
@@ -1,6 +1,21 @@
|
|||||||
let Base;
|
let Base;
|
||||||
|
|
||||||
function createFormSchema (method, config) {
|
function createFormSchema (method, config) {
|
||||||
|
function mungeSelectFromOptions (configObj, value) {
|
||||||
|
configObj.choices = [[null, '']].concat(configObj.choices);
|
||||||
|
configObj._data = configObj.choices;
|
||||||
|
configObj._exp = 'choice[1] for choice in state._data';
|
||||||
|
configObj._format = 'selectFromOptions';
|
||||||
|
|
||||||
|
configObj._data.forEach((val, i) => {
|
||||||
|
if (val[0] === value) {
|
||||||
|
configObj._value = configObj._data[i];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return configObj;
|
||||||
|
}
|
||||||
|
|
||||||
if (!config) {
|
if (!config) {
|
||||||
config = method;
|
config = method;
|
||||||
method = 'GET';
|
method = 'GET';
|
||||||
@@ -15,11 +30,25 @@ function createFormSchema (method, config) {
|
|||||||
Object.keys(schema).forEach(key => {
|
Object.keys(schema).forEach(key => {
|
||||||
schema[key].id = key;
|
schema[key].id = key;
|
||||||
|
|
||||||
if (this.has(key)) {
|
if (this.has(key) && schema[key].type !== 'choice') {
|
||||||
schema[key]._value = this.get(key);
|
schema[key]._value = this.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (schema[key].type === 'choice') {
|
||||||
|
schema[key] = mungeSelectFromOptions(schema[key], this.get(key));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// necessary because authorization_grant_type is not changeable on update
|
||||||
|
if (method === 'put') {
|
||||||
|
schema.authorization_grant_type = mungeSelectFromOptions(Object.assign({}, this
|
||||||
|
.options('actions.GET.authorization_grant_type')), this
|
||||||
|
.get('authorization_grant_type'));
|
||||||
|
|
||||||
|
schema.authorization_grant_type._required = false;
|
||||||
|
schema.authorization_grant_type._disabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
return schema;
|
return schema;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ export default function GetTargetTitle(i18n) {
|
|||||||
case 'template':
|
case 'template':
|
||||||
rtnTitle = i18n._('TEMPLATES');
|
rtnTitle = i18n._('TEMPLATES');
|
||||||
break;
|
break;
|
||||||
|
case 'o_auth2_application':
|
||||||
|
rtnTitle = i18n._('APPLICATIONS');
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rtnTitle;
|
return rtnTitle;
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ export default function ModelToBasePathKey() {
|
|||||||
var basePathKey;
|
var basePathKey;
|
||||||
|
|
||||||
switch(model) {
|
switch(model) {
|
||||||
|
case 'o_auth2_application':
|
||||||
|
basePathKey = 'applications';
|
||||||
|
break;
|
||||||
case 'project':
|
case 'project':
|
||||||
basePathKey = 'projects';
|
basePathKey = 'projects';
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ export default ['templateUrl', 'i18n', function(templateUrl, i18n) {
|
|||||||
|
|
||||||
$scope.options = [
|
$scope.options = [
|
||||||
{label: i18n._('All Activity'), value: 'dashboard'},
|
{label: i18n._('All Activity'), value: 'dashboard'},
|
||||||
|
{label: i18n._('Applications'), value: 'o_auth2_application'},
|
||||||
{label: i18n._('Credentials'), value: 'credential'},
|
{label: i18n._('Credentials'), value: 'credential'},
|
||||||
{label: i18n._('Hosts'), value: 'host'},
|
{label: i18n._('Hosts'), value: 'host'},
|
||||||
{label: i18n._('Inventories'), value: 'inventory'},
|
{label: i18n._('Inventories'), value: 'inventory'},
|
||||||
|
|||||||
Reference in New Issue
Block a user