@@ -4,8 +4,8 @@ remotesq2_ui <- function(id){
4
4
tagList(
5
5
h3(" Working with Remotes" ),
6
6
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." ),
9
9
div(class = " box" , id = ns(" remotes" ),
10
10
div(" Remote" , style = " margin-bottom: 3px; width : 90%;" ),
11
11
div(class = " graph" , id = ns(" graphr" ),
@@ -62,22 +62,30 @@ remotesq2_server <- function(id){
62
62
ns <- session $ ns
63
63
n_commits <- reactiveVal(0 )
64
64
remote_branch <- reactiveVal(FALSE )
65
+ local_branch <- reactiveVal(FALSE )
65
66
remote_commit <- reactiveVal(0 )
67
+ current_dot <- reactiveVal(" dot4" )
68
+
69
+ observeEvent(input $ close ,{
70
+ removeModal()
71
+ })
66
72
67
73
observeEvent(input $ clone , {
68
74
insertUI(
69
75
selector = paste0(" #" , ns(" local" )),
70
76
where = " beforeEnd" ,
71
- ui = div(class = " graph" , id = ns(" graphl " ),
77
+ ui = div(class = " graph" , id = ns(" graph " ),
72
78
div(class = " slice" , id = ns(" slice1l" ),
73
79
div(class = c(" branch" , " main" , " left" ),
74
80
" Main" ,
75
81
div(
82
+ id = ns(' dot1' ),
76
83
class = " dot" ,
77
84
message = " Code V1"
78
85
),
79
86
div(
80
- class = c(" dot" , " tagged" , ' head' ),
87
+ id = ns(' dot2' ),
88
+ class = c(" dot" , " tagged" ),
81
89
message = " Code V2"
82
90
),
83
91
style = " z-index: 3;"
@@ -86,11 +94,13 @@ remotesq2_server <- function(id){
86
94
div(class = " slice" , id = ns(" slice2l" ), style = " z-index: 2;" ,
87
95
div(
88
96
div(
97
+ id = ns(' dot3' ),
89
98
class = " dot" ,
90
99
message = " Code V3"
91
100
),
92
101
div(
93
- class = c(" dot" ),
102
+ id = ns(' dot4' ),
103
+ class = c(" dot" , ' head' ),
94
104
message = " Code V4"
95
105
),
96
106
class = c(" branch" , " samebranch" , " main" , " right" )
@@ -104,7 +114,8 @@ remotesq2_server <- function(id){
104
114
})
105
115
106
116
observeEvent(input $ branch , {
107
- if (input $ clone > 0 ){
117
+
118
+ if (input $ clone > 0 & current_dot() == " dot2" ){
108
119
insertUI(
109
120
selector = paste0(" #" , ns(" slice1l" )),
110
121
where = " afterBegin" ,
@@ -117,33 +128,80 @@ remotesq2_server <- function(id){
117
128
ui = div(class = c(" branch" , " topbranch" ), id = ns(" b1l" ))
118
129
)
119
130
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
+ )
120
152
}
121
153
})
122
154
123
155
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');
128
162
$('#{ns('b1l')}').addClass('analysis2');"
163
+ )
164
+
129
165
)
130
166
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
+ }
132
193
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
+ )
140
202
)
141
-
142
203
)
143
- n_commits(n_commits()+ 1 )
144
- if (n_commits() > = 2 ){
145
- disable(" commit" )
146
- }
204
+
147
205
}
148
206
})
149
207
@@ -204,6 +262,12 @@ remotesq2_server <- function(id){
204
262
205
263
})
206
264
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 )
207
271
208
272
209
273
}
0 commit comments