diff --git a/CHANGELOG.md b/CHANGELOG.md index 0065a551c..d46c5a9f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/app/soapbox/features/ui/components/link_footer.js b/app/soapbox/features/ui/components/link_footer.js index 6e12f46d2..0037bcb6c 100644 --- a/app/soapbox/features/ui/components/link_footer.js +++ b/app/soapbox/features/ui/components/link_footer.js @@ -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'); diff --git a/app/soapbox/features/ui/index.js b/app/soapbox/features/ui/index.js index 31131a757..aec52038e 100644 --- a/app/soapbox/features/ui/index.js +++ b/app/soapbox/features/ui/index.js @@ -154,11 +154,10 @@ const LAYOUT = { RIGHT: null, }, DEFAULT: { - LEFT: [ - , - ], + LEFT: null, RIGHT: [ , + , ], }, STATUS: { diff --git a/app/soapbox/utils/code.js b/app/soapbox/utils/code.js new file mode 100644 index 000000000..b9d33ccec --- /dev/null +++ b/app/soapbox/utils/code.js @@ -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), +}; diff --git a/package.json b/package.json index bac81c6c8..e85487982 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/webpack/loaders/git-loader.js b/webpack/loaders/git-loader.js new file mode 100644 index 000000000..5f003ffec --- /dev/null +++ b/webpack/loaders/git-loader.js @@ -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); +}; diff --git a/webpack/rules/babel-git.js b/webpack/rules/babel-git.js new file mode 100644 index 000000000..b68139ed6 --- /dev/null +++ b/webpack/rules/babel-git.js @@ -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', + }, + }, + ], +}; diff --git a/webpack/rules/git-refresh.js b/webpack/rules/git-refresh.js new file mode 100644 index 000000000..0b708b746 --- /dev/null +++ b/webpack/rules/git-refresh.js @@ -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'), + }, +}; diff --git a/webpack/rules/index.js b/webpack/rules/index.js index 7cf12f0ab..467b23f22 100644 --- a/webpack/rules/index.js +++ b/webpack/rules/index.js @@ -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, ];