Skip to content

Commit 9108de8

Browse files
DhirenderchoudharyDhirenderchoudhary
andauthored
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>
1 parent 3991ab5 commit 9108de8

File tree

7 files changed

+25
-53
lines changed

7 files changed

+25
-53
lines changed

app/components/user-status-modal.js

Lines changed: 5 additions & 9 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(
112-
this.fromDate,
113-
this.untilDate,
110+
getUTCMidnightTimestampFromDate(this.fromDate),
111+
getUTCMidnightTimestampFromDate(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 Status',
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: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,18 @@ 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',
60+
'Reason is present in the payload',
6661
);
6762
assert.strictEqual(
6863
typeof from,
@@ -74,11 +69,6 @@ module('Integration | Component | user-status-modal', function (hooks) {
7469
'number',
7570
'Until is a numeric timestamp',
7671
);
77-
assert.strictEqual(
78-
typeof updatedAt,
79-
'number',
80-
'UpdatedAt is a numeric timestamp',
81-
);
8272
},
8373
});
8474
await render(hbs`
@@ -87,6 +77,7 @@ module('Integration | Component | user-status-modal', function (hooks) {
8777
@newStatus={{this.newStatus}}
8878
@toggleUserStateModal={{this.toggleUserStateModal}}
8979
@updateStatus={{this.updateStatus}}
80+
@createOOORequest={{this.createOOORequest}}
9081
/>
9182
`);
9283

@@ -125,7 +116,6 @@ module('Integration | Component | user-status-modal', function (hooks) {
125116
newStatus: 'OOO',
126117
showUserStateModal: true,
127118
isStatusUpdating: false,
128-
isDevMode: true,
129119
createOOORequest: () => {},
130120
});
131121

@@ -136,7 +126,6 @@ module('Integration | Component | user-status-modal', function (hooks) {
136126
@toggleUserStateModal={{this.toggleUserStateModal}}
137127
@updateStatus={{this.updateStatus}}
138128
@isStatusUpdating={{this.isStatusUpdating}}
139-
@dev={{this.isDevMode}}
140129
@createOOORequest={{this.createOOORequest}}
141130
/>
142131
`);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ module('Integration | Component | user-status', function (hooks) {
4646
assert.dom('[data-test-status]').containsText('You are Idle');
4747
assert
4848
.dom('[data-test-update-status-OOO]')
49-
.containsText('Change your status to OOO');
49+
.containsText('Request OOO Status');
5050
});
5151

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

0 commit comments

Comments
 (0)