mirror of
				https://github.com/strapi/strapi.git
				synced 2025-10-30 17:37:26 +00:00 
			
		
		
		
	Add production mode to ctb
This commit is contained in:
		
							parent
							
								
									2153368bc5
								
							
						
					
					
						commit
						94bd80b59a
					
				| @ -31,7 +31,7 @@ const getDisplayedValue = (type, value, name) => { | |||||||
|     case 'time': |     case 'time': | ||||||
|     case 'datetime': |     case 'datetime': | ||||||
|     case 'timestamp': { |     case 'timestamp': { | ||||||
|       if (value === null) { |       if (value == null) { | ||||||
|         return '-'; |         return '-'; | ||||||
|       } |       } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -88,7 +88,7 @@ const MultipleMenuList = ({ | |||||||
|               <div style={{ marginTop: 3 }}> |               <div style={{ marginTop: 3 }}> | ||||||
|                 <CheckboxWrapper> |                 <CheckboxWrapper> | ||||||
|                   <Label |                   <Label | ||||||
|                     htmlFor="overrideReactSelectBehaviour" |                     htmlFor="overrideReactSelectBehavior" | ||||||
|                     onClick={() => { |                     onClick={() => { | ||||||
|                       handleChangeCategory({ target }); |                       handleChangeCategory({ target }); | ||||||
|                     }} |                     }} | ||||||
|  | |||||||
| @ -35,7 +35,7 @@ const Value = ({ children, ...props }) => { | |||||||
|   const message = |   const message = | ||||||
|     valueLength > '0' |     valueLength > '0' | ||||||
|       ? getTrad('components.componentSelect.value-components') |       ? getTrad('components.componentSelect.value-components') | ||||||
|       : getTrad('components.componentSelect.value-components'); |       : getTrad('components.componentSelect.value-component'); | ||||||
| 
 | 
 | ||||||
|   return ( |   return ( | ||||||
|     <SingleValue {...props}> |     <SingleValue {...props}> | ||||||
|  | |||||||
| @ -20,8 +20,7 @@ const ComponentSelect = ({ | |||||||
|   // Create a ref in order to access the StateManager
 |   // Create a ref in order to access the StateManager
 | ||||||
|   // So we can close the menu after clicking on a menu item
 |   // So we can close the menu after clicking on a menu item
 | ||||||
|   // This allows us to get rid of the menuIsOpen state management
 |   // This allows us to get rid of the menuIsOpen state management
 | ||||||
|   // So we let the lib taking care of it
 |   // So we let the custom components taking care of it
 | ||||||
|   // It's not the best practice but it is efficient
 |  | ||||||
|   const ref = useRef(); |   const ref = useRef(); | ||||||
|   const handleChange = (inputValue, actionMeta) => { |   const handleChange = (inputValue, actionMeta) => { | ||||||
|     const { action } = actionMeta; |     const { action } = actionMeta; | ||||||
| @ -54,7 +53,6 @@ const ComponentSelect = ({ | |||||||
|       value={{ label: value, value }} |       value={{ label: value, value }} | ||||||
|       options={[]} |       options={[]} | ||||||
|       ref={ref} |       ref={ref} | ||||||
|       // menuIsOpen
 |  | ||||||
|       refState={ref} |       refState={ref} | ||||||
|       components={{ |       components={{ | ||||||
|         MenuList: MenuListCompo, |         MenuList: MenuListCompo, | ||||||
|  | |||||||
| @ -37,7 +37,7 @@ import getTrad from '../../utils/getTrad'; | |||||||
| const DataManagerProvider = ({ allIcons, children }) => { | const DataManagerProvider = ({ allIcons, children }) => { | ||||||
|   const [reducerState, dispatch] = useReducer(reducer, initialState, init); |   const [reducerState, dispatch] = useReducer(reducer, initialState, init); | ||||||
|   const [infoModals, toggleInfoModal] = useState({ cancel: false }); |   const [infoModals, toggleInfoModal] = useState({ cancel: false }); | ||||||
|   const { updatePlugin } = useGlobalContext(); |   const { currentEnvironment, updatePlugin } = useGlobalContext(); | ||||||
|   const { |   const { | ||||||
|     components, |     components, | ||||||
|     contentTypes, |     contentTypes, | ||||||
| @ -54,6 +54,8 @@ const DataManagerProvider = ({ allIcons, children }) => { | |||||||
|   const componentMatch = useRouteMatch( |   const componentMatch = useRouteMatch( | ||||||
|     `/plugins/${pluginId}/component-categories/:categoryUid/:componentUid` |     `/plugins/${pluginId}/component-categories/:categoryUid/:componentUid` | ||||||
|   ); |   ); | ||||||
|  |   const isInDevelopmentMode = currentEnvironment === 'development'; | ||||||
|  | 
 | ||||||
|   const isInContentTypeView = contentTypeMatch !== null; |   const isInContentTypeView = contentTypeMatch !== null; | ||||||
|   const firstKeyToMainSchema = isInContentTypeView |   const firstKeyToMainSchema = isInContentTypeView | ||||||
|     ? 'contentType' |     ? 'contentType' | ||||||
| @ -424,8 +426,6 @@ const DataManagerProvider = ({ allIcons, children }) => { | |||||||
|     }); |     }); | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   console.log({ modifiedData }); |  | ||||||
| 
 |  | ||||||
|   return ( |   return ( | ||||||
|     <DataManagerContext.Provider |     <DataManagerContext.Provider | ||||||
|       value={{ |       value={{ | ||||||
| @ -449,6 +449,7 @@ const DataManagerProvider = ({ allIcons, children }) => { | |||||||
|         deleteCategory, |         deleteCategory, | ||||||
|         deleteData, |         deleteData, | ||||||
|         editCategory, |         editCategory, | ||||||
|  |         isInDevelopmentMode, | ||||||
|         initialData, |         initialData, | ||||||
|         isInContentTypeView, |         isInContentTypeView, | ||||||
|         modifiedData, |         modifiedData, | ||||||
| @ -467,6 +468,8 @@ const DataManagerProvider = ({ allIcons, children }) => { | |||||||
|       ) : ( |       ) : ( | ||||||
|         <> |         <> | ||||||
|           {children} |           {children} | ||||||
|  |           {isInDevelopmentMode && ( | ||||||
|  |             <> | ||||||
|               <FormModal /> |               <FormModal /> | ||||||
|               <PopUpWarning |               <PopUpWarning | ||||||
|                 isOpen={infoModals.cancel} |                 isOpen={infoModals.cancel} | ||||||
| @ -485,6 +488,8 @@ const DataManagerProvider = ({ allIcons, children }) => { | |||||||
|               /> |               /> | ||||||
|             </> |             </> | ||||||
|           )} |           )} | ||||||
|  |         </> | ||||||
|  |       )} | ||||||
|     </DataManagerContext.Provider> |     </DataManagerContext.Provider> | ||||||
|   ); |   ); | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -27,18 +27,17 @@ function LeftMenu({ wait }) { | |||||||
|     components, |     components, | ||||||
|     componentsGroupedByCategory, |     componentsGroupedByCategory, | ||||||
|     contentTypes, |     contentTypes, | ||||||
|  |     isInDevelopmentMode, | ||||||
|     sortedContentTypesList, |     sortedContentTypesList, | ||||||
|   } = useDataManager(); |   } = useDataManager(); | ||||||
|   const { currentEnvironment, formatMessage } = useGlobalContext(); |   const { formatMessage } = useGlobalContext(); | ||||||
|   const { push } = useHistory(); |   const { push } = useHistory(); | ||||||
| 
 | 
 | ||||||
|   const isProduction = currentEnvironment === 'production'; |  | ||||||
| 
 |  | ||||||
|   const componentsData = sortBy( |   const componentsData = sortBy( | ||||||
|     Object.keys(componentsGroupedByCategory).map(category => ({ |     Object.keys(componentsGroupedByCategory).map(category => ({ | ||||||
|       name: category, |       name: category, | ||||||
|       title: category, |       title: category, | ||||||
|       isEditable: true, |       isEditable: isInDevelopmentMode, | ||||||
|       onClickEdit: (e, data) => { |       onClickEdit: (e, data) => { | ||||||
|         e.stopPropagation(); |         e.stopPropagation(); | ||||||
|         const search = makeSearch({ |         const search = makeSearch({ | ||||||
| @ -95,16 +94,17 @@ function LeftMenu({ wait }) { | |||||||
|         id: `${pluginId}.menu.section.models.name.`, |         id: `${pluginId}.menu.section.models.name.`, | ||||||
|       }, |       }, | ||||||
|       searchable: true, |       searchable: true, | ||||||
|       customLink: { |       customLink: isInDevelopmentMode | ||||||
|  |         ? { | ||||||
|             Component: CustomLink, |             Component: CustomLink, | ||||||
|             componentProps: { |             componentProps: { | ||||||
|           disabled: isProduction, |  | ||||||
|               id: `${pluginId}.button.model.create`, |               id: `${pluginId}.button.model.create`, | ||||||
|               onClick: () => { |               onClick: () => { | ||||||
|                 handleClickOpenModal('contentType'); |                 handleClickOpenModal('contentType'); | ||||||
|               }, |               }, | ||||||
|             }, |             }, | ||||||
|       }, |           } | ||||||
|  |         : null, | ||||||
|       links: sortedContentTypesList, |       links: sortedContentTypesList, | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
| @ -113,16 +113,17 @@ function LeftMenu({ wait }) { | |||||||
|         id: `${pluginId}.menu.section.components.name.`, |         id: `${pluginId}.menu.section.components.name.`, | ||||||
|       }, |       }, | ||||||
|       searchable: true, |       searchable: true, | ||||||
|       customLink: { |       customLink: isInDevelopmentMode | ||||||
|  |         ? { | ||||||
|             Component: CustomLink, |             Component: CustomLink, | ||||||
|             componentProps: { |             componentProps: { | ||||||
|           disabled: isProduction, |  | ||||||
|               id: `${pluginId}.button.component.create`, |               id: `${pluginId}.button.component.create`, | ||||||
|               onClick: () => { |               onClick: () => { | ||||||
|                 handleClickOpenModal('component'); |                 handleClickOpenModal('component'); | ||||||
|               }, |               }, | ||||||
|             }, |             }, | ||||||
|       }, |           } | ||||||
|  |         : null, | ||||||
|       links: componentsData, |       links: componentsData, | ||||||
|     }, |     }, | ||||||
|   ]; |   ]; | ||||||
|  | |||||||
| @ -37,6 +37,7 @@ const ListPage = () => { | |||||||
|     isInContentTypeView, |     isInContentTypeView, | ||||||
|     // removeAttribute,
 |     // removeAttribute,
 | ||||||
|     // removeComponentFromDynamicZone,
 |     // removeComponentFromDynamicZone,
 | ||||||
|  |     isInDevelopmentMode, | ||||||
|     submitData, |     submitData, | ||||||
|     toggleModalCancel, |     toggleModalCancel, | ||||||
|   } = useDataManager(); |   } = useDataManager(); | ||||||
| @ -168,10 +169,11 @@ const ListPage = () => { | |||||||
|   const label = get(modifiedData, [firstMainDataPath, 'schema', 'name'], ''); |   const label = get(modifiedData, [firstMainDataPath, 'schema', 'name'], ''); | ||||||
| 
 | 
 | ||||||
|   const headerProps = { |   const headerProps = { | ||||||
|     actions: getActions(), |     actions: isInDevelopmentMode ? getActions() : [], | ||||||
|     title: { |     title: { | ||||||
|       label, |       label, | ||||||
|       cta: { |       cta: isInDevelopmentMode | ||||||
|  |         ? { | ||||||
|             icon: 'pencil-alt', |             icon: 'pencil-alt', | ||||||
|             onClick: async () => { |             onClick: async () => { | ||||||
|               await wait(); |               await wait(); | ||||||
| @ -187,7 +189,8 @@ const ListPage = () => { | |||||||
|                 }), |                 }), | ||||||
|               }); |               }); | ||||||
|             }, |             }, | ||||||
|       }, |           } | ||||||
|  |         : null, | ||||||
|     }, |     }, | ||||||
|     content: getDescription(), |     content: getDescription(), | ||||||
|   }; |   }; | ||||||
| @ -210,7 +213,7 @@ const ListPage = () => { | |||||||
|     onClick: () => handleClickAddAttributeMainData(), |     onClick: () => handleClickAddAttributeMainData(), | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   const listActions = [{ ...addButtonProps }]; |   const listActions = isInDevelopmentMode ? [{ ...addButtonProps }] : []; | ||||||
| 
 | 
 | ||||||
|   const convertDataToArray = () => { |   const convertDataToArray = () => { | ||||||
|     return Object.keys(attributes).map((key, index) => { |     return Object.keys(attributes).map((key, index) => { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 soupette
						soupette