mirror of
https://github.com/mastodon/mastodon.git
synced 2026-05-09 04:22:42 -05:00
Add language to collection payload (#38961)
Some checks are pending
Check i18n / check-i18n (push) Waiting to run
Chromatic / Check for relevant changes (push) Waiting to run
Chromatic / Run Chromatic (push) Blocked by required conditions
CodeQL / Analyze (actions) (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
CSS Linting / lint (push) Waiting to run
JavaScript Linting / lint (push) Waiting to run
JavaScript Testing / test (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.3) (push) Blocked by required conditions
Ruby Testing / test (3.4) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.3) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.4) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.29) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.19.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.29) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.4, docker.elastic.co/elasticsearch/elasticsearch:7.17.29) (push) Blocked by required conditions
Some checks are pending
Check i18n / check-i18n (push) Waiting to run
Chromatic / Check for relevant changes (push) Waiting to run
Chromatic / Run Chromatic (push) Blocked by required conditions
CodeQL / Analyze (actions) (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
CSS Linting / lint (push) Waiting to run
JavaScript Linting / lint (push) Waiting to run
JavaScript Testing / test (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.3) (push) Blocked by required conditions
Ruby Testing / test (3.4) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.3) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.4) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.29) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.19.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.29) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.4, docker.elastic.co/elasticsearch/elasticsearch:7.17.29) (push) Blocked by required conditions
This commit is contained in:
parent
658ad9f57e
commit
86e4ecfa20
|
|
@ -46,8 +46,16 @@ import { WizardStepTitle } from './wizard_step_title';
|
|||
export const CollectionDetails: React.FC = () => {
|
||||
const dispatch = useAppDispatch();
|
||||
const history = useHistory();
|
||||
const { id, name, description, topic, discoverable, sensitive, items } =
|
||||
useAppSelector((state) => state.collections.editor);
|
||||
const {
|
||||
id,
|
||||
name,
|
||||
description,
|
||||
topic,
|
||||
language,
|
||||
discoverable,
|
||||
sensitive,
|
||||
items,
|
||||
} = useAppSelector((state) => state.collections.editor);
|
||||
|
||||
const handleNameChange = useCallback(
|
||||
(event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
|
|
@ -110,6 +118,7 @@ export const CollectionDetails: React.FC = () => {
|
|||
name,
|
||||
description,
|
||||
tag_name: topic || null,
|
||||
language: language || null,
|
||||
discoverable,
|
||||
sensitive,
|
||||
};
|
||||
|
|
@ -125,6 +134,9 @@ export const CollectionDetails: React.FC = () => {
|
|||
sensitive,
|
||||
account_ids: items.map((item) => item.account_id),
|
||||
};
|
||||
if (language) {
|
||||
payload.language = language;
|
||||
}
|
||||
if (topic) {
|
||||
payload.tag_name = topic;
|
||||
}
|
||||
|
|
@ -149,6 +161,7 @@ export const CollectionDetails: React.FC = () => {
|
|||
description,
|
||||
topic,
|
||||
discoverable,
|
||||
language,
|
||||
sensitive,
|
||||
dispatch,
|
||||
history,
|
||||
|
|
@ -392,13 +405,8 @@ const renderTagItem = (item: TagSearchResult) => (
|
|||
|
||||
const LanguageField: React.FC = () => {
|
||||
const dispatch = useAppDispatch();
|
||||
const initialLanguage = useAppSelector(
|
||||
(state) => state.compose.get('default_language') as string,
|
||||
);
|
||||
const { language } = useAppSelector((state) => state.collections.editor);
|
||||
|
||||
const selectedLanguage = language ?? initialLanguage;
|
||||
|
||||
const handleLanguageChange = useCallback(
|
||||
(event: React.ChangeEvent<HTMLSelectElement>) => {
|
||||
dispatch(
|
||||
|
|
@ -419,7 +427,7 @@ const LanguageField: React.FC = () => {
|
|||
defaultMessage='Language'
|
||||
/>
|
||||
}
|
||||
value={selectedLanguage}
|
||||
value={language}
|
||||
onChange={handleLanguageChange}
|
||||
>
|
||||
<option value=''>
|
||||
|
|
|
|||
|
|
@ -48,10 +48,10 @@ interface InitialStateMeta {
|
|||
status_page_url: string;
|
||||
terms_of_service_enabled: boolean;
|
||||
emoji_style?: string;
|
||||
wrapstodon?: InitialWrapstodonState | null;
|
||||
wrapstodon?: InitialStateWrapstodon | null;
|
||||
}
|
||||
|
||||
interface Role {
|
||||
interface IntialStateRole {
|
||||
id: string;
|
||||
name: string;
|
||||
permissions: string;
|
||||
|
|
@ -60,17 +60,27 @@ interface Role {
|
|||
collection_limit: number;
|
||||
}
|
||||
|
||||
interface InitialWrapstodonState {
|
||||
interface InitialStateWrapstodon {
|
||||
year: number;
|
||||
state: ApiAnnualReportState;
|
||||
}
|
||||
|
||||
interface InitialStateCompose {
|
||||
text: string;
|
||||
default_privacy?: string;
|
||||
default_sensitive?: boolean;
|
||||
default_language?: string;
|
||||
default_quote_policy?: string;
|
||||
me?: string;
|
||||
}
|
||||
|
||||
export interface InitialState {
|
||||
accounts: Record<string, ApiAccountJSON>;
|
||||
languages: InitialStateLanguage[];
|
||||
compose: InitialStateCompose;
|
||||
critical_updates_pending?: boolean;
|
||||
meta: InitialStateMeta;
|
||||
role?: Role;
|
||||
role?: IntialStateRole;
|
||||
features: string[];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import type {
|
|||
ApiUpdateCollectionPayload,
|
||||
CollectionAccountItem,
|
||||
} from '@/mastodon/api_types/collections';
|
||||
import { me } from '@/mastodon/initial_state';
|
||||
import { initialState, me } from '@/mastodon/initial_state';
|
||||
import {
|
||||
createAppAsyncThunk,
|
||||
createAppSelector,
|
||||
|
|
@ -63,7 +63,7 @@ interface EditorState {
|
|||
name: string;
|
||||
description: string;
|
||||
topic: string;
|
||||
language: string | null;
|
||||
language: string;
|
||||
discoverable: boolean;
|
||||
sensitive: boolean;
|
||||
items: EditorCollectionItem[];
|
||||
|
|
@ -74,7 +74,7 @@ interface UpdateEditorFieldPayload<K extends keyof EditorState> {
|
|||
value: EditorState[K];
|
||||
}
|
||||
|
||||
const initialState: CollectionState = {
|
||||
const initialCollectionState: CollectionState = {
|
||||
collections: {},
|
||||
createdBy: {},
|
||||
featuring: {},
|
||||
|
|
@ -83,7 +83,7 @@ const initialState: CollectionState = {
|
|||
name: '',
|
||||
description: '',
|
||||
topic: '',
|
||||
language: null,
|
||||
language: initialState?.compose.default_language ?? 'en',
|
||||
discoverable: true,
|
||||
sensitive: false,
|
||||
items: [],
|
||||
|
|
@ -92,24 +92,24 @@ const initialState: CollectionState = {
|
|||
|
||||
const collectionSlice = createSlice({
|
||||
name: 'collections',
|
||||
initialState,
|
||||
initialState: initialCollectionState,
|
||||
reducers: {
|
||||
init(state, action: PayloadAction<ApiCollectionJSON | null>) {
|
||||
init(state, action: PayloadAction<ApiCollectionJSON>) {
|
||||
const collection = action.payload;
|
||||
|
||||
state.editor = {
|
||||
id: collection?.id ?? null,
|
||||
name: collection?.name ?? '',
|
||||
description: collection?.description ?? '',
|
||||
topic: inputToHashtag(collection?.tag?.name ?? ''),
|
||||
language: collection?.language ?? '',
|
||||
discoverable: collection?.discoverable ?? true,
|
||||
sensitive: collection?.sensitive ?? false,
|
||||
items: getEditorCollectionItems(collection?.items ?? []),
|
||||
id: collection.id,
|
||||
name: collection.name,
|
||||
description: collection.description ?? '',
|
||||
topic: inputToHashtag(collection.tag?.name ?? ''),
|
||||
language: collection.language ?? '',
|
||||
discoverable: collection.discoverable,
|
||||
sensitive: collection.sensitive,
|
||||
items: getEditorCollectionItems(collection.items),
|
||||
};
|
||||
},
|
||||
reset(state) {
|
||||
state.editor = initialState.editor;
|
||||
state.editor = initialCollectionState.editor;
|
||||
},
|
||||
updateEditorField<K extends keyof EditorState>(
|
||||
state: CollectionState,
|
||||
|
|
@ -233,7 +233,7 @@ const collectionSlice = createSlice({
|
|||
builder.addCase(updateCollection.fulfilled, (state, action) => {
|
||||
const { collection } = action.payload;
|
||||
state.collections[collection.id] = collection;
|
||||
state.editor = initialState.editor;
|
||||
state.editor = initialCollectionState.editor;
|
||||
});
|
||||
|
||||
/**
|
||||
|
|
@ -262,7 +262,7 @@ const collectionSlice = createSlice({
|
|||
const { collection } = actions.payload;
|
||||
|
||||
state.collections[collection.id] = collection;
|
||||
state.editor = initialState.editor;
|
||||
state.editor = initialCollectionState.editor;
|
||||
|
||||
if (state.createdBy[collection.account_id]) {
|
||||
state.createdBy[collection.account_id]?.collectionIds.unshift(
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user