Skip to content

Commit

Permalink
Self Service Step 3 Writable ; Reset advanced settings (#9190)
Browse files Browse the repository at this point in the history
* WIP

* Make Self-Service Step 3 writable; reset advanced permissions

* Cryptography is required by the installation process
  • Loading branch information
castrapel authored Jul 30, 2021
1 parent a16241b commit 773c472
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 6 deletions.
1 change: 1 addition & 0 deletions requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ boto3
cchardet
celery[redis]
cloudaux
cryptography
datamodel-code-generator
decorator<5 # Internal requirement has decorator pinned to <5.
deepdiff
Expand Down
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ certifi==2020.12.5
cffi==1.14.5
# via
# bcrypt
# cryptography
# google-crc32c
chardet==4.0.0
# via
Expand All @@ -89,6 +90,8 @@ cloudaux==1.9.5
# via -r requirements.in
contextlib2==0.6.0.post1
# via schema
cryptography==3.4.7
# via -r requirements.in
datamodel-code-generator==0.11.5
# via -r requirements.in
decorator==4.4.2
Expand Down
13 changes: 13 additions & 0 deletions ui/src/components/selfservice/SelfService.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,18 @@ class SelfService extends Component {
this.setState({ permissions });
}

handleResetUserChoices() {
// This function is called after a user has added a permission set
// to their "shopping cart". It will reset advanced settings so they
// are not carried over to additional permission sets they add to their
// "shopping cart".
this.setState({
extraActions: [],
includeAccounts: [],
excludeAccounts: [],
});
}

getCurrentSelfServiceStep() {
const {
admin_bypass_approval_enabled,
Expand Down Expand Up @@ -218,6 +230,7 @@ class SelfService extends Component {
handleStepClick={this.handleStepClick.bind(this)}
updatePolicy={this.updatePolicy.bind(this)}
handlePermissionsUpdate={this.handlePermissionsUpdate.bind(this)}
handleResetUserChoices={this.handleResetUserChoices.bind(this)}
handleExtraActionsUpdate={this.handleExtraActionsUpdate.bind(this)}
handleIncludeAccountsUpdate={this.handleIncludeAccountsUpdate.bind(
this
Expand Down
2 changes: 2 additions & 0 deletions ui/src/components/selfservice/SelfServiceStep2.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ class SelfServiceStep2 extends Component {
this.props.handlePermissionsUpdate(permissions);
}
);
// Reset extraActions, includeAccounts, and excludeAccounts
this.props.handleResetUserChoices();
}
}

Expand Down
15 changes: 9 additions & 6 deletions ui/src/components/selfservice/SelfServiceStep3.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class SelfServiceStep3 extends Component {
this.handleJustificationChange = this.handleJustificationChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
this.handleAdminSubmit = this.handleAdminSubmit.bind(this);
this.onValueChange = this.onValueChange.bind(this);
}

async componentDidMount() {
Expand Down Expand Up @@ -122,7 +123,11 @@ class SelfServiceStep3 extends Component {
});
}

onValueChange() {}
onValueChange(newValue, e) {
this.setState({
new_policy: newValue,
});
}

buildMonacoEditor() {
const { old_policy, new_policy } = this.state;
Expand All @@ -131,7 +136,6 @@ class SelfServiceStep3 extends Component {
<MonacoDiffComponent
oldValue={old_policy}
newValue={new_policy}
readOnly={true}
onLintError={this.onLintError}
onValueChange={this.onValueChange}
/>
Expand All @@ -150,8 +154,8 @@ class SelfServiceStep3 extends Component {
}

handleSubmit() {
const { role, updated_policy } = this.props;
const { justification, admin_auto_approve } = this.state;
const { role } = this.props;
const { justification, admin_auto_approve, new_policy } = this.state;
if (!justification) {
return this.setState((state) => ({
messages: ["No Justification is Given"],
Expand All @@ -168,7 +172,7 @@ class SelfServiceStep3 extends Component {
change_type: "inline_policy",
action: "attach",
policy: {
policy_document: JSON.parse(updated_policy),
policy_document: JSON.parse(new_policy),
},
},
],
Expand Down Expand Up @@ -438,7 +442,6 @@ class SelfServiceStep3 extends Component {
<MonacoDiffComponent
oldValue={old_policy}
newValue={new_policy}
readOnly={true}
onLintError={this.onLintError}
onValueChange={this.onValueChange}
/>
Expand Down

0 comments on commit 773c472

Please sign in to comment.