Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a refresh button to the Activity Log page #3020

Merged
merged 3 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 12 additions & 1 deletion assets/js/pages/ActivityLogPage/ActivityLogPage.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useState, useEffect } from 'react';
import { useSearchParams } from 'react-router-dom';
import { useSelector } from 'react-redux';
import { EOS_REFRESH } from 'eos-icons-react';

import { map, pipe } from 'lodash/fp';

Expand All @@ -9,6 +10,7 @@ import { allowedActivities } from '@lib/model/activityLog';
import { getActivityLogUsers } from '@state/selectors/activityLog';
import { getUserProfile } from '@state/selectors/user';

import Button from '@common/Button';
import PageHeader from '@common/PageHeader';
import ActivityLogOverview from '@common/ActivityLogOverview';
import ComposedFilter from '@common/ComposedFilter';
Expand Down Expand Up @@ -127,7 +129,7 @@ function ActivityLogPage() {
<PageHeader className="font-bold">Activity Log</PageHeader>
<div className="bg-white rounded-lg shadow">
<div style={{ padding: '1rem' }} />
<div className="flex items-center px-4 space-x-4 pb-4">
<div className="flex items-center px-4 space-x-2 pb-4">
<ComposedFilter
filters={filters}
autoApply={false}
Expand All @@ -139,6 +141,15 @@ function ActivityLogPage() {
setSearchParams
)}
/>
<Button
type="primary-white"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: Maybe the button is too big?
image

We may prefer something lighter like
image

Suggested change
type="primary-white"
type="link"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed like this 7cf3134

className="!w-28"
onClick={fetchActivityLog}
disabled={isLoading}
>
<EOS_REFRESH className="inline-block fill-jungle-green-500" />{' '}
Refresh
</Button>
</div>
<ActivityLogOverview
activityLogDetailModalOpen={activityLogDetailModalOpen}
Expand Down
8 changes: 8 additions & 0 deletions assets/js/pages/ActivityLogPage/ActivityLogPage.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ describe('ActivityLogPage', () => {
expect(screen.getByText('No data available')).toBeVisible();
});

it('should render filter actions', async () => {
const [StatefulActivityLogPage, _] = withDefaultState(<ActivityLogPage />);
await act(() => renderWithRouter(StatefulActivityLogPage));
expect(screen.getByText('Apply')).toBeVisible();
expect(screen.getByText('Reset')).toBeVisible();
expect(screen.getByText('Refresh')).toBeVisible();
});

it.each`
responseStatus | responseBody
${200} | ${{ dataz: [] }}
Expand Down
21 changes: 20 additions & 1 deletion test/e2e/cypress/e2e/activity_log.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const LAST = /^>>$/;

context('Activity Log page', () => {
before(() => {
cy.loadScenario('healthy-27-node-SAP-cluster');
// cy.loadScenario('healthy-27-node-SAP-cluster');
});

describe('Navigation', () => {
Expand Down Expand Up @@ -129,6 +129,25 @@ context('Activity Log page', () => {

cy.wait('@data').its('response.statusCode').should('eq', 200);
});

it('should refresh content based on currently applied filters', () => {
const apiUrl =
'/api/v1/activity_log?first=20&from_date=2024-08-14T10:21:00.000Z&to_date=2024-08-13T10:21:00.000Z&type[]=login_attempt&type[]=resource_tagging';
const pageUrl =
'/activity_log?from_date=custom&from_date=2024-08-14T10%3A21%3A00.000Z&to_date=custom&to_date=2024-08-13T10%3A21%3A00.000Z&type=login_attempt&type=resource_tagging';

cy.intercept({ url: apiUrl }).as('initialDataLoad');

cy.visit(pageUrl);

cy.wait('@initialDataLoad');

cy.intercept({ url: apiUrl }).as('refreshedDataLoad');
cy.contains('Refresh').click();
cy.wait('@refreshedDataLoad');

cy.url().should('eq', `${Cypress.config().baseUrl}${pageUrl}`);
});
});

describe('Pagination', () => {
Expand Down
Loading