-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from fleetbase/dev-v0.1.3
v0.1.3
- Loading branch information
Showing
10 changed files
with
150 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<Modal::Default @modalIsOpened={{@modalIsOpened}} @options={{@options}} @confirm={{@onConfirm}} @decline={{@onDecline}}> | ||
<div class="px-4 text-gray-900 dark:text-gray-50"> | ||
<div class="mb-1 text-base font-semibold"> | ||
You are about to reset the password for | ||
{{this.user.name}} | ||
</div> | ||
<div class="text-sm mb-4">Please enter the new password and confirm it below. You have the option to send the new credentials to the user via email by selecting the checkbox.</div> | ||
<InputGroup> | ||
<div class="grid grid-cols-1 lg:grid-cols-2 gap-4"> | ||
<InputGroup @name="New Password" @type="password" @value={{this.password}} @wrapperClass="mb-0i" /> | ||
<InputGroup @name="Confirm New Password" @type="password" @value={{this.confirmPassword}} @wrapperClass="mb-0i" /> | ||
</div> | ||
</InputGroup> | ||
<InputGroup> | ||
<Checkbox @value={{this.sendCredentials}} @label="Send password credentials to user" @onToggle={{fn (mut this.sendCredentials)}} @alignItems="center" @labelClass="mb-0i" /> | ||
</InputGroup> | ||
</div> | ||
</Modal::Default> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import Component from '@glimmer/component'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import { inject as service } from '@ember/service'; | ||
|
||
export default class ModalsChangeUserPasswordComponent extends Component { | ||
@service fetch; | ||
@service notifications; | ||
@tracked options = {}; | ||
@tracked password; | ||
@tracked confirmPassword; | ||
@tracked sendCredentials = true; | ||
@tracked user; | ||
|
||
constructor(owner, { options }) { | ||
super(...arguments); | ||
this.user = options.user; | ||
this.options = options; | ||
this.setupOptions(); | ||
} | ||
|
||
setupOptions() { | ||
this.options.title = 'Reset User Credentials'; | ||
this.options.acceptButtonText = 'Reset Credentials'; | ||
this.options.declineButtonHidden = true; | ||
this.options.confirm = async (modal) => { | ||
modal.startLoading(); | ||
|
||
try { | ||
await this.fetch.post('auth/change-user-password', { | ||
user: this.user.id, | ||
password: this.password, | ||
password_confirmation: this.confirmPassword, | ||
send_credentials: this.sendCredentials, | ||
}); | ||
|
||
this.notifications.success('User password reset.'); | ||
|
||
if (typeof this.options.onPasswordResetComplete === 'function') { | ||
this.options.onPasswordResetComplete(); | ||
} | ||
|
||
modal.done(); | ||
} catch (error) { | ||
this.notifications.serverError(error); | ||
modal.stopLoading(); | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from '@fleetbase/iam-engine/components/modals/change-user-password'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
tests/integration/components/modals/change-user-password-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupRenderingTest } from 'dummy/tests/helpers'; | ||
import { render } from '@ember/test-helpers'; | ||
import { hbs } from 'ember-cli-htmlbars'; | ||
|
||
module('Integration | Component | modals/change-user-password', function (hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
test('it renders', async function (assert) { | ||
// Set any properties with this.set('myProperty', 'value'); | ||
// Handle any actions with this.set('myAction', function(val) { ... }); | ||
|
||
await render(hbs`<Modals::ChangeUserPassword />`); | ||
|
||
assert.dom().hasText(''); | ||
|
||
// Template block usage: | ||
await render(hbs` | ||
<Modals::ChangeUserPassword> | ||
template block text | ||
</Modals::ChangeUserPassword> | ||
`); | ||
|
||
assert.dom().hasText('template block text'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters