Skip to content

Commit a02ce96

Browse files
authored
Merge pull request #2032 from IFRCGo/project/dref-translation
DREF Translation Update
2 parents 7607352 + 2707d0b commit a02ce96

File tree

71 files changed

+1441
-189
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1441
-189
lines changed

.changeset/angry-rings-shave.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
"go-web-app": patch
3+
---
4+
5+
Enable editing of DREF forms in all languages
6+
7+
- Added new FINALIZING DREF status which indicates form is being finalized and the original language content is being translated into english.
8+
- Added new FINALIZED DREF status which indicates for hase been finalized and the original language has been switched to english.
9+
- Added new FAILED DREF status which indicates form finalization process has failed.
10+
- Added final report and operational update confirmation modal.
11+
- Added view mode for all DREF forms.
12+
- Integrated finalize API in DREF table.
13+
- Updated DREF status and publish APIs to support approval workflow.

app/src/components/Navbar/LanguageDropdown/index.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,10 @@ import {
1616
} from '@togglecorp/fujs';
1717

1818
import DropdownMenuItem from '#components/DropdownMenuItem';
19+
import { languageNameMap } from '#utils/common';
1920

2021
import styles from './styles.module.css';
2122

22-
// NOTE: these doesn't need to be translated
23-
const languageNameMap: Record<Language, string> = {
24-
en: 'English',
25-
fr: 'Français',
26-
es: 'Español',
27-
ar: 'عربي',
28-
};
29-
3023
const languageList = mapToList(
3124
languageNameMap,
3225
(value, key) => ({ key: key as Language, value }),

app/src/components/domain/GoMultiFileInput/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ type Props<T extends NameType> = Omit<RawFileInputProps<T>, 'multiple' | 'value'
6262
withoutPreview?: boolean;
6363
error?: React.ReactNode;
6464
description?: React.ReactNode;
65+
useCurrentLanguageForMutation?: boolean;
6566
}
6667

