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

Fixes #26161: Allow to enable/disable technique from the directive tree scree #6117

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ class DependencyAndDeletionServiceImpl(
}
}

// group by target, and check if target status is enable
// if the target is disable, we can't change the rule status anyhow
// group by target, and check if target status is enabled
// if the target is disabled, we can't change the rule status anyhow
ZIO
.foreach(switchableCr) {
case (rule, targets) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ class DirectiveEditForm(
onSuccessCallback: (Either[Directive, ChangeRequestId]) => JsCmd,
onMigrationCallback: (Directive, Option[Directive]) => JsCmd,
onFailureCallback: () => JsCmd = { () => Noop },
onRemoveSuccessCallBack: () => JsCmd = { () => Noop }
onRemoveSuccessCallBack: () => JsCmd = { () => Noop },
displayTechniqueDetails: ActiveTechniqueId => JsCmd = { _ => Noop }
) extends DispatchSnippet with Loggable {

import DirectiveEditForm.*
Expand Down Expand Up @@ -206,39 +207,46 @@ class DirectiveEditForm(
).display
}

val versionSelect = if (isADirectiveCreation) {
val versionSelect = if (isADirectiveCreation) {
<div id="version" class="row wbBaseField form-group">
<label for="version" class="col-sm-12 wbBaseFieldLabel">Technique version</label>
<div class="col-sm-12"><input name="version" class="form-control" readonly="" value={
directive.techniqueVersion.serialize
}/></div>
</div>
} else { directiveVersion.toForm_! }
val currentVersion = showDeprecatedVersion(directive.techniqueVersion)
val currentVersion = showDeprecatedVersion(directive.techniqueVersion)
// It is always a Full, but in case add a warning
val versionSelectId = directiveVersion.uniqueFieldId match {
val versionSelectId = directiveVersion.uniqueFieldId match {
case Full(id) => id
case _ =>
logger.warn("could not find id for migration select version")
"id_not_found"
}

val (disableMessage, enableBtn) = (activeTechnique.isEnabled, directive._isEnabled) match {
case (false, false) =>
(
"This Directive and its Technique are disabled.",
<span>
{SHtml.ajaxSubmit("Enable Directive", () => onSubmitDisable(DGModAction.Enable), ("class", "btn btn-sm btn-default"))}
<a class="btn btn-sm btn-default" href={
s"/secure/administration/techniqueLibraryManagement/#${activeTechnique.techniqueName.value}"
}>Edit Technique</a>
{
SHtml.ajaxSubmit(
"Enable Technique",
() => displayTechniqueDetails(activeTechnique.id),
("class", "btn btn-sm btn-default")
)
}
</span>
)
case (false, true) =>
(
"The Technique of this Directive is disabled.",
<a class="btn btn-sm btn-default" href={
s"/secure/administration/techniqueLibraryManagement/#${activeTechnique.techniqueName.value}"
}>Edit Technique</a>
SHtml.ajaxSubmit(
"Enable Technique",
() => displayTechniqueDetails(activeTechnique.id),
("class", "btn btn-sm btn-default")
)
)
case (true, false) =>
(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ object DisplayDirectiveTree extends Loggable {

usedDirectiveIds: Seq[(DirectiveUid, Int)],
onClickCategory: Option[FullActiveTechniqueCategory => JsCmd],
onClickTechnique: Option[(FullActiveTechniqueCategory, FullActiveTechnique) => JsCmd],
onClickTechnique: Option[FullActiveTechnique => JsCmd],
onClickDirective: Option[(FullActiveTechniqueCategory, FullActiveTechnique, Directive) => JsCmd],
createDirective: Option[(Technique, FullActiveTechnique) => JsCmd],
addEditLink: Boolean,
Expand All @@ -146,8 +146,6 @@ object DisplayDirectiveTree extends Loggable {
nodeId: String
): JsTreeNode = new JsTreeNode {

private val localOnClickTechnique = onClickTechnique.map(_.curried(category))

private val localOnClickDirective = onClickDirective.map(_.curried(category))

private val tooltipContent = s"""
Expand Down Expand Up @@ -190,7 +188,7 @@ object DisplayDirectiveTree extends Loggable {
})
// We want our technique sorty by human name, default to bundle name in case we don't have any version but that should not happen
.sortBy(at => at.newestAvailableTechnique.map(_.name).getOrElse(at.techniqueName.value))
.map(at => displayActiveTechnique(at, localOnClickTechnique, localOnClickDirective))
.map(at => displayActiveTechnique(at, onClickTechnique, localOnClickDirective))
)

override val attrs =
Expand Down
Loading