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 Sep 19, 2024
1 parent f8409d9 commit ad680fb
Show file tree
Hide file tree
Showing 12 changed files with 518 additions and 472 deletions.
2 changes: 1 addition & 1 deletion en/cozy-desktop/developer/log_analysis/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3274,7 +3274,7 @@

<h1 id="log-analysis">Log analysis<a class="headerlink" href="#log-analysis" title="Permanent link">&para;</a></h1>
<p>Debugging synchronization issues mostly means analysing logs.
Logs are in JSON lines format, generated by bunyan, and can be quite huge
Logs are in JSON lines format, generated by winston, and can be quite huge
(this is a known issue).</p>
<p>We use <a href="https://stedolan.github.io/jq/">jq</a> to filter them. See <a href="https://stedolan.github.io/jq/manual/#Basicfilters">jq manual</a> to get all the
basic and advanced filters. A <code>yarn jq</code> script is also available which
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GET https://announcements.cozycloud.cc/uploads/{{ url }}
1 change: 1 addition & 0 deletions en/cozy-doctypes/cc.cozycloud.announcements/request
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GET https://announcements.cozycloud.cc/api/public-announcements?lang={{ lang }}&channels={{ channels }}
1 change: 1 addition & 0 deletions en/cozy-doctypes/docs/io.cozy.home.settings/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3385,6 +3385,7 @@ <h3 id="fields">Fields:<a class="headerlink" href="#fields" title="Permanent lin
<li><strong><code>order</code></strong>: {number} If provided, the order in which the shortcut should appear.</li>
<li><strong><code>originalName</code></strong>: {string} Original name of the shortcut.</li>
<li><strong><code>announcements</code></strong>: {object} Data related to the lifecycle of announcement inside Cozy</li>
<li><strong><code>announcements.firstActivatedAt</code></strong>: {date} The first time, the user has announcements feature activated. Allow delayed display of the dialog for first time users.</li>
<li><strong><code>announcements.dismissedAt</code></strong>: {date} The last time, the user dismiss the announcements dialog</li>
<li><strong><code>announcements.seen</code></strong>: {string[]} The viewed announcements. The array size is limited to same as the number of announcement return by the API (currently: 5)</li>
</ul>
Expand Down
29 changes: 23 additions & 6 deletions en/cozy-home/src/components/Announcements/Announcements.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC, useState } from 'react'
import React, { FC, useEffect, useState } from 'react'
import { differenceInHours } from 'date-fns'

