-
Notifications
You must be signed in to change notification settings - Fork 33
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
Tan 3487/screening status filter item #9994
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
70202d1
ScreeningStatusFilterItem init
brentguf 6838c7f
Rename to ScreeningStatusFilter
brentguf 91a53bb
Merge branch 'TAN-3486/rename-components' of https://github.com/Citiz…
brentguf 11939bd
Merge branch 'master' of https://github.com/CitizenLabDotCo/citizenla…
brentguf 798ccf9
Use separate component for screening status filter
brentguf f4c0448
Remove redundant code check
brentguf 01fec64
Merge branch 'master' of https://github.com/CitizenLabDotCo/citizenla…
brentguf 3137615
Prescreening status is always automated
brentguf 14b205f
You can never drop into the prescreening status
brentguf f2958ad
Remove typecasting
brentguf 29fc9df
Ensure filter takes full width
brentguf 0cac7f5
Merge pull request #10031 from CitizenLabDotCo/TAN-3487/review
brentguf 6564aaf
Merge branch 'master' of https://github.com/CitizenLabDotCo/citizenla…
brentguf d462f45
Comment on automatic statuses behavior
brentguf f8833d6
Remove unnecessary Box wrapping
brentguf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
107 changes: 107 additions & 0 deletions
107
.../components/admin/PostManager/components/FilterSidebar/statuses/ScreeningStatusFilter.tsx
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,107 @@ | ||
import React from 'react'; | ||
|
||
import { IconTooltip, Box, Tooltip } from '@citizenlab/cl2-component-library'; | ||
import ColorIndicator from 'component-library/components/ColorIndicator'; | ||
import { useParams } from 'react-router-dom'; | ||
import styled from 'styled-components'; | ||
|
||
import { IIdeaStatusData } from 'api/idea_statuses/types'; | ||
import usePhase from 'api/phases/usePhase'; | ||
|
||
import useFeatureFlag from 'hooks/useFeatureFlag'; | ||
|
||
import T from 'components/T'; | ||
|
||
import { FormattedMessage } from 'utils/cl-intl'; | ||
|
||
import messages from '../../../messages'; | ||
|
||
import StatusButton from './StatusButton'; | ||
|
||
const StatusText = styled.div` | ||
&:first-letter { | ||
text-transform: uppercase; | ||
} | ||
`; | ||
|
||
interface Props { | ||
status: IIdeaStatusData; | ||
active: boolean; | ||
onClick: () => void; | ||
} | ||
|
||
const ScreeningStatusFilter = ({ status, active, onClick }: Props) => { | ||
const { phaseId } = useParams(); | ||
const { data: phase } = usePhase(phaseId); | ||
|
||
const preScreeningFeatureFlag = | ||
phase?.data.attributes.participation_method === 'ideation' | ||
? 'prescreening_ideation' | ||
: 'prescreening'; | ||
|
||
const preScreeningFeatureAllowed = useFeatureFlag({ | ||
name: preScreeningFeatureFlag, | ||
onlyCheckAllowed: true, | ||
}); | ||
const phasePrescreeningEnabled = | ||
phase?.data.attributes.prescreening_enabled === true; | ||
|
||
const prescreeningButtonIsDisabled = | ||
!phasePrescreeningEnabled || !preScreeningFeatureAllowed; | ||
|
||
const prescreeningTooltipIsDisabled = | ||
phasePrescreeningEnabled && preScreeningFeatureAllowed; | ||
Comment on lines
+49
to
+53
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've removed the status code checks here since we know code is always |
||
|
||
return ( | ||
// Div wrapping is needed to make the filter take full width. | ||
<div> | ||
<Tooltip | ||
content={ | ||
<div> | ||
{!preScreeningFeatureAllowed ? ( | ||
<FormattedMessage {...messages.prescreeningTooltipUpsell} /> | ||
) : ( | ||
<FormattedMessage | ||
{...messages.prescreeningTooltipPhaseDisabled} | ||
/> | ||
)} | ||
</div> | ||
} | ||
disabled={prescreeningTooltipIsDisabled} | ||
> | ||
<Box> | ||
<StatusButton | ||
onClick={onClick} | ||
active={active} | ||
disabled={prescreeningButtonIsDisabled} | ||
> | ||
<Box | ||
display="flex" | ||
alignItems="center" | ||
justifyContent="flex-start" | ||
w="100%" | ||
> | ||
<ColorIndicator bgColor={status.attributes.color} /> | ||
<Box display="flex" alignItems="center" gap="4px"> | ||
<StatusText> | ||
<T value={status.attributes.title_multiloc} /> | ||
</StatusText> | ||
<IconTooltip | ||
theme="light" | ||
iconSize="16px" | ||
content={ | ||
<FormattedMessage | ||
{...messages.automatedStatusTooltipText} | ||
/> | ||
} | ||
/> | ||
</Box> | ||
</Box> | ||
</StatusButton> | ||
</Box> | ||
</Tooltip> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ScreeningStatusFilter; |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the original StatusFilter with all the prescreening status related code that I'd like to separate from all other status filters. Only changes where indicated. :)