Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 5 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,11 +104,11 @@ export default class UserStatusModalComponent extends Component {
return false;
}

async updateStatusBasedOnMode(isDevMode, newStateObj) {
if (isDevMode) {
async updateStatusBasedOnMode(newStateObj) {
if (this.args.newStatus === USER_STATES.OOO) {
await this.args.createOOORequest(
this.fromDate,
this.untilDate,
newStateObj.from,
newStateObj.until,
this.reason,
);
} else {
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 Status',
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>
20 changes: 5 additions & 15 deletions tests/integration/components/user-status-modal-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,12 @@ module('Integration | Component | user-status-modal', function (hooks) {
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) => {
console.log('createOOORequest Payload:', { from, until, reason });
assert.strictEqual(
message,
reason,
'OOO due to Bad Health',
'Message is present in the payload',
'Reason is present in the payload',
);
assert.strictEqual(
typeof from,
Expand All @@ -74,11 +70,6 @@ module('Integration | Component | user-status-modal', function (hooks) {
'number',
'Until is a numeric timestamp',
);
assert.strictEqual(
typeof updatedAt,
'number',
'UpdatedAt is a numeric timestamp',
);
},
});
await render(hbs`
Expand All @@ -87,6 +78,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 +117,6 @@ module('Integration | Component | user-status-modal', function (hooks) {
newStatus: 'OOO',
showUserStateModal: true,
isStatusUpdating: false,
isDevMode: true,
createOOORequest: () => {},
});

Expand All @@ -136,7 +127,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
2 changes: 1 addition & 1 deletion tests/integration/components/user-status-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,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');
.containsText('Request OOO Status');
});

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