Skip to content
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

Feat/remove ccjs #1991

Merged
merged 43 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
6f3ae0d
fix: Use Cozy-Client store for KonnectorTile
Crash-- Jul 18, 2023
2dc899e
refactor: Remove redux-cozy-client
Crash-- Aug 17, 2023
0c648a7
fix: Tmp commit since there is a bug in the stack
Crash-- Aug 18, 2023
5a6e511
feat: Remove old cozy-client-js stuff
Crash-- Aug 18, 2023
2574c5d
refactor: Usequery() instead of relying on the store directly
Crash-- Aug 18, 2023
9f4ea7e
refactor: Use reselect + useSelector instead of mapStateToProps
Crash-- Aug 18, 2023
04341fe
refactor: Rely on realtime instead of redux action
Crash-- Aug 21, 2023
c8c6f98
refactor: Convert IntentSErvice to functionnal component
Crash-- Aug 21, 2023
4f27dca
refactor: Use cozy-intent instead of cozy-client-js
Crash-- Aug 17, 2023
12217f6
refactor: Use Harvest
Crash-- Aug 21, 2023
12774c6
refactor: Use triggers from appEntry and don't make the request twice
Crash-- Aug 21, 2023
5a1f9fb
refactor: No need of konnector middleware
Crash-- Aug 21, 2023
9254b02
refactor: Use Realtime queries
Crash-- Aug 21, 2023
b9eacee
reactor: Remove unuseud function
Crash-- Aug 21, 2023
d5b962e
refactore: Remove files
Crash-- Aug 21, 2023
aed79c7
refactor: Remove CSS style
Crash-- Aug 28, 2023
ff2c3f7
fix: Intent can be dismissed
Crash-- Aug 28, 2023
dd47719
tests: Remove deleted test
Crash-- Sep 18, 2023
b794ba3
fix: useSelect can return empty. We want an []
Crash-- Sep 18, 2023
2dd2dd2
tests: Fix Services Test
Crash-- Sep 18, 2023
fc12e64
tests: KonnectorTile
Crash-- Sep 19, 2023
86ad0c4
fix: Add the userError
Crash-- Sep 19, 2023
cba39c5
fix: KonnectorTile doesn't have route props
Crash-- Sep 19, 2023
d6d2bc0
fix: Add lang to useI18n type
Crash-- Sep 19, 2023
9aedaa0
fix: Add ts-check and fix errors
Crash-- Sep 19, 2023
b81da2f
fix: KonnectorTile
Crash-- Sep 25, 2023
49e8cde
tests: Remove this test, not needed anymore
Crash-- Sep 25, 2023
8ae1c1a
fix: Add Divider
Crash-- Sep 25, 2023
c0a6538
refactor: Import order
Crash-- Sep 25, 2023
e827429
refactor: Remove cozy-client-js
Crash-- Sep 25, 2023
5cca5ad
fix: Lint issue
Crash-- Sep 25, 2023
579ea05
fix: Request only triggers for worker and clisk
Crash-- Sep 25, 2023
082d1dd
feat: Display datacard options also for the Intent from the Store
Crash-- Sep 26, 2023
7eefc14
fix: Import error from migration cozy-ui 93.0.0
cballevre Oct 20, 2023
b8bcd34
feat: Hide the harvest close button to show only the Intent one
cballevre Oct 20, 2023
1f0a85e
fix: Lint
Crash-- Oct 24, 2023
63a135c
docs: Document Slug for Create account
Crash-- Oct 30, 2023
52eb3ad
feat: Use new feature of cozy-interapp
Crash-- Nov 2, 2023
501256d
feat: Add VIEW INTENT
Crash-- Nov 6, 2023
9162caf
feat: Pass the intentData & intentId to the Harvest Route
Crash-- Nov 7, 2023
1d339f0
fix: Add the same cozy-* attributes as the targets/browser
Crash-- Nov 7, 2023
2c7ddc6
fix: Typing issue
Crash-- Nov 14, 2023
d6bb2e4
test: Remove old snapshops
Crash-- Nov 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions config/webpack.config.cozy-home.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,6 @@ module.exports = {
}
},
plugins: [
environment === 'development'
? new webpack.ProvidePlugin({
'cozy.client': 'cozy-client-js/dist/cozy-client.js'
})
: null,

new ContextReplacementPlugin(
/moment[/\\]locale$/,
regexpMomentDateFnsLocales
Expand Down
1 change: 0 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ module.exports = {
moduleDirectories: ['src', 'node_modules'],
moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx', 'json', 'styl'],
moduleNameMapper: {
'^lib/redux-cozy-client$': '<rootDir>/src/lib/redux-cozy-client',
'\\.(png|gif|jpe?g|svg|css)$': '<rootDir>/test/__mocks__/fileMock.js',
'.styl$': 'identity-obj-proxy',
'^cozy-client$': 'cozy-client/dist/index',
Expand Down
9 changes: 8 additions & 1 deletion manifest.webapp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,14 @@
{
"action": "CREATE",
"type": ["io.cozy.accounts"],
"href": "/intents"
"href": "/intents",
"data": ["slug"]
},
{
"action": "VIEW",
"type": ["io.cozy.accounts"],
"href": "/intents",
"data": ["slug", "accountId"]
},
{
"action": "REDIRECT",
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"cozy-harvest-lib": "^21.0.0",
"cozy-intent": "^2.3.0",
"cozy-keys-lib": "^6.0.0",
"cozy-interapp": "^0.8.1",
"cozy-logger": "1.10.0",
"cozy-realtime": "4.2.9",
"cozy-sharing": "10.0.0",
Expand All @@ -68,6 +69,7 @@
"redux-logger": "3.0.6",
"redux-persist": "^6.0.0",
"redux-thunk": "2.3.0",
"reselect": "^4.1.8",
"terser-webpack-plugin": "1.4.4"
},
"devDependencies": {
Expand All @@ -80,7 +82,6 @@
"babel-jest": "27.5.1",
"babel-preset-cozy-app": "2.0.2",
"bundlemon": "1.3.2",
"cozy-client-js": "0.20.0",
"cozy-scripts": "8.1.1",
"eslint": "8.9.0",
"eslint-config-cozy-app": "4.0.0",
Expand Down
61 changes: 20 additions & 41 deletions src/components/AppWrapper.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* global __DEVELOPMENT__ */

import React, { createContext } from 'react'
import { Provider as ReduxProvider } from 'react-redux'
import memoize from 'lodash/memoize'
Expand All @@ -12,10 +10,6 @@ import CozyTheme from 'cozy-ui/transpiled/react/providers/CozyTheme'
import { BreakpointsProvider } from 'cozy-ui/transpiled/react/providers/Breakpoints'
import { PersistGate } from 'redux-persist/integration/react'

import {
CozyClient as LegacyCozyClient,
CozyProvider as LegacyCozyProvider
} from 'lib/redux-cozy-client'
import configureStore from 'store/configureStore'
import homeConfig from 'config/home.json'
import { RealtimePlugin } from 'cozy-realtime'
Expand Down Expand Up @@ -52,23 +46,14 @@ export const setupAppContext = memoize(() => {
? true
: false
})
const legacyClient = new LegacyCozyClient({
cozyURL: `//${data.cozyDomain}`,
token: data.cozyToken,
cozyClient
})

cozyClient.registerPlugin(flag.plugin)
cozyClient.registerPlugin(RealtimePlugin)
// store
const { store, persistor } = configureStore(
legacyClient,
cozyClient,
context,
{
lang,
...homeConfig
}
)
const { store, persistor } = configureStore(cozyClient, context, {
lang,
...homeConfig
})
cozyClient.setStore(store)

return { cozyClient, store, data, lang, context, persistor }
Expand All @@ -80,6 +65,7 @@ const Inner = ({ children, lang, context }) => (
<RealTimeQueries doctype="io.cozy.apps" />
<RealTimeQueries doctype="io.cozy.jobs" />
<RealTimeQueries doctype="io.cozy.triggers" />
<RealTimeQueries doctype="io.cozy.konnectors" />
{process.env.NODE_ENV !== 'production' ? <CozyDevtools /> : null}
</I18n>
)
Expand All @@ -103,34 +89,27 @@ const ThemeProvider = ({ children }) => {
*/
const AppWrapper = ({ children }) => {
const appContext = setupAppContext()
const { store, cozyClient, data, context, lang, persistor } = appContext
const { store, cozyClient, context, lang, persistor } = appContext

return (
<AppContext.Provider value={appContext}>
<BreakpointsProvider>
<CozyProvider client={cozyClient}>
<ThemeProvider>
<LegacyCozyProvider
store={store}
client={cozyClient}
domain={data.cozyDomain}
secure={!__DEVELOPMENT__}
>
<ReduxProvider store={store}>
<ConditionalWrapper
condition={persistor}
wrapper={children => (
<PersistGate loading={null} persistor={persistor}>
{children}
</PersistGate>
)}
>
<Inner lang={lang} context={context}>
<ReduxProvider store={store}>
<ConditionalWrapper
condition={persistor}
wrapper={children => (
<PersistGate loading={null} persistor={persistor}>
{children}
</Inner>
</ConditionalWrapper>
</ReduxProvider>
</LegacyCozyProvider>
</PersistGate>
)}
>
<Inner lang={lang} context={context}>
{children}
</Inner>
</ConditionalWrapper>
</ReduxProvider>
</ThemeProvider>
</CozyProvider>
</BreakpointsProvider>
Expand Down
5 changes: 1 addition & 4 deletions src/components/AppWrapper.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ jest.mock('cozy-client', () => ({
),
default: () => mockClient
}))
jest.mock('lib/redux-cozy-client', () => ({
CozyClient: children => children,
CozyProvider: ({ children }) => children
}))

jest.mock('store/configureStore', () => () => ({
store: {
dispatch: () => jest.fn(),
Expand Down
6 changes: 3 additions & 3 deletions src/components/Applications.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { memo, useEffect, useRef } from 'react'
import memoize from 'lodash/memoize'

import uniqBy from 'lodash/uniqBy'
import { useQuery } from 'cozy-client'
import flag from 'cozy-flags'
import Divider from 'cozy-ui/transpiled/react/Divider'
Expand Down Expand Up @@ -47,8 +47,8 @@ const getApplicationsList = memoize(data => {
!homeConfig.filteredApps.includes(app.slug) &&
!flag(`home_hidden_apps.${app.slug.toLowerCase()}`) // can be set in the context with `home_hidden_apps: - drive - banks`for example
)

const array = apps.map(app => <AppTile key={app.id} app={app} />)
const dedupapps = uniqBy(apps, 'slug')
const array = dedupapps.map(app => <AppTile key={app.id} app={app} />)

array.push(
<AppHighlightAlertWrapper key="AppHighlightAlertWrapper" apps={apps} />
Expand Down
46 changes: 0 additions & 46 deletions src/components/BanksLink.jsx

This file was deleted.

9 changes: 5 additions & 4 deletions src/components/Banners/UpdateMessage.jsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
/* global cozy */

import React, { useState, useCallback } from 'react'
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
import Button from 'cozy-ui/transpiled/react/deprecated/Button'
import Infos from 'cozy-ui/transpiled/react/deprecated/Infos'
import Typography from 'cozy-ui/transpiled/react/Typography'
import PropTypes from 'prop-types'
import { useClient } from 'cozy-client'
import Intents from 'cozy-interapp'

const UpdateMessage = props => {
const [isRedirecting, setIsRedirecting] = useState(false)
const { t } = useI18n()
const { isBlocking, konnector } = props

const client = useClient()
const intents = new Intents({ client })
const handleRedirectToStore = useCallback(async () => {
setIsRedirecting(true)

try {
await cozy.client.intents.redirect('io.cozy.apps', {
await intents.redirect('io.cozy.apps', {
slug: konnector.slug,
step: 'update'
})
Expand Down
38 changes: 25 additions & 13 deletions src/components/IntentRedirect.jsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,35 @@
/* global cozy */
import React from 'react'
import { Navigate, useSearchParams } from 'react-router-dom'
import { connect } from 'react-redux'

import { getInstalledKonnectors } from 'reducers'

const IntentRedirect = ({ installedKonnectors }) => {
import {
useClient,
useQuery,
isQueryLoading,
hasQueryBeenLoaded
} from 'cozy-client'
import Intents from 'cozy-interapp'
import { konnectorsConn } from 'queries'
const IntentRedirect = () => {
const client = useClient()
const intents = new Intents({ client })
const [searchParams] = useSearchParams()
const queryConnector = searchParams.get('konnector')
const queryAccount = searchParams.get('account')
const konnectorsDataResult = useQuery(konnectorsConn.query, konnectorsConn)

if (
isQueryLoading(konnectorsDataResult) &&
!hasQueryBeenLoaded(konnectorsDataResult)
)
return null

if (!queryConnector) return <Navigate to="/connected" />

if (!installedKonnectors.find(konnector => konnector.slug === queryConnector))
return cozy.client.intents.redirect('io.cozy.apps', {
if (
!konnectorsDataResult.data.find(
konnector => konnector.slug === queryConnector
)
)
return intents.redirect('io.cozy.apps', {
slug: queryConnector
})

Expand All @@ -24,8 +40,4 @@ const IntentRedirect = ({ installedKonnectors }) => {
return <Navigate to={redirectRoute} />
}

const mapStateToProps = state => ({
installedKonnectors: getInstalledKonnectors(state)
})

export default connect(mapStateToProps)(IntentRedirect)
export default IntentRedirect
2 changes: 1 addition & 1 deletion src/components/Konnector.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const StatelessKonnector = ({ konnector, triggers, slug }) => {
}

const StatefulKonnector = connect((state, { slug }) => ({
konnector: getKonnector(state.oldcozy, slug),
konnector: getKonnector(state.cozy, slug),
triggers: getTriggersByKonnector(state, slug)
}))(StatelessKonnector)

Expand Down
Loading
Loading