generated from Real-Dev-Squad/website-template
-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #531 from Real-Dev-Squad/feat/purge-cache
feat: UI for purging members cache
- Loading branch information
Showing
7 changed files
with
152 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{{#if @dev}} | ||
<section class='cache'> | ||
<div data-test-last-time class='cache__last-request'> | ||
Last Request: {{@time}} | ||
</div> | ||
<button | ||
data-test-btn-clear-cache | ||
class='cache__clear-btn' | ||
type='submit' | ||
disabled={{@isPurgingCache}} | ||
{{on 'click' (fn @onClearCache)}} | ||
>{{#if @isPurgingCache}} | ||
<i class='fa fa-spinner fa-spin' data-test-button-spinner></i> | ||
{{/if}} | ||
Clear Cache</button> | ||
<div data-test-pending-requests class='cache__remaining-requests'> | ||
{{@totalTimes}} | ||
/ 3 requests remaining for today | ||
</div> | ||
</section> | ||
{{/if}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const MAX_CACHE_PURGE_COUNT = 3; | ||
// this will be removed once we fetch this from the API | ||
export const LAST_UPDATED_REQUEST = '24 November, 1:23 PM IST'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
.cache { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
margin: auto; | ||
box-shadow: 5px 10px 15px #09113344; | ||
border-radius: 10px; | ||
padding: 30px; | ||
font-weight: 700; | ||
} | ||
|
||
.cache__last-request { | ||
padding: 40px 4px 20px; | ||
color: #1d1283; | ||
font-size: 2rem; | ||
text-align: center; | ||
} | ||
|
||
.cache__clear-btn { | ||
border-radius: 10px; | ||
padding: 16px 60px; | ||
border: 3px solid #e49504; | ||
color: #e49504; | ||
background-color: white; | ||
font-weight: 700; | ||
font-size: 1.25rem; | ||
cursor: pointer; | ||
} | ||
|
||
.cache__remaining-requests { | ||
padding-top: 30px; | ||
color: #1d1283; | ||
font-size: 1.25rem; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupRenderingTest } from 'ember-qunit'; | ||
import { render } from '@ember/test-helpers'; | ||
import { hbs } from 'ember-cli-htmlbars'; | ||
|
||
module('Integration | Component | self-clear-cache', function (hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
test('should render the component with relevant details', async function (assert) { | ||
this.setProperties({ | ||
purgeCache: () => {}, | ||
cacheTriggeredPending: 3, | ||
isDevMode: true, | ||
isPurgingCache: false, | ||
lastUpdatedCacheRequest: '24 November, 1:23 PM IST', | ||
}); | ||
|
||
await render(hbs` | ||
<SelfClearCache | ||
@totalTimes={{this.cacheTriggeredPending}} | ||
@onClearCache={{this.purgeCache}} | ||
@isPurgingCache={{this.isPurgingCache}} | ||
@dev={{this.isDevMode}} | ||
@time={{this.lastUpdatedCacheRequest}} | ||
/> | ||
`); | ||
|
||
assert | ||
.dom('[data-test-pending-requests]') | ||
.hasText(`3 / 3 requests remaining for today`); | ||
assert.dom('[data-test-btn-clear-cache]').hasText('Clear Cache'); | ||
assert | ||
.dom('[data-test-last-time]') | ||
.hasText('Last Request: 24 November, 1:23 PM IST'); | ||
}); | ||
}); |