
* Minor fixes for intl messages * Add esbuild-loader * switch from babel to esbuild-loader * use formatjs enforce-id linter * Generate ids for intl messages * id format defined by idInterpolationPattern * Modify intl messages extraction * remove react-intl-translations-manager * remove transpile-tx.js * use formatjs cli * Modify defaultMessages.json * modify ids in defaultMessages.json with defined idInterpolationPattern * Fix errors * Fix page crash * Use babel to transpile tests * Fix useStateFromProps * Improve render count * Add test to useStateFromProps * Fix reloading state buh * Do not check if form with channels is dirty * Stop blocking save if form has not changed * Remove debug code * Fix form disabling * Fix variant selection checkbox onClick * Update translations * Update messages * Use esbuild to build storybook Co-authored-by: Bartłomiej Wiaduch <tukan2can@gmail.com> Co-authored-by: Jakub Majorek <majorek.jakub@gmail.com>
137 lines
4.1 KiB
TypeScript
137 lines
4.1 KiB
TypeScript
import CardSpacer from "@saleor/components/CardSpacer";
|
|
import Container from "@saleor/components/Container";
|
|
import LanguageSwitch from "@saleor/components/LanguageSwitch";
|
|
import PageHeader from "@saleor/components/PageHeader";
|
|
import {
|
|
CollectionTranslationFragment,
|
|
LanguageCodeEnum
|
|
} from "@saleor/graphql";
|
|
import { commonMessages, sectionNames } from "@saleor/intl";
|
|
import { Backlink } from "@saleor/macaw-ui";
|
|
import { getStringOrPlaceholder } from "@saleor/misc";
|
|
import {
|
|
TranslationInputFieldName,
|
|
TranslationsEntitiesPageProps
|
|
} from "@saleor/translations/types";
|
|
import React from "react";
|
|
import { useIntl } from "react-intl";
|
|
|
|
import TranslationFields from "../TranslationFields";
|
|
|
|
export interface TranslationsCollectionsPageProps
|
|
extends TranslationsEntitiesPageProps {
|
|
data: CollectionTranslationFragment;
|
|
}
|
|
|
|
const TranslationsCollectionsPage: React.FC<TranslationsCollectionsPageProps> = ({
|
|
activeField,
|
|
disabled,
|
|
languageCode,
|
|
languages,
|
|
data,
|
|
saveButtonState,
|
|
onBack,
|
|
onDiscard,
|
|
onEdit,
|
|
onLanguageChange,
|
|
onSubmit
|
|
}) => {
|
|
const intl = useIntl();
|
|
|
|
return (
|
|
<Container>
|
|
<Backlink onClick={onBack}>
|
|
{intl.formatMessage(sectionNames.translations)}
|
|
</Backlink>
|
|
<PageHeader
|
|
title={intl.formatMessage(
|
|
{
|
|
id: "Bphmwe",
|
|
defaultMessage:
|
|
'Translation Collection "{collectionName}" - {languageCode}',
|
|
description: "header"
|
|
},
|
|
{
|
|
collectionName: getStringOrPlaceholder(data?.collection?.name),
|
|
languageCode
|
|
}
|
|
)}
|
|
>
|
|
<LanguageSwitch
|
|
currentLanguage={LanguageCodeEnum[languageCode]}
|
|
languages={languages}
|
|
onLanguageChange={onLanguageChange}
|
|
/>
|
|
</PageHeader>
|
|
<TranslationFields
|
|
activeField={activeField}
|
|
disabled={disabled}
|
|
initialState={true}
|
|
title={intl.formatMessage(commonMessages.generalInformations)}
|
|
fields={[
|
|
{
|
|
displayName: intl.formatMessage({
|
|
id: "VZsE96",
|
|
defaultMessage: "Collection Name"
|
|
}),
|
|
name: TranslationInputFieldName.name,
|
|
translation: data?.translation?.name || null,
|
|
type: "short" as "short",
|
|
value: data?.collection?.name
|
|
},
|
|
{
|
|
displayName: intl.formatMessage(commonMessages.description),
|
|
name: TranslationInputFieldName.description,
|
|
translation: data?.translation?.description || null,
|
|
type: "rich" as "rich",
|
|
value: data?.collection?.description
|
|
}
|
|
]}
|
|
saveButtonState={saveButtonState}
|
|
richTextResetKey={languageCode}
|
|
onEdit={onEdit}
|
|
onDiscard={onDiscard}
|
|
onSubmit={onSubmit}
|
|
/>
|
|
<CardSpacer />
|
|
<TranslationFields
|
|
activeField={activeField}
|
|
disabled={disabled}
|
|
initialState={true}
|
|
title={intl.formatMessage({
|
|
id: "TGX4T1",
|
|
defaultMessage: "Search Engine Preview"
|
|
})}
|
|
fields={[
|
|
{
|
|
displayName: intl.formatMessage({
|
|
id: "HlEpii",
|
|
defaultMessage: "Search Engine Title"
|
|
}),
|
|
name: TranslationInputFieldName.seoTitle,
|
|
translation: data?.translation?.seoTitle || null,
|
|
type: "short" as "short",
|
|
value: data?.collection?.seoTitle
|
|
},
|
|
{
|
|
displayName: intl.formatMessage({
|
|
id: "US3IPU",
|
|
defaultMessage: "Search Engine Description"
|
|
}),
|
|
name: TranslationInputFieldName.seoDescription,
|
|
translation: data?.translation?.seoDescription || null,
|
|
type: "long" as "long",
|
|
value: data?.collection?.seoDescription
|
|
}
|
|
]}
|
|
saveButtonState={saveButtonState}
|
|
richTextResetKey={languageCode}
|
|
onEdit={onEdit}
|
|
onDiscard={onDiscard}
|
|
onSubmit={onSubmit}
|
|
/>
|
|
</Container>
|
|
);
|
|
};
|
|
TranslationsCollectionsPage.displayName = "TranslationsCollectionsPage";
|
|
export default TranslationsCollectionsPage;
|