-
-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve management section placeholders (#5156)
* Use explore projects placeholder for mgmt projects * Add teams placeholder in manage landing page * Add placeholder for organisations * Add placeholder for teams tab * Add campaigns placeholder * Add placeholder for categories tab * Add placeholder for users tab * Add placeholder for licenses tab * Show manage title when organization list is loading * Display placeholder when API is being fetched * Update test cases
- Loading branch information
1 parent
8a74ba6
commit f3f1b69
Showing
26 changed files
with
730 additions
and
194 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
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,63 @@ | ||
import { render, screen, waitFor } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
import { IntlProviders } from '../../../utils/testWithIntl'; | ||
import { InterestsManagement } from '../index'; | ||
|
||
const dummyInterests = [ | ||
{ | ||
id: 1, | ||
name: 'Interest 1', | ||
}, | ||
{ | ||
id: 2, | ||
name: 'Interest 2', | ||
}, | ||
]; | ||
|
||
describe('InterestsManagement component', () => { | ||
it('renders loading placeholder when API is being fetched', () => { | ||
const { container, getByRole } = render( | ||
<IntlProviders> | ||
<InterestsManagement isInterestsFetched={false} /> | ||
</IntlProviders>, | ||
); | ||
expect( | ||
screen.getByRole('heading', { | ||
name: /manage categories/i, | ||
}), | ||
).toBeInTheDocument(); | ||
expect(container.getElementsByClassName('show-loading-animation')).toHaveLength(4); | ||
expect( | ||
getByRole('button', { | ||
name: /new/i, | ||
}), | ||
).toBeInTheDocument(); | ||
}); | ||
|
||
it('does not render loading placeholder after API is fetched', () => { | ||
const { container } = render( | ||
<IntlProviders> | ||
<InterestsManagement isInterestsFetched={true} /> | ||
</IntlProviders>, | ||
); | ||
expect(container.getElementsByClassName('show-loading-animation')).toHaveLength(0); | ||
}); | ||
|
||
it('renders interests list card after API is fetched', async () => { | ||
const { container, getByText } = render( | ||
<IntlProviders> | ||
<InterestsManagement interests={dummyInterests} isInterestsFetched={true} /> | ||
</IntlProviders>, | ||
); | ||
expect( | ||
screen.getByRole('heading', { | ||
name: /manage categories/i, | ||
}), | ||
).toBeInTheDocument(); | ||
await waitFor(() => { | ||
expect(getByText(/Interest 1/i)); | ||
}); | ||
expect(getByText(/Interest 2/i)).toBeInTheDocument(); | ||
expect(container.querySelectorAll('svg').length).toBe(3); | ||
}); | ||
}); |
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,27 @@ | ||
import React from 'react'; | ||
import { TextRow } from 'react-placeholder/lib/placeholders'; | ||
import { CopyrightIcon } from '../svgIcons'; | ||
|
||
export const licenseCardPlaceholderTemplate = () => (_n, i) => | ||
( | ||
<div className="w-50-ns w-100 fl pr3" key={i}> | ||
<div className="cf bg-white blue-dark br1 mv2 pv4 ph3 ba br1 b--grey-light shadow-hover"> | ||
<div className="dib v-mid pr3"> | ||
<div className="z-1 fl br-100 tc h2 w2 bg-blue-light white"> | ||
<span className="relative w-50 dib"> | ||
<CopyrightIcon style={{ paddingTop: '0.475rem' }} /> | ||
</span> | ||
</div> | ||
</div> | ||
<TextRow | ||
className="show-loading-animation f3 mv0 dib v-mid" | ||
color="#CCC" | ||
style={{ width: '55%', marginTop: 0 }} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
|
||
export const nCardPlaceholders = (N) => { | ||
return [...Array(N).keys()].map(licenseCardPlaceholderTemplate()); | ||
}; |
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
27 changes: 27 additions & 0 deletions
27
frontend/src/components/teamsAndOrgs/campaignsPlaceholder.js
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,27 @@ | ||
import React from 'react'; | ||
import { TextRow } from 'react-placeholder/lib/placeholders'; | ||
import { HashtagIcon } from '../svgIcons'; | ||
|
||
export const campaignCardPlaceholderTemplate = () => (_n, i) => | ||
( | ||
<div className="w-50-ns w-100 fl pr3" key={i}> | ||
<div className="cf bg-white blue-dark br1 mv2 pv4 ph3 ba br1 b--grey-light shadow-hover"> | ||
<div className="dib v-mid pr3"> | ||
<div className="z-1 fl br-100 tc h2 w2 bg-blue-light white"> | ||
<span className="relative w-50 dib"> | ||
<HashtagIcon style={{ paddingTop: '0.4175rem' }} /> | ||
</span> | ||
</div> | ||
</div> | ||
<TextRow | ||
className="show-loading-animation f3 mv0 dib v-mid" | ||
color="#CCC" | ||
style={{ width: '55%', marginTop: 0 }} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
|
||
export const nCardPlaceholders = (N) => { | ||
return [...Array(N).keys()].map(campaignCardPlaceholderTemplate()); | ||
}; |
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
35 changes: 35 additions & 0 deletions
35
frontend/src/components/teamsAndOrgs/organisationsPlaceholder.js
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 @@ | ||
import React from 'react'; | ||
import { TextRow, RoundShape, RectShape } from 'react-placeholder/lib/placeholders'; | ||
|
||
export const organisationCardPlaceholderTemplate = () => (_n, i) => | ||
( | ||
<div className="w-50-l w-100 fl pr3" key={i}> | ||
<div className="bg-white blue-dark mv2 pb4 dib w-100 ba br1 b--grey-light shadow-hover"> | ||
<div className="w-25 h4 fl pa3"> | ||
<RectShape | ||
className="show-loading-animation" | ||
style={{ width: '100%', height: 100 }} | ||
color="#DDD" | ||
/> | ||
</div> | ||
<div className="w-75 fl pl3"> | ||
<TextRow className="show-loading-animation mb4" color="#CCC" style={{ width: '50%' }} /> | ||
<TextRow className="show-loading-animation mb2" color="#CCC" style={{ width: '50%' }} /> | ||
<div className="dib"> | ||
{[...Array(2)].map((_, i) => ( | ||
<RoundShape | ||
key={i} | ||
className="show-loading-animation dib mt1" | ||
style={{ width: 25, height: 25 }} | ||
color="#DDD" | ||
/> | ||
))} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
|
||
export const nCardPlaceholders = (N) => { | ||
return [...Array(N).keys()].map(organisationCardPlaceholderTemplate()); | ||
}; |
Oops, something went wrong.