Skip to content

Commit

Permalink
(PC-33066) feat(Achievements): hide locked badge title (#7275)
Browse files Browse the repository at this point in the history
* Achievement name is Badge non délboqué when not completed

* Refacto

* Use badge name from useAchievements

* Add test for remainingAchievementsText

* Refacto

* Refacto tests

* Refacto

* Add tests for sorting

* Refacto

* Refacto

* Remove achievement name in modal when achievement is not completed

* Update snapshot

* Remove description and update snapshot

* Update snapshot
  • Loading branch information
fcarre-pass committed Nov 28, 2024
1 parent 7144094 commit acce87e
Show file tree
Hide file tree
Showing 11 changed files with 437 additions and 242 deletions.
Empty file added .actrc
Empty file.
18 changes: 18 additions & 0 deletions .github/workflows/on_push_pr_preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: "1 [on_push] Deploy PR version to Firebase for"

on:
push:
branches:
- ops/prs-preview

jobs:
deploy_on_firebase:
name: Deploy PR version to Firebase
uses: ./.github/workflows/on_workflow_pr_preview.yml
with:
ENV: "testing"
PUSH_RELEASE_TO_SENTRY: false
CHANNEL: "preview"
EXPIRES: "2d"
REF: "refs/heads/ops/prs-preview"
CACHE_BUCKET_NAME: "passculture-metier-ehp"
107 changes: 107 additions & 0 deletions .github/workflows/on_workflow_pr_preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: "2 [on_workflow/PR] Deploy PR version for validation"

on:
workflow_call:
inputs:
ENV:
type: string
required: true
PUSH_RELEASE_TO_SENTRY:
description: "If true, creates a release in Sentry and uploads sourcemaps"
type: boolean
default: false
CHANNEL:
type: string
required: true
EXPIRES:
type: string
default: "2d"
REF:
type: string
required: true
CACHE_BUCKET_NAME:
type: string
required: true
# secrets:
# GCP_EHP_SERVICE_ACCOUNT:
# required: true
# GCP_EHP_WORKLOAD_IDENTITY_PROVIDER:
# required: true

defaults:
run:
working-directory: '.'

jobs:
deploy_on_firebase:
runs-on: ubuntu-22.04
if: ${{ github.actor != 'dependabot[bot]' }}
steps:
- uses: actions/[email protected]
with:
ref: ${{ inputs.REF }}
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- name: "OpenID Connect Authentication"
if: ${{ !github.event.act }}
id: "openid-auth"
uses: "google-github-actions/auth@v2"
with:
workload_identity_provider: ${{ secrets.GCP_EHP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_EHP_SERVICE_ACCOUNT }}
- name: "Get Secret"
# if: ${{ !github.event.act }}
id: "secrets"
uses: "google-github-actions/get-secretmanager-secrets@v2"
with:
secrets: |-
FIREBASE_TOKEN:passculture-metier-ehp/pc_native_${{ inputs.ENV }}_firebase_json
# SENTRY_TOKEN:passculture-metier-ehp/passculture-app-native-sentry-token
- name: "Cache the node_modules"
if: ${{ !github.event.act }}
id: "yarn-modules-cache"
uses: pass-culture-github-actions/[email protected]
with:
compression-method: "gzip"
bucket: ${{ inputs.CACHE_BUCKET_NAME }}
path: |
**/node_modules
key: v1-yarn-pro-dependency-cache-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
v1-yarn-pro-dependency-cache-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
- run: yarn install --immutable
- run: yarn build:${{ inputs.ENV }}
env:
# By default NodeJS processes are limited to 512MB of memory
# This is not enough for the build process when compiling sourcemaps
# Increases the limit so that the build doesnt fail
NODE_OPTIONS: --max_old_space_size=4096
- if: inputs.ENV != 'testing'
run: |
cat package.json | grep -E '"version": "[0-9]+.[0-9]+.[0-9]+"' | grep -Eo '[0-9]+.[0-9]+.[0-9]+' > build/version.txt
- name: "Create Sentry release"
if: ${{ (inputs.PUSH_RELEASE_TO_SENTRY) && (!github.event.act) }}
uses: getsentry/action-release@v1
env:
SENTRY_AUTH_TOKEN: ${{ steps.secrets.outputs.SENTRY_TOKEN }}
SENTRY_ORG: sentry
SENTRY_PROJECT: pro
SENTRY_URL: https://sentry.passculture.team/
with:
sourcemaps: ./build
working_directory: .
version: ${{ inputs.CHANNEL }}
url_prefix: "~"
- uses: FirebaseExtended/action-hosting-deploy@v0
id: firebase-deploy
with:
repoToken: "${{ secrets.GITHUB_TOKEN }}"
firebaseServiceAccount: ${{ steps.secrets.outputs.FIREBASE_TOKEN }}
expires: ${{ inputs.EXPIRES }}
projectId: pc-native-${{ inputs.ENV }}
entryPoint: native
channelId: ${{ inputs.CHANNEL }}
- name: "Firebase Deployment URL"
run: |
echo "::notice:: Firebase deployment is available at : ${{ steps.firebase-deploy.outputs.details_url }}"
17 changes: 17 additions & 0 deletions ACT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# ACT

## Requirements

- act
- github cli
- podman

### Podman configuration

```shell
podman machine init --cpus 4 --memory 8192 --now gha-act
```

## Local testing

act -W .github/workflows/pr.yml -P ubuntu-22.04=catthehacker/ubuntu:full-22.04 -s GITHUB_TOKEN="$(gh auth token)" --eventpath act/event.json --env-file .env.testing
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,6 @@ exports[`<Achievements/> should match snapshot 1`] = `
data={
[
{
"description": "Réserve ta première place de cinéma",
"id": "FIRST_MOVIE_BOOKING",
"illustration": {
"$$typeof": Symbol(react.forward_ref),
Expand All @@ -405,7 +404,6 @@ exports[`<Achievements/> should match snapshot 1`] = `
"name": "Cinéphile en herbe",
},
{
"description": "Tu as réservé ton premier livre",
"id": "FIRST_BOOK_BOOKING",
"illustration": {
"$$typeof": Symbol(react.forward_ref),
Expand All @@ -427,7 +425,6 @@ exports[`<Achievements/> should match snapshot 1`] = `
"name": "Rat de bibliothèque",
},
{
"description": "Tu as réservé ton premier atelier ou cours artistique",
"id": "FIRST_ART_LESSON_BOOKING",
"illustration": {
"$$typeof": Symbol(react.forward_ref),
Expand All @@ -449,8 +446,7 @@ exports[`<Achievements/> should match snapshot 1`] = `
"name": "Se mettre à la pratique",
},
{
"description": "Réserve du matériel créatif",
"id": "FIRST_INSTRUMENT_BOOKING",
"id": "FIRST_RECORDED_MUSIC_BOOKING",
"illustration": {
"$$typeof": Symbol(react.forward_ref),
"attrs": [
Expand All @@ -468,11 +464,10 @@ exports[`<Achievements/> should match snapshot 1`] = `
"withComponent": [Function],
},
"isCompleted": false,
"name": "Artiste en devenir",
"name": "Badge non débloqué",
},
{
"description": "Réserve ta première visite",
"id": "FIRST_MUSEUM_BOOKING",
"id": "FIRST_SHOW_BOOKING",
"illustration": {
"$$typeof": Symbol(react.forward_ref),
"attrs": [
Expand All @@ -490,11 +485,10 @@ exports[`<Achievements/> should match snapshot 1`] = `
"withComponent": [Function],
},
"isCompleted": false,
"name": "Explorateur culturel",
"name": "Badge non débloqué",
},
{
"description": "Abonne-toi à un média",
"id": "FIRST_NEWS_BOOKING",
"id": "FIRST_MUSEUM_BOOKING",
"illustration": {
"$$typeof": Symbol(react.forward_ref),
"attrs": [
Expand All @@ -512,10 +506,9 @@ exports[`<Achievements/> should match snapshot 1`] = `
"withComponent": [Function],
},
"isCompleted": false,
"name": "Futur Hugo Décrypte",
"name": "Badge non débloqué",
},
{
"description": "Réserve ton premier concert ou festival",
"id": "FIRST_LIVE_MUSIC_BOOKING",
"illustration": {
"$$typeof": Symbol(react.forward_ref),
Expand All @@ -534,11 +527,10 @@ exports[`<Achievements/> should match snapshot 1`] = `
"withComponent": [Function],
},
"isCompleted": false,
"name": "Premier Beat",
"name": "Badge non débloqué",
},
{
"description": "Réserve ton premier CD ou vinyle",
"id": "FIRST_RECORDED_MUSIC_BOOKING",
"id": "FIRST_NEWS_BOOKING",
"illustration": {
"$$typeof": Symbol(react.forward_ref),
"attrs": [
Expand All @@ -556,11 +548,10 @@ exports[`<Achievements/> should match snapshot 1`] = `
"withComponent": [Function],
},
"isCompleted": false,
"name": "Premier tour de platine",
"name": "Badge non débloqué",
},
{
"description": "Réserve ton premier spectacle",
"id": "FIRST_SHOW_BOOKING",
"id": "FIRST_INSTRUMENT_BOOKING",
"illustration": {
"$$typeof": Symbol(react.forward_ref),
"attrs": [
Expand All @@ -578,7 +569,7 @@ exports[`<Achievements/> should match snapshot 1`] = `
"withComponent": [Function],
},
"isCompleted": false,
"name": "Rideau rouge levé",
"name": "Badge non débloqué",
},
{
"description": "",
Expand Down Expand Up @@ -1112,7 +1103,7 @@ exports[`<Achievements/> should match snapshot 1`] = `
]
}
>
Artiste en devenir
Badge non débloqué
</Text>
</View>
</View>
Expand Down Expand Up @@ -1248,7 +1239,7 @@ exports[`<Achievements/> should match snapshot 1`] = `
]
}
>
Explorateur culturel
Badge non débloqué
</Text>
</View>
</View>
Expand Down Expand Up @@ -1365,7 +1356,7 @@ exports[`<Achievements/> should match snapshot 1`] = `
]
}
>
Futur Hugo Décrypte
Badge non débloqué
</Text>
</View>
</View>
Expand Down Expand Up @@ -1501,7 +1492,7 @@ exports[`<Achievements/> should match snapshot 1`] = `
]
}
>
Premier Beat
Badge non débloqué
</Text>
</View>
</View>
Expand Down Expand Up @@ -1618,7 +1609,7 @@ exports[`<Achievements/> should match snapshot 1`] = `
]
}
>
Premier tour de platine
Badge non débloqué
</Text>
</View>
</View>
Expand Down Expand Up @@ -1754,7 +1745,7 @@ exports[`<Achievements/> should match snapshot 1`] = `
]
}
>
Rideau rouge levé
Badge non débloqué
</Text>
</View>
</View>
Expand Down
9 changes: 9 additions & 0 deletions act/event.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"act":true,
"inputs":{
"ENV":"testing",
"PUSH_RELEASE_TO_SENTRY":"false",
"CHANNEL":"pr-testing-foo",
"REF":"master"
}
}
7 changes: 3 additions & 4 deletions src/features/profile/components/Achievements/Badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, { FC } from 'react'
import styled, { useTheme } from 'styled-components/native'