6768
function GoMultiFileInput<T extends NameType>(props: Props<T>) {
@@ -85,6 +86,7 @@ function GoMultiFileInput<T extends NameType>(props: Props<T>) {
8586
withoutPreview,
8687
error,
8788
description,
89+
useCurrentLanguageForMutation = false,
8890
} = props;
8991

9092
const strings = useTranslation(i18n);
@@ -97,6 +99,7 @@ function GoMultiFileInput<T extends NameType>(props: Props<T>) {
9799
formData: true,
98100
url,
99101
method: 'POST',
102+
useCurrentLanguageForMutation,
100103
body: (body: { files: File[] }) => {
101104
const formData = new FormData();
102105

app/src/components/domain/GoSingleFileInput/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ type Props<T extends NameType> = Omit<RawFileInputProps<T>, 'multiple' | 'value'
4545
description?: React.ReactNode;
4646
onSuccess?: () => void;
4747
withoutStatus?: boolean;
48+
useCurrentLanguageForMutation?: boolean;
4849
}
4950

5051
function GoSingleFileInput<T extends NameType>(props: Props<T>) {
@@ -72,6 +73,7 @@ function GoSingleFileInput<T extends NameType>(props: Props<T>) {
7273
requestBody,
7374
onSuccess,
7475
withoutStatus,
76+
useCurrentLanguageForMutation = false,
7577
} = props;
7678

7779
const strings = useTranslation(i18n);
@@ -88,6 +90,7 @@ function GoSingleFileInput<T extends NameType>(props: Props<T>) {
8890
// FIXME: fix typing in server (low priority)
8991
// the server generated type for response and body is the same
9092
body: (body) => body as never,
93+
useCurrentLanguageForMutation,
9194
onSuccess: (response) => {
9295
const { id, file } = response;
9396
onChange(id, name);

app/src/components/domain/ImageWithCaptionInput/index.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ interface Props<N> {
3030
name: N;
3131
url: SupportedPaths;
3232
value: Value | null | undefined;
33+
readOnly: boolean;
3334
onChange: (value: SetValueArg<Value> | undefined, name: N) => void;
3435
error: ObjectError<Value> | undefined;
3536
fileIdToUrlMap: Record<number, string>;
@@ -38,12 +39,14 @@ interface Props<N> {
3839
icons?: React.ReactNode;
3940
actions?: React.ReactNode;
4041
disabled?: boolean;
42+
useCurrentLanguageForMutation?: boolean;
4143
}
4244

4345
// FIXME: Move this to components
4446
function ImageWithCaptionInput<const N extends string | number>(props: Props<N>) {
4547
const {
4648
className,
49+
readOnly,
4750
name,
4851
value,
4952
url,
@@ -55,6 +58,7 @@ function ImageWithCaptionInput<const N extends string | number>(props: Props<N>)
5558
icons,
5659
actions,
5760
disabled,
61+
useCurrentLanguageForMutation,
5862
} = props;
5963

6064
const strings = useTranslation(i18n);
@@ -92,6 +96,7 @@ function ImageWithCaptionInput<const N extends string | number>(props: Props<N>)
9296
name="id"
9397
accept="image/*"
9498
value={value?.id}
99+
readOnly={readOnly}
95100
onChange={handleFileInputChange}
96101
url={url}
97102
fileIdToUrlMap={fileIdToUrlMap}
@@ -108,6 +113,7 @@ function ImageWithCaptionInput<const N extends string | number>(props: Props<N>)
108113
/>
109114
) : undefined}
110115
clearable
116+
useCurrentLanguageForMutation={useCurrentLanguageForMutation}
111117
>
112118
{label}
113119
</GoSingleFileInput>
@@ -116,6 +122,7 @@ function ImageWithCaptionInput<const N extends string | number>(props: Props<N>)
116122
className={styles.captionInput}
117123
name="caption"
118124
value={value?.caption}
125+
readOnly={readOnly}
119126
onChange={setFieldValue}
120127
error={error?.caption}
121128
placeholder={strings.imageWithCaptionEnterCaption}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"namespace": "languageMismatchMessage",
33
"strings": {
4-
"languageMismatchErrorTitle": "Edit not available in selected language!",
5-
"languageMismatchErrorMessage": "This form was originally created in {originalLanguage} and cannot be edited in a different language!",
6-
"languageMismatchHelpMessage": "Please change the language to {originalLanguage} to edit it!"
4+
"languageMismatchErrorTitle": "Edit not available in {selectedLanguage} language!",
5+
"languageMismatchErrorMessage": "This is because form was originally created in {originalLanguage} language and edits cannot be edited in the {selectedLanguage} language.",
6+
"languageMismatchHelpMessage": "To make changes, please switch to the original language of the form."
77
}
88
}

app/src/components/domain/LanguageMismatchMessage/index.tsx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@ interface Props {
1414
// FIXME: typings should be fixed in the server
1515
// this should be of type Language
1616
originalLanguage: string | undefined;
17+
selectedLanguage: Language;
1718
}
1819

1920
function LanguageMismatchMessage(props: Props) {
2021
const strings = useTranslation(i18n);
2122

2223
const {
2324
title = strings.languageMismatchErrorTitle,
24-
originalLanguage = 'en',
25+
originalLanguage,
26+
selectedLanguage,
2527
} = props;
2628

2729
return (
@@ -32,16 +34,13 @@ function LanguageMismatchMessage(props: Props) {
3234
resolveToString(
3335
strings.languageMismatchErrorMessage,
3436
// FIXME: this should not require cast
35-
{ originalLanguage: languageNameMapEn[originalLanguage as Language] ?? '--' },
36-
)
37-
}
38-
actions={
39-
resolveToString(
40-
strings.languageMismatchHelpMessage,
41-
// FIXME: this should not require cast
42-
{ originalLanguage: languageNameMapEn[originalLanguage as Language] ?? '--' },
37+
{
38+
originalLanguage: languageNameMapEn[originalLanguage as Language] ?? '--',
39+
selectedLanguage: languageNameMapEn[selectedLanguage] ?? '--',
40+
},
4341
)
4442
}
43+
actions={strings.languageMismatchHelpMessage}
4544
/>
4645
);
4746
}

app/src/components/domain/MultiImageWithCaptionInput/index.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ interface Props<N> {
4545
label: React.ReactNode;
4646
icons?: React.ReactNode;
4747
actions?: React.ReactNode;
48+
readOnly?: boolean;
4849
disabled?: boolean;
50+
useCurrentLanguageForMutation?: boolean;
4951
}
5052

5153
// FIXME: Move this to components
@@ -62,7 +64,9 @@ function MultiImageWithCaptionInput<const N extends string | number>(props: Prop
6264
label,
6365
icons,
6466
actions,
67+
readOnly,
6568
disabled,
69+
useCurrentLanguageForMutation = false,
6670
} = props;
6771

6872
const strings = useTranslation(i18n);
@@ -139,7 +143,9 @@ function MultiImageWithCaptionInput<const N extends string | number>(props: Prop
139143
icons={icons}
140144
actions={actions}
141145
withoutPreview
146+
readOnly={readOnly}
142147
disabled={disabled}
148+
useCurrentLanguageForMutation={useCurrentLanguageForMutation}
143149
>
144150
{label}
145151
</GoMultiFileInput>
@@ -168,7 +174,7 @@ function MultiImageWithCaptionInput<const N extends string | number>(props: Prop
168174
ariaLabel={strings.removeImagesButtonTitle}
169175
variant="secondary"
170176
spacing="none"
171-
disabled={disabled}
177+
disabled={disabled || readOnly}
172178
>
173179
<DeleteBinLineIcon />
174180
</IconButton>
@@ -187,6 +193,7 @@ function MultiImageWithCaptionInput<const N extends string | number>(props: Prop
187193
onChange={handleCaptionChange}
188194
error={imageError?.caption}
189195
placeholder={strings.enterCaptionPlaceholder}
196+
readOnly={readOnly}
190197
disabled={disabled}
191198
/>
192199
</div>

app/src/components/domain/SourceInformationInput/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ interface Props {
3131
onRemove: (index: number) => void;
3232
index: number;
3333
disabled?: boolean;
34+
readOnly: boolean;
3435
}
3536

3637
function SourceInformationInput(props: Props) {
@@ -41,6 +42,7 @@ function SourceInformationInput(props: Props) {
4142
index,
4243
onRemove,
4344
disabled,
45+
readOnly,
4446
} = props;
4547

4648
const strings = useTranslation(i18n);
@@ -92,6 +94,7 @@ function SourceInformationInput(props: Props) {
9294
value={value.source_name}
9395
error={error?.source_name}
9496
onChange={onFieldChange}
97+
readOnly={readOnly}
9598
disabled={disabled}
9699
/>
97100
<TextInput
@@ -101,14 +104,15 @@ function SourceInformationInput(props: Props) {
101104
value={value.source_link}
102105
error={error?.source_link}
103106
onChange={handleSourceFieldChange}
107+
readOnly={readOnly}
104108
disabled={disabled}
105109
/>
106110
<Button
107111
className={styles.removeButton}
108112
name={index}
109113
onClick={onRemove}
110114
variant="tertiary"
111-
disabled={disabled}
115+
disabled={disabled || readOnly}
112116
title={strings.sourceInformationDeleteButton}
113117
>
114118
<DeleteBinTwoLineIcon />

app/src/utils/common.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { type Language } from '@ifrc-go/ui/contexts';
12
import { DEFAULT_INVALID_TEXT } from '@ifrc-go/ui/utils';
23
import { isTruthyString } from '@togglecorp/fujs';
34

@@ -37,6 +38,14 @@ export function downloadFile(
3738
URL.revokeObjectURL(url);
3839
}
3940

41+
// NOTE: these doesn't need to be translated
42+
export const languageNameMap: Record<Language, string> = {
43+
en: 'English',
44+
fr: 'Français',
45+
es: 'Español',
46+
ar: 'عربي',
47+
};
48+
4049
export function getFirstTruthyString(
4150
primaryStr: string | null | undefined,
4251
secondaryStr: string | null | undefined,

0 commit comments

Comments
 (0)