Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed create profiles and formats issues #923

Merged
merged 5 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions server/service/core/action/post/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ func createPost(ctx context.Context, post post, status string, r *http.Request)
SpaceID: uint(sID),
DescriptionAMP: post.DescriptionAMP,
MigratedHTML: post.MigratedHTML,
Language: post.Language,
}

if post.MigrationID != nil {
Expand Down Expand Up @@ -554,6 +555,7 @@ func createPost(ctx context.Context, post post, status string, r *http.Request)
"tag_ids": post.TagIDs,
"category_ids": post.CategoryIDs,
"author_ids": post.AuthorIDs,
"language": result.Language,
}

if result.Format.Slug == "fact-check" {
Expand Down
3 changes: 2 additions & 1 deletion server/service/core/action/post/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ type post struct {
Meta postgres.Jsonb `json:"meta" swaggertype:"primitive,string"`
HeaderCode string `json:"header_code"`
FooterCode string `json:"footer_code"`
Language string `json:"language"`
MetaFields postgres.Jsonb `json:"meta_fields" swaggertype:"primitive,string"`
DescriptionAMP string `json:"description_amp"`
MigrationID *uint `json:"migration_id"`
MigrationID *uint `json:"migration_id"`
MigratedHTML string `json:"migrated_html"`
CategoryIDs []uint `json:"category_ids"`
TagIDs []uint `json:"tag_ids"`
Expand Down
2 changes: 2 additions & 0 deletions server/service/core/action/post/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ func update(w http.ResponseWriter, r *http.Request) {
"meta_fields": post.MetaFields,
"description_amp": post.DescriptionAMP,
"migrated_html": post.MigratedHTML,
"language": post.Language,
}

if post.MigrationID != nil {
Expand Down Expand Up @@ -648,6 +649,7 @@ func update(w http.ResponseWriter, r *http.Request) {
"tag_ids": post.TagIDs,
"category_ids": post.CategoryIDs,
"author_ids": post.AuthorIDs,
"language": result.Language,
}

if result.Format.Slug == "fact-check" {
Expand Down
1 change: 1 addition & 0 deletions server/service/core/model/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type Post struct {
Medium *Medium `gorm:"foreignKey:featured_medium_id" json:"medium"`
FormatID uint `gorm:"column:format_id" json:"format_id" sql:"DEFAULT:NULL"`
Format *Format `json:"format"`
Language string `gorm:"column:language" json:"language"`
PublishedDate *time.Time `gorm:"column:published_date" json:"published_date"`
SpaceID uint `gorm:"column:space_id" json:"space_id"`
Schemas postgres.Jsonb `gorm:"column:schemas" json:"schemas" swaggertype:"primitive,string"`
Expand Down
4 changes: 2 additions & 2 deletions studio/src/pages/dashboard/components/Features.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function Features() {
actions={[
<Button
onClick={() => {
dispatch(addDefaultFormats(selectedSpace)).then(() => history.push('/advanced/formats'));
dispatch(addDefaultFormats(selectedSpace));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pallavimshr please redirect to the formats list page to make it consistent with create policies behaviour.

}}
>
<PlusOutlined /> CREATE FORMATS
Expand All @@ -129,7 +129,7 @@ function Features() {
actions={[
<Button
onClick={() => {
dispatch(addDefaultPolicies()).then(() => history.push('/members/policies'));
dispatch(addDefaultPolicies()).then(() => history.push('settings/members/policies'));
}}
>
<PlusOutlined /> CREATE POLICIES
Expand Down
17 changes: 16 additions & 1 deletion studio/src/pages/posts/components/PostForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
Collapse,
Divider,
ConfigProvider,
Select,
} from 'antd';
import Selector from '../../../components/Selector';
import { maker } from '../../../utils/sluger';
Expand All @@ -43,6 +44,7 @@ import MonacoEditor from '../../../components/MonacoEditor';
import getJsonValue from '../../../utils/getJsonValue';
import { DescriptionInput, SlugInput } from '../../../components/FormItems';
import { formatDate } from '../../../utils/date';
import languages from '../../../utils/languages.json'

function PostForm({ onCreate, data = {}, actions = {}, format, page = false }) {
const history = useHistory();
Expand All @@ -58,6 +60,7 @@ function PostForm({ onCreate, data = {}, actions = {}, format, page = false }) {
const [seoDrawer, setSeoDrawerVisible] = useState(false);
const [isModalVisible, setIsModalVisible] = useState(false);
const [isMobileScreen, setIsMobileScreen] = useState(false);
const [selectedLanguage, setSelectedLanguage] = useState('English');

React.useEffect(() => {
const handleResize = () => {
Expand All @@ -71,6 +74,11 @@ function PostForm({ onCreate, data = {}, actions = {}, format, page = false }) {
handleResize();
return () => window.removeEventListener('resize', handleResize);
}, []);
const languagesList = languages.map(language => ({ value: language, label: language }));

const handleLanguageChange = (value) => {
setSelectedLanguage(value);
};


const showSchemaModal = () => {
Expand Down Expand Up @@ -412,6 +420,13 @@ function PostForm({ onCreate, data = {}, actions = {}, format, page = false }) {
<Form.Item name="authors" label="Authors">
<Selector mode="multiple" display={'display_name'} action="Authors" />
</Form.Item>
<Form.Item name="language" label="Language">
<Select
options={languagesList}
defaultValue={selectedLanguage}
onChange={handleLanguageChange}
/>
</Form.Item>
<Form.Item name="featured_medium_id" label="Featured Image">
<MediaSelector />
</Form.Item>
Expand Down Expand Up @@ -682,4 +697,4 @@ function PostForm({ onCreate, data = {}, actions = {}, format, page = false }) {
);
}

export default PostForm;
export default PostForm;
136 changes: 136 additions & 0 deletions studio/src/utils/languages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
[
"Afrikaan",
"Albanian",
"Amharic",
"Arabic",
"Armenian",
"Assamese",
"Aymara",
"Azerbaijani",
"Bambara",
"Basque",
"Belarusian",
"Bengali",
"Bhojpuri",
"Bosnian",
"Bulgarian",
"Catalan",
"Cebuano",
"Chinese (Simplified)",
"Chinese (Traditional)",
"Corsican",
"Croatian",
"Czech",
"Danish",
"Dhivehi",
"Dogri",
"Dutch",
"English",
"Esperanto",
"Estonian",
"Ewe",
"Filipino (Tagalog)",
"Finnish",
"French",
"Frisian",
"Galician",
"Georgian",
"German",
"Greek",
"Guarani",
"Gujarati",
"Haitian Creole",
"Hausa",
"Hawaiian",
"Hebrew ",
"Hindi",
"Hmong",
"Hungarian",
"Icelandic",
"Igbo",
"Ilocano",
"Indonesian",
"Irish",
"Italian",
"Japanese",
"Javanese ",
"Kannada",
"Kazakh",
"Khmer",
"Kinyarwanda",
"Konkani",
"Korean",
"Krio",
"Kurdish",
"Kurdish (Sorani)",
"Kyrgyz",
"Lao",
"Latin",
"Latvian",
"Lingala",
"Lithuanian",
"Luganda",
"Luxembourgish",
"Macedonian",
"Maithili",
"Malagasy",
"Malay",
"Malayalam",
"Maltese",
"Maori",
"Marathi",
"Meiteilon (Manipuri)",
"Mizo",
"Mongolian",
"Myanmar (Burmese)",
"Nepali",
"Norwegian",
"Nyanja (Chichewa)",
"Odia (Oriya)",
"Oromo",
"Pashto",
"Persian",
"Polish",
"Portuguese (Portugal, Brazil)",
"Punjabi",
"Quechua",
"Romanian",
"Russian",
"Samoan",
"Sanskrit",
"Scots Gaelic",
"Sepedi",
"Serbian",
"Sesotho",
"Shona",
"Sindhi",
"Sinhala (Sinhalese)",
"Slovak",
"Slovenian",
"Somali",
"Spanish",
"Sundanese",
"Swahili",
"Swedish",
"Tagalog (Filipino)",
"Tajik",
"Tamil",
"Tatar",
"Telugu",
"Thai",
"Tigrinya",
"Tsonga",
"Turkish",
"Turkmen",
"Twi (Akan)",
"Ukrainian",
"Urdu",
"Uyghur",
"Uzbek",
"Vietnamese",
"Welsh",
"Xhosa",
"Yiddish",
"Yoruba",
"Zulu"
]