Skip to content

Commit 51c80bc

Browse files
iamitprakashDhirenderchoudharyDhirenderchoudhary
authored
Dev to Main Sync (#1113)
* Feature flag removed : user OOO approve reject (#1110) * code changes OOO flow Migrated from users page to request flow * removed console log * changed assert.expect * fix: pass date strings instead of timestamps to createOOORequest * fixed errors * wrong commit fix * removed else * removed stateobj --------- Co-authored-by: Dhirenderchoudhary <dhirenderchoudhary0001@gmailcom> * fix: OOO migration date issues (#1112) * fixed date issues * fix lint --------- Co-authored-by: Dhirenderchoudhary <dhirenderchoudhary0001@gmailcom> * fix: Update OOO request button text (#1116) * message changed * message fix * lint fix --------- Co-authored-by: Dhirenderchoudhary <dhirenderchoudhary0001@gmailcom> --------- Co-authored-by: Dhirender Choudhary <[email protected]> Co-authored-by: Dhirenderchoudhary <dhirenderchoudhary0001@gmailcom>
2 parents 1bf9842 + 85d791d commit 51c80bc

File tree

7 files changed

+25
-63
lines changed

7 files changed

+25
-63
lines changed

app/components/user-status-modal.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import { TOAST_OPTIONS } from '../constants/toast-options';
2222

2323
export default class UserStatusModalComponent extends Component {
2424
@service toast;
25-
@service featureFlag;
2625
@tracked currentStatus;
2726
@tracked fromDate = '';
2827
@tracked untilDate = '';
@@ -45,7 +44,6 @@ export default class UserStatusModalComponent extends Component {
4544

4645
@action
4746
async getCurrentStatusObj() {
48-
const isDevMode = this.featureFlag.isDevMode;
4947
if (!this.isValidStatusChange()) return;
5048

5149
const updatedAt = Date.now();
@@ -56,7 +54,7 @@ export default class UserStatusModalComponent extends Component {
5654
message: this.reason,
5755
state: this.args.newStatus,
5856
};
59-
await this.updateStatusBasedOnMode(isDevMode, newStateObj);
57+
await this.updateStatusBasedOnMode(newStateObj);
6058
this.resetInputFields();
6159
this.disableSubmitButton = true;
6260
}
@@ -106,15 +104,13 @@ export default class UserStatusModalComponent extends Component {
106104
return false;
107105
}
108106

109-
async updateStatusBasedOnMode(isDevMode, newStateObj) {
110-
if (isDevMode) {
107+
async updateStatusBasedOnMode() {
108+
if (this.args.newStatus === USER_STATES.OOO) {
111109
await this.args.createOOORequest(
112110
this.fromDate,
113111
this.untilDate,
114112
this.reason,
115113
);
116-
} else {
117-
await this.args.updateStatus({ currentStatus: newStateObj });
118114
}
119115
}
120116

app/components/user-status.hbs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,7 @@
2525
<div class="buttons">
2626
{{#each this.currentUserStatus as |currentStatus|}}
2727
{{#if (eq @status currentStatus.status)}}
28-
{{#if @dev}}
29-
<button
30-
data-test-request-status-OOO
31-
class="buttons__request--ooo"
32-
type="button"
33-
{{on "click" this.changeStatus}}
34-
>
35-
<span>Request OOO Status</span>
36-
</button>
37-
{{else}}
38-
{{#if (eq currentStatus.status "OOO")}}
28+
{{#if (eq currentStatus.status "OOO")}}
3929
<button
4030
data-test-cancel-status-OOO
4131
class="buttons__cancel--ooo"
@@ -60,8 +50,7 @@
6050
<span>{{otherPossibleStatus.message}}</span>
6151
</button>
6252
{{/each}}
63-
{{/if}}
64-
{{/if}}
53+
{{/if}}
6554
{{/if}}
6655
{{/each}}
6756
</div>

app/components/user-status.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default class UserStatusComponent extends Component {
2020
},
2121
[USER_STATES.OOO]: {
2222
status: USER_STATES.OOO,
23-
message: 'Change your status to OOO',
23+
message: 'Request OOO',
2424
class: 'buttons__ooo',
2525
},
2626
};

app/constants/apis.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const SELF_USER_STATUS_URL = `${APPS.API_BACKEND}/users/status/self`;
3535

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

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

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

app/templates/status.hbs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
{{page-title "User Status"}}
22

33
<div class="status-container">
4-
<UserStatus
4+
<UserStatus
55
@status={{this.status}}
6-
@changeStatus={{this.changeStatus}}
6+
@changeStatus={{this.changeStatus}}
77
@isStatusUpdating={{this.isStatusUpdating}}
8-
@updateStatus={{this.updateStatus}}
9-
@dev={{this.isDevMode}}
10-
@createOOORequest={{this.createOOORequest}}
8+
@updateStatus={{this.updateStatus}}
9+
@createOOORequest={{this.createOOORequest}}
1110
/>
1211

13-
<UserStatusModal
14-
@isStatusUpdating={{this.isStatusUpdating}}
12+
<UserStatusModal
13+
@isStatusUpdating={{this.isStatusUpdating}}
1514
@newStatus={{this.newStatus}}
16-
@showUserStateModal={{this.showUserStateModal}}
15+
@showUserStateModal={{this.showUserStateModal}}
1716
@toggleUserStateModal={{this.toggleUserStateModal}}
18-
@updateStatus={{this.updateStatus}}
19-
@dev={{this.isDevMode}}
20-
@createOOORequest={{this.createOOORequest}}
21-
/>
17+
@updateStatus={{this.updateStatus}}
18+
@createOOORequest={{this.createOOORequest}}
19+
/>
2220
</div>

tests/integration/components/user-status-modal-test.js

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -46,39 +46,21 @@ module('Integration | Component | user-status-modal', function (hooks) {
4646
});
4747

4848
test('payload contains relevant data when status is changed to OOO', async function (assert) {
49-
assert.expect(6);
49+
assert.expect(4);
5050
this.setProperties({
5151
newStatus: 'OOO',
5252
showUserStateModal: true,
5353
toggleUserStateModal: () => {
5454
this.set('showUserStateModal', !this.showUserStateModal);
5555
},
56-
updateStatus: (statusPayLoad) => {
57-
const {
58-
currentStatus: { state, from, until, message, updatedAt },
59-
} = statusPayLoad;
60-
console.log('Payload:', JSON.stringify(statusPayLoad, null, 2));
61-
assert.strictEqual(state, 'OOO', 'New state is present in the payload');
56+
createOOORequest: (from, until, reason) => {
6257
assert.strictEqual(
63-
message,
58+
reason,
6459
'OOO due to Bad Health',
65-
'Message is present in the payload',
66-
);
67-
assert.strictEqual(
68-
typeof from,
69-
'number',
70-
'From is a numeric timestamp',
71-
);
72-
assert.strictEqual(
73-
typeof until,
74-
'number',
75-
'Until is a numeric timestamp',
76-
);
77-
assert.strictEqual(
78-
typeof updatedAt,
79-
'number',
80-
'UpdatedAt is a numeric timestamp',
60+
'Reason is present in the payload',
8161
);
62+
assert.strictEqual(typeof from, 'string', 'From is a date string');
63+
assert.strictEqual(typeof until, 'string', 'Until is a date string');
8264
},
8365
});
8466
await render(hbs`
@@ -87,6 +69,7 @@ module('Integration | Component | user-status-modal', function (hooks) {
8769
@newStatus={{this.newStatus}}
8870
@toggleUserStateModal={{this.toggleUserStateModal}}
8971
@updateStatus={{this.updateStatus}}
72+
@createOOORequest={{this.createOOORequest}}
9073
/>
9174
`);
9275

@@ -125,7 +108,6 @@ module('Integration | Component | user-status-modal', function (hooks) {
125108
newStatus: 'OOO',
126109
showUserStateModal: true,
127110
isStatusUpdating: false,
128-
isDevMode: true,
129111
createOOORequest: () => {},
130112
});
131113

@@ -136,7 +118,6 @@ module('Integration | Component | user-status-modal', function (hooks) {
136118
@toggleUserStateModal={{this.toggleUserStateModal}}
137119
@updateStatus={{this.updateStatus}}
138120
@isStatusUpdating={{this.isStatusUpdating}}
139-
@dev={{this.isDevMode}}
140121
@createOOORequest={{this.createOOORequest}}
141122
/>
142123
`);

tests/integration/components/user-status-test.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ module('Integration | Component | user-status', function (hooks) {
4444
`);
4545

4646
assert.dom('[data-test-status]').containsText('You are Idle');
47-
assert
48-
.dom('[data-test-update-status-OOO]')
49-
.containsText('Change your status to OOO');
47+
assert.dom('[data-test-update-status-OOO]').containsText('Request OOO');
5048
});
5149

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

0 commit comments

Comments
 (0)