Skip to content

Commit

Permalink
feat: added new changes from Mark for specifying paths for new tiddle…
Browse files Browse the repository at this point in the history
…rs and other UI improvements
  • Loading branch information
saqimtiaz committed Nov 1, 2021
1 parent cb9d2ff commit 469855c
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 6 deletions.
15 changes: 9 additions & 6 deletions tiddlers/Make a PR.tid
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
created: 20211022225251013
modified: 20211024083502867
modified: 20211029173439544
tags:
title: Make a PR

Expand All @@ -8,26 +8,29 @@ title: Make a PR
\end

\define makePRActions()
<<updateOTP>>
<$action-sendmessage
$message="tm-makepr"
$param={{$:/temp/pr-tiddlers}}
slug={{{ [{$:/temp/pr-title}slugify[]] }}}
/>
\end

|tc-import-table tc-edit-field-value|k
|tc-import-table tc-edit-field-value pr-table|k
|[[Github Personal Access Token|https://github.com/settings/tokens/new?scopes=public_repo]] |<$password name="github"/> |
|PR title: |<$edit-text tiddler="$:/temp/pr-title" default="" tag="input" class="tc-edit-texteditor" inputActions=<<inputActions>>/>|
|PR message: |<$edit-text tiddler="$:/temp/pr-message" default="" tag="textarea" class="tc-edit-texteditor"/>|
|Tiddlers to include: |//Use double square brackets around titles with spaces// <br><$edit-text tiddler="$:/temp/pr-tiddlers" default="" tag="textarea" class="tc-edit-texteditor"/><$list filter="[subfilter{$:/temp/pr-tiddlers}!is[tiddler]]">@@color:red;Tiddler titles are incorrect or tiddlers do not exist.@@</$list>|

|Tiddlers to include: |//Use double square brackets around titles with spaces// <br><$edit-text tiddler="$:/temp/pr-tiddlers" default="" tag="textarea" class="tc-edit-texteditor"/><div style="width: 80%"><$list filter="[subfilter{$:/temp/pr-tiddlers}!is[tiddler]limit[1]]">@@color:red;Some specified tiddlers do not exist. @@</$list><$wikify text="<<arePathsOK>>" name="pathsOK" ><$list filter="[<pathsOK>match[no]]">@@color:red;Specify file paths for new tiddlers below.@@</$list></$wikify></div>|
|Specify file paths for any new tiddlers here: |^//Select path for each new tiddler.// <<createPRpaths>> |

<$wikify text="<<areAllNewTiddlersPathed>>" name="allNewTiddlersPathed" >
<$button
actions=<<makePRActions>>
disabled={{{ [{$:/temp/pr-title}] =[{$:/temp/pr-message}] [{$:/temp/pr-tiddlers}] +[!is[blank]count[]!match[3]then[yes]else[]!is[blank]] :else[subfilter{$:/temp/pr-tiddlers}!is[tiddler]then[yes]else[no]] }}}
actions=<<makePRActions>>
disabled={{{ [{$:/temp/pr-title}] =[{$:/temp/pr-message}] [{$:/temp/pr-tiddlers}] +[!is[blank]count[]!match[3]then[yes]else[]!is[blank]] :else[subfilter{$:/temp/pr-tiddlers}!is[tiddler]limit[1]then[yes]else[]!is[blank]] :else[<allNewTiddlersPathed>match[no]then[yes]else[no]] }}}
>
Make a PR
</$button>
</$wikify>

<$list filter="[{$:/state/makepr/prlink}!is[blank]]">
@@background-color:#D7BCE880;padding:1em;margin:1em;border-radius:0.5em;
Expand Down
95 changes: 95 additions & 0 deletions tiddlers/PR File Path Selection Macros.tid
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
created: 20211027005404249
modified: 20211029182952628
tags: $:/tags/Macro
title: PR File Path Selection Macros

\define selectPRpath()
<$select tiddler=<<selTiddler>> default="--pick-path--">
<option value="">tiddlers (standard)</option>
<$list filter="[<data>indexes[]]
:map[<data>getindex<currentTiddler>split[/]butlast[]join[/]]
+[!is[blank]unique[]sort[]]" >
<option value=<<currentTiddler>>><<currentTiddler>></option>
</$list>
</$select>
\end

\define findNewPRTiddlers()
<$vars data="$:/config/OriginalTiddlerPaths" pfx="../node_modules/tiddlywiki/editions/tw5.com/tiddlers/">
<$list filter="[subfilter{$:/temp/pr-tiddlers}] :map[<data>getindex<currentTiddler>then[KILL-THIS-TIDDLER]else<currentTiddler>] +[unique[]] -[[KILL-THIS-TIDDLER]] +[!is[blank]]" variable=newtid>
<$vars selTiddler={{{ [[$:/temp/prpath-]addsuffix<newtid>]}}} >
<tr><td><$text text=<<newtid>> /></td><td><<selectPRpath>></td></tr>
</$vars>
</$list>
</$vars>
\end

\define buttonPRaddPath()
<$vars regexp='\^|<|>|/|~|:|\?|\\|\*|\"|\|' >
<$vars goodName={{{ [<newtid>search-replace:g:regexp<regexp>,[_]]}}}
jsonName={{{[<newtid>jsonstringify[]]}}}
>
<$list filter="[<selTiddler>get[text]trim[]!is[blank]]" variable="dummy">
<$button class="tc-btn-invisible tc-tiddlylink">{{$:/core/images/plus-button}}
<$action-setfield $tiddler=<<data>> $index=<<jsonName>> $value={{{ [<selTiddler>get[text]addsuffix[/]addsuffix<goodName>addsuffix[.tid]] }}} />
</$button>
</$list>
</$vars></$vars>
\end

\define updateOTP()
<$list filter="[subfilter<unPathedTiddlersFilter>]" variable="newtid">
<$vars selTiddler={{{[[$:/temp/prpath-]addsuffix<newtid>]}}}
regexp='\^|<|>|/|~|:|\?|\\|\*|\"|\|'
data="$:/config/OriginalTiddlerPaths"
>
<$vars goodName={{{ [<newtid>search-replace:g:regexp<regexp>,[_]]}}}
jsonName={{{[<newtid>jsonstringify[]]}}}
>
<$list filter="[<selTiddler>get[text]trim[]!is[blank]]" variable="dummy">
<$action-setfield $tiddler=<<data>> $index=<<jsonName>> $value={{{ [<selTiddler>get[text]addsuffix[/]addsuffix<goodName>addsuffix[.tid]] }}} />
</$list>
</$vars></$vars>
</$list>
\end


\define createPRpaths()
<table style="border: none;">
<<findNewPRTiddlers>>
</table>
\end

\define arePathsOK(yes: "yes" no: "no" ) {{{[subfilter{$:/temp/pr-tiddlers}] :map[[$:/config/OriginalTiddlerPaths]getindex<currentTiddler>then[KILL-THIS-TIDDLER]else<currentTiddler>] +[unique[]] -[[KILL-THIS-TIDDLER]] +[!is[blank]limit[1]then<__no__>else<__yes__>]}}}

\define unPathedTiddlersFilter() [subfilter{$:/temp/pr-tiddlers}] :map[[$:/config/OriginalTiddlerPaths]getindex<currentTiddler>then[KILL-THIS-TIDDLER]else<currentTiddler>] +[unique[]] -[[KILL-THIS-TIDDLER]]

\define unPathedTiddlers() {{{[subfilter<unPathedTiddlersFilter>]}}}


\define unPathedTiddlersx() {{{[subfilter{$:/temp/pr-tiddlers}] :map[[$:/config/OriginalTiddlerPaths]getindex<currentTiddler>then[KILL-THIS-TIDDLER]else<currentTiddler>] +[unique[]] -[[KILL-THIS-TIDDLER]]}}}

\define singleline(yes: "yes" no: "no") {{{[<__yes__>]}}}

\define areAllNewTiddlersPathed(yes: "yes" no: "no") {{{[subfilter<unPathedTiddlersFilter>addprefix[$:/temp/prpath-]is[missing]!is[blank]limit[1]then<__no__>else<__yes__>]}}}

\define test2() {{{[subfilter<unPathedTiddlersFilter>count[]]}}}


<hr/>

<<createPRpaths>>

<<areAreNewTiddlersPathed>>

Paths OK? <<arePathsOK>>

Unpathed: <<unPathedTiddlers>>

Test: <<test2>>

<<xselectPRpath>>

<$button>updateOTP
<<updateOTP>>
</$button>
8 changes: 8 additions & 0 deletions tiddlers/PR Styles.tid
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
created: 20211028224033142
modified: 20211029164622789
tags: $:/tags/Stylesheet
title: PR Styles

table.pr-table tr:nth-child(5) { display: <<arePathsOK none table-row>>;}

table.pr-table > tbody > tr > td:nth-child(1) { width: 8em; }

0 comments on commit 469855c

Please sign in to comment.