Skip to content

Commit

Permalink
Handle content rename if it's in the current path (#1250)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoltan Takacs authored Mar 23, 2021
1 parent 868a580 commit a222d81
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
14 changes: 13 additions & 1 deletion apps/sensenet/src/components/content/Explore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export function Explore({
const uiSettings = useContext(ResponsivePersonalSettings)
const activeContent = useQuery().get('content') ?? ''
const contentTypeName = useQuery().get('content-type')
const pathFromUrl = useQuery().get('path')
const snRoute = useSnRoute()
const activeAction = snRoute.match!.params.action

Expand Down Expand Up @@ -117,7 +118,18 @@ export function Explore({
key={activeContent}
actionName={activeAction}
contentPath={`${rootPath}${activeContent}`}
submitCallback={() => navigateToAction({ history, routeMatch: snRoute.match })}
submitCallback={(savedContent) => {
const contentNameBeforeEdit = PathHelper.getSegments(activeContent).pop()
if (contentNameBeforeEdit && contentNameBeforeEdit !== savedContent.Name && pathFromUrl) {
return navigateToAction({
history,
routeMatch: snRoute.match,
queryParams: { path: pathFromUrl.replace(contentNameBeforeEdit, savedContent.Name) },
})
}

navigateToAction({ history, routeMatch: snRoute.match })
}}
/>
)
case 'new':
Expand Down
4 changes: 2 additions & 2 deletions apps/sensenet/src/components/view-controls/edit-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { ViewTitle } from './common/view-title'
export interface EditViewProps {
renderIcon?: (name: string) => ReactElement
handleCancel?: () => void
submitCallback?: () => void
submitCallback?: (savedContent: GenericContent) => void
actionName?: ActionNameType
isFullPage?: boolean
contentPath: string
Expand Down Expand Up @@ -76,7 +76,7 @@ export const EditView: React.FC<EditViewProps> = (props) => {
},
},
})
props.submitCallback?.()
props.submitCallback?.(response.d)
} catch (error) {
logger.error({
message:
Expand Down

0 comments on commit a222d81

Please sign in to comment.