From 8ee1b7fa403d50f7f8dc17d426e6dc976aa56ca5 Mon Sep 17 00:00:00 2001 From: Hariom Vashista Date: Sat, 28 Dec 2024 20:06:09 +0530 Subject: [PATCH 1/3] Updated deprecated API endpoint users/self to users?profile=true (#931) --- __tests__/applications/applications.test.js | 2 +- __tests__/groups/group.test.js | 2 +- __tests__/home/home.test.js | 2 +- __tests__/task-requests/task-requestDetails.test.js | 2 +- __tests__/user-details/task-duedate-hover.test.js | 2 +- .../users/onboarding-31-days-multiple-selections.test.js | 2 +- __tests__/users/onboarding31days.test.js | 2 +- admin-panel/index.js | 2 +- applications/utils.js | 2 +- groups/utils.js | 2 +- identity-service-logs/utils.js | 2 +- mock-data/taskRequests/index.js | 3 ++- profile/utils.js | 2 +- taskEvents/utils.js | 2 +- utils.js | 4 ++-- 15 files changed, 17 insertions(+), 16 deletions(-) diff --git a/__tests__/applications/applications.test.js b/__tests__/applications/applications.test.js index 2d805e3c..56ee4701 100644 --- a/__tests__/applications/applications.test.js +++ b/__tests__/applications/applications.test.js @@ -60,7 +60,7 @@ describe('Applications page', () => { 'Access-Control-Allow-Headers': 'Content-Type, Authorization', }, }); - } else if (url === `${STAGING_API_URL}/users/self`) { + } else if (url === `${STAGING_API_URL}/users?profile=true`) { interceptedRequest.respond({ status: 200, contentType: 'application/json', diff --git a/__tests__/groups/group.test.js b/__tests__/groups/group.test.js index be21648d..f0a108b6 100644 --- a/__tests__/groups/group.test.js +++ b/__tests__/groups/group.test.js @@ -51,7 +51,7 @@ describe('Discord Groups Page', () => { }, body: JSON.stringify(allUsersData), }); - } else if (url === `${STAGING_API_URL}/users/self`) { + } else if (url === `${STAGING_API_URL}/users?profile=true`) { interceptedRequest.respond({ status: 200, contentType: 'application/json', diff --git a/__tests__/home/home.test.js b/__tests__/home/home.test.js index c1582559..0dfa2949 100644 --- a/__tests__/home/home.test.js +++ b/__tests__/home/home.test.js @@ -21,7 +21,7 @@ describe('Home Page', () => { await page.setRequestInterception(true); page.on('request', (interceptedRequest) => { const url = interceptedRequest.url(); - if (url === `${STAGING_API_URL}/users/self`) { + if (url === `${STAGING_API_URL}/users?profile=true`) { interceptedRequest.respond({ status: 200, contentType: 'application/json', diff --git a/__tests__/task-requests/task-requestDetails.test.js b/__tests__/task-requests/task-requestDetails.test.js index 7a49605d..ca33d925 100644 --- a/__tests__/task-requests/task-requestDetails.test.js +++ b/__tests__/task-requests/task-requestDetails.test.js @@ -25,7 +25,7 @@ describe('Request container for non-super users', () => { await page.setRequestInterception(true); page.on('request', (interceptedRequest) => { const url = interceptedRequest.url(); - if (url == `${STAGING_API_URL}/users/self`) { + if (url == `${STAGING_API_URL}/users?profile=true`) { interceptedRequest.respond({ ...defaultMockResponseHeaders, body: JSON.stringify(user), diff --git a/__tests__/user-details/task-duedate-hover.test.js b/__tests__/user-details/task-duedate-hover.test.js index fc041c4c..1fc4d345 100644 --- a/__tests__/user-details/task-duedate-hover.test.js +++ b/__tests__/user-details/task-duedate-hover.test.js @@ -45,7 +45,7 @@ describe('Tasks On User Management Page', () => { body: JSON.stringify(userDetails), }); } else if ( - url === `${STAGING_API_URL}/users/self` || + url === `${STAGING_API_URL}/users?profile=true` || url === `${STAGING_API_URL}/users/ankush` ) { interceptedRequest.respond({ diff --git a/__tests__/users/onboarding-31-days-multiple-selections.test.js b/__tests__/users/onboarding-31-days-multiple-selections.test.js index ddac366a..ab866dc1 100644 --- a/__tests__/users/onboarding-31-days-multiple-selections.test.js +++ b/__tests__/users/onboarding-31-days-multiple-selections.test.js @@ -33,7 +33,7 @@ describe('Tests the "Onboarding > 31 Days" Filter', () => { }, body: JSON.stringify(userDetailsApi), }); - } else if (url === `${STAGING_API_URL}/users/self`) { + } else if (url === `${STAGING_API_URL}/users?profile=true`) { // When we encounter the respective api call we respond with the below response interceptedRequest.respond({ status: 200, diff --git a/__tests__/users/onboarding31days.test.js b/__tests__/users/onboarding31days.test.js index 80bb9497..84893769 100644 --- a/__tests__/users/onboarding31days.test.js +++ b/__tests__/users/onboarding31days.test.js @@ -34,7 +34,7 @@ describe('Tests the "Onboarding > 31 Days" Filter', () => { }, body: JSON.stringify(userDetailsApi), }); - } else if (url === `${STAGING_API_URL}/users/self`) { + } else if (url === `${STAGING_API_URL}/users?profile=true`) { // When we encounter the respective api call we respond with the below response interceptedRequest.respond({ status: 200, diff --git a/admin-panel/index.js b/admin-panel/index.js index b0f28001..885f1c2d 100644 --- a/admin-panel/index.js +++ b/admin-panel/index.js @@ -5,7 +5,7 @@ const loading = document.getElementById('loading'); const selectElement = document.getElementById('select-tags'); (async function setAuth() { try { - const res = await fetch(`${API_BASE_URL}/users/self`, { + const res = await fetch(`${API_BASE_URL}/users?profile=true`, { method: 'GET', credentials: 'include', headers: { diff --git a/applications/utils.js b/applications/utils.js index d5541409..173e6af3 100644 --- a/applications/utils.js +++ b/applications/utils.js @@ -68,7 +68,7 @@ async function getApplicationById(applicationId) { async function getIsSuperUser() { try { - const res = await fetch(`${BASE_URL}/users/self`, { + const res = await fetch(`${BASE_URL}/users?profile=true`, { method: 'GET', credentials: 'include', headers: { diff --git a/groups/utils.js b/groups/utils.js index 3ad47aaf..f97112f4 100644 --- a/groups/utils.js +++ b/groups/utils.js @@ -17,7 +17,7 @@ async function getMembers() { } async function getUserSelf() { try { - const res = await fetch(`${BASE_URL}/users/self`, { + const res = await fetch(`${BASE_URL}/users?profile=true`, { method: 'GET', credentials: 'include', headers: { diff --git a/identity-service-logs/utils.js b/identity-service-logs/utils.js index bcf6c8b3..8b81f33f 100644 --- a/identity-service-logs/utils.js +++ b/identity-service-logs/utils.js @@ -216,7 +216,7 @@ function showToaster(message) { async function getIsSuperUser() { try { - const res = await fetch(`${API_BASE_URL}/users/self`, { + const res = await fetch(`${API_BASE_URL}/users?profile=true`, { method: 'GET', credentials: 'include', headers: { diff --git a/mock-data/taskRequests/index.js b/mock-data/taskRequests/index.js index c17e92ca..63a829e8 100644 --- a/mock-data/taskRequests/index.js +++ b/mock-data/taskRequests/index.js @@ -351,7 +351,8 @@ const defaultMockResponseHeaders = { }; const urlMappings = { - 'https://staging-api.realdevsquad.com/users/self': superUserDetails.user, + 'https://staging-api.realdevsquad.com/users?profile=true': + superUserDetails.user, 'https://api.realdevsquad.com/taskRequests/dM5wwD9QsiTzi7eG7Oq5': individualTaskReqDetail, 'https://api.realdevsquad.com/taskRequests/dM5wwD9QsiTzi7eG7Oq6': diff --git a/profile/utils.js b/profile/utils.js index 08b4c278..411a2a34 100644 --- a/profile/utils.js +++ b/profile/utils.js @@ -318,7 +318,7 @@ function wantedData(data) { } async function getSelfUser() { - const res = await fetch(`${API_BASE_URL}/users/self`, { + const res = await fetch(`${API_BASE_URL}/users?profile=true`, { method: 'GET', credentials: 'include', headers: { diff --git a/taskEvents/utils.js b/taskEvents/utils.js index b10e0e4b..abd081d8 100644 --- a/taskEvents/utils.js +++ b/taskEvents/utils.js @@ -80,7 +80,7 @@ async function getUserData(username) { } async function getSelfDetails() { - const res = await fetch(`${API_BASE_URL}/users/self`, { + const res = await fetch(`${API_BASE_URL}/users?profile=true`, { method: 'GET', credentials: 'include', headers: { diff --git a/utils.js b/utils.js index 246077da..e5466e42 100644 --- a/utils.js +++ b/utils.js @@ -4,7 +4,7 @@ function goToAuthPage() { window.open(authUrl, '_self'); } -async function getSelfUser(endpoint = '/users/self') { +async function getSelfUser(endpoint = '/users?profile=true') { try { const res = await fetch(`${API_BASE_URL}${endpoint}`, { method: 'GET', @@ -13,7 +13,7 @@ async function getSelfUser(endpoint = '/users/self') { 'Content-type': 'application/json', }, }); - if (endpoint === '/users/self') { + if (endpoint === '/users?profile=true') { const self_user = await res.json(); if (res.status === 200) { return self_user?.user || self_user; From 1dc33289753a1fa2aa2ab327f5e41ed9b78d8efc Mon Sep 17 00:00:00 2001 From: Anuj Chhikara <107175639+AnujChhikara@users.noreply.github.com> Date: Wed, 15 Jan 2025 15:37:24 +0530 Subject: [PATCH 2/3] Fix: Markdown Rendering Issue on the TCR Page (#935) fixes the markdown issue on the tcr page --- task-requests/details/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/task-requests/details/script.js b/task-requests/details/script.js index 50b4d7f5..1ef8fa01 100644 --- a/task-requests/details/script.js +++ b/task-requests/details/script.js @@ -385,7 +385,7 @@ const renderGithubIssue = async () => { ], }), ); - const body = DOMPurify.sanitize(res?.body ?? ''); + const body = DOMPurify.sanitize(res?.body ?? '').replace(/\n/g, '\n\n'); const html = converter.makeHtml(body); taskContainer.appendChild( createCustomElement({ From c74e1f4230cf3fd4ea4b4552e2d2423a58d9860e Mon Sep 17 00:00:00 2001 From: Vinit khandal <111434418+vinit717@users.noreply.github.com> Date: Fri, 31 Jan 2025 01:42:38 +0530 Subject: [PATCH 3/3] feat: add date and username filter (#938) * feat: add date and username filter * chore: fix filters * chore: fix css * chore: fix ui for filters * chore: update constant file * chore: fix mobile css * chore: fix query builder for date * chore: fix clearusername icon * chore: fix styling * chore: remove console statement --- feed/assets/user.svg | 3 + feed/index.html | 36 ++++++- feed/script.js | 184 +++++++++++++++++++++++++++++++-- feed/style.css | 240 +++++++++++++++++++++++++++++++++++++------ feed/utils.js | 40 ++++++++ 5 files changed, 465 insertions(+), 38 deletions(-) create mode 100644 feed/assets/user.svg diff --git a/feed/assets/user.svg b/feed/assets/user.svg new file mode 100644 index 00000000..39320c31 --- /dev/null +++ b/feed/assets/user.svg @@ -0,0 +1,3 @@ + + + diff --git a/feed/index.html b/feed/index.html index ed297483..0f6c20cc 100644 --- a/feed/index.html +++ b/feed/index.html @@ -20,7 +20,39 @@

Activity Feed

- + diff --git a/feed/script.js b/feed/script.js index e31799b0..d60578c0 100644 --- a/feed/script.js +++ b/feed/script.js @@ -3,6 +3,8 @@ const activityFeedContainer = document.getElementById(ACITIVITY_FEED_CONTAINER); const activityList = document.querySelector('.activity-list'); const tabsList = document.querySelector('.tabs'); const lastElementContainer = document.querySelector(LAST_ELEMENT_CONTAINER); +const usernameInput = document.getElementById('assignee-search'); +const clearUsernameBtn = document.getElementById('clear-username'); let query = {}; let newLink = ''; @@ -10,6 +12,7 @@ let activityFeedPage = 0; let nextLink = ''; let isDataLoading = false; let category = CATEGORY.ALL; +let activeIndex = -1; const tabsData = [ { name: 'All', 'data-type': CATEGORY.ALL, class: 'active' }, @@ -21,7 +24,7 @@ const tabsData = [ async function renderFeed() { changeFilter(); - await populateActivityFeed({ category }); + await populateActivityFeed({ category: currentCategory, ...activeFilters }); addIntersectionObserver(); } @@ -38,9 +41,9 @@ function createTabListItem(tab) { function handleTabClick(tab) { tabs.forEach((t) => t.classList.remove('active')); tab.classList.add('active'); - const category = tab.dataset.type; - changeFilter(); - populateActivityFeed({ category }); + currentCategory = tab.dataset.type; + + refreshFeed(); } tabsData.forEach((tab) => { @@ -300,16 +303,30 @@ function formatTaskRequestsLog(data) { async function populateActivityFeed(query = {}, newLink) { activityFeedPage++; const currentVersion = activityFeedPage; + + const combinedQuery = { ...query, ...activeFilters }; + try { isDataLoading = true; addLoader(container); - const activityFeedData = await getActivityFeedData(query, newLink); + + const activityFeedData = await getActivityFeedData(combinedQuery, newLink); + + activityFeedContainer.innerHTML = ''; + if (activityFeedData) { nextLink = activityFeedData.next; const allActivityFeedData = activityFeedData.data; + if (currentVersion !== activityFeedPage) { return; } + + if (allActivityFeedData.length === 0) { + addEmptyPageMessage(activityFeedContainer); + return; + } + for (const data of allActivityFeedData) { const renderedItem = renderActivityItem(data); activityFeedContainer.appendChild(renderedItem); @@ -319,6 +336,7 @@ async function populateActivityFeed(query = {}, newLink) { showMessage(activityFeedContainer, error); } finally { if (currentVersion !== activityFeedPage) return; + removeLoader('loader'); isDataLoading = false; } @@ -335,7 +353,6 @@ async function getActivityFeedData(query = {}, nextLink) { 'Content-type': 'application/json', }, }); - try { const res = await fetch(finalUrl, { credentials: 'include', @@ -370,5 +387,160 @@ async function getActivityFeedData(query = {}, nextLink) { } } +let currentCategory = CATEGORY.ALL; + +function handleTabClick(tab) { + tabs.forEach((t) => t.classList.remove('active')); + tab.classList.add('active'); + currentCategory = tab.dataset.type; + changeFilter(); + populateActivityFeed({ category: currentCategory }); +} + +let activeFilters = { + username: null, + startDate: null, + endDate: null, +}; + +document.getElementById('start-date').addEventListener('change', applyFilter); +document.getElementById('end-date').addEventListener('change', applyFilter); +clearUsernameBtn.addEventListener('click', clearUsernameFilter); + +clearUsernameBtn.style.display = 'none'; + +usernameInput.addEventListener('input', function () { + if (usernameInput.value.trim() !== '') { + clearUsernameBtn.style.display = 'inline'; + } else { + clearUsernameBtn.style.display = 'none'; + } +}); + +function applyFilter() { + const username = document.getElementById('assignee-search').value.trim(); + const startDate = document.getElementById('start-date').value; + const endDate = document.getElementById('end-date').value; + + if (startDate && endDate && new Date(startDate) > new Date(endDate)) { + alert('Start Date cannot be later than End Date!'); + return; + } + + activeFilters.username = username || null; + activeFilters.startDate = startDate + ? new Date(startDate).toISOString() + : null; + activeFilters.endDate = endDate ? new Date(endDate).toISOString() : null; + + populateActivityFeed({ category: currentCategory, ...activeFilters }); +} + +function clearUsernameFilter() { + const usernameInput = document.getElementById('assignee-search'); + const suggestionBox = document.getElementById('suggestion-box'); + const clearUsernameBtn = document.getElementById('clear-username'); + + usernameInput.value = ''; + suggestionBox.style.display = 'none'; + clearUsernameBtn.style.display = 'none'; + + activeFilters.username = null; + populateActivityFeed({ category: currentCategory, ...activeFilters }); +} + +async function fetchSuggestions() { + const input = document.getElementById('assignee-search'); + const query = input.value.trim(); + const suggestionBox = document.getElementById('suggestion-box'); + + if (!query) { + suggestionBox.style.display = 'none'; + return; + } + + try { + const response = await fetch(`${API_BASE_URL}/users?search=${query}`, { + method: 'GET', + credentials: 'include', + headers: { + 'Content-Type': 'application/json', + }, + }); + + if (response.ok) { + const data = await response.json(); + const users = data.users || []; + if (users.length > 0) { + renderSuggestions(users); + suggestionBox.style.display = 'block'; + } else { + suggestionBox.innerHTML = + '
No users found
'; + suggestionBox.style.display = 'block'; + } + } else { + console.error('Error fetching suggestions:', response.statusText); + } + } catch (error) { + console.error('Error:', error); + } +} + +function renderSuggestions(users) { + const suggestionBox = document.getElementById('suggestion-box'); + suggestionBox.innerHTML = users + .map((user, index) => { + const userIcon = `User Icon`; + return `
+
+ ${userIcon} + ${user.username} +
+
`; + }) + .join(''); +} + +function selectAssignee(username) { + const input = document.getElementById('assignee-search'); + input.value = username; + const suggestionBox = document.getElementById('suggestion-box'); + suggestionBox.style.display = 'none'; + applyFilter(); +} + +document.getElementById('assignee-search').addEventListener('keydown', (e) => { + const suggestionBox = document.getElementById('suggestion-box'); + const items = suggestionBox.querySelectorAll('.suggestion-item'); + + if (e.key === 'ArrowDown') { + e.preventDefault(); + activeIndex = (activeIndex + 1) % items.length; + } else if (e.key === 'ArrowUp') { + e.preventDefault(); + activeIndex = (activeIndex - 1 + items.length) % items.length; + } else if (e.key === 'Enter') { + e.preventDefault(); + if (activeIndex >= 0 && activeIndex < items.length) { + items[activeIndex].click(); + } + } else if (e.key === 'Escape') { + suggestionBox.style.display = 'none'; + } + + items.forEach((item, index) => { + if (index === activeIndex) { + item.classList.add('active'); + } else { + item.classList.remove('active'); + } + }); +}); + // main entry renderFeed(); diff --git a/feed/style.css b/feed/style.css index aeea812e..c7d84781 100644 --- a/feed/style.css +++ b/feed/style.css @@ -1,5 +1,26 @@ +:root { + --background-color: #dbe9f9; + --blue-color: #007bff; + --white-color: #ffffff; + --gray-color: #aaa; + --light-gray-color: #f9fafb; + --dark-gray-color: #080707; + --pink-color: rgb(198, 78, 170); + --light-pink-color: rgb(180, 70, 150); + --dark-pink-color: rgb(165, 65, 135); + --teal-color: rgb(98, 178, 170); + --light-teal-color: rgb(88, 160, 150); + --red-color: rgb(255, 102, 102); + --light-red-color: rgb(235, 85, 85); + --tab-background-color: #f6faff; + --tab-border-color: #ddd; + --activity-item-background: #ffffff; + --activity-item-border: #ddd; + --primary-color: #1d1283; +} + body { - background: #dbe9f9; + background: var(--background-color); } .header { @@ -10,13 +31,13 @@ body { } #activity_feed_container { - padding: 10px 0; - max-width: 800px; + padding: 1rem 0; + width: 50rem; margin: 0 auto; } .activity-feed { - border: 1px solid #ddd; + border: 1px solid var(--activity-item-border); padding: 1rem; margin-bottom: 1rem; } @@ -28,17 +49,17 @@ body { .activity-item { margin-bottom: 0.5rem; - display: flex; /* Allow for inline elements with spacing */ + display: flex; border: 1.5px; - border-radius: 5px; - padding: 0 10px; - background: white; + border-radius: 0.5rem; + padding: 0 1rem; + background: var(--activity-item-background); width: 100%; flex-direction: column; } .activity-item a { - color: #007bff; + color: var(--blue-color); text-decoration: none; } @@ -48,12 +69,13 @@ body { .activity-item time { font-size: 0.8rem; - color: #aaa; + color: var(--gray-color); } + .tabs-container { - margin: 0 auto; /* Center the tabs container horizontally */ - max-width: 800px; /* Set a maximum width */ - padding: 15px; /* Add some padding around the tabs */ + margin: 0 auto; + width: 50rem; + padding: 0.5rem 0; } .tabs { @@ -62,12 +84,12 @@ body { list-style: none; padding: 0; margin: 0; - background: #f6faff; - border-bottom: 2px solid #ddd; + background: var(--tab-background-color); + border-bottom: 2px solid var(--tab-border-color); } .tabs li { - padding: 15px 25px; /* Adjust padding for desired spacing */ + padding: 1rem 1.5rem; font-weight: bold; cursor: pointer; text-align: center; @@ -76,34 +98,33 @@ body { } .tabs li:hover { - background-color: #e0e0e0; + background-color: var(--light-gray-color); } .tabs li.active { - border-bottom: 4px solid rgb(198, 78, 170); + border-bottom: 4px solid var(--pink-color); font-weight: bold; - color: #080707; - background-color: #ffffff; + color: var(--dark-gray-color); + background-color: var(--white-color); } .timestamp { text-align: right; - font-size: 10px; - color: gray; + font-size: 1rem; + color: var(--gray-color); } .img_icon { - height: 30px; - width: 30px; + height: 1.8rem; + width: 1.8rem; } .title { display: flex; align-items: center; - gap: 10px; + gap: 1rem; } -/* Loader Container */ .loader-text { text-align: center; font-size: 1.5rem; @@ -119,8 +140,167 @@ body { } .page-message { - text-align: center; - margin: auto auto; - font-weight: 800; - font-size: 2em; + display: flex; + justify-content: center; + align-items: center; + font-weight: 600; + font-size: 2rem; +} + +.filters { + display: flex; + flex-direction: column; + gap: 1.2rem; + align-items: center; +} + +.filter-row { + display: flex; + gap: 1.2rem; + justify-content: center; + align-items: center; + max-width: 50rem; + width: 100%; + padding: 1rem 0; +} + +.input-wrapper { + position: relative; + max-width: 12rem; + display: flex; + flex-direction: column; + gap: 1rem; +} + +#assignee-search { + width: 100%; + padding: 0.8rem; + max-width: 15rem; + border: 1px solid var(--input-border); + border-radius: 0.5rem; + font-size: 1rem; + background: var(--light-gray-color); + transition: border-color 0.2s ease-in-out; + box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1); + height: 2.8rem; +} + +.clear-icon { + position: absolute; + top: 75%; + right: 1rem; + transform: translateY(-50%); + cursor: pointer; + color: var(--gray-color); + font-size: 1.4rem; + font-weight: bold; +} + +.clear-icon:hover { + color: var(--primary-color); +} + +.date-filters { + display: flex; + gap: 1.2rem; + flex-grow: 2; +} + +.date-inputs { + display: flex; + gap: 1rem; + flex-direction: column; +} + +.date-inputs input { + width: 100%; + max-width: 15rem; + padding: 0.8rem; + border: 1px solid var(--input-border); + border-radius: 0.5rem; + font-size: 1rem; + background: var(--light-gray-color); +} + +.suggestion-box { + position: absolute; + top: 100%; + left: 0; + max-height: 12rem; + overflow-y: auto; + border: 1px solid var(--input-border); + background-color: var(--white-color); + width: 100%; + z-index: 1000; + display: none; + border-radius: 0.5rem; + margin-top: 0.4rem; +} + +.suggestion-item { + display: flex; + align-items: center; + gap: 1.2rem; + padding: 0.5rem; + cursor: pointer; + transition: background-color 0.2s; + border-radius: 0.5rem; + height: 2rem; +} + +.suggestion-item:hover { + background-color: var(--light-gray-color); +} + +.suggestion-item.active { + background-color: var(--light-teal-color); +} + +.suggestion-content { + display: flex; + align-items: center; + justify-content: center; + gap: 1rem; +} + +.user-icon { + width: 1.8rem; + height: 1.8rem; + border-radius: 50%; +} + +@media (max-width: 480px) { + .filters, + .filter-row { + flex-direction: column; + gap: 1rem; + align-items: stretch; + } + + .input-wrapper, + .date-inputs input { + max-width: 100%; + } + + .tabs-container { + width: 25rem; + overflow: scroll; + } + + .container, + .tabs { + overflow: scroll; + } + + #activity_feed_container { + overflow: scroll; + } + #assignee-search, + .suggestion-box { + width: 14rem; + } + + .clear-icon { + right: 45%; + } } diff --git a/feed/utils.js b/feed/utils.js index f70fd40f..35cfb92a 100644 --- a/feed/utils.js +++ b/feed/utils.js @@ -3,7 +3,20 @@ function generateActivityFeedParams(query) { dev: true, format: 'feed', type: getLogTypesFromCategory(query?.category), + username: query.username || undefined, + startDate: query.startDate + ? Math.floor(new Date(query.startDate).getTime() / 1000) + : undefined, + endDate: query.endDate + ? Math.floor(new Date(query.endDate).getTime() / 1000) + : undefined, }; + Object.keys(queryParams).forEach((key) => { + if (queryParams[key] === undefined) { + delete queryParams[key]; + } + }); + const queryString = new URLSearchParams(queryParams).toString(); return `?${queryString}`; } @@ -106,3 +119,30 @@ function truncateWithEllipsis(text, maxLength = 120) { } return `${text.slice(0, maxLength)}...`; } + +function generateQueryParams(params) { + return Object.entries(params) + .flatMap(([key, value]) => + Array.isArray(value) + ? value.map( + (v) => `${encodeURIComponent(key)}=${encodeURIComponent(v)}`, + ) + : `${encodeURIComponent(key)}=${encodeURIComponent(value)}`, + ) + .join('&'); +} + +function refreshFeedWithQuery(query) { + changeFilter(); + populateActivityFeed(query); +} + +function refreshFeed() { + const query = { + category: currentCategory, + ...activeFilters, + }; + + changeFilter(); + populateActivityFeed(query); +}