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

[7095] Rename dialog offers the ability to edit a broken reference but will not allow the user to open the content form #4079

Draft
wants to merge 9 commits into
base: develop
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export function LegacyFormDialog(props: LegacyFormDialogProps) {
onRenamed={onContentRenamed}
path={renameContentDialogData.path}
value={renameContentDialogData.value}
allowEditDependencies={false}
/>
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ import { ensureSingleSlash, isBlank } from '../../utils/string';
export interface RenameContentDialogProps extends EnhancedDialogProps {
path: string;
value?: string;
allowEditDependencies?: boolean;
onRenamed(name: string): void;
onSubmittingAndOrPendingChange(value: onSubmittingAndOrPendingChangeProps): void;
}

export function RenameContentDialog(props: RenameContentDialogProps) {
const { path, value, onRenamed, onSubmittingAndOrPendingChange, ...dialogProps } = props;
const { path, value, allowEditDependencies, onRenamed, onSubmittingAndOrPendingChange, ...dialogProps } = props;
const [dependantItems, setDependantItems] = useState<DetailedItem[]>(null);
const [fetchingDependantItems, setFetchingDependantItems] = useState(false);
const [error, setError] = useState(null);
Expand Down Expand Up @@ -73,6 +74,7 @@ export function RenameContentDialog(props: RenameContentDialogProps) {
onSubmittingAndOrPendingChange={onSubmittingAndOrPendingChange}
onRenamed={onRenamed}
error={error}
allowEditDependencies={allowEditDependencies}
/>
</EnhancedDialog>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { applyContentNameRules } from '../../utils/content';
export interface RenameContentDialogContainerProps
extends Pick<
RenameContentDialogProps,
'path' | 'value' | 'onRenamed' | 'onClose' | 'onSubmittingAndOrPendingChange'
'path' | 'value' | 'onRenamed' | 'onClose' | 'onSubmittingAndOrPendingChange' | 'allowEditDependencies'
> {
dependantItems: DetailedItem[];
fetchingDependantItems: boolean;
Expand All @@ -50,6 +50,7 @@ export function RenameContentDialogContainer(props: RenameContentDialogContainer
dependantItems,
fetchingDependantItems,
error,
allowEditDependencies,
onSubmittingAndOrPendingChange
} = props;
const isPage = value.includes('/index.xml');
Expand Down Expand Up @@ -104,6 +105,7 @@ export function RenameContentDialogContainer(props: RenameContentDialogContainer
<FormattedMessage defaultMessage="Consisting of lowercase letters without accents, numbers, dash (-) and underscore (_)." />
)
}
allowEditDependencies={allowEditDependencies}
/>
</DialogBody>
<DialogFooter>
Expand Down
4 changes: 3 additions & 1 deletion ui/app/src/components/RenameDialogBody/RenameItemView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export interface RenameItemViewProps {
onRename: () => void;
onInputChanges: (event: React.ChangeEvent<HTMLInputElement>) => void;
helperText?: ReactNode;
allowEditDependencies?: boolean;
}

export function RenameItemView(props: RenameItemViewProps) {
Expand All @@ -61,6 +62,7 @@ export function RenameItemView(props: RenameItemViewProps) {
fetchingDependantItems,
error,
helperText,
allowEditDependencies = true,
setConfirmBrokenReferences,
onRename,
onInputChanges
Expand Down Expand Up @@ -115,7 +117,7 @@ export function RenameItemView(props: RenameItemViewProps) {
compactView={false}
showTypes="all-deps"
renderAction={(dependency) =>
isEditableAsset(dependency.path) ? (
allowEditDependencies && isEditableAsset(dependency.path) ? (
<IconButton onClick={() => handleEditorDisplay(dependency)}>
<EditRoundedIcon />
</IconButton>
Expand Down