mirror of
https://github.com/strapi/strapi.git
synced 2025-12-16 17:53:53 +00:00
Fix layout update from ctb
This commit is contained in:
parent
53d0014dc2
commit
5e94cf56f7
@ -7,16 +7,25 @@
|
|||||||
},
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"increments": true,
|
"increments": true,
|
||||||
"timestamps": true,
|
"timestamps": [
|
||||||
|
"created_at",
|
||||||
|
"updated_at"
|
||||||
|
],
|
||||||
"comment": ""
|
"comment": ""
|
||||||
},
|
},
|
||||||
"attributes": {
|
"attributes": {
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"rocketshipmaker": {
|
"pic": {
|
||||||
"model": "rocketshipmaker",
|
"model": "file",
|
||||||
"via": "rocketships"
|
"via": "related",
|
||||||
|
"plugin": "upload"
|
||||||
|
},
|
||||||
|
"pictures": {
|
||||||
|
"collection": "file",
|
||||||
|
"via": "related",
|
||||||
|
"plugin": "upload"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -13,10 +13,6 @@
|
|||||||
"attributes": {
|
"attributes": {
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
|
||||||
"rocketships": {
|
|
||||||
"collection": "rocketship",
|
|
||||||
"via": "rocketshipmaker"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -210,12 +210,12 @@ input editRecipeInput {
|
|||||||
|
|
||||||
input editRocketshipInput {
|
input editRocketshipInput {
|
||||||
name: String
|
name: String
|
||||||
rocketshipmaker: ID
|
pic: ID
|
||||||
|
pictures: [ID]
|
||||||
}
|
}
|
||||||
|
|
||||||
input editRocketshipmakerInput {
|
input editRocketshipmakerInput {
|
||||||
name: String
|
name: String
|
||||||
rocketships: [ID]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
input editRoleInput {
|
input editRoleInput {
|
||||||
@ -392,7 +392,8 @@ input RecipeInput {
|
|||||||
|
|
||||||
type Rocketship {
|
type Rocketship {
|
||||||
name: String
|
name: String
|
||||||
rocketshipmaker: Rocketshipmaker
|
pic: UploadFile
|
||||||
|
pictures(sort: String, limit: Int, start: Int, where: JSON): [UploadFile]
|
||||||
id: ID!
|
id: ID!
|
||||||
created_at: DateTime!
|
created_at: DateTime!
|
||||||
updated_at: DateTime!
|
updated_at: DateTime!
|
||||||
@ -400,12 +401,12 @@ type Rocketship {
|
|||||||
|
|
||||||
input RocketshipInput {
|
input RocketshipInput {
|
||||||
name: String
|
name: String
|
||||||
rocketshipmaker: ID
|
pic: ID
|
||||||
|
pictures: [ID]
|
||||||
}
|
}
|
||||||
|
|
||||||
type Rocketshipmaker {
|
type Rocketshipmaker {
|
||||||
name: String
|
name: String
|
||||||
rocketships(sort: String, limit: Int, start: Int, where: JSON): [Rocketship]
|
|
||||||
id: ID!
|
id: ID!
|
||||||
created_at: DateTime!
|
created_at: DateTime!
|
||||||
updated_at: DateTime!
|
updated_at: DateTime!
|
||||||
@ -413,7 +414,6 @@ type Rocketshipmaker {
|
|||||||
|
|
||||||
input RocketshipmakerInput {
|
input RocketshipmakerInput {
|
||||||
name: String
|
name: String
|
||||||
rocketships: [ID]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
input RoleInput {
|
input RoleInput {
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import {
|
|||||||
GET_LAYOUT_SUCCEEDED,
|
GET_LAYOUT_SUCCEEDED,
|
||||||
ON_CHANGE_LIST_LABELS,
|
ON_CHANGE_LIST_LABELS,
|
||||||
RESET_LIST_LABELS,
|
RESET_LIST_LABELS,
|
||||||
|
RESET_PROPS,
|
||||||
} from './constants';
|
} from './constants';
|
||||||
|
|
||||||
export function deleteLayout(uid) {
|
export function deleteLayout(uid) {
|
||||||
@ -67,3 +68,9 @@ export function resetListLabels(slug) {
|
|||||||
slug,
|
slug,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function resetProps() {
|
||||||
|
return {
|
||||||
|
type: RESET_PROPS,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
@ -7,3 +7,4 @@ export const GET_LAYOUT_SUCCEEDED = 'ContentManager/Main/GET_LAYOUT_SUCCEEDED';
|
|||||||
export const ON_CHANGE_LIST_LABELS =
|
export const ON_CHANGE_LIST_LABELS =
|
||||||
'ContentManager/Main/ON_CHANGE_LIST_LABELS';
|
'ContentManager/Main/ON_CHANGE_LIST_LABELS';
|
||||||
export const RESET_LIST_LABELS = 'ContentManager/Main/RESET_LIST_LABELS';
|
export const RESET_LIST_LABELS = 'ContentManager/Main/RESET_LIST_LABELS';
|
||||||
|
export const RESET_PROPS = 'ContentManager/Main/RESET_PROPS';
|
||||||
|
|||||||
@ -16,7 +16,7 @@ import SettingViewModel from '../SettingViewModel';
|
|||||||
import SettingViewGroup from '../SettingViewGroup';
|
import SettingViewGroup from '../SettingViewGroup';
|
||||||
import SettingsView from '../SettingsView';
|
import SettingsView from '../SettingsView';
|
||||||
|
|
||||||
import { getData, getLayout } from './actions';
|
import { getData, getLayout, resetProps } from './actions';
|
||||||
import reducer from './reducer';
|
import reducer from './reducer';
|
||||||
import saga from './saga';
|
import saga from './saga';
|
||||||
import makeSelectMain from './selectors';
|
import makeSelectMain from './selectors';
|
||||||
@ -33,6 +33,7 @@ function Main({
|
|||||||
location: { pathname, search },
|
location: { pathname, search },
|
||||||
global: { plugins },
|
global: { plugins },
|
||||||
models,
|
models,
|
||||||
|
resetProps,
|
||||||
}) {
|
}) {
|
||||||
strapi.useInjectReducer({ key: 'main', reducer, pluginId });
|
strapi.useInjectReducer({ key: 'main', reducer, pluginId });
|
||||||
strapi.useInjectSaga({ key: 'main', saga, pluginId });
|
strapi.useInjectSaga({ key: 'main', saga, pluginId });
|
||||||
@ -40,15 +41,21 @@ function Main({
|
|||||||
const source = getQueryParameters(search, 'source');
|
const source = getQueryParameters(search, 'source');
|
||||||
const getDataRef = useRef();
|
const getDataRef = useRef();
|
||||||
const getLayoutRef = useRef();
|
const getLayoutRef = useRef();
|
||||||
|
const resetPropsRef = useRef();
|
||||||
|
|
||||||
getDataRef.current = getData;
|
getDataRef.current = getData;
|
||||||
getLayoutRef.current = getLayout;
|
getLayoutRef.current = getLayout;
|
||||||
|
resetPropsRef.current = resetProps;
|
||||||
|
|
||||||
const shouldShowLoader =
|
const shouldShowLoader =
|
||||||
slug !== 'ctm-configurations' && layouts[slug] === undefined;
|
slug !== 'ctm-configurations' && layouts[slug] === undefined;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getDataRef.current();
|
getDataRef.current();
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
resetPropsRef.current();
|
||||||
|
};
|
||||||
}, [getDataRef]);
|
}, [getDataRef]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (shouldShowLoader) {
|
if (shouldShowLoader) {
|
||||||
@ -118,6 +125,7 @@ Main.propTypes = {
|
|||||||
search: PropTypes.string,
|
search: PropTypes.string,
|
||||||
}),
|
}),
|
||||||
models: PropTypes.array.isRequired,
|
models: PropTypes.array.isRequired,
|
||||||
|
resetProps: PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
const mapStateToProps = makeSelectMain();
|
const mapStateToProps = makeSelectMain();
|
||||||
@ -127,6 +135,7 @@ export function mapDispatchToProps(dispatch) {
|
|||||||
{
|
{
|
||||||
getData,
|
getData,
|
||||||
getLayout,
|
getLayout,
|
||||||
|
resetProps,
|
||||||
},
|
},
|
||||||
dispatch
|
dispatch
|
||||||
);
|
);
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import {
|
|||||||
GET_LAYOUT_SUCCEEDED,
|
GET_LAYOUT_SUCCEEDED,
|
||||||
ON_CHANGE_LIST_LABELS,
|
ON_CHANGE_LIST_LABELS,
|
||||||
RESET_LIST_LABELS,
|
RESET_LIST_LABELS,
|
||||||
|
RESET_PROPS,
|
||||||
} from './constants';
|
} from './constants';
|
||||||
|
|
||||||
export const initialState = fromJS({
|
export const initialState = fromJS({
|
||||||
@ -58,6 +59,8 @@ function mainReducer(state = initialState, action) {
|
|||||||
return state.updateIn(['layouts', action.slug], () =>
|
return state.updateIn(['layouts', action.slug], () =>
|
||||||
state.getIn(['initialLayouts', action.slug])
|
state.getIn(['initialLayouts', action.slug])
|
||||||
);
|
);
|
||||||
|
case RESET_PROPS:
|
||||||
|
return initialState;
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -129,7 +129,6 @@ function SettingViewModel({
|
|||||||
}, [modifiedData]);
|
}, [modifiedData]);
|
||||||
|
|
||||||
// Retrieve the metadatas for the field's form of the edit view
|
// Retrieve the metadatas for the field's form of the edit view
|
||||||
// Doesn't need to be a function
|
|
||||||
const getSelectedItemMetas = useCallback(() => {
|
const getSelectedItemMetas = useCallback(() => {
|
||||||
return get(modifiedData, ['metadatas', itemNameToSelect, 'edit'], null);
|
return get(modifiedData, ['metadatas', itemNameToSelect, 'edit'], null);
|
||||||
}, [modifiedData, itemNameToSelect]);
|
}, [modifiedData, itemNameToSelect]);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user