Merge branch 'link-footer-improvements' into 'develop'

Link footer improvements

See merge request soapbox-pub/soapbox-fe!461
This commit is contained in:
Alex Gleason 2021-03-30 21:09:46 +00:00
commit e0df861658
9 changed files with 84 additions and 12 deletions

View file

@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Heart reaction works on Pleroma >= 2.3.0
- Pagination of Blocks and Mutes
## [1.1.0] - 2020-10-05
### Fixed

View file

@ -7,14 +7,7 @@ import { connect } from 'react-redux';
import { openModal } from '../../../actions/modal';
import { logOut } from 'soapbox/actions/auth';
import { isStaff } from 'soapbox/utils/accounts';
// FIXME: Let this be configured
const sourceCode = {
name: 'soapbox-fe',
url: 'https://gitlab.com/soapbox-pub/soapbox-fe',
repository: 'soapbox-pub/soapbox-fe',
version: '1.1.0',
};
import sourceCode from 'soapbox/utils/code';
const mapStateToProps = state => {
const me = state.get('me');

View file

@ -154,11 +154,10 @@ const LAYOUT = {
RIGHT: null,
},
DEFAULT: {
LEFT: [
<LinkFooter key='1' />,
],
LEFT: null,
RIGHT: [
<FeaturesPanel key='0' />,
<LinkFooter key='1' />,
],
},
STATUS: {

39
app/soapbox/utils/code.js Normal file
View file

@ -0,0 +1,39 @@
// @preval
const pkg = require('../../../package.json');
const { execSync } = require('child_process');
const shortRepoName = url => new URL(url).pathname.substring(1);
const trimHash = hash => hash.substring(0, 7);
const version = pkg => {
// Try to discern from GitLab CI first
const { CI_COMMIT_TAG, CI_COMMIT_REF_NAME, CI_COMMIT_SHA } = process.env;
if (CI_COMMIT_TAG === `v${pkg.version}` || CI_COMMIT_REF_NAME === 'stable') {
return pkg.version;
}
if (typeof CI_COMMIT_SHA === 'string') {
return `${pkg.version}-${trimHash(CI_COMMIT_SHA)}`;
}
// Fall back to git directly
try {
const head = String(execSync('git rev-parse HEAD'));
const tag = String(execSync(`git rev-parse v${pkg.version}`));
if (head !== tag) return `${pkg.version}-${trimHash(head)}`;
} catch (e) {
// Continue
}
// Fall back to version in package.json
return pkg.version;
};
module.exports = {
name: pkg.name,
url: pkg.repository.url,
repository: shortRepoName(pkg.repository.url),
version: version(pkg),
};

View file

@ -5,7 +5,7 @@
"homepage": "https://soapbox.pub/",
"repository": {
"type": "git",
"url": "https://gitlab.com/soapbox-pub/soapbox-fe.git"
"url": "https://gitlab.com/soapbox-pub/soapbox-fe"
},
"keywords": [
"fediverse",

View file

@ -0,0 +1,8 @@
const { resolve } = require('path');
// Forces recompile whenever the current commit changes
// Useful for generating the version hash in the UI
module.exports = function(source, map) {
this.addDependency(resolve(__dirname, '../../.git/logs/HEAD'));
this.callback(null, source, map);
};

View file

@ -0,0 +1,19 @@
const { resolve } = require('path');
const { env } = require('../configuration');
// This is a hack, used in conjunction with rules/git-refresh.js
// https://github.com/kentcdodds/babel-plugin-preval/issues/19
module.exports = {
test: resolve(__dirname, '../../app/soapbox/utils/code.js'),
use: [
{
loader: 'babel-loader',
options: {
cacheDirectory: false,
cacheCompression: env.NODE_ENV === 'production',
compact: env.NODE_ENV === 'production',
},
},
],
};

View file

@ -0,0 +1,9 @@
const { resolve } = require('path');
// Recompile code.js whenever git changes
module.exports = {
test: resolve(__dirname, '../../app/soapbox/utils/code.js'),
use: {
loader: resolve(__dirname, '../loaders/git-loader.js'),
},
};

View file

@ -1,4 +1,6 @@
const babel = require('./babel');
const git = require('./babel-git');
const gitRefresh = require('./git-refresh');
const css = require('./css');
const file = require('./file');
const nodeModules = require('./node_modules');
@ -11,4 +13,6 @@ module.exports = [
css,
nodeModules,
babel,
git,
gitRefresh,
];