From b8e9bebad9a7aeeac5cabd2e4b9716252b5743d1 Mon Sep 17 00:00:00 2001 From: Guido Doumen Date: Sat, 14 Nov 2026 16:40:16 +0100 Subject: [PATCH 1/3] feat: apps settings as expandable list, aligned with the mobile app Replace the logo tiles and the separate settings page per app with a single list: every entry shows the name and the connection status and expands to connect/disconnect and the operations of the app. The list is rendered from the apps provided by the apps service. Strava and Intervals.icu share one OAuthAppSettings component. Komoot keeps its login dialog and uses the same settings view. The operation labels match the mobile app. Remove the app logos that are no longer used from the bundle, and stop logging the user name when connecting. --- public/images/intervals.png | Bin 12635 -> 0 bytes public/images/velo-black.png | Bin 2201 -> 0 bytes .../modules/Settings/Apps/AppsSettings.jsx | 123 +++++++-------- .../Settings/Apps/AppsSettings.stories.jsx | 58 ++++--- .../Settings/Apps/AppsSettings.unit.test.jsx | 61 ++++++++ .../Apps/Intervals/IntervalsSettings.jsx | 138 ----------------- .../Intervals/IntervalsSettings.stories.jsx | 34 ---- .../modules/Settings/Apps/Intervals/index.jsx | 1 - .../Settings/Apps/Komoot/KomootSettings.jsx | 95 +----------- .../Settings/Apps/OAuthAppSettings.jsx | 58 +++++++ .../Settings/Apps/Strava/StravaSettings.jsx | 145 ------------------ .../Apps/Strava/StravaSettings.stories.jsx | 34 ---- .../modules/Settings/Apps/Strava/index.jsx | 1 - .../Apps/AppSettingsView/AppSettingsView.jsx | 50 ++++++ .../AppSettingsView.unit.test.jsx | 89 +++++++++++ .../molecules/Apps/AppSettingsView/index.jsx | 1 + .../molecules/Apps/AppsItem/AppsItem.jsx | 87 +++++++---- .../Apps/AppsItem/AppsItem.stories.jsx | 38 ----- .../Apps/AppsItem/AppsItem.unit.test.jsx | 70 +++++++++ .../OperationsSelector/OperationsSelector.jsx | 46 +++--- src/components/molecules/Apps/index.jsx | 3 +- 21 files changed, 513 insertions(+), 619 deletions(-) delete mode 100644 public/images/intervals.png delete mode 100644 public/images/velo-black.png create mode 100644 src/components/modules/Settings/Apps/AppsSettings.unit.test.jsx delete mode 100644 src/components/modules/Settings/Apps/Intervals/IntervalsSettings.jsx delete mode 100644 src/components/modules/Settings/Apps/Intervals/IntervalsSettings.stories.jsx delete mode 100644 src/components/modules/Settings/Apps/Intervals/index.jsx create mode 100644 src/components/modules/Settings/Apps/OAuthAppSettings.jsx delete mode 100644 src/components/modules/Settings/Apps/Strava/StravaSettings.jsx delete mode 100644 src/components/modules/Settings/Apps/Strava/StravaSettings.stories.jsx delete mode 100644 src/components/modules/Settings/Apps/Strava/index.jsx create mode 100644 src/components/molecules/Apps/AppSettingsView/AppSettingsView.jsx create mode 100644 src/components/molecules/Apps/AppSettingsView/AppSettingsView.unit.test.jsx create mode 100644 src/components/molecules/Apps/AppSettingsView/index.jsx delete mode 100644 src/components/molecules/Apps/AppsItem/AppsItem.stories.jsx create mode 100644 src/components/molecules/Apps/AppsItem/AppsItem.unit.test.jsx diff --git a/public/images/intervals.png b/public/images/intervals.png deleted file mode 100644 index 4289e66ff72b640964f753d5bd9358d9bcc9e3ca..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12635 zcmch;^;=Zm7dE_S7`ht?K|&CbkPcyxRLVq3Kt(`6x^n;lX%H2pyOoxfp(G`wdnoDd zn)A%(`My8Af5CHIb6sb4%)Qoq?>PIcvnKSBwi-DJGYJ5I{DHdi695pnuP{J_hr2Le z95Mia2OeoYQ^6HGsFmvL>(2%z^Yin~Zi+8Ia^Cw=bbNgL_3PJsR)sm%Ct=*u+I)Ny z6BFA($z^3_eSLknrlZQXUySz`78bU)wj6oIBO@cby1Le_LgvLxE-x<=5)x+c)K*qj ztZqve6cm({lte{E_4M>yF0MTg6RWJOY-G3}78bUjQ@ymbG)t;+($e43(vo@oUUYQy zrf1v)p=vV6JzUew%*>Lq6^38`+qZ8J7F$4r=xtHPqZ z`9nFmtlNdVySwA$f*@#a zZf;;;V8ztW-rhbUA_7-5Gc(&lCH&KM@1#+#s;XLgXou74*|TSzot?eCz4L-bID#`o z>c4*d8X6kHc^D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+5w@ z7aCqhrq~#Vw_(7A^Y6dDHx^SRs8*C>Hd@r+^oX8+* zTAt=2R@yA|;Yx~Vfv>fjj0!6DAi_jcvjf%{0uVriSJZl6ZTtN+-R5v_^-rL8o!}wW z2TFoT=SgW&>tyHmGScq`Wu~wS!kdJ+>^`2X;`8^d=_#Veg8XGzY&6M*2rk#Kd+le6 zB=}$A;b8aSRLeGYaLOQP3Zcjv>pVf_2+dI`(>)5{xZJy6LsII`3Wzv0@3Y|zoTPEw z&(&~uMNQ>Hw94a~#MXB(&V$z`5sGwFvVNdx;9NnGj!;+LU;YN95WvS!e2jk@a0wA- zy05;fk{wTIu7sjF!a^B~IX^Ht;@`nx#J*zW=|zM=Dpc(q20eI6V%KQLVE~tQs&3MA z0I#fpI>R6>Dm5w(cErF+8b{c*sW_!&gbS8ek?JgChS6gKYl3jbO5#dcn_CUeP<2m> zEt4XZjAoA#l=i<|((InwFgNIh<%*DEC1;%`sjZ@Euh=>kF*wP0Asn*}-S~4woca9k zw$#S9AFDo=IP>U<>nD{Rg;051pKgzz2T8v?p`?^F^7?h0U+C0wx84POGT*!iIF`DN zTDiV2>u?nRcf`8pfp35me68Gdl5av9&Z4SisBzmD;h;QpGF<)+ucUE5f&9(1NAv$L o5jV%@*ZpRl8e@TD`D%#3F?wbbuA7c8g1poj5 diff --git a/public/images/velo-black.png b/public/images/velo-black.png deleted file mode 100644 index 984371df686ea6ab2f6436b179a0346114ea6d4b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2201 zcmV;K2xj+*P)ZgXgFbngSdJ^%m!Ds)9ybVG7w zVRUJ4ZXi@?ZDjyNZy+-6ncgeemp5)u+-n7H>vnr_-=JI$u2-52wrROUC6 z-}9aC^E|)jdGcK{nfxCf9#`;}yH3F4+s8ABhbx{*JY4Zi;^B&C5)W5AlX$q|nZ&~t z&m380Yp(m5WsOPthR}v*QiuXx_6!DE%Kdr zc5{kgM)xS z5FjXp2}h&EqY=c8bJr=~D%TiE{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KL?{GZ>NP>uU}}ZjdIoA+qn7+uWrNy3o8$qmOu(eV0gfoNT>6RdB9iau+r}* zQ8`IUjw1lAigqgGEnrtE8-3LUd6u~;-=z@Wy*YA;LD5zong)e_uV|T=!y|!hVzkb# zo<;&~gLC!XAnx*4-X4S1jcsGME9~qX^}P{MDdeJ`<0jJSJY$~%*R=`_KuF9mlMsLw zmBZsJ?l>*XM*jJ@ocfpJ`>|aC#$Dp`V z9_m2`HPZnpK{7n_m7yfE)IuMO)!jOJ1Bj-O1LxxusX_JlCYLzl>T{lMd5dk`0R&=m z1s;UXu1uiQdB#7xF*PcU9Fd6B-^FWH&_-0mXIxR3fy1X)|KUyLdhy2l=d6Bg)2nas zawEXXQU*zkF}?VZ=}V7pP}+FK-nntS%cref)RjE>l@+9-hC!5cE=!=iLD4*GB*m=~ zsfQ{{j~@{)mNA7m*_kwc?G^hsd9pXIK9^{7u(eO_$qW%8&Rii&`K3k|CeZ0TUva=^ zqG>10oE{`J${ME29e)Px@*93N%H(E;&Lji}tJT1$X%vekjz^qH^vpf}SZy;mpCgr< z<(}2#xVX;7LH%4$vTK{Ht{TkEt0ZS;Np?+YJ8SG}=Is>d<6!Qxd6?#J(-NXQPa%E8 z>vF#}U#rtF-cJQQT=9OH=HZHG5)W5AlX$q|nZ&~t&m props.width || 'calc(100% - 2vw)'}; - // height: ${props=>props.height || 'calc(100% - 2vh)'}; text-align: left ; margin:auto; display: flex; flex-direction:column; - padding-left: 1vw; - padding-right: 1vw; - padding-top: 1vh; - padding-bottom: 1vh; padding:1vw; top:0; left:0; background: ${props => props.background || props.theme.dialogContent.background || 'white'}; `; -const getMapping = (service) => { - const mapping = { - strava: StravaSettings, - komoot: KomootSettings, - intervals: IntervalsSettings - } - const C = mapping[service] - return C -} +const Empty = styled.div` + padding: 1vh 1vw; +` -const SettingsPage = ( {service,onBack} ) => { - - const C = getMapping(service) - if (!C) - return null +// Apps that are connected through an image button instead of a text button +const CONNECT_IMAGES = { + strava: 'images/btn_strava_connectwith_orange.svg' +} - return +const renderApp = (app) => { + if (app.key === 'komoot') + return + return } - export const AppsSettings = ( ) => { const service = useAppsService() - const [state,setState] = useState(null) + const logger = useRef(new EventLogger('AppsSettings')).current - useEffect( ()=>{ - if (state?.initialized) - return; + const [apps, setApps] = useState(null) + const [expandedKey, setExpandedKey] = useState(null) - const apps = service.openSettings() - + // keeps the connection status of the entries up to date, whenever an app was (dis)connected + const refresh = useCallback( ()=>{ + setApps( service.openSettings() ) + },[service]) - setState({apps, initialized:true}) - },[service, state]) + useEffect( ()=>{ + refresh() + service.on('connected', refresh) + service.on('disconnected', refresh) - const onClick=(key) => { - setState( current=> ({...current, selected:key}) ) - } + return ()=>{ + service.off('connected', refresh) + service.off('disconnected', refresh) + } + },[service, refresh]) - const onBack=()=>{ - setState( current=> ({...current, selected:null}) ) + const onToggle = (key) => { + const expanded = expandedKey!==key + logger.logEvent({message:'app toggled', app:key, expanded, eventSource:'user'}) + setExpandedKey( expanded ? key : null) } - if (!state?.initialized ) - return null; - - if (state.selected && getMapping(state.selected)) - return - - return - - + if (!apps) + return null + return } -export const AppsSettingsView = ({apps,onClick}) => { +/** + * List of all apps (same UX as in the mobile app): every entry shows the name and the connection status + * and expands to the settings of the app. Only one entry is expanded at a time. + */ +export const AppsSettingsView = ({apps, expandedKey, onToggle, renderApp}) => { - const onClickHandler = (name) => { - if (onClick && typeof onClick==='function') { - onClick(name) - } - } - return ( - { apps?.length ? - apps.map( (app) => - onClickHandler(app.key)} /> - ) : - No Apps available + { apps?.length ? + apps.map( (app) => + onToggle?.(app.key)}> + {renderApp?.(app)} + + ) : + No Apps available } - ) - -} \ No newline at end of file +} diff --git a/src/components/modules/Settings/Apps/AppsSettings.stories.jsx b/src/components/modules/Settings/Apps/AppsSettings.stories.jsx index 8544d20..58097e0 100644 --- a/src/components/modules/Settings/Apps/AppsSettings.stories.jsx +++ b/src/components/modules/Settings/Apps/AppsSettings.stories.jsx @@ -1,33 +1,53 @@ -import styled from "styled-components"; -import { Row } from "../../../atoms"; -import { AppsSettingsView } from "./AppsSettings"; -import React from 'react' +import React, { useState } from 'react' +import styled from "styled-components" +import { Row } from "../../../atoms" +import { AppSettingsView } from "../../../molecules/Apps/AppSettingsView" +import { AppsSettingsView } from "./AppsSettings" -const View = styled(Row)` +const View = styled(Row)` width: 800px; height: 600px; overflow-y: hidden; -`; - +` export default { component: AppsSettingsView, - title: 'Modules/Settings/AppsSettings', - argTypes: { - onClick: { action: 'select' } , + title: 'Modules/Settings/AppsSettings', + argTypes: { + onToggle: { action: 'toggle' }, }, +} + +const apps = [ + { name: 'Strava', key: 'strava', isConnected: true }, + { name: 'Komoot', key: 'komoot', isConnected: false }, + { name: 'Intervals.icu', key: 'intervals', isConnected: false }, +] -}; +const operations = [ + { operation: 'ActivityUpload', enabled: true }, + { operation: 'RouteDownload', enabled: false }, +] -const Template = args => +const renderApp = (app) => -export const Default = Template.bind({}); -Default.args = { - apps: [ - { name:'Strava', key:'strava', iconUrl: 'https://static.cdnlogo.com/logos/s/42/strava-wordmark.svg' }, - { name:'VeloHero', key:'velohero', iconUrl: 'images/velo-white.png' }, - { name:'Komoot', key:'komoot', iconUrl:'https://www.komoot.com/assets/4d8ae313eec53e6e.svg' }, - ] +const Template = args => { + const [expandedKey, setExpandedKey] = useState(args.expandedKey) + const onToggle = (key) => setExpandedKey(current => current === key ? null : key) + + return + + } +export const Collapsed = Template.bind({}) +Collapsed.args = { apps } + +export const ConnectedExpanded = Template.bind({}) +ConnectedExpanded.args = { apps, expandedKey: 'strava' } + +export const NotConnectedExpanded = Template.bind({}) +NotConnectedExpanded.args = { apps, expandedKey: 'intervals' } +export const NoApps = Template.bind({}) +NoApps.args = { apps: [] } diff --git a/src/components/modules/Settings/Apps/AppsSettings.unit.test.jsx b/src/components/modules/Settings/Apps/AppsSettings.unit.test.jsx new file mode 100644 index 0000000..7e5468c --- /dev/null +++ b/src/components/modules/Settings/Apps/AppsSettings.unit.test.jsx @@ -0,0 +1,61 @@ +import React from 'react' +import { describe, test, expect, vi } from 'vitest' +import { render, screen, fireEvent } from '@testing-library/react' + +import { AppsSettingsView } from './AppsSettings' + +const apps = [ + { name: 'Strava', key: 'strava', isConnected: true }, + { name: 'Komoot', key: 'komoot', isConnected: false }, + { name: 'Intervals.icu', key: 'intervals', isConnected: false }, +] + +const renderApp = (app) =>
settings of {app.key}
+ +describe('AppsSettingsView', () => { + + test('lists all apps with their connection status', () => { + render() + + expect(screen.getByText('Strava')).toBeDefined() + expect(screen.getByText('Komoot')).toBeDefined() + expect(screen.getByText('Intervals.icu')).toBeDefined() + expect(screen.getAllByLabelText('Connected')).toHaveLength(1) + expect(screen.getAllByLabelText('Not connected')).toHaveLength(2) + }) + + test('shows the settings of the expanded app only', () => { + render() + + expect(screen.getByText('settings of komoot')).toBeDefined() + expect(screen.queryByText('settings of strava')).toBeNull() + expect(screen.queryByText('settings of intervals')).toBeNull() + }) + + test('shows no settings if nothing is expanded', () => { + render() + + expect(screen.queryByText(/settings of/)).toBeNull() + }) + + test('reports the key of the clicked app', () => { + const onToggle = vi.fn() + render() + + fireEvent.click(screen.getByText('Intervals.icu')) + + expect(onToggle).toHaveBeenCalledWith('intervals') + }) + + test('shows a hint if there are no apps', () => { + render() + + expect(screen.getByText('No Apps available')).toBeDefined() + }) + + test('handles missing apps', () => { + render() + + expect(screen.getByText('No Apps available')).toBeDefined() + }) +}) diff --git a/src/components/modules/Settings/Apps/Intervals/IntervalsSettings.jsx b/src/components/modules/Settings/Apps/Intervals/IntervalsSettings.jsx deleted file mode 100644 index e8ea428..0000000 --- a/src/components/modules/Settings/Apps/Intervals/IntervalsSettings.jsx +++ /dev/null @@ -1,138 +0,0 @@ -import React, { useState } from 'react' -import styled from "styled-components" -import { Button, Row, Text, View } from "../../../../atoms" -import { ArrowLeftIcon } from '@primer/octicons-react' -import { AppThemeProvider } from '../../../../../theme' -import { EventLogger } from 'gd-eventlog' -import { hasFeature } from '../../../../../utils/electron/integration' -import { OAuthBinding } from '../../../../../bindings' - -import { useAppsService } from 'incyclist-services' -import { OperationsSelector } from '../../../../molecules/Apps/OperationsSelector' - -export const IntervalsSettings = ({onBack})=> { - - const logger = new EventLogger('IntervalsSettings') - const [connecting,setConnecting] = useState(false) - const service = useAppsService() - - const [settings,setSettings] = useState( service.openAppSettings('intervals')) - - - const onConnect = async ()=>{ - - logger.logEvent({message:'onConnectIntervals'}) - if (hasFeature('oauth')) { - - setConnecting(true) - const res = await OAuthBinding.getInstance().authorize('intervals'); - - if (res.success) { - logger.logEvent({message:'onConnectIntervals succes', username:res.user.name}) - await service.connect('intervals', res.user?.auth?.intervals) - const settings = service.openAppSettings('intervals') - setSettings( current=> ({...current, ...settings}) ) - - - } - else { - logger.logEvent({message:'onConnectIntervals failed', reason:res.reason}) - } - setConnecting(false) - - } - } - - const onDisconnect = ()=>{ - service.disconnect('intervals') - setSettings( {isConnected:false}) - } - - const onOperationsChanged = (operation, enabled) => { - const operations = service.enableOperation('intervals',operation,enabled,true) - setSettings( current=> ({...current,operations} )) - } - - return - - -} - -const Container = styled(View)` - position: relative; -` - -const BackRow = styled(Row)` - position: absolute; - top: 0; - right: 0; - padding: 1vw - - color: ${props => props.theme.list.normal.text}; - background: ${props => props.theme.list.normal.background}; - - &:hover { - color: ${props => props.theme.list.hover.text}; - background: ${props => props.theme.list.hover.background}; - border-style: solid; - border-width: 1px; - border-color: white; - } - -` - -const Icon = styled(ArrowLeftIcon)` -` - -const Title = styled(Row)` - height: 32px; - font-size: 2.2vh; - padding: 1vw; - text-transform: uppercase; - - user-select: none; - pointer-events: none; - color: ${props => props.theme.title.text}; - background: ${props => props.theme.title.background}; - -` - -export const IntervalsSettingsView = ( {isConnected, isConnecting, operations, onBack, onConnect, onDisconnect,onOperationsChanged}) => { - - return - - - Intervals.icu Settings - - - - {isConnected ? -
- -
- : -
-
- } -
- - {isConnected ? - - - :null} - - - - - - -
-
- -} \ No newline at end of file diff --git a/src/components/modules/Settings/Apps/Intervals/IntervalsSettings.stories.jsx b/src/components/modules/Settings/Apps/Intervals/IntervalsSettings.stories.jsx deleted file mode 100644 index 0bc1602..0000000 --- a/src/components/modules/Settings/Apps/Intervals/IntervalsSettings.stories.jsx +++ /dev/null @@ -1,34 +0,0 @@ -import React from 'react' -import styled from "styled-components"; -import { IntervalsSettingsView } from "./IntervalsSettings"; -import { Row } from "../../../../atoms"; - -const View = styled(Row)` - width: 800px; - height: 600px; - overflow-y: hidden; -`; - - -export default { - component: IntervalsSettingsView, - title: 'Modules/Settings/Intervals.icu', - argTypes: { - onConnect: { action: 'connect' } , - onDisconnect: { action: 'discconnect' } , - onBack: {action:'back'} - }, - -}; - -const Template = args => - -export const Default = Template.bind({}); -Default.args = { - isConnected: false -} - -export const Connected = Template.bind({}); -Connected.args = { - isConnected: true -} \ No newline at end of file diff --git a/src/components/modules/Settings/Apps/Intervals/index.jsx b/src/components/modules/Settings/Apps/Intervals/index.jsx deleted file mode 100644 index bd9742e..0000000 --- a/src/components/modules/Settings/Apps/Intervals/index.jsx +++ /dev/null @@ -1 +0,0 @@ -export * from './IntervalsSettings' \ No newline at end of file diff --git a/src/components/modules/Settings/Apps/Komoot/KomootSettings.jsx b/src/components/modules/Settings/Apps/Komoot/KomootSettings.jsx index 701b0d9..2459800 100644 --- a/src/components/modules/Settings/Apps/Komoot/KomootSettings.jsx +++ b/src/components/modules/Settings/Apps/Komoot/KomootSettings.jsx @@ -1,16 +1,12 @@ import React, { useRef, useState } from 'react' -import styled from "styled-components" -import { Button, Row, Text, View } from "../../../../atoms" -import { ArrowLeftIcon } from '@primer/octicons-react' -import { AppThemeProvider } from '../../../../../theme' -import { OperationsSelector } from '../../../../molecules/Apps/OperationsSelector' +import { AppSettingsView } from '../../../../molecules/Apps/AppSettingsView' import { DialogLauncher, KomootLoginDialog } from '../../../../molecules' import { useAppsService } from 'incyclist-services' import { useUnmountEffect } from '../../../../../hooks' const SERVICE = 'komoot' -export const KomootSettings = ({onBack})=> { +export const KomootSettings = ()=> { const [connecting,setConnecting] = useState(false) const service = useAppsService() @@ -98,88 +94,9 @@ export const KomootSettings = ({onBack})=> { return <> - - - - - + } - -const Container = styled(View)` - position: relative; -` - -const BackRow = styled(Row)` - position: absolute; - top: 0; - right: 0; - padding: 1vw - - color: ${props => props.theme.list.normal.text}; - background: ${props => props.theme.list.normal.background}; - - &:hover { - color: ${props => props.theme.list.hover.text}; - background: ${props => props.theme.list.hover.background}; - border-style: solid; - border-width: 1px; - border-color: white; - } - -` - -const Icon = styled(ArrowLeftIcon)` -` - -const Title = styled(Row)` - height: 32px; - font-size: 2.2vh; - padding: 1vw; - text-transform: uppercase; - - user-select: none; - pointer-events: none; - color: ${props => props.theme.title.text}; - background: ${props => props.theme.title.background}; - -` - -export const VeloHeroSettingsView = ( {isConnected, isConnecting, operations, onBack, onConnect, onDisconnect,onOperationsChanged}) => { - - return - - - Komoot Settings - - - - {isConnected ? -
- -
- : -
-
- } -
- - {isConnected ? - - - :null} - - - - - - -
-
- -} \ No newline at end of file diff --git a/src/components/modules/Settings/Apps/OAuthAppSettings.jsx b/src/components/modules/Settings/Apps/OAuthAppSettings.jsx new file mode 100644 index 0000000..8c200f3 --- /dev/null +++ b/src/components/modules/Settings/Apps/OAuthAppSettings.jsx @@ -0,0 +1,58 @@ +import React, { useRef, useState } from 'react' +import { EventLogger } from 'gd-eventlog' +import { useAppsService } from 'incyclist-services' +import { hasFeature } from '../../../../utils/electron/integration' +import { OAuthBinding } from '../../../../bindings' +import { AppSettingsView } from '../../../molecules/Apps/AppSettingsView' + +/** + * Settings of an app that is connected through the OAuth flow of the auth-server (Strava, Intervals.icu, ...) + */ +export const OAuthAppSettings = ({ appKey, name, connectImage }) => { + + const logger = useRef(new EventLogger('OAuthAppSettings')).current + const service = useAppsService() + + const [connecting, setConnecting] = useState(false) + const [settings, setSettings] = useState(() => service.openAppSettings(appKey)) + + const onConnect = async () => { + if (!hasFeature('oauth')) + return + + try { + logger.logEvent({ message: 'connect', app: appKey }) + setConnecting(true) + + const res = await OAuthBinding.getInstance().authorize(appKey) + + if (res.success) { + logger.logEvent({ message: 'connect success', app: appKey }) + await service.connect(appKey, res.user?.auth?.[appKey]) + setSettings(current => ({ ...current, ...service.openAppSettings(appKey) })) + } + else { + logger.logEvent({ message: 'connect failed', app: appKey, reason: res.reason }) + } + } + catch (err) { + logger.logEvent({ message: 'error', fn: 'onConnect', app: appKey, error: err.message, stack: err.stack }) + } + finally { + setConnecting(false) + } + } + + const onDisconnect = () => { + service.disconnect(appKey) + setSettings({ isConnected: false }) + } + + const onOperationsChanged = (operation, enabled) => { + const operations = service.enableOperation(appKey, operation, enabled, true) + setSettings(current => ({ ...current, operations })) + } + + return +} diff --git a/src/components/modules/Settings/Apps/Strava/StravaSettings.jsx b/src/components/modules/Settings/Apps/Strava/StravaSettings.jsx deleted file mode 100644 index c702e05..0000000 --- a/src/components/modules/Settings/Apps/Strava/StravaSettings.jsx +++ /dev/null @@ -1,145 +0,0 @@ -import React, { useState } from 'react' -import styled from "styled-components" -import { Button, Row, Text, View } from "../../../../atoms" -import { ArrowLeftIcon } from '@primer/octicons-react' -import { AppThemeProvider } from '../../../../../theme' -import { EventLogger } from 'gd-eventlog' -import { hasFeature } from '../../../../../utils/electron/integration' -import { OAuthBinding} from '../../../../../bindings' -import { useAppsService } from 'incyclist-services' -import { OperationsSelector } from '../../../../molecules/Apps/OperationsSelector' - -export const StravaSettings = ({onBack})=> { - - const logger = new EventLogger('StravaSettings') - const [connecting,setConnecting] = useState(false) - const service = useAppsService() - - const [settings,setSettings] = useState( service.openAppSettings('strava')) - - - const onConnect = async ()=>{ - - try { - logger.logEvent({message:'onConnectStrava'}) - if (hasFeature('oauth')) { - - setConnecting(true) - const res = await OAuthBinding.getInstance().authorize('strava'); - - if (res.success) { - logger.logEvent({message:'onConnectStrava succes', username:res.user.name}) - await service.connect('strava', res.user?.auth?.strava) - const settings = service.openAppSettings('strava') - setSettings( current=> ({...current, ...settings}) ) - - - } - else { - logger.logEvent({message:'onConnectStrava failed', reason:res.reason}) - } - setConnecting(false) - - } - } - catch(err) { - logger.logEvent({message:'error', fn:'onConnect', error:err.message, stack:err.stack}) - } - } - - const onDisconnect = ()=>{ - service.disconnect('strava') - setSettings( {isConnected:false}) - } - - const onOperationsChanged = (operation, enabled) => { - const operations = service.enableOperation('strava',operation,enabled,true ) - setSettings( current=> ({...current,operations} )) - } - - return - - -} - -const Container = styled(View)` - position: relative; -` - -const BackRow = styled(Row)` - position: absolute; - top: 0; - right: 0; - padding: 1vw - - color: ${props => props.theme.list.normal.text}; - background: ${props => props.theme.list.normal.background}; - - &:hover { - color: ${props => props.theme.list.hover.text}; - background: ${props => props.theme.list.hover.background}; - border-style: solid; - border-width: 1px; - border-color: white; - } - -` - -const Icon = styled(ArrowLeftIcon)` -` - -const Title = styled(Row)` - height: 32px; - font-size: 2.2vh; - padding: 1vw; - text-transform: uppercase; - - user-select: none; - pointer-events: none; - color: ${props => props.theme.title.text}; - background: ${props => props.theme.title.background}; - -` - -export const StravaSettingsView = ( {isConnected, isConnecting, operations, onBack, onConnect, onDisconnect,onOperationsChanged}) => { - - return - - - Strava Settings - - - - {isConnected ? -
- -
- : -
- -
- } -
- - {isConnected ? - - - :null} - - - - - - -
-
- -} \ No newline at end of file diff --git a/src/components/modules/Settings/Apps/Strava/StravaSettings.stories.jsx b/src/components/modules/Settings/Apps/Strava/StravaSettings.stories.jsx deleted file mode 100644 index c3e4bf3..0000000 --- a/src/components/modules/Settings/Apps/Strava/StravaSettings.stories.jsx +++ /dev/null @@ -1,34 +0,0 @@ -import React from 'react' -import styled from "styled-components"; -import { StravaSettingsView } from "./StravaSettings"; -import { Row } from "../../../../atoms"; - -const View = styled(Row)` - width: 800px; - height: 600px; - overflow-y: hidden; -`; - - -export default { - component: StravaSettingsView, - title: 'Modules/Settings/Strava', - argTypes: { - onConnect: { action: 'connect' } , - onDisconnect: { action: 'discconnect' } , - onBack: {action:'back'} - }, - -}; - -const Template = args => - -export const Default = Template.bind({}); -Default.args = { - isConnected: false -} - -export const Connected = Template.bind({}); -Connected.args = { - isConnected: true -} diff --git a/src/components/modules/Settings/Apps/Strava/index.jsx b/src/components/modules/Settings/Apps/Strava/index.jsx deleted file mode 100644 index 0da88cb..0000000 --- a/src/components/modules/Settings/Apps/Strava/index.jsx +++ /dev/null @@ -1 +0,0 @@ -export * from './StravaSettings' \ No newline at end of file diff --git a/src/components/molecules/Apps/AppSettingsView/AppSettingsView.jsx b/src/components/molecules/Apps/AppSettingsView/AppSettingsView.jsx new file mode 100644 index 0000000..16e80a0 --- /dev/null +++ b/src/components/molecules/Apps/AppSettingsView/AppSettingsView.jsx @@ -0,0 +1,50 @@ +import React from 'react' +import styled from 'styled-components' +import { Button, Text } from '../../../atoms' +import AppTheme, { AppThemeProvider } from '../../../../theme' +import { OperationsSelector } from '../OperationsSelector' + +const Content = styled.div` + display: flex; + flex-direction: column; + align-items: flex-start; + gap: 1.6vh; +` + +const ConnectArea = styled.div` + display: flex; + align-items: center; + min-height: 4.4vh; +` + +/** + * Connect/disconnect and operation settings of a single app, shown inside the expanded + * entry of the Apps list. + * + * @param {string} name display name of the app + * @param {string} [connectImage] optional brand image (e.g. "Connect with Strava") that is used as connect button + */ +export const AppSettingsView = ({ name, isConnected, isConnecting, operations, connectImage, onConnect, onDisconnect, onOperationsChanged }) => { + + const renderConnect = () => { + if (isConnecting) + return + + if (isConnected) + return + + return