Skip to content

Commit

Permalink
Added time synchronization card for Harmony's overview screen
Browse files Browse the repository at this point in the history
  • Loading branch information
mkurczewski committed Oct 7, 2024
1 parent 60b8d20 commit 9b94cb1
Show file tree
Hide file tree
Showing 7 changed files with 382 additions and 4 deletions.
3 changes: 3 additions & 0 deletions libs/core/__deprecated__/renderer/locales/default/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,9 @@
"module.overview.systemUpdateUpToDate": "You’re up to date.",
"module.overview.systemVersion": "MuditaOS version",
"module.overview.systemVersionTitle": "Current version:",
"module.overview.timeSynchronizationTitle": "Time and date",
"module.overview.timeSynchronizationDescription": "You can synchronize Harmony to match your computer’s date and time.",
"module.overview.timeSynchronizationButton": "Synchronize",
"module.overview.updateAvailableAboutOsVersionSubDescription": "the device will be upgraded to this version",
"module.overview.updateAvailableAboutUpdatesTitle": "{num, plural, =1 {ABOUT UPDATE} other {ABOUT UPDATES}}",
"module.overview.updateAvailableButton": "{num, plural, =1 {Download} other {Download all}}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import { DeviceType } from "device-protocol/models"
import { FunctionComponent } from "Core/core/types/function-component.interface"
import {
DeviceInfo,
OverviewHarmonyWrapper,
StatusInfo,
SystemInfo,
OverviewWrapper,
TimeSynchronizationInfo,
} from "Core/overview/components/overview/overview.styles"

interface OverviewProps {
Expand All @@ -36,7 +37,7 @@ const OverviewContent: FunctionComponent<OverviewProps> = ({
caseColour,
}) => {
return (
<OverviewWrapper>
<OverviewHarmonyWrapper>
<DeviceInfo
caseColour={caseColour}
deviceType={DeviceType.MuditaHarmony}
Expand All @@ -54,7 +55,8 @@ const OverviewContent: FunctionComponent<OverviewProps> = ({
onDownload={onUpdateDownload}
onUpdate={onUpdateInstall}
/>
</OverviewWrapper>
<TimeSynchronizationInfo />
</OverviewHarmonyWrapper>
)
}
export default OverviewContent
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import { DeviceType } from "device-protocol/models"
import { Feature, flags } from "Core/feature-flags"
import { HarmonyOverviewProps } from "Core/overview/components/overview-screens/harmony-overview/harmony-overview.component.interface"
import OverviewContent from "Core/overview/components/overview-screens/harmony-overview/overview-content.component"
import OverviewContent
from "Core/overview/components/overview-screens/harmony-overview/harmony-overview-content.component"
import { UpdateOsFlow } from "Core/overview/components/update-os-flow"
import UpdatingForceModalFlow from "Core/overview/components/updating-force-modal-flow/updating-force-modal-flow.component"
import { CheckForUpdateMode } from "Core/update/constants"
Expand Down
13 changes: 13 additions & 0 deletions libs/core/overview/components/overview/overview.styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Status from "Core/overview/components/status/status.component"
import System from "Core/overview/components/system/system.component"
import FilesManager from "Core/overview/components/files-manager/files-manager.component"
import Backup from "Core/overview/components/backup/backup.component"
import TimeSynchronization from "../time-synchronization/time-synchronization.component"

export const DeviceInfo = styled(DevicePreview)`
grid-area: Device;
Expand All @@ -25,6 +26,10 @@ export const BackupInfo = styled(Backup)`
grid-area: Backup;
`

export const TimeSynchronizationInfo = styled(TimeSynchronization)`
grid-area: TimeSynchronization;
`

const overviewWrapperWithBackup = css`
grid-template-rows: repeat(3, minmax(20.4rem, 1fr));
grid-template-areas:
Expand All @@ -49,6 +54,14 @@ export const OverviewPureWrapper = styled(OverviewWrapper)`
${overviewWrapperWithBackup};
`

export const OverviewHarmonyWrapper = styled(OverviewWrapper)`
grid-template-areas:
"Device Network"
"Device System"
"Device TimeSynchronization";
grid-template-rows: repeat(3, 1fr);
`

export const FileManagerInfo = styled(FilesManager)`
grid-area: FilesManager;
display: none; /* TODO: Remove when feature becomes available */
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Copyright (c) Mudita sp. z o.o. All rights reserved.
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/

export enum TimeSynchronizationIds {
SynchronizeButton = "synchronize-button",
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/**
* Copyright (c) Mudita sp. z o.o. All rights reserved.
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/

import Card, {
CardAction,
CardBody,
CardContent,
CardHeader,
} from "Core/overview/components/card.elements"
import Text, {
TextDisplayStyle,
} from "Core/__deprecated__/renderer/components/core/text/text.component"
import { FunctionComponent } from "Core/core/types/function-component.interface"
import React from "react"
import { defineMessages, FormattedMessage } from "react-intl"
import { DisplayStyle } from "Core/__deprecated__/renderer/components/core/button/button.config"
import ButtonComponent from "Core/__deprecated__/renderer/components/core/button/button.component"
import { TimeSynchronizationIds } from "Core/overview/components/time-synchronization/time-synchronization-ids.enum"

const messages = defineMessages({
timeSynchronizationTitle: {
id: "module.overview.timeSynchronizationTitle",
},
timeSynchronizationDescription: {
id: "module.overview.timeSynchronizationDescription",
},
timeSynchronizationButton: {
id: "module.overview.timeSynchronizationButton",
},
})

interface Props {
// deviceType: DeviceType
// osVersion?: string
// onUpdateCheck?: () => void
// onUpdate?: () => void
// onDownload?: () => void
}

const TimeSynchronization: FunctionComponent<Props> = ({
// deviceType,
// osVersion = "",
// onUpdateCheck = noop,
// onUpdate = noop,
// onDownload = noop,
...props
}) => {
// const {
// checkForUpdateInProgress,
// checkForUpdatePerformed,
// checkForUpdateFailed,
// updateAvailable,
// updateDownloaded,
// } = useUpdateFlowState({
// deviceType: deviceType,
// })
return (
<Card {...props}>
<CardHeader>
<FormattedMessage {...messages.timeSynchronizationTitle} />
<Text displayStyle={TextDisplayStyle.Label} color="secondary">
<FormattedMessage {...messages.timeSynchronizationDescription} />
</Text>
</CardHeader>
<CardBody>
<CardContent>
{/*TODO: Show current Harmony time and date */}
</CardContent>
<CardAction>
<ButtonComponent
displayStyle={DisplayStyle.Secondary}
labelMessage={messages.timeSynchronizationButton}
// onClick={onDownload}
data-testid={TimeSynchronizationIds.SynchronizeButton}
/>
</CardAction>
</CardBody>
</Card>
)
}

export default TimeSynchronization
Loading

0 comments on commit 9b94cb1

Please sign in to comment.