Skip to content

Commit

Permalink
apply replacements to title and description also
Browse files Browse the repository at this point in the history
  • Loading branch information
phil294 committed Sep 17, 2022
1 parent 258a8f9 commit 25a54bf
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions web/src/views/GitInput.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,21 @@ import { ref, Ref, computed, defineComponent, reactive, watchEffect, nextTick }

###*
# @param actions {ConfigGitAction[]}
# @param param_replacements {[string,string][]}
# @param replacements {[string,string][]}
# @return {GitAction[]}
###
export parse_config_actions = (actions, param_replacements = []) =>
namespace = param_replacements.map(([k]) => k).join('-') or 'global'
export parse_config_actions = (actions, replacements = []) =>
namespace = replacements.map(([k]) => k).join('-') or 'global'
do_replacements = (###* @type {string} ### txt) =>
for replacement from replacements
txt = txt.replaceAll(replacement[0], replacement[1])
txt
actions.map (action) => {
...action
title: do_replacements(action.title)
description: if action.description then do_replacements(action.description) else undefined
config_key: "action-#{namespace}-#{action.title}"
params: action.params?.map (param) =>
for replacement from param_replacements
param = param.replaceAll(replacement[0], replacement[1])
param
params: action.params?.map do_replacements
}

export default defineComponent
Expand Down

0 comments on commit 25a54bf

Please sign in to comment.