Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix the upload profile image button #614

Merged
9 changes: 9 additions & 0 deletions app/controllers/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ const BASE_URL = ENV.BASE_API_URL;
export default class ProfileController extends Controller {
@service toast;
@service router;
get isDev() {
if (
this.router.currentRoute &&
this.router.currentRoute.queryParams.dev === 'true'
) {
return this.router.currentRoute.queryParams.dev;
}
return false;
}
get imageUploadUrl() {
return `${BASE_URL}/users/picture`;
}
Expand Down
16 changes: 15 additions & 1 deletion app/styles/profile.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
}

.profile-page-error {
text-align: center;
text-align: center;
color: red;
}

Expand Down Expand Up @@ -91,6 +91,7 @@
aspect-ratio: 1;
margin: auto;
text-align: center;
position: relative;
}

.profile-form .user__pic {
Expand All @@ -101,6 +102,19 @@

.edit-btn {
padding: 0;
margin-top: 0.5rem;
color: var(--profile-edit-btn-clr);
font-weight: 600;
font-size: 1rem;
}

.profile-edit-button {
padding: 8px;
z-index: 10;
border-radius: 100%;
position: absolute;
top: 8px;
right: 12px;
mdansarijaved marked this conversation as resolved.
Show resolved Hide resolved
font-size: 1rem;
margin-top: 0.5rem;
color: var(--profile-edit-btn-clr);
Expand Down
23 changes: 15 additions & 8 deletions app/templates/profile.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,23 @@
<img
class='user__pic'
src={{'dummyProfilePicture.png'}}
alt='user profile '
alt='user profile'
/>
{{/if}}
<Button
@onClick={{this.handleShowEditProfilePictureModal}}
@class='edit-btn btn'
@data-test-btn='edit'
>
Update Picture
</Button>

{{#if this.isDev}}
<Button @onClick={{this.handleShowEditProfilePictureModal}}
@class='profile-edit-button '
@data-test-btn='edit'>
<FaIcon @icon="edit" />
</Button>
{{else}}
<Button @onClick={{this.handleShowEditProfilePictureModal}}
@class='edit-btn btn'
@data-test-btn='edit'>
Update Picture
</Button>
{{/if}}
</div>
<div class='profile-form-grid'>
{{#if (get @model 'isDeveloper')}}
Expand Down
12 changes: 12 additions & 0 deletions tests/unit/routes/profile-test.js
mdansarijaved marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,16 @@ module('Unit | Route | profile', function (hooks) {
assert.dom('[data-test-modal="image-upload"]').exists();
assert.dom('[data-test-btn="browse"]').exists();
});
test('button appearance based on dev query param', async (assert) => {
await visit('/profile?dev=true');

assert.dom('[data-test-btn="edit"]').exists();
assert.dom('[data-test-btn="edit"]').hasClass('profile-edit-button');

await visit('/profile?dev=false');

assert.dom('[data-test-btn="edit"]').exists();
assert.dom('[data-test-btn="edit"]').hasClass('edit-btn');
assert.dom('[data-test-btn="edit"]').hasText('Update Picture');
});
});
Loading