import flag from 'cozy-flags'
Expand All @@ -11,20 +11,37 @@ import { useAnnouncementsSettings } from 'hooks/useAnnouncementsSettings'
const Announcements: FC = () => {
const config = flag<AnnouncementsConfigFlag>('home.announcements')
const [hasBeenDismissed, setBeenDismissed] = useState(false)
const { values, save } = useAnnouncementsSettings()
const { fetchStatus, values, save } = useAnnouncementsSettings()
const [hasBeenActivated, setBeenActivated] = useState(false)

useEffect(() => {
if (
!values.firstActivatedAt &&
!hasBeenActivated &&
fetchStatus === 'loaded'
) {
save({
firstActivatedAt: new Date().toISOString()
})
setBeenActivated(true)
}
}, [hasBeenActivated, save, values.firstActivatedAt, fetchStatus])

const handleDismiss = (): void => {
save({
dismissedAt: new Date().toISOString()
})
setBeenDismissed(true)
}

const hasBeenActivatedForMoreThanAHour = values.firstActivatedAt
? differenceInHours(new Date(), Date.parse(values.firstActivatedAt)) >= 1
: false
const moreThan = config?.delayAfterDismiss ?? 24
const hasBeenDismissedForMoreThan = values.dismissedAt
? differenceInHours(new Date(), Date.parse(values.dismissedAt)) >= moreThan
: true
const canBeDisplayed = !hasBeenDismissed && hasBeenDismissedForMoreThan
const canBeDisplayed =
!hasBeenDismissed &&
hasBeenDismissedForMoreThan &&
hasBeenActivatedForMoreThanAHour
const announcements = useAnnouncements({
canBeDisplayed
})
Expand Down
20 changes: 18 additions & 2 deletions en/cozy-home/src/components/Announcements/AnnouncementsDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,29 @@ const AnnouncementsDialog: FC<AnnouncementsDialogProps> = ({
setActiveStep(index)
}

const handleLast = (): void => {
const uuid = announcements[activeStep].attributes.uuid
save({
dismissedAt: new Date().toISOString(),
seen: [...(values?.seen ?? []), uuid]
})
onDismiss()
}

const handleDismiss = (): void => {
save({
dismissedAt: new Date().toISOString()
})
onDismiss()
}

const maxSteps = announcements.length

return (
<CozyTheme variant="normal">
<FixedActionsDialog
open
onClose={onDismiss}
onClose={handleDismiss}
content={
<SwipeableViews
index={activeStep}
Expand All @@ -64,8 +80,8 @@ const AnnouncementsDialog: FC<AnnouncementsDialogProps> = ({
key={index}
isLast={index === maxSteps - 1}
announcement={announcement}
onDismiss={onDismiss}
onNext={handleNext}
onLast={handleLast}
/>
))}
</SwipeableViews>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import { useAnnouncementsImage } from 'hooks/useAnnouncementsImage'
interface AnnouncementsDialogContentProps {
isLast: boolean
announcement: Announcement
onDismiss: () => void
onNext: () => void
onLast: () => void
}

const AnnouncementsDialogContent: FC<AnnouncementsDialogContentProps> = ({
isLast,
announcement,
onDismiss,
onNext
onNext,
onLast
}) => {
const { t, f } = useI18n()
const primaryImage = useAnnouncementsImage(
Expand Down Expand Up @@ -87,7 +87,7 @@ const AnnouncementsDialogContent: FC<AnnouncementsDialogContentProps> = ({
: 'AnnouncementsDialogContent.next'
)}
variant="secondary"
onClick={isLast ? onDismiss : onNext}
onClick={isLast ? onLast : onNext}
/>
{secondaryImage ? (
<img
Expand Down
6 changes: 1 addition & 5 deletions en/cozy-home/src/hooks/useAnnouncements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,9 @@ const useAnnouncements = ({
)
const unseenData = getUnseenAnnouncements(rawData, uuidsInCommon)

// we consider the first post to have been seen as soon as it is displayed
if (unseenData.length > 0) {
uuidsInCommon.push(unseenData[0].attributes.uuid)
}
save({ seen: uuidsInCommon })

setUnseenData(unseenData)
setUnseenData(unseenData.slice(0, 5))
}
}, [hasStartedFiltering, rawData, values, save])

Expand Down
20 changes: 17 additions & 3 deletions en/cozy-home/src/hooks/useAnnouncementsSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,31 @@ import { useSettings } from 'cozy-client'

const defaultAnnouncements = {
dismissedAt: undefined,
seen: []
seen: [],
firstActivatedAt: undefined
}

const useAnnouncementsSettings = (): {
fetchStatus: string
values: {
dismissedAt?: string
seen: string[]
firstActivatedAt?: string
}
save: (data: { dismissedAt?: string; seen?: string[] }) => void
save: (data: {
dismissedAt?: string
seen?: string[]
firstActivatedAt?: string
}) => void
} => {
const { values, save } = useSettings('home', [
const { query, values, save } = useSettings('home', [
'announcements'
]) as unknown as UseSettingsType

const saveAnnouncement = (data: {
dismissedAt?: string
seen?: string[]
firstActivatedAt?: string
}): void => {
const announcements = {
...(values?.announcements ?? defaultAnnouncements),
Expand All @@ -30,22 +38,28 @@ const useAnnouncementsSettings = (): {
}

return {
fetchStatus: query.fetchStatus,
values: values?.announcements ?? defaultAnnouncements,
save: saveAnnouncement
}
}

interface UseSettingsType {
query: {
fetchStatus: string
}
values?: {
announcements: {
dismissedAt: string
seen: string[]
firstActivatedAt: string
}
}
save: (data: {
announcements: {
dismissedAt?: string
seen: string[]
firstActivatedAt?: string
}
}) => void
}
Expand Down
2 changes: 1 addition & 1 deletion en/search/search_index.json

Large diffs are not rendered by default.

Loading

0 comments on commit ad680fb

Please sign in to comment.