Skip to content

Commit

Permalink
Disable project options save when URL/token is blank
Browse files Browse the repository at this point in the history
  • Loading branch information
fourls committed Aug 5, 2024
1 parent 97a351b commit da95e79
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

* Project Options now prevents a blank server URL or project key when in Connected Mode.

### Fixed

* Incompatibility with SonarQube 9.9, by using the HTTP Basic authentication scheme instead of the Bearer scheme.
Expand Down
8 changes: 4 additions & 4 deletions client/source/DelphiLint.OptionsForm.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ object LintOptionsForm: TLintOptionsForm
Width = 234
Height = 23
Anchors = [akLeft, akTop, akRight]
EditLabel.Width = 56
EditLabel.Width = 61
EditLabel.Height = 15
EditLabel.Caption = 'Server URL'
EditLabel.Caption = 'Server URL*'
TabOrder = 0
Text = ''
OnChange = SonarHostUrlEditChange
Expand All @@ -93,9 +93,9 @@ object LintOptionsForm: TLintOptionsForm
Width = 234
Height = 23
Anchors = [akLeft, akTop, akRight]
EditLabel.Width = 58
EditLabel.Width = 63
EditLabel.Height = 15
EditLabel.Caption = 'Project key'
EditLabel.Caption = 'Project key*'
TabOrder = 1
Text = ''
OnChange = SonarHostProjectKeyEditChange
Expand Down
18 changes: 16 additions & 2 deletions client/source/DelphiLint.OptionsForm.pas
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ TLintOptionsForm = class(TForm)

procedure UpdateControls;
procedure UpdateTokenInfo;
function Validate: Boolean;
public
procedure RefreshOptions;
procedure RefreshTheme;
Expand Down Expand Up @@ -137,7 +138,6 @@ procedure TLintOptionsForm.UpdateControls;
SonarHostDownloadPluginCheckBox.Checked := FProjectOptions.SonarHostDownloadPlugin;
AnalysisBaseDirEdit.Text := FProjectOptions.AnalysisBaseDir;
AnalysisReadPropertiesCheckBox.Checked := FProjectOptions.AnalysisReadProperties;
SaveButton.Enabled := True;

ProjectName := TPath.GetFileName(FProjectFile);
ProjectNameLabel.Caption := 'DelphiLint: ' + ProjectName;
Expand All @@ -149,12 +149,12 @@ procedure TLintOptionsForm.UpdateControls;
SonarHostDownloadPluginCheckBox.Checked := False;
AnalysisBaseDirEdit.Text := '';
AnalysisReadPropertiesCheckBox.Checked := False;
SaveButton.Enabled := False;

ProjectNameLabel.Caption := 'DelphiLint: (no project)';
Caption := 'DelphiLint Project Options (no project)';
end;

SaveButton.Enabled := Validate;
UpdateTokenInfo;
end;

Expand Down Expand Up @@ -242,6 +242,7 @@ procedure TLintOptionsForm.SonarHostUrlEditChange(Sender: TObject);
FProjectOptions.SonarHostUrl := SonarHostUrlEdit.Text;
UpdateTokenInfo;
end;
SaveButton.Enabled := Validate;
end;

//______________________________________________________________________________________________________________________
Expand All @@ -261,6 +262,7 @@ procedure TLintOptionsForm.SonarHostProjectKeyEditChange(Sender: TObject);
if Assigned(FProjectOptions) then begin
FProjectOptions.SonarHostProjectKey := SonarHostProjectKeyEdit.Text;
end;
SaveButton.Enabled := Validate;
end;

//______________________________________________________________________________________________________________________
Expand Down Expand Up @@ -324,4 +326,16 @@ procedure TLintOptionsForm.UpdateTokenInfo;

//______________________________________________________________________________________________________________________

function TLintOptionsForm.Validate: Boolean;
begin
if IsConnectedMode then begin
Result := (SonarHostUrlEdit.Text <> '') and (SonarHostProjectKeyEdit.Text <> '');
end
else begin
Result := True;
end;
end;

//______________________________________________________________________________________________________________________

end.

0 comments on commit da95e79

Please sign in to comment.