Skip to content

Commit 49fcba3

Browse files
committed
chore(cleanup): format code and move from js-beautify to prettier
1 parent ab12cce commit 49fcba3

21 files changed

+373
-302
lines changed

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
"name": "docker-registry-ui",
33
"version": "2.1.0",
44
"scripts": {
5+
"format": "npm run format-html && npm run format-js && npm run format-riot",
6+
"format-html": "find src rollup rollup.config.js -name '*.html' -exec prettier --config .prettierrc -w --parser html {} \\;",
7+
"format-js": "find src rollup rollup.config.js -name '*.js' -exec prettier --config .prettierrc -w {} \\;",
8+
"format-riot": "find src rollup rollup.config.js -name '*.riot' -exec prettier --config .prettierrc -w --parser html {} \\;",
59
"start": "rollup -c -w --environment ROLLUP_SERVE:true",
610
"build": "rollup -c",
711
"build:electron": "npm run build && cd examples/electron && npm install && npm run dist"
@@ -25,8 +29,8 @@
2529
"@rollup/plugin-json": "^4.1.0",
2630
"@rollup/plugin-node-resolve": "^13.1.3",
2731
"core-js": "^3.19.1",
28-
"js-beautify": "^1.14.0",
2932
"node-sass": "^7.0.1",
33+
"prettier": "^2.6.2",
3034
"riot": "^6.1.2",
3135
"riot-mui": "github:joxit/riot-5-mui#4d68d7f",
3236
"rollup": "^2.59.0",

rollup/license.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ export default `/*
1515
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
*
1717
* @license AGPL
18-
*/`
18+
*/`;

src/components/catalog/catalog-element.riot

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
9696
onAuthentication: props.onAuthentication,
9797
});
9898
oReq.addEventListener('load', function () {
99-
if (this.status == 200) {
99+
if (this.status === 200) {
100100
const nbTags = (JSON.parse(this.responseText).tags || []).length;
101101
self.update({ nbTags });
102-
} else if (this.status == 404) {
102+
} else if (this.status === 404) {
103103
props.onNotify('Server not found', true);
104104
} else {
105105
props.onNotify(this.responseText, true);

src/components/catalog/catalog.riot

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
7373
onAuthentication: this.props.onAuthentication,
7474
});
7575
oReq.addEventListener('load', function () {
76-
if (this.status == 200) {
76+
if (this.status === 200) {
7777
repositories = JSON.parse(this.responseText).repositories || [];
7878
repositories.sort();
7979
repositories = repositories.reduce(function (acc, e) {
8080
const slash = e.indexOf('/');
8181
if (slash > 0) {
8282
const repoName = e.substring(0, slash) + '/';
83-
if (acc.length == 0 || acc[acc.length - 1].repo != repoName) {
83+
if (acc.length === 0 || acc[acc.length - 1].repo != repoName) {
8484
acc.push({
8585
repo: repoName,
8686
images: [],
@@ -92,7 +92,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
9292
acc.push(e);
9393
return acc;
9494
}, []);
95-
} else if (this.status == 404) {
95+
} else if (this.status === 404) {
9696
self.props.onNotify('Server not found', true);
9797
} else {
9898
self.props.onNotify(this.responseText);

src/components/dialogs/add-registry-url.riot

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@
3131
</div>
3232
</material-popup>
3333
<script>
34-
import {
35-
addRegistryServers
36-
} from '../../scripts/utils';
34+
import { addRegistryServers } from '../../scripts/utils';
3735
import router from '../../scripts/router';
3836
3937
export default {
@@ -52,11 +50,11 @@
5250
return this.props.onNotify('The input field should start with http:// or https://.', true);
5351
}
5452
const url = addRegistryServers(input.value);
55-
router.home()
53+
router.home();
5654
this.props.onServerChange(url);
57-
this.props.onClose()
55+
this.props.onClose();
5856
setTimeout(() => router.updateUrlQueryParam(url), 100);
59-
}
60-
}
57+
},
58+
};
6159
</script>
62-
</add-registry-url>
60+
</add-registry-url>

src/components/dialogs/change-registry-url.riot

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@
3232
</div>
3333
</material-popup>
3434
<script>
35-
import {
36-
addRegistryServers,
37-
getRegistryServers
38-
} from '../../scripts/utils';
35+
import { addRegistryServers, getRegistryServers } from '../../scripts/utils';
3936
import router from '../../scripts/router';
4037
export default {
4138
change(event) {
@@ -47,13 +44,13 @@
4744
return this.props.onNotify('The select field should start with http:// or https://.', true);
4845
}
4946
const url = addRegistryServers(select.value);
50-
router.home()
47+
router.home();
5148
this.props.onServerChange(url);
52-
this.props.onClose()
49+
this.props.onClose();
5350
setTimeout(() => router.updateUrlQueryParam(url), 100);
5451
},
55-
getRegistryServers
56-
}
52+
getRegistryServers,
53+
};
5754
</script>
5855
<style>
5956
:host select {
@@ -74,4 +71,4 @@
7471
margin: 1.5em 0;
7572
}
7673
</style>
77-
</change-registry-url>
74+
</change-registry-url>

src/components/dialogs/confirm-delete-image.riot

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@
5252
const oReq = new Http({ onAuthentication });
5353
const self = this;
5454
oReq.addEventListener('loadend', function () {
55-
if (this.status == 200 || this.status == 202) {
55+
if (this.status === 200 || this.status === 202) {
5656
oReq.getContentDigest(function (digest) {
5757
if (!digest) {
5858
onNotify(ERROR_CAN_NOT_READ_CONTENT_DIGEST);
5959
} else {
6060
self.deleteImage({ name, tag, digest }, opts);
6161
}
6262
});
63-
} else if (this.status == 404) {
63+
} else if (this.status === 404) {
6464
onNotify(`Manifest for ${name}:${tag} not found`, true);
6565
} else {
6666
onNotify(this.responseText);
@@ -77,10 +77,10 @@
7777
const { registryUrl, ignoreError, onNotify, onAuthentication, onClick } = opts;
7878
const oReq = new Http({ onAuthentication });
7979
oReq.addEventListener('loadend', function () {
80-
if (this.status == 200 || this.status == 202) {
80+
if (this.status === 200 || this.status === 202) {
8181
router.taglist(name);
8282
onNotify(`Deleting ${name}:${tag} image. Run \`registry garbage-collect config.yml\` on your registry`);
83-
} else if (this.status == 404) {
83+
} else if (this.status === 404) {
8484
ignoreError ||
8585
onNotify({
8686
message: 'Digest not found for this image in your registry.',

src/components/dialogs/dialogs-menu.riot

Lines changed: 53 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,35 @@
1515
along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
-->
1717
<dialogs-menu>
18-
<add-registry-url if="{ !props.readOnlyRegistries }" opened="{ state['add-registry-url'] }" on-close="{ onClose('add-registry-url') }"
19-
on-notify="{ props.onNotify }" on-server-change="{ props.onServerChange }"></add-registry-url>
20-
<change-registry-url opened="{ state['change-registry-url'] }" on-close="{ onClose('change-registry-url') }"
21-
on-notify="{ props.onNotify }" on-server-change="{ props.onServerChange }"></change-registry-url>
22-
<remove-registry-url if="{ !props.readOnlyRegistries }" opened="{ state['remove-registry-url'] }" on-close="{ onClose('remove-registry-url') }"
23-
on-notify="{ props.onNotify }" on-server-change="{ props.onServerChange }"></remove-registry-url>
18+
<add-registry-url
19+
if="{ !props.readOnlyRegistries }"
20+
opened="{ state['add-registry-url'] }"
21+
on-close="{ onClose('add-registry-url') }"
22+
on-notify="{ props.onNotify }"
23+
on-server-change="{ props.onServerChange }"
24+
></add-registry-url>
25+
<change-registry-url
26+
opened="{ state['change-registry-url'] }"
27+
on-close="{ onClose('change-registry-url') }"
28+
on-notify="{ props.onNotify }"
29+
on-server-change="{ props.onServerChange }"
30+
></change-registry-url>
31+
<remove-registry-url
32+
if="{ !props.readOnlyRegistries }"
33+
opened="{ state['remove-registry-url'] }"
34+
on-close="{ onClose('remove-registry-url') }"
35+
on-notify="{ props.onNotify }"
36+
on-server-change="{ props.onServerChange }"
37+
></remove-registry-url>
2438
<div class="container">
2539
<material-button onClick="{ onClick }" waves-center="true" rounded="true" waves-opacity="0.6" waves-duration="600">
2640
<i class="material-icons">more_vert</i>
2741
</material-button>
28-
<material-dropdown-list items="{ dropdownItems.filter(item => item.ro || !props.readOnlyRegistries) }" onSelect="{ onDropdownSelect }"
29-
opened="{ state.isDropdownOpened }" />
42+
<material-dropdown-list
43+
items="{ dropdownItems.filter(item => item.ro || !props.readOnlyRegistries) }"
44+
onSelect="{ onDropdownSelect }"
45+
opened="{ state.isDropdownOpened }"
46+
/>
3047
</div>
3148
<div class="overlay" onclick="{ onClick }" if="{ state.isDropdownOpened }"></div>
3249
<script>
@@ -38,44 +55,48 @@
3855
components: {
3956
AddRegistryUrl,
4057
ChangeRegistryUrl,
41-
RemoveRegistryUrl
58+
RemoveRegistryUrl,
4259
},
43-
dropdownItems: [{
44-
title: 'Add URL',
45-
name: 'add-registry-url',
46-
ro: false
47-
}, {
48-
title: 'Change URL',
49-
name: 'change-registry-url',
50-
ro: true
51-
}, {
52-
title: 'Remove URL',
53-
name: 'remove-registry-url',
54-
ro: false
55-
}],
60+
dropdownItems: [
61+
{
62+
title: 'Add URL',
63+
name: 'add-registry-url',
64+
ro: false,
65+
},
66+
{
67+
title: 'Change URL',
68+
name: 'change-registry-url',
69+
ro: true,
70+
},
71+
{
72+
title: 'Remove URL',
73+
name: 'remove-registry-url',
74+
ro: false,
75+
},
76+
],
5677
onDropdownSelect(key, item) {
5778
this.update({
5879
[item.name]: true,
59-
isDropdownOpened: false
80+
isDropdownOpened: false,
6081
});
6182
},
6283
onClose(name) {
6384
return () => {
6485
this.update({
6586
[name]: false,
66-
isDropdownOpened: false
67-
})
68-
}
87+
isDropdownOpened: false,
88+
});
89+
};
6990
},
7091
onClick() {
7192
this.update({
72-
isDropdownOpened: !this.state.isDropdownOpened
73-
})
74-
}
75-
}
93+
isDropdownOpened: !this.state.isDropdownOpened,
94+
});
95+
},
96+
};
7697
</script>
7798
<style>
78-
:host > .container{
99+
:host > .container {
79100
position: absolute;
80101
top: 0px;
81102
right: 16px;
@@ -128,4 +149,4 @@
128149
line-height: 36px;
129150
}
130151
</style>
131-
</dialogs-menu>
152+
</dialogs-menu>

src/components/dialogs/remove-registry-url.riot

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
2121
<ul class="list">
2222
<li each="{ url in getRegistryServers() }">
2323
<span>
24-
<material-button onClick="{ remove }" url="{ url }" rounded="true" waves-color="rgba(158,158,158,.4)"
25-
waves-center="true">
24+
<material-button
25+
onClick="{ remove }"
26+
url="{ url }"
27+
rounded="true"
28+
waves-color="rgba(158,158,158,.4)"
29+
waves-center="true"
30+
>
2631
<i class="material-icons">delete</i>
2732
</material-button>
2833
<span class="url">{ url }</span>
@@ -37,18 +42,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
3742
</div>
3843
</material-popup>
3944
<script>
40-
import {
41-
getRegistryServers,
42-
removeRegistryServers
43-
} from '../../scripts/utils';
45+
import { getRegistryServers, removeRegistryServers } from '../../scripts/utils';
4446
export default {
4547
remove(event) {
4648
const url = event.currentTarget.attributes.url && event.currentTarget.attributes.url.value;
4749
removeRegistryServers(url);
4850
setTimeout(() => this.update(), 100);
4951
},
50-
getRegistryServers
51-
}
52+
getRegistryServers,
53+
};
5254
</script>
5355
<style>
5456
:host material-popup .popup material-button {
@@ -59,4 +61,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
5961
color: #777;
6062
}
6163
</style>
62-
</remove-registry-url>
64+
</remove-registry-url>

0 commit comments

Comments
 (0)