Skip to content

Commit

Permalink
feat: Remove deprecated slug prop from AppLinker
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Use app={{ slug: 'drive' }} instead of slug='drive' as
AppLinker prop. Also, `name` is not passed anymore as render prop.
  • Loading branch information
zatteo committed Jan 7, 2025
1 parent b5d21f4 commit 674f4ed
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 132 deletions.
34 changes: 3 additions & 31 deletions react/AppLinker/Readme.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
Render-props component that provides onClick/href handler to
apply to an anchor that needs to open an app.

If the app is known to Cozy (for example Drive or Banks), and
the user has installed it on its device, the native app will
be opened.

The app's manifest can be set in the `app` prop. Then, in a
ReactNative environment, the AppLinker will be able to send
`openApp` message to the native environment with this `app`
data. Ideally the `mobile` member should be set with all data
needed to open the native app ([more info](https://github.com/cozy/cozy-stack/blob/master/docs/apps.md#mobile))
data.

Handles several cases:

Expand All @@ -28,32 +23,9 @@ const app = {
};

<AppLinker app={app} href='http://dalailama-banks.mycozy.cloud'>{
({ onClick, href, name }) => (
<a href={href} onClick={onClick}>
Open { name }
</a>
)
}</AppLinker>
```

### Exemple with mobile data

```jsx
import AppLinker from 'cozy-ui/transpiled/react/AppLinker';

const app = {
slug: 'passwords',
mobile: {
schema: 'cozypass://',
id_playstore: 'io.cozy.pass',
id_appstore: 'cozy-pass/id1502262449'
}
};

<AppLinker app={app} href='http://dalailama-passwords.mycozy.cloud'>{
({ onClick, href, name }) => (
({ onClick, href }) => (
<a href={href} onClick={onClick}>
Open { name }
Open
</a>
)
}</AppLinker>
Expand Down
13 changes: 0 additions & 13 deletions react/AppLinker/__snapshots__/index.deprecated.spec.jsx.snap

This file was deleted.

71 changes: 0 additions & 71 deletions react/AppLinker/index.deprecated.spec.jsx

This file was deleted.

18 changes: 1 addition & 17 deletions react/AppLinker/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,7 @@ export class AppLinker extends React.Component {
}

static getSlug(props) {
if (props.app && props.app.slug) {
return props.app.slug
}

return props.slug
}

static deprecateSlug(props) {
if (props.slug) {
console.warn(
`AppLinker's 'slug' prop is deprecated, please use 'app.slug' instead`
)
}
return props.app.slug
}

static getOnClickHref(props, context, imgRef) {
Expand Down Expand Up @@ -95,8 +83,6 @@ export class AppLinker extends React.Component {
render() {
const { children } = this.props

AppLinker.deprecateSlug(this.props)

const { href, onClick } = AppLinker.getOnClickHref(
this.props,
this.context,
Expand All @@ -112,8 +98,6 @@ export class AppLinker extends React.Component {
}

AppLinker.propTypes = {
/** DEPRECATED: please use app.slug prop */
slug: PropTypes.string,
/*
Full web url : Used by default on desktop browser
Used as a fallback_uri on mobile web
Expand Down

0 comments on commit 674f4ed

Please sign in to comment.