Skip to content

Commit 908e125

Browse files
committed
Update remotes to add checkout
1 parent 8197786 commit 908e125

File tree

2 files changed

+98
-25
lines changed

2 files changed

+98
-25
lines changed

mods/mod-remotesq2.R

Lines changed: 87 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ remotesq2_ui <- function(id){
44
tagList(
55
h3("Working with Remotes"),
66
p("Let's walk through Sylvie's workflow to make the updates for Camille.
7-
First we are going to clone the repository. Then, we will make a new branch,
8-
add a commit and finally push back to the remote so Camille can see the updates."),
7+
First we are going to clone the repository. Then, need to 'checkout' the tagged commit by clicking on it.
8+
After, we can make a new branch, add a commit and finally push back to the remote so Camille can see the updates."),
99
div(class = "box", id = ns("remotes"),
1010
div("Remote", style = "margin-bottom: 3px; width : 90%;" ),
1111
div(class = "graph", id = ns("graphr"),
@@ -62,22 +62,30 @@ remotesq2_server <- function(id){
6262
ns <- session$ns
6363
n_commits <- reactiveVal(0)
6464
remote_branch <- reactiveVal(FALSE)
65+
local_branch <- reactiveVal(FALSE)
6566
remote_commit <- reactiveVal(0)
67+
current_dot <- reactiveVal("dot4")
68+
69+
observeEvent(input$close,{
70+
removeModal()
71+
})
6672

6773
observeEvent(input$clone, {
6874
insertUI(
6975
selector = paste0("#", ns("local")),
7076
where = "beforeEnd",
71-
ui = div(class = "graph", id = ns("graphl"),
77+
ui = div(class = "graph", id = ns("graph"),
7278
div(class = "slice", id = ns("slice1l"),
7379
div(class = c("branch", "main", "left"),
7480
"Main",
7581
div(
82+
id = ns('dot1'),
7683
class = "dot",
7784
message = "Code V1"
7885
),
7986
div(
80-
class = c("dot", "tagged", 'head'),
87+
id = ns('dot2'),
88+
class = c("dot", "tagged"),
8189
message = "Code V2"
8290
),
8391
style = "z-index: 3;"
@@ -86,11 +94,13 @@ remotesq2_server <- function(id){
8694
div(class = "slice", id = ns("slice2l"), style = "z-index: 2;",
8795
div(
8896
div(
97+
id = ns('dot3'),
8998
class = "dot",
9099
message = "Code V3"
91100
),
92101
div(
93-
class = c("dot"),
102+
id = ns('dot4'),
103+
class = c("dot", 'head'),
94104
message = "Code V4"
95105
),
96106
class = c("branch", "samebranch", "main", "right")
@@ -104,7 +114,8 @@ remotesq2_server <- function(id){
104114
})
105115

106116
observeEvent(input$branch, {
107-
if(input$clone > 0){
117+
118+
if(input$clone > 0 & current_dot() == "dot2"){
108119
insertUI(
109120
selector = paste0("#", ns("slice1l")),
110121
where = "afterBegin",
@@ -117,33 +128,80 @@ remotesq2_server <- function(id){
117128
ui = div(class = c("branch", "topbranch"), id = ns("b1l"))
118129
)
119130
disable("branch")
131+
local_branch(TRUE)
132+
} else if(input$clone == 0){
133+
showModal(
134+
modalDialog(
135+
title = "Oops",
136+
p("You need to clone before you can branch"),
137+
footer=tagList(
138+
actionButton(ns('close'), 'close')
139+
)
140+
)
141+
)
142+
} else if(current_dot() != "dot2"){
143+
showModal(
144+
modalDialog(
145+
title = "Oops",
146+
p("You need to 'checkout' to the tagged commit, by clicking on it before you can branch."),
147+
footer=tagList(
148+
actionButton(ns('close'), 'close')
149+
)
150+
)
151+
)
120152
}
121153
})
122154

123155
observeEvent(input$commit, {
124-
if(input$branch > 0){
125-
shinyjs::runjs(
126-
str_glue(
127-
"$('#{ns('graphl')}').find('.head').first().removeClass('head');
156+
157+
if(local_branch()){
158+
if(current_dot() %in% c("dot2", "dot1-b1")){
159+
shinyjs::runjs(
160+
str_glue(
161+
"$('#{ns('graph')}').find('.head').first().removeClass('head');
128162
$('#{ns('b1l')}').addClass('analysis2');"
163+
)
164+
129165
)
130166

131-
)
167+
insertUI(
168+
selector = paste0("#", ns("b1l")),
169+
where = "beforeEnd",
170+
ui = div(
171+
id = ns(paste0('dot',input$commit,'-b1')),
172+
class = c("dot", 'head'),
173+
message = ifelse(n_commits() == 0, "Journal Update",
174+
"Final Journal Update")
175+
)
176+
177+
)
178+
n_commits(n_commits()+1)
179+
if(n_commits() >= 2){
180+
disable("commit")
181+
}
182+
} else {
183+
showModal(
184+
modalDialog(
185+
title = "Oops",
186+
p("For now we are only adding commits to our new branch, try again"),
187+
footer=tagList(
188+
actionButton(ns('close'), 'close')
189+
)
190+
)
191+
)
192+
}
132193

133-
insertUI(
134-
selector = paste0("#", ns("b1l")),
135-
where = "beforeEnd",
136-
ui = div(
137-
class = c("dot", 'head'),
138-
message = ifelse(n_commits() == 0, "Journal Update",
139-
"Final Journal Update")
194+
} else {
195+
showModal(
196+
modalDialog(
197+
title = "Oops",
198+
p("You need to branch before you can commit"),
199+
footer=tagList(
200+
actionButton(ns('close'), 'close')
201+
)
140202
)
141-
142203
)
143-
n_commits(n_commits()+1)
144-
if(n_commits() >= 2){
145-
disable("commit")
146-
}
204+
147205
}
148206
})
149207

@@ -204,6 +262,12 @@ remotesq2_server <- function(id){
204262

205263
})
206264

265+
dot_update("dot1", ns, session, current_dot)
266+
dot_update("dot2", ns, session, current_dot)
267+
dot_update("dot3", ns, session, current_dot)
268+
dot_update("dot4", ns, session, current_dot)
269+
dot_update("dot1-b1", ns, session, current_dot)
270+
dot_update("dot2-b1", ns, session, current_dot)
207271

208272

209273
}

www/style.css

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ background-color: #f2e5e1;
108108
}
109109

110110
.branch.topbranch:before {
111-
width: calc(var(--radius)*2);
111+
width: calc(var(--radius)*2.1);
112112
left: calc(var(--radius)*-1);
113113
top: 105%;
114114
transform: rotate(132deg);
@@ -184,4 +184,13 @@ background-color: #f2e5e1;
184184
min-width: fit-content;
185185
}
186186

187-
187+
.bottomtop:before{
188+
width: calc(var(--radius)*6);
189+
left: calc(var(--radius)*-1);
190+
top: 111%;
191+
transform: rotate(160deg);
192+
content: '';
193+
border-bottom: 3px solid;
194+
position: absolute;
195+
color: #000;
196+
}

0 commit comments

Comments
 (0)