@@ -29,11 +29,27 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
29
29
<i class =" material-icons" >arrow_back</i >
30
30
</material-button >
31
31
<h2 >History of { props .image }:{ props .tag } <i class =" material-icons" >history</i ></h2 >
32
+ <material-button
33
+ text-color =" var(--accent-text)"
34
+ color =" inherit"
35
+ waves-color =" var(--hover-background)"
36
+ waves-center =" true"
37
+ rounded =" true"
38
+ outlined
39
+ onClick =" { showDockerfile }"
40
+ >
41
+ Dockerfile
42
+ </material-button >
32
43
</div >
33
44
</material-card >
34
45
<div if =" { ! state .loadend }" class =" spinner-wrapper" >
35
46
<material-spinner ></material-spinner >
36
47
</div >
48
+ <dockerfile
49
+ opened =" { state .showDockerfile }"
50
+ on-close =" { onDockerfileClose }"
51
+ elements =" { state .elements }"
52
+ ></dockerfile >
37
53
38
54
<material-tabs
39
55
if =" { state .archs && state .loadend }"
@@ -57,11 +73,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
57
73
<script >
58
74
import { DockerImage } from ' ../../scripts/docker-image' ;
59
75
import { bytesToSize } from ' ../../scripts/utils' ;
76
+ import Dockerfile from ' ../dialogs/dockerfile.riot' ;
60
77
import router from ' ../../scripts/router' ;
61
78
import TagHistoryElement from ' ./tag-history-element.riot' ;
62
79
export default {
63
80
components: {
64
81
TagHistoryElement,
82
+ Dockerfile,
65
83
},
66
84
onBeforeMount (props , state ) {
67
85
state .elements = [];
@@ -105,10 +123,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
105
123
for (var attribute in elt) {
106
124
if (elt .hasOwnProperty (attribute) && attribute != ' empty_layer' ) {
107
125
const value = elt[attribute];
108
- const guiElement = {
109
- ' key' : attribute,
110
- ' value' : modifySpecificAttributeTypes (attribute, value),
111
- };
126
+ const guiElement = modifySpecificAttributeTypes (attribute, value);
112
127
guiElements .push (guiElement);
113
128
}
114
129
}
@@ -143,6 +158,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
143
158
toTaglist () {
144
159
return router .taglist (this .props .image );
145
160
},
161
+ showDockerfile () {
162
+ console .log (this );
163
+ this .update ({ showDockerfile: true });
164
+ },
165
+ onDockerfileClose () {
166
+ this .update ({ showDockerfile: false });
167
+ },
146
168
};
147
169
const eltIdx = function (e ) {
148
170
switch (e) {
@@ -171,27 +193,47 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
171
193
return eltIdx (e1 .key ) - eltIdx (e2 .key );
172
194
};
173
195
174
- const modifySpecificAttributeTypes = function (attribute , value ) {
175
- switch (attribute) {
196
+ const parseCreatedBy = (value ) => {
197
+ if (value .startsWith (' COPY' )) {
198
+ return {
199
+ value: ' COPY' ,
200
+ content: value .replace (/ ^ COPY / , ' ' ),
201
+ };
202
+ }
203
+ let cmd = value .match (/ \/ bin\/ sh * -c * #\( nop\) * ([A-Z ] + ) (. * )/ );
204
+ return {
205
+ value: (cmd && cmd[1 ]) || ' RUN' ,
206
+ content: (cmd && cmd[2 ]) || value .replace (/ ^ \/ bin\/ sh * -c * (#\( nop\) )? / , ' ' ),
207
+ };
208
+ };
209
+
210
+ const modifySpecificAttributeTypes = function (key , value ) {
211
+ switch (key) {
176
212
case ' created' :
177
- return new Date (value).toLocaleString ();
213
+ return { key, value : new Date (value).toLocaleString () } ;
178
214
case ' created_by' :
179
- const cmd = value .match (/ \/ bin\/ sh * -c * #\( nop\) * ([A-Z ] + )/ );
180
- return (cmd && cmd[1 ]) || ' RUN' ;
215
+ const cmd = value .match (/ \/ bin\/ sh * -c * #\( nop\) * ([A-Z ] + ) (. * )/ );
216
+ return {
217
+ key,
218
+ ... parseCreatedBy (value),
219
+ };
181
220
case ' size' :
182
- return bytesToSize (value);
221
+ return { key, value : bytesToSize (value) } ;
183
222
case ' Entrypoint' :
184
223
case ' Cmd' :
185
- return (value || []).join (' ' );
224
+ return { key, value : (value || []).join (' ' ) } ;
186
225
case ' Labels' :
187
- return Object .keys (value || {}).map (function (elt ) {
188
- return value[elt] ? elt + ' =' + value[elt] : ' ' ;
189
- });
226
+ return {
227
+ key,
228
+ value: Object .keys (value || {}).map (function (elt ) {
229
+ return value[elt] ? elt + ' =' + value[elt] : ' ' ;
230
+ }),
231
+ };
190
232
case ' Volumes' :
191
233
case ' ExposedPorts' :
192
- return Object .keys (value);
234
+ return { key, value : Object .keys (value) } ;
193
235
}
194
- return value || ' ' ;
236
+ return { key, value: value || ' ' } ;
195
237
};
196
238
197
239
const getConfig = function (blobs , { historyCustomLabels }) {
@@ -238,4 +280,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
238
280
return res;
239
281
};
240
282
</script >
283
+ <style >
284
+ h2 {
285
+ flex-grow : 1 ;
286
+ display : flex ;
287
+ flex-direction : row ;
288
+ align-items : center ;
289
+ }
290
+ </style >
241
291
</tag-history >
0 commit comments