Skip to content

Commit

Permalink
Introduction de l'indicateur de PR depuis #482
Browse files Browse the repository at this point in the history
  • Loading branch information
laem committed Aug 22, 2022
1 parent 68981c4 commit bdc461f
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 6 deletions.
2 changes: 1 addition & 1 deletion source/RulesProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ const removeLoader = () => {

export default ({ children }) => {
const branchData = useBranchData()
console.log('BD', branchData)
const rules = useSelector((state) => state.rules)

const dispatch = useDispatch()

const setRules = (rules) => dispatch({ type: 'SET_RULES', rules })

useEffect(() => {
if (!branchData.loaded) return
if (NODE_ENV === 'development' && branchData.shouldUseLocalFiles) {
// Rules are stored in nested yaml files
const req = require.context(
Expand Down
38 changes: 36 additions & 2 deletions source/components/SessionBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { backgroundConferenceAnimation } from '../sites/publicodes/conference/co
import SurveyBarLazy from '../sites/publicodes/conference/SurveyBarLazy'
import ProgressCircle from './ProgressCircle'
import CardGameIcon from './CardGameIcon'
import { usePersistingState } from './utils/persistState'

const ActionsInteractiveIcon = () => {
const actionChoices = useSelector((state) => state.actionChoices),
Expand All @@ -30,6 +31,7 @@ const openmojis = {
sondage: '1F4CA',
profile: '1F464',
personas: '1F465',
github: 'E045',
}
export const openmojiURL = (name) => `/images/${openmojis[name]}.svg`
export const actionImg = openmojiURL('action')
Expand All @@ -50,8 +52,8 @@ const MenuButton = styled.div`
padding: 0;
font-size: 100%;
}
> img,
> svg {
img,
svg {
display: block;
font-size: 200%;
margin: 0.6rem !important;
Expand Down Expand Up @@ -148,6 +150,10 @@ export default function SessionBar({
`
: ''
const persona = useSelector((state) => state.simulation?.persona)
const [pullRequestNumber, setPullRequestNumber] = usePersistingState(
'PR',
undefined
)

let elements = [
<Button
Expand Down Expand Up @@ -207,6 +213,34 @@ export default function SessionBar({
Personas
</Button>
),
pullRequestNumber && (
<MenuButton
key="pullRequest"
className="simple small"
css={buttonStyle('github')}
>
<a
href={
'https://github.com/datagir/nosgestesclimat/pull/' +
pullRequestNumber
}
css={`
display: flex;
align-items: center;
`}
>
<img
src={openmojiURL('github')}
css="width: 2rem"
aria-hidden="true"
/>
#{pullRequestNumber}
</a>
<button onClick={() => setPullRequestNumber(null)}>
<img css="width: 1.2rem" src="/images/close-plain.svg" />
</button>
</MenuButton>
),
conference?.room && (
<GroupModeMenuEntry
title="Conférence"
Expand Down
15 changes: 12 additions & 3 deletions source/components/useBranchData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@ export default () => {

const [pullRequestNumber, setPullRequestNumber] = usePersistingState(
'PR',
null
undefined
)

const searchPR = urlParams.get('PR')

useEffect(() => setPullRequestNumber(searchPR), [searchPR])
useEffect(() => {
if (searchPR != null)
// setting should be triggered by an explicit ?PR=, not the absence of it when navigating
setPullRequestNumber(searchPR)
}, [searchPR])

const deployURL = `https://${
branch
Expand All @@ -26,5 +30,10 @@ export default () => {

const shouldUseLocalFiles = !(branch || pullRequestNumber)

return { deployURL, branch, pullRequestNumber, shouldUseLocalFiles }
return {
deployURL,
pullRequestNumber,
shouldUseLocalFiles,
loaded: pullRequestNumber !== undefined,
}
}
1 change: 1 addition & 0 deletions source/components/useFetchDocumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export default () => {
const branchData = useBranchData()

useEffect(() => {
if (!branchData.loaded) return
if (NODE_ENV === 'development' && branchData.shouldUseLocalFiles) {
const req = require.context(
'raw-loader!../../../nosgestesclimat/documentation/',
Expand Down
12 changes: 12 additions & 0 deletions source/images/E045.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions source/sites/publicodes/Personas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export const PersonaGrid = ({
const branchData = useBranchData()

useEffect(() => {
if (!branchData.loaded) return
if (NODE_ENV === 'development' && branchData.shouldUseLocalFiles) {
const personas =
require('../../../../nosgestesclimat/personas.yaml').default
Expand Down

0 comments on commit bdc461f

Please sign in to comment.