diff --git a/src/components/docker-registry-ui.riot b/src/components/docker-registry-ui.riot index 47f7a74..3cc5191 100644 --- a/src/components/docker-registry-ui.riot +++ b/src/components/docker-registry-ui.riot @@ -17,7 +17,10 @@ along with this program. If not, see . - Docker Registry UI + + Docker Registry UI + + . import DialogsMenu from './dialogs/dialogs-menu.riot'; import SearchBar from './search-bar.riot'; import ErrorPage from './error-page.riot'; + import VersionNotification from './version-notification.riot'; import { stripHttps, getRegistryServers, setRegistryServers, truthy, stringToArray } from '../scripts/utils'; import router from '../scripts/router'; import { loadTheme } from '../scripts/theme'; @@ -156,6 +160,7 @@ along with this program. If not, see . Router, Route, ErrorPage, + VersionNotification, }, onUpdated(props, state) { state.snackbarIsError = false; @@ -170,7 +175,7 @@ along with this program. If not, see . } window.onselectstart = (e) => { - if (e.target && e.target.className) { + if (e.target && e.target.className && typeof e.target.className.indexOf === 'function') { return !['checkbox', 'checkmark', 'remove-tag'].find((elt) => e.target.className.indexOf(elt) >= 0); } }; @@ -274,6 +279,12 @@ along with this program. If not, see . flex-shrink: 1; } + material-navbar .nav-wrapper .logo { + display: flex; + align-items: center; + flex-direction: row; + } + material-footer { color: var(--footer-neutral-text); background-color: var(--footer-background); diff --git a/src/components/version-notification.riot b/src/components/version-notification.riot new file mode 100644 index 0000000..f66d9be --- /dev/null +++ b/src/components/version-notification.riot @@ -0,0 +1,109 @@ + + + + Check for updates + + The version { state.tag_name } of Docker Regisrty UI now available. + You can download the lastest version with docker. + joxit/docker-registry-ui:{ state.tag_name } + + + + Release Note + + + Close + + + + + + diff --git a/src/images/rocket.svg b/src/images/rocket.svg new file mode 100644 index 0000000..fd5b1ff --- /dev/null +++ b/src/images/rocket.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/src/scripts/utils.js b/src/scripts/utils.js index 81e4328..010a461 100644 --- a/src/scripts/utils.js +++ b/src/scripts/utils.js @@ -220,3 +220,40 @@ export function truthy(value) { export function stringToArray(value) { return value && typeof value === 'string' ? value.split(',') : []; } + +const compareNumbers = (a, b) => { + const na = parseInt(a); + const nb = parseInt(b); + if (na > nb) return 1; + if (nb > na) return -1; + if (!isNaN(na) && isNaN(nb)) return 1; + if (isNaN(na) && !isNaN(nb)) return -1; + return 0; +}; + +export function isNewestVersion(current = '0.0.0', release = '0.0.0') { + if (current === release) { + return true; + } + current = current.split('.'); + release = release.split('.'); + const isDev = current[2].indexOf('-') >= 0; + const major = compareNumbers(current[0], release[0]); + const minor = compareNumbers(current[1], release[1]); + const patch = compareNumbers(current[2], release[2]); + if (!isDev && (major > 0 || (major === 0 && minor > 0) || (major === 0 && minor === 0 && patch >= 0))) { + return true; + } else if (isDev && (major > 0 || (major === 0 && minor > 0))) { + return true; + } + return false; +} + +export function parseJSON(json) { + if (!json) { + return; + } + try { + return JSON.parse(json); + } catch (e) {} +} diff --git a/test/taglist-order.test.js b/test/taglist-order.test.js index 12f42ed..163ee19 100644 --- a/test/taglist-order.test.js +++ b/test/taglist-order.test.js @@ -3,7 +3,7 @@ import { getTagComparator } from '../src/scripts/taglist-order.js'; import { DockerRegistryUIError } from '../src/scripts/error.js'; import assert from 'assert'; -describe('utils tests', () => { +describe('taglist-order tests', () => { describe('taglistOrderVariants', () => { it(`should return the input when it's well formed and num first`, () => { const expected = ['num-asc;alpha-asc', 'num-asc;alpha-desc', 'num-desc;alpha-asc', 'num-desc;alpha-asc']; diff --git a/test/utils.test.js b/test/utils.test.js new file mode 100644 index 0000000..a98b05d --- /dev/null +++ b/test/utils.test.js @@ -0,0 +1,52 @@ +import { isNewestVersion } from '../src/scripts/utils.js'; +import assert from 'assert'; + +describe('utils tests', () => { + describe('isNewestVersion', () => { + it(`should return true for the same version`, () => { + const expected = ['2.0.0', '2.4.1', '2.5.0', null, undefined]; + expected.forEach((e) => assert.ok(isNewestVersion(e, e))); + }); + + it(`should return true with on common versions`, () => { + assert.ok(isNewestVersion('2.5.1', '2.5.0')); + assert.ok(isNewestVersion('2.5.0', '2.0.0')); + assert.ok(isNewestVersion('2.15.0', '1.25.10')); + assert.ok(isNewestVersion('10.10.10', '2.25.20')); + }); + + it(`should return false on common versions`, () => { + assert.equal(isNewestVersion('1.0.0', '2.5.0'), false); + assert.equal(isNewestVersion('10.10.10', '20.20.20'), false); + assert.equal(isNewestVersion('2.4.10', '2.5.0'), false); + assert.equal(isNewestVersion('2.5.0', '2.6.0'), false); + }); + + it(`should return true for -dev next versions`, () => { + assert.ok(isNewestVersion('2.5.0-dev', '2.4.1')); + assert.ok(isNewestVersion('2.6.0-dev', '2.5.0')); + assert.ok(isNewestVersion('2.15.0-dev', '2.14.1')); + assert.ok(isNewestVersion('2.15.0-dev', '1.16.0')); + }); + + it(`should return false for -dev with current minor version`, () => { + assert.equal(isNewestVersion('2.5.0-dev', '2.5.0'), false); + assert.equal(isNewestVersion('2.5.0-dev', '2.5.10'), false); + assert.equal(isNewestVersion('2.15.0-dev', '2.15.0'), false); + assert.equal(isNewestVersion('2.0.0-dev', '2.15.0'), false); + }); + it(`should return true for -{commit sha} next versions`, () => { + assert.ok(isNewestVersion('2.5.0-ffb6d14baf', '2.4.1')); + assert.ok(isNewestVersion('2.6.0-ffb6d14baf', '2.5.0')); + assert.ok(isNewestVersion('2.15.0-ffb6d14baf', '2.14.1')); + assert.ok(isNewestVersion('2.15.0-ffb6d14baf', '1.16.0')); + }); + + it(`should return false for -{commit sha} with current minor version`, () => { + assert.equal(isNewestVersion('2.5.0-ffb6d14baf', '2.5.0'), false); + assert.equal(isNewestVersion('2.5.0-ffb6d14baf', '2.5.10'), false); + assert.equal(isNewestVersion('2.15.0-ffb6d14baf', '2.15.0'), false); + assert.equal(isNewestVersion('2.0.0-ffb6d14baf', '2.15.0'), false); + }); + }); +});
The version { state.tag_name } of Docker Regisrty UI now available.
You can download the lastest version with docker.
joxit/docker-registry-ui:{ state.tag_name }