mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-31 01:25:38 -05:00
Add validation for new file names for sql projects (#21601)
* Add validation for new file names for sql projects * Addres comments and add validation for new project dialog * Address comments * Address comments on test * Fix tests * Remove extra error messages and rename file * Address comments * Fix tests * Add test file back
This commit is contained in:
@@ -15,6 +15,7 @@ import { IconPathHelper } from '../common/iconHelper';
|
||||
import { defaultProjectSaveLocation } from '../common/projectLocationHelper';
|
||||
import { TelemetryActions, TelemetryReporter, TelemetryViews } from '../common/telemetry';
|
||||
import { WorkspaceService } from '../services/workspaceService';
|
||||
import { isValidBasename, isValidBasenameErrorMessage } from '../common/pathUtilsHelper';
|
||||
|
||||
class NewProjectDialogModel {
|
||||
projectTypeId: string = '';
|
||||
@@ -174,16 +175,25 @@ export class NewProjectDialog extends DialogBase {
|
||||
}
|
||||
}));
|
||||
|
||||
const projectNameTextBox = view.modelBuilder.inputBox().withProps({
|
||||
ariaLabel: constants.ProjectNameTitle,
|
||||
placeHolder: constants.ProjectNamePlaceholder,
|
||||
required: true,
|
||||
width: constants.DefaultInputWidth
|
||||
}).component();
|
||||
const projectNameTextBox = view.modelBuilder.inputBox().withValidation(
|
||||
component => isValidBasename(component.value)
|
||||
)
|
||||
.withProps({
|
||||
ariaLabel: constants.ProjectNameTitle,
|
||||
placeHolder: constants.ProjectNamePlaceholder,
|
||||
required: true,
|
||||
width: constants.DefaultInputWidth
|
||||
}).component();
|
||||
|
||||
this.register(projectNameTextBox.onTextChanged(() => {
|
||||
this.model.name = projectNameTextBox.value!;
|
||||
return projectNameTextBox.updateProperty('title', projectNameTextBox.value);
|
||||
this.register(projectNameTextBox.onTextChanged(text => {
|
||||
const errorMessage = isValidBasenameErrorMessage(text);
|
||||
if (errorMessage) {
|
||||
// Set validation error message if project name is invalid
|
||||
return void projectNameTextBox.updateProperty('validationErrorMessage', errorMessage);
|
||||
} else {
|
||||
this.model.name = projectNameTextBox.value!;
|
||||
return projectNameTextBox.updateProperty('title', projectNameTextBox.value);
|
||||
}
|
||||
}));
|
||||
|
||||
const locationTextBox = view.modelBuilder.inputBox().withProps({
|
||||
|
||||
Reference in New Issue
Block a user