Skip to content

Commit

Permalink
feat(settings): more context helps and empty texts
Browse files Browse the repository at this point in the history
  • Loading branch information
Blarc committed May 1, 2023
1 parent be274af commit 9e81169
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.blarc.gitlab.template.lint.plugin.settings.configurables

import com.github.blarc.gitlab.template.lint.plugin.GitlabLintBundle
import com.github.blarc.gitlab.template.lint.plugin.extensions.emptyText
import com.github.blarc.gitlab.template.lint.plugin.extensions.notBlank
import com.github.blarc.gitlab.template.lint.plugin.extensions.reportBugLink
import com.github.blarc.gitlab.template.lint.plugin.settings.AppSettings
Expand Down Expand Up @@ -51,13 +52,19 @@ class SettingsConfigurable(val project: Project) :
.bindText(project.service<ProjectSettings>()::remote)
.validationOnApply { notBlank(it.text) }
.align(Align.FILL)
.resizableColumn()
.emptyText(GitlabLintBundle.message("settings.remote.empty-text"))

contextHelp(GitlabLintBundle.message("settings.remote.comment"))
}
row {
label(GitlabLintBundle.message("settings.fallback-branch"))
.widthGroup("label")
textField()
.bindText(project.service<ProjectSettings>()::fallbackBranch)
.align(Align.FILL)
.resizableColumn()
.emptyText(GitlabLintBundle.message("settings.fallback-branch.empty-text"))

contextHelp(GitlabLintBundle.message("settings.fallback-branch.comment"))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.github.blarc.gitlab.template.lint.plugin.settings.gitlabUrlToken;

import com.github.blarc.gitlab.template.lint.plugin.GitlabLintBundle.message
import com.github.blarc.gitlab.template.lint.plugin.extensions.createColumn
import com.github.blarc.gitlab.template.lint.plugin.extensions.emptyText
import com.github.blarc.gitlab.template.lint.plugin.extensions.notBlank
import com.github.blarc.gitlab.template.lint.plugin.extensions.replaceAt
import com.github.blarc.gitlab.template.lint.plugin.gitlab.Gitlab
Expand All @@ -23,7 +24,6 @@ import java.awt.event.ActionEvent
import java.net.URL
import javax.swing.Action
import javax.swing.JLabel
import javax.swing.JTextField
import javax.swing.ListSelectionModel.SINGLE_SELECTION

class GitlabUrlTokenTable(val project: Project) {
Expand Down Expand Up @@ -102,7 +102,7 @@ class GitlabUrlTokenTable(val project: Project) {
DialogWrapper(true) {
var gitlabUrlToken = newGitlabUrlToken ?: GitlabUrlToken()
val gitlabUrlTextField = JBTextField()
val gitlabTokenTextField = JTextField()
val gitlabTokenTextField = JBTextField()
val verifyLabel = JLabel()

init {
Expand All @@ -125,12 +125,14 @@ class GitlabUrlTokenTable(val project: Project) {
.focused()
.validationOnApply { notBlank(it.text) }
.comment(message("settings.gitlab-url-token.gitlab-url.comment"))
.emptyText(message("settings.gitlab-url-token.gitlab-url.empty-text"))
}
row(message("settings.gitlab-url-token.gitlab-token")) {
cell(gitlabTokenTextField)
.align(Align.FILL)
.bindText({ gitlabUrlToken.gitlabToken.orEmpty() }, { gitlabUrlToken.gitlabToken = it })
.validationOnApply { notBlank(it.text) }
.emptyText(message("settings.gitlab-url-token.gitlab-token.empty-text"))
.comment(message("settings.gitlab-url-token.gitlab-token.comment"), action= {
val host: String = try {
val uri = URL(gitlabUrlTextField.text).toURI()
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/messages/MyBundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,9 @@ settings.globs.exclusions.title=Exclusions
settings.fallback-branch=Fallback branch
settings.fallback-branch.comment=Git branch that is used for linting, if the current branch does not exist on remote. \
Keep in mind that linting result might not be accurate when fallback branch is used.
settings.fallback-branch.empty-text=main
settings.remote.empty-text=origin
settings.gitlab-url-token.gitlab-url.empty-text=https://gitlab.example.com/api/v4
settings.gitlab-url-token.gitlab-token.empty-text=glpat-c67zrFe81alZuEstHCgL
settings.remote.comment=Git remote that is used for linting.

0 comments on commit 9e81169

Please sign in to comment.