import { AchievementDetailsModal } from 'features/profile/components/Modals/AchievementDetailsModal'
import { useAchievementDetails } from 'features/profile/components/Modals/useAchievementDetails'
import { AchievementId } from 'features/profile/pages/Achievements/AchievementData'
import { useModal } from 'ui/components/modals/useModal'
import { TouchableOpacity } from 'ui/components/TouchableOpacity'
Expand All @@ -12,11 +11,11 @@ import { Spacer, TypoDS, getSpacing } from 'ui/theme'
type BadgeProps = {
id: AchievementId
Illustration: React.FC<AccessibleIcon>
name: string
isCompleted?: boolean
}

export const Badge: FC<BadgeProps> = ({ Illustration, id, isCompleted }) => {
const achievement = useAchievementDetails(id)
export const Badge: FC<BadgeProps> = ({ Illustration, id, name, isCompleted }) => {
const { visible, showModal, hideModal } = useModal(false)
const theme = useTheme()

Expand All @@ -29,7 +28,7 @@ export const Badge: FC<BadgeProps> = ({ Illustration, id, isCompleted }) => {
</IllustrationContainer>
<Spacer.Column numberOfSpaces={2} />
<TypoBadgeName numberOfLines={2} isCompleted={!!isCompleted}>
{achievement?.name}
{name}
</TypoBadgeName>
</BadgeContainer>
</StyledTouchableOpacity>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,12 @@ export const AchievementDetailsModal = ({ visible, hideModal, id }: Props) => {
)}
</BodyWrapper>
<Spacer.Column numberOfSpaces={4} />
<TypoDS.Title3>{achievement.name}</TypoDS.Title3>
<Spacer.Column numberOfSpaces={4} />
{achievement.completed ? (
<React.Fragment>
<TypoDS.Title3>{achievement.name}</TypoDS.Title3>
<Spacer.Column numberOfSpaces={4} />
</React.Fragment>
) : null}
<StyledDescrption>
{achievement.completed ? achievement.descriptionUnlocked : achievement.descriptionLocked}
</StyledDescrption>
Expand Down
Loading

0 comments on commit acce87e

Please sign in to comment.