
* Replace withStyleswith useStyles (#1100) * Replace withStyleswith useStyles * Update messages * Use rem as a spacing unit (#1101) * Use rems as spacing units * Fix visual bugs * Update stories * Use macaw-ui as theme provider (#1108) * Use macaw ui as a theme provider * Add react-dom to aliases * Fix jest module resolution * Update useTheme hook usage * Fix test wrapper * Use macaw from git repo * Fix CI * Update stories * Fix aliasing * Extract savebar to macaw ui (#1146) * wip * Use savebar from macaw * Use confirm button from macaw * Improve file structure * Use sidebar context from macaw * Update macaw * Update macaw version * Remove savebar from storybook * Update stories * Use alerts and notifications from macaw (#1166) * Use alerts from macaw * Add notifications from macaw * Update stories * Pin macaw version * Encapsulate limit reached in one component * Remove unused imports * Use backlinks from macaw (#1183) * Use backlink from macaw * Update macaw version * Use macaw sidebar (#1148) * Use sidebar from macaw * Use shipped logo * Use lowercase * Update stories * Use user chip from macaw (#1191) * Use user chip from macaw * Use dedicated components for menu items * Simplify code * Bump version and fix types (#1210) * Rename onBack to onClick * Rename UserChip to UserChipMenu * Rename IMenuItem to SidebarMenuItem * Update macaw version * Fix tables after changes in macaw (#1220) * Update macaw version * Update changelog * Update stories * Fix after rebase * Update to macaw 0.2.0 * Lint files * Update macaw to 0.2.2
128 lines
4 KiB
TypeScript
128 lines
4 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 } from "@saleor/fragments/types/CollectionTranslationFragment";
|
|
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 { LanguageCodeEnum } from "../../../types/globalTypes";
|
|
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(
|
|
{
|
|
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({
|
|
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}
|
|
onEdit={onEdit}
|
|
onDiscard={onDiscard}
|
|
onSubmit={onSubmit}
|
|
/>
|
|
<CardSpacer />
|
|
<TranslationFields
|
|
activeField={activeField}
|
|
disabled={disabled}
|
|
initialState={true}
|
|
title={intl.formatMessage({
|
|
defaultMessage: "Search Engine Preview"
|
|
})}
|
|
fields={[
|
|
{
|
|
displayName: intl.formatMessage({
|
|
defaultMessage: "Search Engine Title"
|
|
}),
|
|
name: TranslationInputFieldName.seoTitle,
|
|
translation: data?.translation?.seoTitle || null,
|
|
type: "short" as "short",
|
|
value: data?.collection?.seoTitle
|
|
},
|
|
{
|
|
displayName: intl.formatMessage({
|
|
defaultMessage: "Search Engine Description"
|
|
}),
|
|
name: TranslationInputFieldName.seoDescription,
|
|
translation: data?.translation?.seoDescription || null,
|
|
type: "long" as "long",
|
|
value: data?.collection?.seoDescription
|
|
}
|
|
]}
|
|
saveButtonState={saveButtonState}
|
|
onEdit={onEdit}
|
|
onDiscard={onDiscard}
|
|
onSubmit={onSubmit}
|
|
/>
|
|
</Container>
|
|
);
|
|
};
|
|
TranslationsCollectionsPage.displayName = "TranslationsCollectionsPage";
|
|
export default TranslationsCollectionsPage;
|