Skip to content

Commit 8918671

Browse files
yeion7SaraVieira
authored andcommitted
Validate name when renaming file (codesandbox#2494)
* break long names * validate filename on rename * show color validation when active
1 parent e58bb38 commit 8918671

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

packages/app/src/app/pages/Sandbox/Editor/Workspace/Files/DirectoryEntry/Entry/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ class Entry extends React.PureComponent {
3939
handleValidateTitle = title => {
4040
const isInvalidTitle = this.props.renameValidator(this.props.id, title);
4141
this.setState({ error: isInvalidTitle });
42+
43+
return isInvalidTitle;
4244
};
4345

4446
handleRename = (newTitle, force) => {

packages/app/src/app/pages/Sandbox/Editor/Workspace/Files/DirectoryEntry/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,14 @@ class DirectoryEntry extends React.Component {
325325
body={
326326
<span>
327327
Are you sure you want to delete{' '}
328-
<b>{this.state.moduleToDeleteTitle}</b>?
328+
<b
329+
css={`
330+
word-break: break-all;
331+
`}
332+
>
333+
{this.state.moduleToDeleteTitle}
334+
</b>
335+
?
329336
<br />
330337
The file will be permanently removed.
331338
</span>

packages/app/src/app/pages/Sandbox/Editor/Workspace/elements.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@ export const getContainerStyles = props => {
6060
}
6161
`;
6262

63+
if (props.active) {
64+
styles += `
65+
color: ${getSelectedColor(
66+
theme['list.activeSelectionForeground']
67+
)} !important;
68+
border-color: ${color()} !important;
69+
background-color: ${color.lighten(0.1).clearer(0.8)()} !important;
70+
`;
71+
}
72+
6373
if (props.editing) {
6474
styles += `
6575
color: ${theme.white()};
@@ -75,16 +85,6 @@ export const getContainerStyles = props => {
7585
}
7686
}
7787

78-
if (props.active) {
79-
styles += `
80-
color: ${getSelectedColor(
81-
theme['list.activeSelectionForeground']
82-
)} !important;
83-
border-color: ${color()} !important;
84-
background-color: ${color.lighten(0.1).clearer(0.8)()} !important;
85-
`;
86-
}
87-
8888
if (props.rightColors) {
8989
styles += `
9090
border-right: 2px solid ${props.rightColors[0]};

0 commit comments

Comments
 (0)