mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-16 20:43:48 +00:00
Moved version link to common component, and fixed coding styles
This commit is contained in:
@@ -2,11 +2,12 @@ import React from 'react';
|
|||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { pipe } from 'ramda';
|
import { pipe } from 'ramda';
|
||||||
|
import { ExternalLink } from 'react-external-link';
|
||||||
import { serverType } from '../servers/prop-types';
|
import { serverType } from '../servers/prop-types';
|
||||||
import { versionToPrintable, versionToSemVer } from '../utils/helpers/version';
|
import { versionToPrintable, versionToSemVer } from '../utils/helpers/version';
|
||||||
import { ExternalLink } from 'react-external-link';
|
|
||||||
|
|
||||||
const SHLINK_WEB_CLIENT_VERSION = '%_VERSION_%';
|
const SHLINK_WEB_CLIENT_VERSION = '%_VERSION_%';
|
||||||
|
const normalizeVersion = pipe(versionToSemVer(), versionToPrintable);
|
||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
selectedServer: serverType,
|
selectedServer: serverType,
|
||||||
@@ -14,13 +15,27 @@ const propTypes = {
|
|||||||
clientVersion: PropTypes.string,
|
clientVersion: PropTypes.string,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const versionLinkPropTypes = {
|
||||||
|
project: PropTypes.oneOf([ 'shlink', 'shlink-web-client' ]).isRequired,
|
||||||
|
version: PropTypes.string.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
const VersionLink = ({ project, version }) => (
|
||||||
|
<ExternalLink href={`https://github.com/shlinkio/${project}/releases/${version}`} className="text-muted">
|
||||||
|
<b>{version}</b>
|
||||||
|
</ExternalLink>
|
||||||
|
);
|
||||||
|
|
||||||
|
VersionLink.propTypes = versionLinkPropTypes;
|
||||||
|
|
||||||
const ShlinkVersions = ({ selectedServer, className, clientVersion = SHLINK_WEB_CLIENT_VERSION }) => {
|
const ShlinkVersions = ({ selectedServer, className, clientVersion = SHLINK_WEB_CLIENT_VERSION }) => {
|
||||||
const { printableVersion: serverVersion } = selectedServer;
|
const { printableVersion: serverVersion } = selectedServer;
|
||||||
const normalizedClientVersion = pipe(versionToSemVer(), versionToPrintable)(clientVersion);
|
const normalizedClientVersion = normalizeVersion(clientVersion);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<small className={classNames('text-muted', className)}>
|
<small className={classNames('text-muted', className)}>
|
||||||
Client: {<ExternalLink href="https://github.com/shlinkio/shlink-web-client/releases/" className="text-muted"><b>{normalizedClientVersion}</b></ExternalLink>} - Server: {<ExternalLink href="https://github.com/shlinkio/shlink/releases/" className="text-muted"><b>{serverVersion}</b></ExternalLink>}
|
Client: <VersionLink project="shlink-web-client" version={normalizedClientVersion} /> -
|
||||||
|
Server: <VersionLink project="shlink" version={serverVersion} />
|
||||||
</small>
|
</small>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user