Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions app/components/user-status-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { TOAST_OPTIONS } from '../constants/toast-options';

export default class UserStatusModalComponent extends Component {
@service toast;
@service featureFlag;
@tracked currentStatus;
@tracked fromDate = '';
@tracked untilDate = '';
Expand All @@ -45,7 +44,6 @@ export default class UserStatusModalComponent extends Component {

@action
async getCurrentStatusObj() {
const isDevMode = this.featureFlag.isDevMode;
if (!this.isValidStatusChange()) return;

const updatedAt = Date.now();
Expand All @@ -56,7 +54,7 @@ export default class UserStatusModalComponent extends Component {
message: this.reason,
state: this.args.newStatus,
};
await this.updateStatusBasedOnMode(isDevMode, newStateObj);
await this.updateStatusBasedOnMode(newStateObj);
this.resetInputFields();
this.disableSubmitButton = true;
}
Expand Down Expand Up @@ -106,15 +104,13 @@ export default class UserStatusModalComponent extends Component {
return false;
}

async updateStatusBasedOnMode(isDevMode, newStateObj) {
if (isDevMode) {
async updateStatusBasedOnMode() {
if (this.args.newStatus === USER_STATES.OOO) {
await this.args.createOOORequest(
this.fromDate,
this.untilDate,
this.reason,
);
} else {
await this.args.updateStatus({ currentStatus: newStateObj });
}
}

Expand Down
15 changes: 2 additions & 13 deletions app/components/user-status.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,7 @@
<div class="buttons">
{{#each this.currentUserStatus as |currentStatus|}}
{{#if (eq @status currentStatus.status)}}
{{#if @dev}}
<button
data-test-request-status-OOO
class="buttons__request--ooo"
type="button"
{{on "click" this.changeStatus}}
>
<span>Request OOO Status</span>
</button>
{{else}}
{{#if (eq currentStatus.status "OOO")}}
{{#if (eq currentStatus.status "OOO")}}
<button
data-test-cancel-status-OOO
class="buttons__cancel--ooo"
Expand All @@ -60,8 +50,7 @@
<span>{{otherPossibleStatus.message}}</span>
</button>
{{/each}}
{{/if}}
{{/if}}
{{/if}}
{{/if}}
{{/each}}
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/components/user-status.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default class UserStatusComponent extends Component {
},
[USER_STATES.OOO]: {
status: USER_STATES.OOO,
message: 'Change your status to OOO',
message: 'Request OOO',
class: 'buttons__ooo',
},
};
Expand Down
2 changes: 1 addition & 1 deletion app/constants/apis.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const SELF_USER_STATUS_URL = `${APPS.API_BACKEND}/users/status/self`;

export const UPDATE_USER_STATUS = `${APPS.API_BACKEND}/users/status/self?userStatusFlag=true`;

export const CREATE_OOO_REQUEST_URL = `${APPS.API_BACKEND}/requests?dev=true`;
export const CREATE_OOO_REQUEST_URL = `${APPS.API_BACKEND}/requests`;

export const SELF_USER_PROFILE_URL = `${APPS.API_BACKEND}/users?profile=true`;

Expand Down
22 changes: 10 additions & 12 deletions app/templates/status.hbs
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
{{page-title "User Status"}}

<div class="status-container">
<UserStatus
<UserStatus
@status={{this.status}}
@changeStatus={{this.changeStatus}}
@changeStatus={{this.changeStatus}}
@isStatusUpdating={{this.isStatusUpdating}}
@updateStatus={{this.updateStatus}}
@dev={{this.isDevMode}}
@createOOORequest={{this.createOOORequest}}
@updateStatus={{this.updateStatus}}
@createOOORequest={{this.createOOORequest}}
/>

<UserStatusModal
@isStatusUpdating={{this.isStatusUpdating}}
<UserStatusModal
@isStatusUpdating={{this.isStatusUpdating}}
@newStatus={{this.newStatus}}
@showUserStateModal={{this.showUserStateModal}}
@showUserStateModal={{this.showUserStateModal}}
@toggleUserStateModal={{this.toggleUserStateModal}}
@updateStatus={{this.updateStatus}}
@dev={{this.isDevMode}}
@createOOORequest={{this.createOOORequest}}
/>
@updateStatus={{this.updateStatus}}
@createOOORequest={{this.createOOORequest}}
/>
</div>
33 changes: 7 additions & 26 deletions tests/integration/components/user-status-modal-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,39 +46,21 @@ module('Integration | Component | user-status-modal', function (hooks) {
});

test('payload contains relevant data when status is changed to OOO', async function (assert) {
assert.expect(6);
assert.expect(4);
this.setProperties({
newStatus: 'OOO',
showUserStateModal: true,
toggleUserStateModal: () => {
this.set('showUserStateModal', !this.showUserStateModal);
},
updateStatus: (statusPayLoad) => {
const {
currentStatus: { state, from, until, message, updatedAt },
} = statusPayLoad;
console.log('Payload:', JSON.stringify(statusPayLoad, null, 2));
assert.strictEqual(state, 'OOO', 'New state is present in the payload');
createOOORequest: (from, until, reason) => {
assert.strictEqual(
message,
reason,
'OOO due to Bad Health',
'Message is present in the payload',
);
assert.strictEqual(
typeof from,
'number',
'From is a numeric timestamp',
);
assert.strictEqual(
typeof until,
'number',
'Until is a numeric timestamp',
);
assert.strictEqual(
typeof updatedAt,
'number',
'UpdatedAt is a numeric timestamp',
'Reason is present in the payload',
);
assert.strictEqual(typeof from, 'string', 'From is a date string');
assert.strictEqual(typeof until, 'string', 'Until is a date string');
},
});
await render(hbs`
Expand All @@ -87,6 +69,7 @@ module('Integration | Component | user-status-modal', function (hooks) {
@newStatus={{this.newStatus}}
@toggleUserStateModal={{this.toggleUserStateModal}}
@updateStatus={{this.updateStatus}}
@createOOORequest={{this.createOOORequest}}
/>
`);

Expand Down Expand Up @@ -125,7 +108,6 @@ module('Integration | Component | user-status-modal', function (hooks) {
newStatus: 'OOO',
showUserStateModal: true,
isStatusUpdating: false,
isDevMode: true,
createOOORequest: () => {},
});

Expand All @@ -136,7 +118,6 @@ module('Integration | Component | user-status-modal', function (hooks) {
@toggleUserStateModal={{this.toggleUserStateModal}}
@updateStatus={{this.updateStatus}}
@isStatusUpdating={{this.isStatusUpdating}}
@dev={{this.isDevMode}}
@createOOORequest={{this.createOOORequest}}
/>
`);
Expand Down
4 changes: 1 addition & 3 deletions tests/integration/components/user-status-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ module('Integration | Component | user-status', function (hooks) {
`);

assert.dom('[data-test-status]').containsText('You are Idle');
assert
.dom('[data-test-update-status-OOO]')
.containsText('Change your status to OOO');
assert.dom('[data-test-update-status-OOO]').containsText('Request OOO');
});

test('show relevant data when status is OOO', async function (assert) {
Expand Down