Merge pull request #15430 from strapi/enhancement/ctb-edit-ct-draft-publish

CTB: Replace ToggleInput with Checkbox for the d&p switch
This commit is contained in:
Gustav Hansen 2023-01-25 08:49:11 +01:00 committed by GitHub
commit ccab323cf2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 41 additions and 128 deletions

View File

@ -118,7 +118,7 @@ const EventInput = ({ isDraftAndPublish }) => {
title={formatMessage({
id: 'Settings.webhooks.event.publish-tooltip',
defaultMessage:
'This event only exists for contents with Draft/Publish system enabled',
'This event only exists for content with draft & publish enabled',
})}
>
<Typography variant="sigma" textColor="neutral600">

View File

@ -6,21 +6,11 @@
import React, { useState } from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
import { useIntl } from 'react-intl';
import { Dialog, DialogBody, DialogFooter } from '@strapi/design-system/Dialog';
import { ToggleInput } from '@strapi/design-system/ToggleInput';
import { Typography } from '@strapi/design-system/Typography';
import { Flex } from '@strapi/design-system/Flex';
import { Stack } from '@strapi/design-system/Stack';
import { Button } from '@strapi/design-system/Button';
import ExclamationMarkCircle from '@strapi/icons/ExclamationMarkCircle';
import { Checkbox } from '@strapi/design-system';
import { ConfirmDialog } from '@strapi/helper-plugin';
import { getTrad } from '../../utils';
const TypographyTextAlign = styled(Typography)`
text-align: center;
`;
const DraftAndPublishToggle = ({
description,
disabled,
@ -66,65 +56,27 @@ const DraftAndPublishToggle = ({
return (
<>
<ToggleInput
checked={value || false}
disabled={disabled}
hint={hint}
label={label}
name={name}
offLabel={formatMessage({
id: 'app.components.ToggleCheckbox.off-label',
defaultMessage: 'Off',
})}
onLabel={formatMessage({
id: 'app.components.ToggleCheckbox.on-label',
defaultMessage: 'On',
})}
onChange={handleChange}
<Checkbox checked={value} disabled={disabled} hint={hint} name={name} onChange={handleChange}>
{label}
</Checkbox>
<ConfirmDialog
isOpen={showWarning}
onToggleDialog={handleToggle}
onConfirm={handleConfirm}
bodyText={{
id: getTrad('popUpWarning.draft-publish.message'),
defaultMessage: 'If you disable the draft & publish, your drafts will be deleted.',
}}
leftButtonText={{
id: 'components.popUpWarning.button.cancel',
defaultMessage: 'No, cancel',
}}
rightButtonText={{
id: getTrad('popUpWarning.draft-publish.button.confirm'),
defaultMessage: 'Yes, disable',
}}
/>
{showWarning && (
<Dialog onClose={handleToggle} title="Confirmation" isOpen={showWarning}>
<DialogBody icon={<ExclamationMarkCircle />}>
<Stack spacing={2}>
<Flex justifyContent="center">
<TypographyTextAlign id="confirm-description">
{formatMessage({
id: getTrad('popUpWarning.draft-publish.message'),
defaultMessage:
'If you disable the Draft/Publish system, your drafts will be deleted.',
})}
</TypographyTextAlign>
</Flex>
<Flex justifyContent="center">
<Typography id="confirm-description">
{formatMessage({
id: getTrad('popUpWarning.draft-publish.second-message'),
defaultMessage: 'Are you sure you want to disable it?',
})}
</Typography>
</Flex>
</Stack>
</DialogBody>
<DialogFooter
startAction={
<Button onClick={handleToggle} variant="tertiary">
{formatMessage({
id: 'components.popUpWarning.button.cancel',
defaultMessage: 'No, cancel',
})}
</Button>
}
endAction={
<Button variant="danger-light" onClick={handleConfirm}>
{formatMessage({
id: getTrad('popUpWarning.draft-publish.button.confirm'),
defaultMessage: 'Yes, disable',
})}
</Button>
}
/>
</Dialog>
)}
</>
);
};

View File

@ -15,19 +15,16 @@ const forms = {
return {
sections: [
{
sectionTitle: {
id: getTrad('form.contentType.divider.draft-publish'),
defaultMessage: 'Draft/Publish',
},
items: [
{
intlLabel: {
id: getTrad('contentType.draftAndPublish.label'),
defaultMessage: 'Draft/publish system',
defaultMessage: 'Draft & publish',
},
description: {
id: getTrad('contentType.draftAndPublish.description'),
defaultMessage: 'Write a draft version of each entry before publishing it',
defaultMessage:
'Allows writing a draft version of an entry, before it is published',
},
name: 'draftAndPublish',
type: 'toggle-draft-publish',

View File

@ -211,19 +211,17 @@ const forms = {
return contentTypeForm.base.edit();
},
advanced({ extensions, ...rest }) {
const baseForm = contentTypeForm.advanced.default(rest).sections;
advanced({ extensions }) {
const baseForm = contentTypeForm.advanced
.default()
.sections.map((section) => section.items)
.flat();
const itemsToAdd = extensions.getAdvancedForm(['contentType']);
return {
sections: [
...baseForm,
{
sectionTitle: {
id: 'global.settings',
defaultMessage: 'Settings',
},
items: itemsToAdd,
items: [...baseForm, ...itemsToAdd],
},
],
};

View File

@ -128,7 +128,6 @@
"form.button.select-component": "Komponente auswählen",
"form.button.single-type.description": "Nützlich für einzelne Instanz wie Über uns, Startseite, etc.",
"form.button.single-type.name": "Einzel-Eintrag",
"form.contentType.divider.draft-publish": "Entwurf/Veröffentlichen",
"from": "von",
"listView.headerLayout.description": "Baue die Daten-Architektur deines Inhalts",
"menu.section.components.name": "Komponenten",

View File

@ -122,7 +122,6 @@
"form.button.configure-view": "Konfigurér visning",
"form.button.select-component": "Vælg et komponent",
"form.button.single-type.description": "Bedst til enkelte forekomster som \"om os\", forside osv...",
"form.contentType.divider.draft-publish": "Udkast/offentliggør",
"from": "fra",
"listView.headerLayout.description": "Byg datastrukturen for dit indhold",
"modalForm.attribute.form.base.name.description": "Mellemrum er ikke tilladt i navnet",

View File

@ -51,8 +51,8 @@
"contentType.collectionName.description": "Useful when the name of your Content Type and your table name differ",
"contentType.collectionName.label": "Collection name",
"contentType.displayName.label": "Display name",
"contentType.draftAndPublish.description": "Write a draft version of each entry before publishing it",
"contentType.draftAndPublish.label": "Draft/publish system",
"contentType.draftAndPublish.description": "Allows writing a draft version of an entry, before it is published",
"contentType.draftAndPublish.label": "Draft & publish",
"contentType.kind.change.warning": "You just changed the kind of a content type: API will be reset (routes, controllers, and services will be overwritten).",
"error.attributeName.reserved-name": "This name cannot be used in your content type as it might break other functionalities",
"error.contentType.pluralName-used": "This value cannot be the same as the singular one",
@ -129,7 +129,6 @@
"form.button.select-component": "Select a component",
"form.button.single-type.description": "Best for single instance like about us, homepage, etc.",
"form.button.single-type.name": "Single Type",
"form.contentType.divider.draft-publish": "Draft/Publish",
"from": "from",
"listView.headerLayout.description": "Build the data architecture of your content",
"menu.section.components.name": "Components",
@ -179,7 +178,7 @@
"popUpWarning.bodyMessage.component.delete": "Are you sure you want to delete this component?",
"popUpWarning.bodyMessage.contentType.delete": "Are you sure you want to delete this collection type?",
"popUpWarning.draft-publish.button.confirm": "Yes, disable",
"popUpWarning.draft-publish.message": "If you disable the Draft/Publish system, your drafts will be deleted.",
"popUpWarning.draft-publish.message": "If you disable the Draft & publish, your drafts will be deleted.",
"popUpWarning.draft-publish.second-message": "Are you sure you want to disable it?",
"prompt.unsaved": "Are you sure you want to leave? All your modifications will be lost.",
"relation.attributeName.placeholder": "Ex: author, category, tag",

View File

@ -122,7 +122,6 @@
"form.button.configure-view": "Configurar la vista",
"form.button.select-component": "Seleccione un componente",
"form.button.single-type.description": "Lo mejor para una sola instancia como acerca de nosotros, página de inicio, etc.",
"form.contentType.divider.draft-publish": "BORRAR/PUBLICAR",
"from": "de",
"listView.headerLayout.description": "Construya la arquitectura de datos de su contenido",
"modalForm.attribute.form.base.name.description": "No se permiten espacios para el nombre del atributo",

View File

@ -42,7 +42,6 @@
"form.button.add.field.to.singleType": "Ajouter un nouveau champ à ce single type",
"form.button.cancel": "Annuler",
"form.button.configure-view": "Configurer la vue",
"form.contentType.divider.draft-publish": "BROUILLON/PUBLIER",
"from": "de",
"modalForm.attribute.form.base.name.placeholder": "ex : Slug, URL SEO, URL Canonique",
"modalForm.attribute.target-field": "Champ associé",

View File

@ -112,7 +112,6 @@
"form.button.configure-view": "Konfigurasi tampilan",
"form.button.select-component": "Pilih sebuah komponen",
"form.button.single-type.description": "Terbaik untuk satu contoh seperti tentang kami, beranda, dll.",
"form.contentType.divider.draft-publish": "DRAF/TERBIT",
"from": "dari",
"modalForm.attribute.form.base.name.description": "Tidak ada spasi yang diperbolehkan untuk nama atribut",
"modalForm.attribute.form.base.name.placeholder": "Misalnya Siput, URL SEO, URL Kanonis",

View File

@ -113,7 +113,6 @@
"form.button.configure-view": "Configura vista",
"form.button.select-component": "Seleziona un componente",
"form.button.single-type.description": "Indicato per entità uniche come home page, chi siamo, ecc...",
"form.contentType.divider.draft-publish": "Draft/Publish",
"from": "da",
"modalForm.attribute.form.base.name.description": "Spazi non ammessi per il nome dell'attributo",
"modalForm.attribute.form.base.name.placeholder": "Es: Slug, URL SEO, URL Canonico",

View File

@ -122,7 +122,6 @@
"form.button.configure-view": "보기 설정",
"form.button.select-component": "컴포넌트 선택",
"form.button.single-type.description": "About us, 홈페이지 등 단일 콘텐츠가 필요한 경우에 적합합니다.",
"form.contentType.divider.draft-publish": "초안/발행",
"from": "from",
"listView.headerLayout.description": "콘텐츠 구조를 만듭니다.",
"modalForm.attribute.form.base.name.description": "속성 이름에는 공백을 사용할 수 없습니다.",

View File

@ -128,7 +128,6 @@
"form.button.select-component": "Wybierz komponent",
"form.button.single-type.description": "Najlepsze rozwiązanie dla pojedynczych wystąpień typu strona główna, strona o nas itd",
"form.button.single-type.name": "Pojedynczy typ",
"form.contentType.divider.draft-publish": "Szkic/Publikacja",
"from": "z",
"listView.headerLayout.description": "Stwórz strukturę danych dla twoich treści",
"menu.section.components.name": "Komponenty",

View File

@ -128,7 +128,6 @@
"form.button.select-component": "Selecionar componente",
"form.button.single-type.description": "Melhor para instância única, como sobre nós, página inicial etc.",
"form.button.single-type.name": "Tipo Único",
"form.contentType.divider.draft-publish": "Rascunho / Publicar",
"from": "de",
"listView.headerLayout.description": "Crie a arquitetura de dados do seu conteúdo",
"menu.section.components.name": "Componentes",

View File

@ -114,7 +114,6 @@
"form.button.configure-view": "Настроить отображение",
"form.button.select-component": "Выбрать компонент",
"form.button.single-type.description": "Лучше всего подходит для одного экземпляра, например, о нас, домашняя страница и т.д.",
"form.contentType.divider.draft-publish": "ЧЕРНОВИК/ПУБЛИКАЦИЯ",
"from": "из",
"modalForm.attribute.form.base.name.description": "Пробелы в имени атрибута недопустимы",
"modalForm.attribute.form.base.name.placeholder": "e.g. Slug, SEO URL, Canonical URL",

View File

@ -129,7 +129,6 @@
"form.button.select-component": "Välj en komponent",
"form.button.single-type.description": "Bäst för poster som bara förekommer en gång såsom startsida, om oss, m.m.",
"form.button.single-type.name": "Engångstyper",
"form.contentType.divider.draft-publish": "Utkast/Publicera",
"from": "från",
"listView.headerLayout.description": "Skapa datastrukturen för ditt innehåll",
"menu.section.components.name": "Komponenter",

View File

@ -107,7 +107,6 @@
"form.button.select-component": "Bir bileşen seç",
"form.button.single-type.description": "Tekil kayıtlar (hakkımızda, ana sayfa, v.b.) için ideal",
"form.button.single-type.name": "Tekil Tip",
"form.contentType.divider.draft-publish": "Taslak/Yayınla",
"from": "kimden",
"listView.headerLayout.description": "İçeriğinin veri mimarisini kur",
"menu.section.components.name": "Bileşenler",

View File

@ -129,7 +129,6 @@
"form.button.select-component": "選擇一個元件",
"form.button.single-type.description": "適用於單一實例,如首頁、關於 ...... 等",
"form.button.single-type.name": "單一型別",
"form.contentType.divider.draft-publish": "草稿/發佈",
"from": "從",
"listView.headerLayout.description": "建立您的內容的資料結構",
"menu.section.components.name": "元件",

View File

@ -102,12 +102,12 @@ export default {
name: 'pluginOptions.i18n.localized',
description: {
id: getTrad('plugin.schema.i18n.localized.description-content-type'),
defaultMessage: 'Allow you to have content in different locales',
defaultMessage: 'Allows translating an entry into different languages',
},
type: 'checkboxConfirmation',
intlLabel: {
id: getTrad('plugin.schema.i18n.localized.label-content-type'),
defaultMessage: 'Enable localization for this Content-Type',
defaultMessage: 'Localization',
},
},
];

View File

@ -55,10 +55,8 @@
"plugin.description.short": "Dieses Plugin ermöglicht es, Inhalte in verschiedenen Sprachen zu erstellen, zu lesen und zu aktualisieren, sowohl über das Admin-Panel als auch über die API",
"plugin.name": "Internationalisierung",
"plugin.schema.i18n.ensure-unique-localization": "Einzigartige Felder müssen lokalisiert sein",
"plugin.schema.i18n.localized.description": "Ermöglicht es Inhalte in verschiedenen Sprachen zu pflegen",
"plugin.schema.i18n.localized.description-content-type": "Ermöglicht es Inhalte in verschiedenen Sprachen zu pflegen",
"plugin.schema.i18n.localized.description-field": "Das Feld kann verschiedene Werte in jeder Sprache haben",
"plugin.schema.i18n.localized.label": "Übersetzungen für diesen Inhaltstyp aktivieren",
"plugin.schema.i18n.localized.label-content-type": "Übersetzungen für diesen Inhaltstyp aktivieren",
"plugin.schema.i18n.localized.label-content-type": "Übersetzungen",
"plugin.schema.i18n.localized.label-field": "Übersetzungen für dieses Feld aktivieren"
}

View File

@ -55,10 +55,8 @@
"plugin.description.short": "Dette plugin gør det muligt at oprette, læse og redigere indhold på forskellige sprog, både fra admin panelt og igennem API.",
"plugin.name": "Internationalisering",
"plugin.schema.i18n.ensure-unique-localization": "Unikke felter skal udfyldes for alle sprogvarianter",
"plugin.schema.i18n.localized.description": "Muliggør indhold på forskellige sprog",
"plugin.schema.i18n.localized.description-content-type": "Muliggør indhold på forskellige sprog",
"plugin.schema.i18n.localized.description-field": "Feltet kan have forskellige værdier for hver sprogvariant",
"plugin.schema.i18n.localized.label": "Aktivér sprogvarianter for denne indholdstype",
"plugin.schema.i18n.localized.label-content-type": "Aktivér sprogvarianter for denne indholdstype",
"plugin.schema.i18n.localized.label-field": "Aktivér sprogvarianter for dette felt"
}

View File

@ -55,10 +55,8 @@
"plugin.description.short": "This plugin enables to create, to read and to update content in different languages, both from the Admin Panel and from the API.",
"plugin.name": "Internationalization",
"plugin.schema.i18n.ensure-unique-localization": "Unique fields must be localized",
"plugin.schema.i18n.localized.description": "Allow you to have content in different locales",
"plugin.schema.i18n.localized.description-content-type": "Allow you to have content in different locales",
"plugin.schema.i18n.localized.description-field": "The field can have different values in each locale",
"plugin.schema.i18n.localized.label": "Enable localization for this Content-Type",
"plugin.schema.i18n.localized.label-content-type": "Enable localization for this Content-Type",
"plugin.schema.i18n.localized.description-content-type": "Allows translating an entry into different languages",
"plugin.schema.i18n.localized.description-field": "The field can have different values in each language",
"plugin.schema.i18n.localized.label-content-type": "Internationalization",
"plugin.schema.i18n.localized.label-field": "Enable localization for this field"
}

View File

@ -55,10 +55,8 @@
"plugin.description.short": "Este plugin permite crear, leer y actualizar contenido en diferentes idiomas, tanto desde el Panel de Administración como desde la API.",
"plugin.name": "Internacionalización",
"plugin.schema.i18n.ensure-unique-localization": "Los campos únicos deben estar localizados",
"plugin.schema.i18n.localized.description": "Permitir que tengas contenido en diferentes configuraciones regionales.",
"plugin.schema.i18n.localized.description-content-type": "Permitir que tengas contenido en diferentes configuraciones regionales.",
"plugin.schema.i18n.localized.description-field": "El campo puede tener distintos valores en cada configuración regional.",
"plugin.schema.i18n.localized.label": "Habilitar la localización para este Content-Type",
"plugin.schema.i18n.localized.label-content-type": "Habilitar la localización para este Content-Type",
"plugin.schema.i18n.localized.label-field": "Habilitar la localización para este campo"
}

View File

@ -55,10 +55,8 @@
"plugin.description.short": "Créez, lisez et modifiez votre contenu en différentes langues depuis le panel d'administration et votre API.",
"plugin.name": "Internationalisation",
"plugin.schema.i18n.ensure-unique-localization": "Les champs uniques doivent avoir une locale",
"plugin.schema.i18n.localized.description": "Donne la possibilité d'avoir du contenu dans différentes locales",
"plugin.schema.i18n.localized.description-content-type": "Donne la possibilité d'avoir du contenu dans différentes locales",
"plugin.schema.i18n.localized.description-field": "Le champ peut avoir des valeurs différentes dans chaque locale",
"plugin.schema.i18n.localized.label": "Activer la localisation pour ce type de contenu",
"plugin.schema.i18n.localized.label-content-type": "Activer la localisation pour ce type de contenu",
"plugin.schema.i18n.localized.label-field": "Activer la localisation pour ce champ"
}

View File

@ -54,10 +54,8 @@
"plugin.description.short": "이 플러그인을 사용하면 어드민 패널과 API에서 서로 다른 언어로 된 컨텐츠를 만들고, 읽고, 업데이트할 수 있습니다.",
"plugin.name": "국제화",
"plugin.schema.i18n.ensure-unique-localization": "유니크 필드는 지역화(localized)되어야 합니다.",
"plugin.schema.i18n.localized.description": "로케일별로 콘텐츠를 저장할 수 있습니다.",
"plugin.schema.i18n.localized.description-content-type": "로케일별로 콘텐츠를 저장할 수 있습니다.",
"plugin.schema.i18n.localized.description-field": "필드는 각 로케일에서 서로 다른 값을 가질 수 있습니다.",
"plugin.schema.i18n.localized.label": "이 콘텐츠 타입의 지역화(localization) 켜기",
"plugin.schema.i18n.localized.label-content-type": "이 콘텐츠 타입의 지역화(localization) 켜기",
"plugin.schema.i18n.localized.label-field": "이 필드의 지역화(localization) 켜기"
}

View File

@ -55,10 +55,8 @@
"plugin.description.short": "Ten plugin umożliwia tworzenie, czytanie i aktualizowanie treści w różnych językach, zarówno z poziomu panelu admina jak i z API.",
"plugin.name": "Internationalization",
"plugin.schema.i18n.ensure-unique-localization": "Unikalne pola muszą zostać zlokalizowane",
"plugin.schema.i18n.localized.description": "Pozwala mieć treść w różnych ustawieniach regionalnych",
"plugin.schema.i18n.localized.description-content-type": "Pozwala mieć treść w różnych ustawieniach regionalnych",
"plugin.schema.i18n.localized.description-field": "To pole może mieć różne wartości w zależności od różnych ustawień regionalnych",
"plugin.schema.i18n.localized.label": "Włącz lokalizację dla tego typu treści",
"plugin.schema.i18n.localized.label-content-type": "Włącz lokalizację dla tego typu treści",
"plugin.schema.i18n.localized.label-field": "Włącz lokalizację dla tego pola"
}

View File

@ -55,10 +55,8 @@
"plugin.description.short": "Bu eklenti, hem Yönetim paneli hem de API üzerinden, farklı dillerdeki içeriği oluşturma, okuma ve güncelleme imkanı sağlar.",
"plugin.name": "Uluslararasılaştırma",
"plugin.schema.i18n.ensure-unique-localization": "Benzersiz alanlar yerelleştirilmelidir",
"plugin.schema.i18n.localized.description": "İçerikleri yerelleştirebilmenize imkan tanır",
"plugin.schema.i18n.localized.description-content-type": "İçerikleri yerelleştirebilmenize imkan tanır",
"plugin.schema.i18n.localized.description-field": "Bu alan farklı yerel ayarlarda farklı değer alabilir",
"plugin.schema.i18n.localized.label": "Bu İçerik-Tipi için yerelleştirmeyi etkinleştir",
"plugin.schema.i18n.localized.label-content-type": "Bu İçerik-Tipi için yerelleştirmeyi etkinleştir",
"plugin.schema.i18n.localized.label-field": "Bu Alan için yerelleştirmeyi etkinleştir"
}

View File

@ -46,10 +46,8 @@
"plugin.description.short": "在管理面板或是API中创建查询及更新不同语言的内容",
"plugin.name": "国际化",
"plugin.schema.i18n.ensure-unique-localization": "唯一字段必须本地化",
"plugin.schema.i18n.localized.description": "允许您为内容设置不同的语言",
"plugin.schema.i18n.localized.description-content-type": "允许您为内容设置不同的语言",
"plugin.schema.i18n.localized.description-field": "该字段在不同的语言环境中有不同的值",
"plugin.schema.i18n.localized.label": "为内容类型开启本地化",
"plugin.schema.i18n.localized.label-content-type": "为该内容类型开启本地化",
"plugin.schema.i18n.localized.label-field": "为该字段开启本地化"
}

View File

@ -55,10 +55,8 @@
"plugin.description.short": "此外掛程式允許您從管理面板和 API 建立、讀取、更新不同語言的內容。",
"plugin.name": "國際化",
"plugin.schema.i18n.ensure-unique-localization": "唯一欄位必須本地化",
"plugin.schema.i18n.localized.description": "讓您的內容有多種地區設定",
"plugin.schema.i18n.localized.description-content-type": "讓您的內容有多種地區設定",
"plugin.schema.i18n.localized.description-field": "此欄位在各個地區設定中可以有不同數值",
"plugin.schema.i18n.localized.label": "為此內容型別啟用本地化",
"plugin.schema.i18n.localized.label-content-type": "為此內容型別啟用本地化",
"plugin.schema.i18n.localized.label-field": "為此欄位啟用本地化"
}