diff --git a/app/components/self-clear-cache.hbs b/app/components/self-clear-cache.hbs index fca13aac..e37ef920 100644 --- a/app/components/self-clear-cache.hbs +++ b/app/components/self-clear-cache.hbs @@ -1,4 +1,4 @@ -{{#if @dev}} +{{#if @cache}}
Last Request: {{@time}} diff --git a/app/components/user-status-modal.hbs b/app/components/user-status-modal.hbs index b2edafd6..0ff8d8cf 100644 --- a/app/components/user-status-modal.hbs +++ b/app/components/user-status-modal.hbs @@ -2,7 +2,6 @@
+ {{/if}} diff --git a/app/controllers/index.js b/app/controllers/index.js index dbd87934..076f8244 100644 --- a/app/controllers/index.js +++ b/app/controllers/index.js @@ -9,6 +9,7 @@ import { MAX_CACHE_PURGE_COUNT, LAST_UPDATED_REQUEST, } from '../constants/self-clear-cache'; +import { getUTCMidnightTimestampFromDate } from '../utils/date-conversion'; const BASE_URL = ENV.BASE_API_URL; @@ -30,6 +31,9 @@ export default class IndexController extends Controller { get isDevMode() { return this.featureFlag.isDevMode; } + get isCacheEnabled() { + return this.featureFlag.isCacheEnabled; + } @action async updateStatus(newStatus) { this.isStatusUpdating = true; @@ -76,6 +80,39 @@ export default class IndexController extends Controller { } } + @action + async statusUpdateDevApi(from, until, message) { + const statusRequestBody = { + type: 'OOO', + from: getUTCMidnightTimestampFromDate(from), + until: getUTCMidnightTimestampFromDate(until), + message, + state: 'PENDING', + }; + try { + const response = await fetch(`${BASE_URL}/requests?dev=true`, { + method: 'POST', + body: JSON.stringify(statusRequestBody), + headers: { + 'Content-Type': 'application/json', + }, + credentials: 'include', + }); + if (response.ok) { + const data = await response.json(); + this.toast.success(data.message, '', toastNotificationTimeoutOptions); + } + } catch (error) { + this.toast.error( + 'OOO status request failed. Something went wrong.', + '', + toastNotificationTimeoutOptions + ); + } finally { + this.isStatusUpdating = false; + } + } + @action changeStatus(status) { this.newStatus = status; this.toggleUserStateModal(); diff --git a/app/services/feature-flag.js b/app/services/feature-flag.js index 31759c49..ba52c477 100644 --- a/app/services/feature-flag.js +++ b/app/services/feature-flag.js @@ -8,4 +8,9 @@ export default class FeatureFlagService extends Service { const queryParams = this.router.currentRoute.queryParams; return queryParams.dev === 'true'; } + + get isCacheEnabled() { + const queryParams = this.router.currentRoute.queryParams; + return queryParams.cache === 'true'; + } } diff --git a/app/styles/user-status.css b/app/styles/user-status.css index 971c11ae..21d51c30 100644 --- a/app/styles/user-status.css +++ b/app/styles/user-status.css @@ -90,6 +90,24 @@ width: 15rem; } +.buttons__request--ooo { + font-size: 1.25rem; + color: var(--button--ooo--text); + font-weight: 700; + border: 3px solid var(--button--ooo--border); + padding: 20px; + margin-bottom: 40px; + border-radius: 10px; + background: var(--button--ooo--bg); + cursor: pointer; + width: 25rem; +} + +.buttons__request--ooo:hover { + color: var(--button--ooo--bg); + background: var(--button--ooo--text); +} + .buttons__ooo:hover { color: var(--button--ooo--bg); background: var(--button--ooo--text); diff --git a/app/templates/index.hbs b/app/templates/index.hbs index 7282738e..b61585ad 100644 --- a/app/templates/index.hbs +++ b/app/templates/index.hbs @@ -6,13 +6,16 @@ @onClearCache={{this.purgeCache}} @isPurgingCache={{this.isPurgingCache}} @time={{this.lastUpdatedCacheRequest}} - @dev={{this.isDevMode}} + @cache={{this.isCacheEnabled}} /> \ No newline at end of file diff --git a/tests/integration/components/self-clear-cache-test.js b/tests/integration/components/self-clear-cache-test.js index 0bf00945..61ddc7d1 100644 --- a/tests/integration/components/self-clear-cache-test.js +++ b/tests/integration/components/self-clear-cache-test.js @@ -10,7 +10,7 @@ module('Integration | Component | self-clear-cache', function (hooks) { this.setProperties({ purgeCache: () => {}, cacheTriggeredPending: 3, - isDevMode: true, + isCacheEnabled: true, isPurgingCache: false, lastUpdatedCacheRequest: '24 November, 1:23 PM IST', }); @@ -20,7 +20,7 @@ module('Integration | Component | self-clear-cache', function (hooks) { @totalTimes={{this.cacheTriggeredPending}} @onClearCache={{this.purgeCache}} @isPurgingCache={{this.isPurgingCache}} - @dev={{this.isDevMode}} + @cache={{this.isCacheEnabled}} @time={{this.lastUpdatedCacheRequest}} /> `); diff --git a/tests/integration/components/user-status-modal-test.js b/tests/integration/components/user-status-modal-test.js index 356c0786..bfaec41b 100644 --- a/tests/integration/components/user-status-modal-test.js +++ b/tests/integration/components/user-status-modal-test.js @@ -47,7 +47,7 @@ module('Integration | Component | user-status-modal', function (hooks) { assert.dom('.modal__close').doesNotExist(); }); - test('payload contains relevant data when status is changed to OOO', async function (assert) { + test.skip('payload contains relevant data when status is changed to OOO', async function (assert) { this.setProperties({ newStatus: 'OOO', showUserStateModal: true,