Skip to content

Commit

Permalink
publish: Add Ubuntu 24.04 cozy-stack packages
Browse files Browse the repository at this point in the history
generated from commit b2d4b2f
  • Loading branch information
Travis CI User committed Jul 19, 2024
1 parent 968c65d commit bfdb186
Show file tree
Hide file tree
Showing 13 changed files with 762 additions and 666 deletions.
49 changes: 49 additions & 0 deletions en/cozy-home/src/components/KonnectorHelpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import {
IOCozyAccount,
IOCozyTrigger,
IOCozyKonnector
} from 'cozy-client/types/types'

export const STATUS = {
OK: 0,
MAINTENANCE: 2,
ERROR: 3,
NO_ACCOUNT: 4,
LOADING: 5
} as const

/**
* Get accounts from triggers
* @param {IOCozyAccount[]} accounts
* @param {IOCozyTrigger[]} triggers
* @returns {IOCozyAccount[]}
*/
export const getAccountsFromTrigger = (
accounts: IOCozyAccount[],
triggers: IOCozyTrigger[]
): IOCozyAccount[] => {
const triggerAccountIds = triggers.map(trigger => trigger.message.account)
const matchingAccounts = Object.values(accounts).filter(account =>
triggerAccountIds.includes(account._id)
)
return matchingAccounts
}

/**
* Get triggers by slug
* @param {IOCozyTrigger[]} triggers
* @param {IOCozyKonnector['slug']} slug
* @returns {IOCozyTrigger[]}
*/
export function getTriggersBySlug(
triggers: IOCozyTrigger[],
slug: IOCozyKonnector['slug']
): IOCozyTrigger[] {
return Object.values(triggers).filter(trigger => {
return (
trigger.message &&
trigger.message.konnector &&
trigger.message.konnector === slug
)
})
}
54 changes: 19 additions & 35 deletions en/cozy-home/src/components/KonnectorTile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ import { getErrorLocaleBound, KonnectorJobError } from 'cozy-harvest-lib'
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
import { generateWebLink, useClient } from 'cozy-client'

import {
STATUS,
getAccountsFromTrigger,
getTriggersBySlug
} from 'components/KonnectorHelpers'

/**
*
* @param {object} param
Expand All @@ -25,20 +31,25 @@ const getKonnectorError = ({ error, lang, konnector }) => {
return getErrorLocaleBound(konnError, konnector, lang, 'title')
}

export const STATUS = {
OK: 0,
MAINTENANCE: 2,
ERROR: 3,
NO_ACCOUNT: 4,
LOADING: 5
}
/**
* @typedef {Object} StatusMap
* @property {string} [STATUS.NO_ACCOUNT] - The status when there is no account, represented as 'ghost'.
* @property {string} [STATUS.MAINTENANCE] - The status when under maintenance, represented as 'maintenance'.
* @property {string} [STATUS.ERROR] - The status when there is an error, represented as 'error'.
* @property {string} [STATUS.LOADING] - The status when loading, represented as 'loading'.
*/

/**
* A mapping of status constants to their corresponding string representations.
* @type {StatusMap}
*/
const statusMap = {
[STATUS.NO_ACCOUNT]: 'ghost',
[STATUS.MAINTENANCE]: 'maintenance',
[STATUS.ERROR]: 'error',
[STATUS.LOADING]: 'loading'
}

/**
*
* @param {object} props
Expand All @@ -63,21 +74,6 @@ export const getKonnectorStatus = ({
else return STATUS.OK
}

/**
* @param {object} triggers
* @param {import('cozy-client/types/types').IOCozyTrigger} triggers.trigger - io.cozy.triggers object
* @param {import('cozy-client/types/types').IOCozyKonnector['slug']} slug
* @returns
*/
function getTriggersBySlug(triggers, slug) {
return Object.values(triggers).filter(trigger => {
return (
trigger.message &&
trigger.message.konnector &&
trigger.message.konnector === slug
)
})
}
/**
* @param {import('cozy-client/types/types').IOCozyTrigger[]} triggers - io.cozy.triggers object
* @param {object} jobs
Expand All @@ -99,19 +95,7 @@ function getErrorForTriggers(triggers, jobs) {
}
return null
}
/**
*
* @param {import('cozy-client/types/types').IOCozyAccount[]} accounts
* @param {import('cozy-client/types/types').IOCozyTrigger[]} triggers
* @returns
*/
const getAccountsFromTrigger = (accounts, triggers) => {
const triggerAccountIds = triggers.map(trigger => trigger.message.account)
const matchingAccounts = Object.values(accounts).filter(account =>
triggerAccountIds.includes(account.id)
)
return matchingAccounts
}

/**
*
* @param {import('cozy-client/types/types').IOCozyTrigger[]} triggers
Expand Down
7 changes: 2 additions & 5 deletions en/cozy-home/src/components/KonnectorTile.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@ import { render } from '@testing-library/react'
import CozyTheme from 'cozy-ui/transpiled/react/providers/CozyTheme'
import { createMockClient } from 'cozy-client/dist/mock'

import {
KonnectorTile,
getKonnectorStatus,
STATUS
} from 'components/KonnectorTile'
import { KonnectorTile, getKonnectorStatus } from 'components/KonnectorTile'
import { STATUS } from 'components/KonnectorHelpers'
import AppLike from 'test/AppLike'

jest.mock('react-router-dom', () => ({
Expand Down
11 changes: 8 additions & 3 deletions en/cozy-home/src/components/Sections/SectionAppGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
import React from 'react'
import get from 'lodash/get'
import cx from 'classnames'

import type { IOCozyFile, IOCozyKonnector } from 'cozy-client/types/types'
import { nameToColor } from 'cozy-ui/react/Avatar/helpers'
import Typography from 'cozy-ui/transpiled/react/Typography'
import Grid from 'cozy-ui/transpiled/react/Grid'
import AppIcon from 'cozy-ui/transpiled/react/AppIcon'
import { STATUS } from 'components/KonnectorHelpers'

interface SectionAppGroupProps {
items: IOCozyFile[] | IOCozyKonnector[]
}

interface SectionAppTileProps {
item: IOCozyFile | IOCozyKonnector
item: (IOCozyFile | IOCozyKonnector) & {
status?: number
}
}

const typedNameToColor = nameToColor as (name: string) => string

const SectionAppTile = ({ item }: SectionAppTileProps): JSX.Element => {
const icon = get(item, 'attributes.metadata.icon') as string
const iconMimeType = get(item, 'attributes.metadata.iconMimeType') as string

return (
<Grid item xs={6} key={item.id} className="section-app-group-grid">
{item.type === 'konnector' ? (
<AppIcon
app={(item as IOCozyKonnector).slug}
type="konnector"
className="item-grid-icon"
className={cx('item-grid-icon', {
ghost: item.status === STATUS.NO_ACCOUNT
})}
/>
) : icon ? (
<img
Expand Down
9 changes: 9 additions & 0 deletions en/cozy-home/src/components/Sections/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"categoriesWhitelist": [
"banking",
"clouds",
"isp",
"energy",
"public_service"
]
}
Loading

0 comments on commit bfdb186

Please sign in to comment.