Skip to content

Commit

Permalink
Issue argoproj#1662 - Role edit page fails with JS error (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Matyushentsev authored May 29, 2019
1 parent a49314b commit 32bfad2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@ export const ProjectRoleEditPanel = (props: ProjectRoleEditPanelProps) => {
getApi={props.getApi}
defaultValues={{
projName: props.defaultParams.projName,
roleName: (props.defaultParams.role !== undefined ? props.defaultParams.role.name : ''),
description: (props.defaultParams.role !== undefined ? props.defaultParams.role.description : ''),
policies: (props.defaultParams.role !== undefined && props.defaultParams.role.policies !== null
? props.defaultParams.role.policies : []),
jwtTokens: (props.defaultParams.role !== undefined ? props.defaultParams.role.jwtTokens : []),
groups: (props.defaultParams.role !== undefined ? props.defaultParams.role.groups : []),
roleName: (props.defaultParams.role && props.defaultParams.role.name || ''),
description: (props.defaultParams.role && props.defaultParams.role.description || ''),
policies: (props.defaultParams.role && props.defaultParams.role.policies || []),
jwtTokens: (props.defaultParams.role && props.defaultParams.role.jwtTokens || []),
groups: (props.defaultParams.role && props.defaultParams.role.groups || []),
}}
validateError={(params: ProjectRoleParams) => ({
projName: !params.projName && 'Project name is required',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function generatePolicy(project: string, role: string, action?: string, object?:
const actions = ['get', 'create', 'update', 'delete', 'sync'];

export const ProjectRolePoliciesEdit = (props: ProjectRolePoliciesProps) => (
<DataLoader load={() => services.applications.list([props.projName])}>
<DataLoader load={() => services.applications.list([props.projName], { fields: ['items.metadata.name'] })}>
{(applications) => (
<React.Fragment>
<h4>Policy Rules</h4>
Expand Down
12 changes: 8 additions & 4 deletions src/app/shared/services/applications-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,15 @@ export class ApplicationsService {

private parseAppFields(data: any): models.Application {
const app = data as models.Application;
app.spec.project = app.spec.project || 'default';
delete app.spec.source.componentParameterOverrides;
app.kind = app.kind || 'Application';
app.status.resources = app.status.resources || [];
app.status.summary = app.status.summary || {};
if (app.spec) {
app.spec.project = app.spec.project || 'default';
delete app.spec.source.componentParameterOverrides;
}
if (app.status) {
app.status.resources = app.status.resources || [];
app.status.summary = app.status.summary || {};
}
return app;
}
}

0 comments on commit 32bfad2

Please sign in to comment.