Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:mudita/mudita-center into CP-3276
Browse files Browse the repository at this point in the history
  • Loading branch information
MateuszMudita committed Dec 5, 2024
2 parents 46c4fff + 84aa1de commit fcf62b7
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 24 deletions.
12 changes: 12 additions & 0 deletions libs/e2e-test-ids/src/e2e-test-ids.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ export enum PredefinedBackupPasswordTestIds {
SkipButton = "predefined-backup-password-skip-button",
}

export enum PredefinedBackupProgressTestIds {
Title = "predefined-backup-progress-title",
Description = "predefined-backup-progress-description",
ProgressBar = "predefined-backup-progress-progressbar",
}

export enum ProgressBarTestIds {
Description = "progressbar-description",
Progress = "progressbar-progress",
Details = "progressbar-details",
}

export enum ContactSupportModalTestIds {
Title = "contact-support-modal-success-title",
Description = "contact-support-modal-success-description",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,40 @@ export const startImportToDevice = createAsyncThunk<
data: dataToImport[domain.domainKey],
})

const preSendResponse = await startPreSendWithDataFileRequest(
let preSendResponse = await startPreSendWithDataFileRequest(
`${dataTransferId}-${domain.domainKey}`,
domain.path,
data,
deviceId
)

if (!preSendResponse.ok) {
clearTransfers()
return rejectWithValue(
preSendResponse.error?.type as ApiFileTransferError
)
if (
preSendResponse.error.type ===
ApiFileTransferError.FileAlreadyExists &&
dataTransferId &&
deviceId
) {
await cancelDataTransferRequest(dataTransferId, deviceId)
await delay(1000)
preSendResponse = await startPreSendWithDataFileRequest(
`${dataTransferId}-${domain.domainKey}`,
domain.path,
data,
deviceId
)
if (!preSendResponse.ok) {
clearTransfers()
return rejectWithValue(
preSendResponse.error?.type as ApiFileTransferError
)
}
} else {
clearTransfers()
return rejectWithValue(
preSendResponse.error?.type as ApiFileTransferError
)
}
}

domainsPaths[i].transfer = preSendResponse.data
Expand Down
2 changes: 1 addition & 1 deletion libs/generic-view/store/src/lib/views/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export const genericViewsReducer = createReducer(initialState, (builder) => {
[feature]: {
...state.devices[deviceId].features?.[feature],
config: transformGenericComponents({
...state.devices[deviceId].features?.[feature].config,
...state.devices[deviceId].features?.[feature]?.config,
...config,
}),
data: state.devices[deviceId].features?.[feature]?.data,
Expand Down
2 changes: 1 addition & 1 deletion libs/generic-view/ui/src/lib/entities/entities-loader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ export const EntitiesLoader: APIFC<undefined, EntitiesLoaderConfig> = ({

const fetchEntityData = useCallback(
async (entitiesType: string) => {
await dispatch(getEntitiesDataAction({ entitiesType, deviceId }))
await dispatch(getEntitiesMetadataAction({ entitiesType, deviceId }))
await dispatch(getEntitiesDataAction({ entitiesType, deviceId }))
},
[dispatch, deviceId]
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import React, { useId } from "react"
import { APIFC } from "generic-view/utils"
import styled from "styled-components"
import { ProgressBarConfig, ProgressBarData } from "generic-view/models"
import { ProgressBarTestIds } from "e2e-test-ids"

export const ProgressBar: APIFC<ProgressBarData, ProgressBarConfig> = ({
data,
Expand All @@ -16,13 +17,21 @@ export const ProgressBar: APIFC<ProgressBarData, ProgressBarConfig> = ({
const id = useId()
return (
<Wrapper {...props}>
{data?.message && <Message>{data?.message}</Message>}
{data?.message && (
<Message data-testid={ProgressBarTestIds.Description}>
{data?.message}
</Message>
)}
<Progress
id={"progress-" + id}
max={config.maxValue}
value={data?.value}
data-testid={ProgressBarTestIds.Progress}
/>
<Label htmlFor={"progress-" + id}>
<Label
htmlFor={"progress-" + id}
data-testid={ProgressBarTestIds.Details}
>
{data?.value}
{config.valueUnit || "%"}
</Label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,9 @@ const messages = defineMessages({
})

const comingSoonMessages = defineMessages({
messages: {
id: "module.genericViews.backup.features.comingSoon.messages",
},
notes: {
id: "module.genericViews.backup.features.comingSoon.notes",
},
calendar: {
id: "module.genericViews.backup.features.comingSoon.calendar",
},
apps: {
id: "module.genericViews.backup.features.comingSoon.apps",
},
})

interface Props {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { defineMessages } from "react-intl"
import { intl } from "Core/__deprecated__/renderer/utils/intl"
import { useSelector } from "react-redux"
import { backupProgress } from "generic-view/store"
import { PredefinedBackupProgressTestIds } from "e2e-test-ids"

const messages = defineMessages({
title: {
Expand Down Expand Up @@ -50,8 +51,12 @@ export const BackupProgress: FunctionComponent<Props> = ({ features }) => {
return (
<>
<Modal.TitleIcon config={{ type: IconType.Backup }} />
<Modal.Title>{intl.formatMessage(messages.title)}</Modal.Title>
<p>{intl.formatMessage(messages.description)}</p>
<Modal.Title data-testid={PredefinedBackupProgressTestIds.Title}>
{intl.formatMessage(messages.title)}
</Modal.Title>
<p data-testid={PredefinedBackupProgressTestIds.Description}>
{intl.formatMessage(messages.description)}
</p>
<Progress
config={{
maxValue: 100,
Expand All @@ -60,6 +65,7 @@ export const BackupProgress: FunctionComponent<Props> = ({ features }) => {
value: progressStatus.progress,
message: detailMessage,
}}
data-testid={PredefinedBackupProgressTestIds.ProgressBar}
/>
</>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const ImportContactsForm: FunctionComponent<ImportContactsConfig> = ({
setFreezedStatus(importStatus)
dispatch(closeModalAction({ key: modalKey }))
dispatch(cleanImportProcess())
dataTransferAbortReference.current?.()
setError(undefined)
}

Expand Down Expand Up @@ -108,13 +109,17 @@ const ImportContactsForm: FunctionComponent<ImportContactsConfig> = ({

useEffect(() => {
if (importError) {
let message = importError
let message = ""

if (importError === ApiFileTransferError.NotEnoughSpace) {
message = intl.formatMessage(messages.notEnoughSpace)
}
setError({
message: message as string,
})

if (message) {
setError({
message,
})
}
}
}, [importError])

Expand Down

0 comments on commit fcf62b7

Please sign in to comment.