Skip to content

Commit 686e435

Browse files
committed
feat: update link for subscription flag
1 parent e24cba5 commit 686e435

File tree

4 files changed

+59
-10
lines changed

4 files changed

+59
-10
lines changed

src/components/Bar.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ export class Bar extends Component {
136136

137137
renderRight = () => {
138138
const { isPublic } = this.props
139-
return !isPublic ? <Settings onLogOut={this.props.onLogOut} /> : null
139+
return !isPublic ? (
140+
<Settings client={this.props.cozyClient} onLogOut={this.props.onLogOut} />
141+
) : null
140142
}
141143

142144
render() {

src/components/Settings/index.jsx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ import get from 'lodash/get'
55

66
import { translate } from 'cozy-ui/react/I18n'
77
import { Button } from 'cozy-ui/react/Button'
8-
import { queryConnect } from 'cozy-client/dist'
8+
import { queryConnect, generateWebLink } from 'cozy-client/dist'
99
import { models } from 'cozy-client'
10+
import flag from 'cozy-flags'
11+
1012
let instanceModel = undefined
1113
let hasAnOffer = undefined
1214
let isFremiumFixed = undefined
@@ -92,7 +94,8 @@ export class Settings extends Component {
9294
contextQuery,
9395
storageData,
9496
settingsAppURL,
95-
isFetching
97+
isFetching,
98+
client
9699
} = this.props
97100

98101
let shouldDisplayViewOfferButton = false
@@ -114,7 +117,21 @@ export class Settings extends Component {
114117
shouldDisplayViewOfferButton =
115118
instanceModel.shouldDisplayOffers(data) || hasAnOffer(data)
116119

117-
managerUrlPremiumLink = instanceModel.buildPremiumLink(data)
120+
const hasSubscription = flag('settings.subscription')
121+
122+
if (hasSubscription && client) {
123+
const webLink = generateWebLink({
124+
cozyUrl: client.getStackClient().uri,
125+
hash: '/subscription',
126+
pathname: '/',
127+
slug: 'settings',
128+
subDomainType: client.getInstanceOptions().subdomain
129+
})
130+
131+
managerUrlPremiumLink = webLink
132+
} else {
133+
managerUrlPremiumLink = instanceModel.buildPremiumLink(data)
134+
}
118135
}
119136
}
120137

src/components/__snapshots__/Bar.spec.jsx.snap

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,13 @@ exports[`Bar should change allow theme overrides 1`] = `
3838
<div
3939
className="u-flex-grow"
4040
/>
41-
<Wrapper />
41+
<Wrapper
42+
client={
43+
CozyClient {
44+
"uri": undefined,
45+
}
46+
}
47+
/>
4248
<Connect(Drawer)
4349
drawerListener={[Function]}
4450
onClose={[Function]}
@@ -82,7 +88,13 @@ exports[`Bar should change theme 1`] = `
8288
<div
8389
className="u-flex-grow"
8490
/>
85-
<Wrapper />
91+
<Wrapper
92+
client={
93+
CozyClient {
94+
"uri": undefined,
95+
}
96+
}
97+
/>
8698
<Connect(Drawer)
8799
drawerListener={[Function]}
88100
onClose={[Function]}
@@ -136,7 +148,13 @@ exports[`Bar should display the Searchbar 1`] = `
136148
}
137149
/>
138150
</div>
139-
<Wrapper />
151+
<Wrapper
152+
client={
153+
CozyClient {
154+
"uri": undefined,
155+
}
156+
}
157+
/>
140158
<Connect(Drawer)
141159
drawerListener={[Function]}
142160
onClose={[Function]}
@@ -225,7 +243,13 @@ exports[`Bar should not display searchbar if we are not on Cozy Drive 1`] = `
225243
<div
226244
className="u-flex-grow"
227245
/>
228-
<Wrapper />
246+
<Wrapper
247+
client={
248+
CozyClient {
249+
"uri": undefined,
250+
}
251+
}
252+
/>
229253
<Connect(Drawer)
230254
drawerListener={[Function]}
231255
onClose={[Function]}
@@ -271,7 +295,13 @@ exports[`Bar should not display searchbar if we are on mobile 1`] = `
271295
<div
272296
className="u-flex-grow"
273297
/>
274-
<Wrapper />
298+
<Wrapper
299+
client={
300+
CozyClient {
301+
"uri": undefined,
302+
}
303+
}
304+
/>
275305
<Connect(Drawer)
276306
drawerListener={[Function]}
277307
onClose={[Function]}

src/locales/fr.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"drawer": "Afficher le menu latéral",
33
"profile": "Profil",
4-
"plans": "Forfait",
4+
"plans": "Offres et options",
55
"permissions": "Permissions",
66
"connectedDevices": "Appareils connectés",
77
"connections": "Connexions",

0 commit comments

Comments
 (0)