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

Handle content rename if it's in the current path #1250

Merged
merged 2 commits into from
Mar 23, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
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