mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-22 17:10:26 +03:00
Fixed coding styles
This commit is contained in:
parent
343a93b984
commit
a91f1b3bd4
60 changed files with 133 additions and 125 deletions
|
@ -41,6 +41,7 @@
|
|||
"no-magic-numbers": "off",
|
||||
"react/no-array-index-key": "off",
|
||||
"react/no-did-update-set-state": "off",
|
||||
"react/display-name": "off",
|
||||
"react/jsx-curly-spacing": ["error", "never"],
|
||||
"react/jsx-indent-props": ["error", 2],
|
||||
"react/jsx-first-prop-new-line": ["error", "multiline-multiprop"],
|
||||
|
@ -52,7 +53,10 @@
|
|||
"files": ["**/*.ts", "**/*.tsx"],
|
||||
"extends": [
|
||||
"@shlinkio/js-coding-standard"
|
||||
]
|
||||
],
|
||||
"rules": {
|
||||
"react/display-name": "off"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ const { NODE_ENV } = process.env;
|
|||
|
||||
if (!NODE_ENV) {
|
||||
throw new Error(
|
||||
'The NODE_ENV environment variable is required but was not specified.'
|
||||
'The NODE_ENV environment variable is required but was not specified.',
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ dotenvFiles.forEach((dotenvFile) => {
|
|||
require('dotenv-expand')(
|
||||
require('dotenv').config({
|
||||
path: dotenvFile,
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
});
|
||||
|
@ -82,7 +82,7 @@ function getClientEnvironment(publicUrl) {
|
|||
// This should only be used as an escape hatch. Normally you would put
|
||||
// images into the `src` and `import` them in code to get their paths.
|
||||
PUBLIC_URL: publicUrl,
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
// Stringify all values so we can feed into Webpack DefinePlugin
|
||||
|
|
|
@ -75,7 +75,7 @@ module.exports = (webpackEnv) => {
|
|||
loader: MiniCssExtractPlugin.loader,
|
||||
options: Object.assign(
|
||||
{},
|
||||
shouldUseRelativeAssetPaths ? { publicPath: '../../' } : undefined
|
||||
shouldUseRelativeAssetPaths ? { publicPath: '../../' } : undefined,
|
||||
),
|
||||
},
|
||||
{
|
||||
|
@ -281,7 +281,7 @@ module.exports = (webpackEnv) => {
|
|||
modules: [ 'node_modules' ].concat(
|
||||
|
||||
// It is guaranteed to exist because we tweak it in `env.js`
|
||||
process.env.NODE_PATH.split(path.delimiter).filter(Boolean)
|
||||
process.env.NODE_PATH.split(path.delimiter).filter(Boolean),
|
||||
),
|
||||
|
||||
// These are the reasonable defaults supported by the Node ecosystem.
|
||||
|
@ -372,7 +372,7 @@ module.exports = (webpackEnv) => {
|
|||
loader: require.resolve('babel-loader'),
|
||||
options: {
|
||||
customize: require.resolve(
|
||||
'babel-preset-react-app/webpack-overrides'
|
||||
'babel-preset-react-app/webpack-overrides',
|
||||
),
|
||||
|
||||
plugins: [
|
||||
|
@ -470,7 +470,7 @@ module.exports = (webpackEnv) => {
|
|||
importLoaders: 2,
|
||||
sourceMap: isEnvProduction && shouldUseSourceMap,
|
||||
},
|
||||
'sass-loader'
|
||||
'sass-loader',
|
||||
),
|
||||
|
||||
// Don't consider CSS imports dead code even if the
|
||||
|
@ -491,7 +491,7 @@ module.exports = (webpackEnv) => {
|
|||
modules: true,
|
||||
getLocalIdent: getCSSModuleLocalIdent,
|
||||
},
|
||||
'sass-loader'
|
||||
'sass-loader',
|
||||
),
|
||||
},
|
||||
|
||||
|
@ -544,8 +544,8 @@ module.exports = (webpackEnv) => {
|
|||
minifyURLs: true,
|
||||
},
|
||||
}
|
||||
: undefined
|
||||
)
|
||||
: undefined,
|
||||
),
|
||||
),
|
||||
|
||||
// Inlines the webpack runtime script. This script is too small to warrant
|
||||
|
|
|
@ -75,12 +75,12 @@ checkBrowsers(paths.appPath, isInteractive)
|
|||
console.log(
|
||||
`\nSearch for the ${
|
||||
chalk.underline(chalk.yellow('keywords'))
|
||||
} to learn more about each warning.`
|
||||
} to learn more about each warning.`,
|
||||
);
|
||||
console.log(
|
||||
`To ignore, add ${
|
||||
chalk.cyan('// eslint-disable-next-line')
|
||||
} to the line before.\n`
|
||||
} to the line before.\n`,
|
||||
);
|
||||
} else {
|
||||
console.log(chalk.green('Compiled successfully.\n'));
|
||||
|
@ -93,7 +93,7 @@ checkBrowsers(paths.appPath, isInteractive)
|
|||
previousFileSizes,
|
||||
paths.appBuild,
|
||||
WARN_AFTER_BUNDLE_GZIP_SIZE,
|
||||
WARN_AFTER_CHUNK_GZIP_SIZE
|
||||
WARN_AFTER_CHUNK_GZIP_SIZE,
|
||||
);
|
||||
console.log();
|
||||
},
|
||||
|
@ -101,7 +101,7 @@ checkBrowsers(paths.appPath, isInteractive)
|
|||
console.log(chalk.red('Failed to compile.\n'));
|
||||
printBuildError(err);
|
||||
process.exit(1);
|
||||
}
|
||||
},
|
||||
)
|
||||
.then(() => hasVersion && !withoutDist && zipDist(version))
|
||||
.catch((err) => {
|
||||
|
@ -133,7 +133,7 @@ function build(previousFileSizes) {
|
|||
});
|
||||
} else {
|
||||
messages = formatWebpackMessages(
|
||||
stats.toJson({ all: false, warnings: true, errors: true })
|
||||
stats.toJson({ all: false, warnings: true, errors: true }),
|
||||
);
|
||||
}
|
||||
if (messages.errors.length) {
|
||||
|
@ -154,8 +154,8 @@ function build(previousFileSizes) {
|
|||
console.log(
|
||||
chalk.yellow(
|
||||
'\nTreating warnings as errors because process.env.CI = true.\n' +
|
||||
'Most CI servers set it automatically.\n'
|
||||
)
|
||||
'Most CI servers set it automatically.\n',
|
||||
),
|
||||
);
|
||||
|
||||
return reject(new Error(messages.warnings.join('\n\n')));
|
||||
|
|
|
@ -49,15 +49,15 @@ if (process.env.HOST) {
|
|||
console.log(
|
||||
chalk.cyan(
|
||||
`Attempting to bind to HOST environment variable: ${chalk.yellow(
|
||||
chalk.bold(process.env.HOST)
|
||||
)}`
|
||||
)
|
||||
chalk.bold(process.env.HOST),
|
||||
)}`,
|
||||
),
|
||||
);
|
||||
console.log(
|
||||
'If this was unintentional, check that you haven\'t mistakenly set it in your shell.'
|
||||
'If this was unintentional, check that you haven\'t mistakenly set it in your shell.',
|
||||
);
|
||||
console.log(
|
||||
`Learn more here: ${chalk.yellow('http://bit.ly/CRA-advanced-config')}`
|
||||
`Learn more here: ${chalk.yellow('http://bit.ly/CRA-advanced-config')}`,
|
||||
);
|
||||
console.log();
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ checkBrowsers(paths.appPath, isInteractive)
|
|||
// Serve webpack assets generated by the compiler over a web server.
|
||||
const serverConfig = createDevServerConfig(
|
||||
proxyConfig,
|
||||
urls.lanUrlForConfig
|
||||
urls.lanUrlForConfig,
|
||||
);
|
||||
const devServer = new WebpackDevServer(compiler, serverConfig);
|
||||
|
||||
|
|
50
src/App.js
50
src/App.js
|
@ -9,32 +9,36 @@ const propTypes = {
|
|||
servers: PropTypes.object,
|
||||
};
|
||||
|
||||
const App = (MainHeader, Home, MenuLayout, CreateServer, EditServer, Settings) => ({ fetchServers, servers }) => {
|
||||
// On first load, try to fetch the remote servers if the list is empty
|
||||
useEffect(() => {
|
||||
if (Object.keys(servers).length === 0) {
|
||||
fetchServers();
|
||||
}
|
||||
}, []);
|
||||
const App = (MainHeader, Home, MenuLayout, CreateServer, EditServer, Settings) => {
|
||||
const AppComp = ({ fetchServers, servers }) => {
|
||||
// On first load, try to fetch the remote servers if the list is empty
|
||||
useEffect(() => {
|
||||
if (Object.keys(servers).length === 0) {
|
||||
fetchServers();
|
||||
}
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="container-fluid app-container">
|
||||
<MainHeader />
|
||||
return (
|
||||
<div className="container-fluid app-container">
|
||||
<MainHeader />
|
||||
|
||||
<div className="app">
|
||||
<Switch>
|
||||
<Route exact path="/" component={Home} />
|
||||
<Route exact path="/settings" component={Settings} />
|
||||
<Route exact path="/server/create" component={CreateServer} />
|
||||
<Route exact path="/server/:serverId/edit" component={EditServer} />
|
||||
<Route path="/server/:serverId" component={MenuLayout} />
|
||||
<Route component={NotFound} />
|
||||
</Switch>
|
||||
<div className="app">
|
||||
<Switch>
|
||||
<Route exact path="/" component={Home} />
|
||||
<Route exact path="/settings" component={Settings} />
|
||||
<Route exact path="/server/create" component={CreateServer} />
|
||||
<Route exact path="/server/:serverId/edit" component={EditServer} />
|
||||
<Route path="/server/:serverId" component={MenuLayout} />
|
||||
<Route component={NotFound} />
|
||||
</Switch>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
);
|
||||
};
|
||||
|
||||
AppComp.propTypes = propTypes;
|
||||
|
||||
return AppComp;
|
||||
};
|
||||
|
||||
App.propTypes = propTypes;
|
||||
|
||||
export default App;
|
||||
|
|
|
@ -26,7 +26,7 @@ const MenuLayout = (
|
|||
ShortUrlVisits,
|
||||
TagVisits,
|
||||
ShlinkVersions,
|
||||
ServerError
|
||||
ServerError,
|
||||
) => {
|
||||
const MenuLayoutComp = ({ match, location, selectedServer }) => {
|
||||
const [ sidebarVisible, toggleSidebar, showSidebar, hideSidebar ] = useToggle();
|
||||
|
@ -44,7 +44,7 @@ const MenuLayout = (
|
|||
});
|
||||
const swipeMenuIfNoModalExists = (callback) => (e) => {
|
||||
const swippedOnVisitsTable = e.event.path.some(
|
||||
({ classList }) => classList && classList.contains('visits-table')
|
||||
({ classList }) => classList && classList.contains('visits-table'),
|
||||
);
|
||||
|
||||
if (swippedOnVisitsTable || document.querySelector('.modal')) {
|
||||
|
|
|
@ -29,7 +29,7 @@ const provideServices = (bottle, connect, withRouter) => {
|
|||
'ShortUrlVisits',
|
||||
'TagVisits',
|
||||
'ShlinkVersions',
|
||||
'ServerError'
|
||||
'ServerError',
|
||||
);
|
||||
bottle.decorator('MenuLayout', connect([ 'selectedServer', 'shortUrlsListParams' ], [ 'selectServer' ]));
|
||||
bottle.decorator('MenuLayout', withRouter);
|
||||
|
|
|
@ -25,7 +25,7 @@ const mapActionService = (map, actionName) => ({
|
|||
const connect = (propsFromState, actionServiceNames = []) =>
|
||||
reduxConnect(
|
||||
propsFromState ? pick(propsFromState) : null,
|
||||
actionServiceNames.reduce(mapActionService, {})
|
||||
actionServiceNames.reduce(mapActionService, {}),
|
||||
);
|
||||
|
||||
bottle.serviceFactory('App', App, 'MainHeader', 'Home', 'MenuLayout', 'CreateServer', 'EditServer', 'Settings');
|
||||
|
|
|
@ -15,7 +15,7 @@ const localStorageConfig = {
|
|||
};
|
||||
|
||||
const store = createStore(reducers, load(localStorageConfig), composeEnhancers(
|
||||
applyMiddleware(save(localStorageConfig), ReduxThunk)
|
||||
applyMiddleware(save(localStorageConfig), ReduxThunk),
|
||||
));
|
||||
|
||||
export default store;
|
||||
|
|
|
@ -28,6 +28,6 @@ render(
|
|||
</ErrorHandler>
|
||||
</BrowserRouter>
|
||||
</Provider>,
|
||||
document.getElementById('root')
|
||||
document.getElementById('root'),
|
||||
);
|
||||
registerServiceWorker();
|
||||
|
|
|
@ -18,8 +18,8 @@ const isLocalhost = Boolean(
|
|||
|
||||
// 127.0.0.1/8 is considered localhost for IPv4.
|
||||
window.location.hostname.match(
|
||||
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
|
||||
)
|
||||
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/,
|
||||
),
|
||||
);
|
||||
|
||||
export default function register() {
|
||||
|
@ -46,7 +46,7 @@ export default function register() {
|
|||
return navigator.serviceWorker.ready.then(() => {
|
||||
console.log(
|
||||
'This web app is being served cache-first by a service ' +
|
||||
'worker. To learn more, visit https://goo.gl/SC7cgQ'
|
||||
'worker. To learn more, visit https://goo.gl/SC7cgQ',
|
||||
);
|
||||
});
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ function checkValidServiceWorker(swUrl) {
|
|||
})
|
||||
.catch(() => {
|
||||
console.log(
|
||||
'No internet connection found. App is running in offline mode.'
|
||||
'No internet connection found. App is running in offline mode.',
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ export const LATEST_VERSION_CONSTRAINT = 'latest';
|
|||
const initialState = null;
|
||||
const versionToSemVer = pipe(
|
||||
(version) => version === LATEST_VERSION_CONSTRAINT ? MAX_FALLBACK_VERSION : version,
|
||||
toSemVer(MIN_FALLBACK_VERSION)
|
||||
toSemVer(MIN_FALLBACK_VERSION),
|
||||
);
|
||||
|
||||
const getServerVersion = memoizeWith(identity, (serverId, health) => health().then(({ version }) => ({
|
||||
|
@ -27,7 +27,7 @@ export const resetSelectedServer = createAction(RESET_SELECTED_SERVER);
|
|||
|
||||
export const selectServer = (buildShlinkApiClient, loadMercureInfo) => (serverId) => async (
|
||||
dispatch,
|
||||
getState
|
||||
getState,
|
||||
) => {
|
||||
dispatch(resetSelectedServer());
|
||||
dispatch(resetShortUrlParams());
|
||||
|
|
|
@ -27,7 +27,7 @@ const serversListToMap = reduce((acc, server) => assoc(server.id, server, acc),
|
|||
export const createServers = pipe(
|
||||
map(assocId),
|
||||
serversListToMap,
|
||||
(newServers) => ({ type: CREATE_SERVERS, newServers })
|
||||
(newServers) => ({ type: CREATE_SERVERS, newServers }),
|
||||
);
|
||||
|
||||
export const editServer = (serverId, serverData) => ({ type: EDIT_SERVER, serverId, serverData });
|
||||
|
|
|
@ -23,7 +23,7 @@ const SearchBar = (colorGenerator, ForServerVersion) => {
|
|||
const selectedTags = shortUrlsListParams.tags || [];
|
||||
const setDate = (dateName) => pipe(
|
||||
formatDate(),
|
||||
(date) => listShortUrls({ ...shortUrlsListParams, [dateName]: date })
|
||||
(date) => listShortUrls({ ...shortUrlsListParams, [dateName]: date }),
|
||||
);
|
||||
|
||||
return (
|
||||
|
@ -63,7 +63,7 @@ const SearchBar = (colorGenerator, ForServerVersion) => {
|
|||
{
|
||||
...shortUrlsListParams,
|
||||
tags: selectedTags.filter((selectedTag) => selectedTag !== tag),
|
||||
}
|
||||
},
|
||||
)}
|
||||
/>
|
||||
))}
|
||||
|
|
|
@ -23,7 +23,7 @@ const propTypes = {
|
|||
const ShortUrlsRow = (
|
||||
ShortUrlsRowMenu,
|
||||
colorGenerator,
|
||||
useStateFlagTimeout
|
||||
useStateFlagTimeout,
|
||||
) => {
|
||||
const ShortUrlsRowComp = ({ shortUrl, selectedServer, refreshList, shortUrlsListParams }) => {
|
||||
const [ copiedToClipboard, setCopiedToClipboard ] = useStateFlagTimeout();
|
||||
|
|
|
@ -33,9 +33,9 @@ const initialState = {
|
|||
const setPropFromActionOnMatchingShortUrl = (prop) => (state, { shortCode, domain, [prop]: propValue }) => assocPath(
|
||||
[ 'shortUrls', 'data' ],
|
||||
state.shortUrls.data.map(
|
||||
(shortUrl) => shortUrlMatches(shortUrl, shortCode, domain) ? assoc(prop, propValue, shortUrl) : shortUrl
|
||||
(shortUrl) => shortUrlMatches(shortUrl, shortCode, domain) ? assoc(prop, propValue, shortUrl) : shortUrl,
|
||||
),
|
||||
state
|
||||
state,
|
||||
);
|
||||
|
||||
export default handleActions({
|
||||
|
@ -55,9 +55,9 @@ export default handleActions({
|
|||
state.shortUrls && state.shortUrls.data && state.shortUrls.data.map(
|
||||
(shortUrl) => shortUrlMatches(shortUrl, shortCode, domain)
|
||||
? assoc('visitsCount', visitsCount, shortUrl)
|
||||
: shortUrl
|
||||
: shortUrl,
|
||||
),
|
||||
state
|
||||
state,
|
||||
),
|
||||
}, initialState);
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ const provideServices = (bottle, connect) => {
|
|||
// Components
|
||||
bottle.serviceFactory('ShortUrls', ShortUrls, 'SearchBar', 'ShortUrlsList');
|
||||
bottle.decorator('ShortUrls', reduxConnect(
|
||||
(state) => assoc('shortUrlsList', state.shortUrlsList.shortUrls, state.shortUrlsList)
|
||||
(state) => assoc('shortUrlsList', state.shortUrlsList.shortUrls, state.shortUrlsList),
|
||||
));
|
||||
|
||||
bottle.serviceFactory('SearchBar', SearchBar, 'ColorGenerator', 'ForServerVersion');
|
||||
|
@ -32,7 +32,7 @@ const provideServices = (bottle, connect) => {
|
|||
bottle.serviceFactory('ShortUrlsList', ShortUrlsList, 'ShortUrlsRow');
|
||||
bottle.decorator('ShortUrlsList', connect(
|
||||
[ 'selectedServer', 'shortUrlsListParams', 'mercureInfo' ],
|
||||
[ 'listShortUrls', 'resetShortUrlParams', 'createNewVisit', 'loadMercureInfo' ]
|
||||
[ 'listShortUrls', 'resetShortUrlParams', 'createNewVisit', 'loadMercureInfo' ],
|
||||
));
|
||||
|
||||
bottle.serviceFactory('ShortUrlsRow', ShortUrlsRow, 'ShortUrlsRowMenu', 'ColorGenerator', 'useStateFlagTimeout');
|
||||
|
@ -44,14 +44,14 @@ const provideServices = (bottle, connect) => {
|
|||
'EditTagsModal',
|
||||
'EditMetaModal',
|
||||
'EditShortUrlModal',
|
||||
'ForServerVersion'
|
||||
'ForServerVersion',
|
||||
);
|
||||
bottle.serviceFactory('CreateShortUrlResult', CreateShortUrlResult, 'useStateFlagTimeout');
|
||||
|
||||
bottle.serviceFactory('CreateShortUrl', CreateShortUrl, 'TagsSelector', 'CreateShortUrlResult', 'ForServerVersion');
|
||||
bottle.decorator(
|
||||
'CreateShortUrl',
|
||||
connect([ 'shortUrlCreationResult', 'selectedServer' ], [ 'createShortUrl', 'resetCreateShortUrl' ])
|
||||
connect([ 'shortUrlCreationResult', 'selectedServer' ], [ 'createShortUrl', 'resetCreateShortUrl' ]),
|
||||
);
|
||||
|
||||
bottle.serviceFactory('DeleteShortUrlModal', () => DeleteShortUrlModal);
|
||||
|
|
|
@ -23,7 +23,7 @@ const propTypes = {
|
|||
|
||||
const TagsList = (TagCard) => {
|
||||
const TagListComp = (
|
||||
{ filterTags, forceListTags, tagsList, selectedServer, createNewVisit, loadMercureInfo, mercureInfo }
|
||||
{ filterTags, forceListTags, tagsList, selectedServer, createNewVisit, loadMercureInfo, mercureInfo },
|
||||
) => {
|
||||
const [ displayedTag, setDisplayedTag ] = useState();
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ export default handleActions({
|
|||
|
||||
export const editTag = (buildShlinkApiClient, colorGenerator) => (oldName, newName, color) => async (
|
||||
dispatch,
|
||||
getState
|
||||
getState,
|
||||
) => {
|
||||
dispatch({ type: EDIT_TAG_START });
|
||||
const { editTag } = buildShlinkApiClient(getState);
|
||||
|
|
|
@ -18,7 +18,7 @@ const provideServices = (bottle, connect) => {
|
|||
'DeleteTagConfirmModal',
|
||||
'EditTagModal',
|
||||
'ForServerVersion',
|
||||
'ColorGenerator'
|
||||
'ColorGenerator',
|
||||
);
|
||||
|
||||
bottle.serviceFactory('DeleteTagConfirmModal', () => DeleteTagConfirmModal);
|
||||
|
@ -30,7 +30,7 @@ const provideServices = (bottle, connect) => {
|
|||
bottle.serviceFactory('TagsList', TagsList, 'TagCard');
|
||||
bottle.decorator('TagsList', connect(
|
||||
[ 'tagsList', 'selectedServer', 'mercureInfo' ],
|
||||
[ 'forceListTags', 'filterTags', 'createNewVisit', 'loadMercureInfo' ]
|
||||
[ 'forceListTags', 'filterTags', 'createNewVisit', 'loadMercureInfo' ],
|
||||
));
|
||||
|
||||
// Actions
|
||||
|
|
|
@ -68,7 +68,7 @@ const VisitsStats = ({ processStatsFromVisits, normalizeVisits }, OpenMapModalBt
|
|||
const normalizedVisits = useMemo(() => normalizeVisits(visits), [ visits ]);
|
||||
const { os, browsers, referrers, countries, cities, citiesForMap } = useMemo(
|
||||
() => processStatsFromVisits(normalizedVisits),
|
||||
[ normalizedVisits ]
|
||||
[ normalizedVisits ],
|
||||
);
|
||||
const mapLocations = values(citiesForMap);
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ const VisitsTable = ({
|
|||
'visits-table__sticky': isSticky,
|
||||
})}
|
||||
onClick={() => setSelectedVisits(
|
||||
selectedVisits.length < resultSet.total ? resultSet.visitsGroups.flat() : []
|
||||
selectedVisits.length < resultSet.total ? resultSet.visitsGroups.flat() : [],
|
||||
)}
|
||||
>
|
||||
<FontAwesomeIcon icon={checkIcon} className={classNames({ 'text-primary': selectedVisits.length > 0 })} />
|
||||
|
@ -149,7 +149,7 @@ const VisitsTable = ({
|
|||
style={{ cursor: 'pointer' }}
|
||||
className={classNames({ 'table-primary': isSelected })}
|
||||
onClick={() => setSelectedVisits(
|
||||
isSelected ? selectedVisits.filter((v) => v !== visit) : [ ...selectedVisits, visit ]
|
||||
isSelected ? selectedVisits.filter((v) => v !== visit) : [ ...selectedVisits, visit ],
|
||||
)}
|
||||
>
|
||||
<td className="text-center">
|
||||
|
|
|
@ -117,7 +117,7 @@ const LineChartCard = ({ title, visits, highlightedVisits, highlightedLabel = 'S
|
|||
);
|
||||
const groupedHighlighted = useMemo(
|
||||
() => fillTheGaps(groupVisitsByStep(step, reverse(highlightedVisits)), labels),
|
||||
[ highlightedVisits, step, labels ]
|
||||
[ highlightedVisits, step, labels ],
|
||||
);
|
||||
|
||||
const data = {
|
||||
|
|
|
@ -44,9 +44,9 @@ const SortableBarGraph = ({
|
|||
const sortedPairs = !order.orderField ? pairs : sortBy(
|
||||
pipe(
|
||||
prop(order.orderField === head(keys(sortingItems)) ? 0 : 1),
|
||||
toLowerIfString
|
||||
toLowerIfString,
|
||||
),
|
||||
pairs
|
||||
pairs,
|
||||
);
|
||||
|
||||
return !order.orderDir || order.orderDir === 'ASC' ? sortedPairs : reverse(sortedPairs);
|
||||
|
@ -56,7 +56,7 @@ const SortableBarGraph = ({
|
|||
const sortedKeys = sortedPairs.map(pickKeyFromPair);
|
||||
// The highlighted stats have to be ordered based on the regular stats, not on its own values
|
||||
const sortedHighlightedPairs = highlightedStats && toPairs(
|
||||
{ ...zipObj(sortedKeys, sortedKeys.map(() => 0)), ...highlightedStats }
|
||||
{ ...zipObj(sortedKeys, sortedKeys.map(() => 0)), ...highlightedStats },
|
||||
);
|
||||
|
||||
if (sortedPairs.length <= itemsPerPage) {
|
||||
|
@ -94,7 +94,7 @@ const SortableBarGraph = ({
|
|||
const { currentPageStats, currentPageHighlightedStats, pagination, max } = determineStats(
|
||||
stats,
|
||||
highlightedStats && keys(highlightedStats).length > 0 ? highlightedStats : undefined,
|
||||
sortingItems
|
||||
sortingItems,
|
||||
);
|
||||
const activeCities = keys(currentPageStats);
|
||||
const computeTitle = () => (
|
||||
|
|
|
@ -56,7 +56,7 @@ export const processStatsFromVisits = (normalizedVisits) =>
|
|||
|
||||
return stats;
|
||||
},
|
||||
{ os: {}, browsers: {}, referrers: {}, countries: {}, cities: {}, citiesForMap: {} }
|
||||
{ os: {}, browsers: {}, referrers: {}, countries: {}, cities: {}, citiesForMap: {} },
|
||||
);
|
||||
|
||||
export const normalizeVisits = map(({ userAgent, date, referer, visitLocation }) => {
|
||||
|
|
|
@ -17,12 +17,12 @@ const provideServices = (bottle, connect) => {
|
|||
bottle.serviceFactory('ShortUrlVisits', ShortUrlVisits, 'VisitsStats');
|
||||
bottle.decorator('ShortUrlVisits', connect(
|
||||
[ 'shortUrlVisits', 'shortUrlDetail', 'mercureInfo' ],
|
||||
[ 'getShortUrlVisits', 'getShortUrlDetail', 'cancelGetShortUrlVisits', 'createNewVisit', 'loadMercureInfo' ]
|
||||
[ 'getShortUrlVisits', 'getShortUrlDetail', 'cancelGetShortUrlVisits', 'createNewVisit', 'loadMercureInfo' ],
|
||||
));
|
||||
bottle.serviceFactory('TagVisits', TagVisits, 'VisitsStats', 'ColorGenerator');
|
||||
bottle.decorator('TagVisits', connect(
|
||||
[ 'tagVisits', 'mercureInfo' ],
|
||||
[ 'getTagVisits', 'cancelGetTagVisits', 'createNewVisit', 'loadMercureInfo' ]
|
||||
[ 'getTagVisits', 'cancelGetTagVisits', 'createNewVisit', 'loadMercureInfo' ],
|
||||
));
|
||||
|
||||
// Services
|
||||
|
|
|
@ -30,7 +30,7 @@ describe('<ErrorHandler />', () => {
|
|||
|
||||
expect(wrapper.text()).toContain('Oops! This is awkward :S');
|
||||
expect(wrapper.text()).toContain(
|
||||
'It seems that something went wrong. Try refreshing the page or just click this button.'
|
||||
'It seems that something went wrong. Try refreshing the page or just click this button.',
|
||||
);
|
||||
expect(wrapper.find(Button)).toHaveLength(1);
|
||||
});
|
||||
|
|
|
@ -24,7 +24,7 @@ describe('<NotFound />', () => {
|
|||
const { content } = createWrapper();
|
||||
|
||||
expect(content).toContain(
|
||||
'Use your browser\'s back button to navigate to the page you have previously come from, or just press this button.'
|
||||
'Use your browser\'s back button to navigate to the page you have previously come from, or just press this button.',
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ describe('<CreateServer />', () => {
|
|||
const CreateServer = createServerConstruct(ImportServersBtn, () => [ serversImported, () => '' ]);
|
||||
|
||||
wrapper = shallow(
|
||||
<CreateServer createServer={createServerMock} resetSelectedServer={identity} history={historyMock} />
|
||||
<CreateServer createServer={createServerMock} resetSelectedServer={identity} history={historyMock} />,
|
||||
);
|
||||
|
||||
return wrapper;
|
||||
|
|
|
@ -22,7 +22,7 @@ describe('<DeleteServerModal />', () => {
|
|||
isOpen={true}
|
||||
deleteServer={deleteServerMock}
|
||||
history={historyMock}
|
||||
/>
|
||||
/>,
|
||||
);
|
||||
});
|
||||
afterEach(() => wrapper.unmount());
|
||||
|
@ -38,7 +38,7 @@ describe('<DeleteServerModal />', () => {
|
|||
const modalBody = wrapper.find(ModalBody);
|
||||
|
||||
expect(modalBody.find('p').first().text()).toEqual(
|
||||
`Are you sure you want to remove ${serverName}?`
|
||||
`Are you sure you want to remove ${serverName}?`,
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ describe('<EditServer />', () => {
|
|||
match={match}
|
||||
selectedServer={selectedServer}
|
||||
selectServer={jest.fn()}
|
||||
/>
|
||||
/>,
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ describe('<ServersDropdown />', () => {
|
|||
|
||||
it('shows a message when no servers exist yet', () => {
|
||||
wrapped = shallow(
|
||||
<ServersDropdown servers={{}} listServers={identity} history={history} />
|
||||
<ServersDropdown servers={{}} listServers={identity} history={history} />,
|
||||
);
|
||||
const item = wrapped.find(DropdownItem);
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ describe('<ForServerVersion />', () => {
|
|||
wrapped = mount(
|
||||
<ForServerVersion minVersion={minVersion} maxVersion={maxVersion} selectedServer={selectedServer}>
|
||||
<span>Hello</span>
|
||||
</ForServerVersion>
|
||||
</ForServerVersion>,
|
||||
);
|
||||
|
||||
return wrapped;
|
||||
|
|
|
@ -23,7 +23,7 @@ describe('<ImportServersBtn />', () => {
|
|||
const ImportServersBtn = importServersBtnConstruct(serversImporterMock);
|
||||
|
||||
wrapper = shallow(
|
||||
<ImportServersBtn createServers={createServersMock} fileRef={fileRef} onImport={onImportMock} />
|
||||
<ImportServersBtn createServers={createServersMock} fileRef={fileRef} onImport={onImportMock} />,
|
||||
);
|
||||
});
|
||||
afterEach(() => wrapper.unmount());
|
||||
|
|
|
@ -33,7 +33,7 @@ describe('<ServerError />', () => {
|
|||
wrapper = shallow(
|
||||
<BrowserRouter>
|
||||
<ServerError type={type} servers={{}} selectedServer={selectedServer} />
|
||||
</BrowserRouter>
|
||||
</BrowserRouter>,
|
||||
);
|
||||
const wrapperText = wrapper.html();
|
||||
const textPairs = Object.entries(textsToFind);
|
||||
|
|
|
@ -17,7 +17,7 @@ describe('<CreateShortUrl />', () => {
|
|||
const CreateShortUrl = createShortUrlsCreator(TagsSelector, () => '', () => '');
|
||||
|
||||
wrapper = shallow(
|
||||
<CreateShortUrl shortUrlCreationResult={shortUrlCreationResult} createShortUrl={createShortUrl} />
|
||||
<CreateShortUrl shortUrlCreationResult={shortUrlCreationResult} createShortUrl={createShortUrl} />,
|
||||
);
|
||||
});
|
||||
afterEach(() => {
|
||||
|
|
|
@ -52,7 +52,7 @@ describe('<SearchBar />', () => {
|
|||
|
||||
it('updates short URLs list when a tag is removed', () => {
|
||||
wrapper = shallow(
|
||||
<SearchBar shortUrlsListParams={{ tags: [ 'foo' ] }} listShortUrls={listShortUrlsMock} />
|
||||
<SearchBar shortUrlsListParams={{ tags: [ 'foo' ] }} listShortUrls={listShortUrlsMock} />,
|
||||
);
|
||||
const tag = wrapper.find(Tag).first();
|
||||
|
||||
|
@ -63,7 +63,7 @@ describe('<SearchBar />', () => {
|
|||
|
||||
it.each([ 'startDateChange', 'endDateChange' ])('updates short URLs list when date range changes', (event) => {
|
||||
wrapper = shallow(
|
||||
<SearchBar shortUrlsListParams={{}} listShortUrls={listShortUrlsMock} />
|
||||
<SearchBar shortUrlsListParams={{}} listShortUrls={listShortUrlsMock} />,
|
||||
);
|
||||
const dateRange = wrapper.find(DateRangeRow);
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ describe('<ShortUrlsList />', () => {
|
|||
]
|
||||
}
|
||||
mercureInfo={{ loading: true }}
|
||||
/>
|
||||
/>,
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ describe('<DeleteShortUrlModal />', () => {
|
|||
toggle={identity}
|
||||
deleteShortUrl={deleteShortUrl}
|
||||
resetDeleteShortUrl={identity}
|
||||
/>
|
||||
/>,
|
||||
);
|
||||
|
||||
return wrapper;
|
||||
|
|
|
@ -17,7 +17,7 @@ describe('<EditMetaModal />', () => {
|
|||
toggle={toggle}
|
||||
editShortUrlMeta={editShortUrlMeta}
|
||||
resetShortUrlMeta={resetShortUrlMeta}
|
||||
/>
|
||||
/>,
|
||||
);
|
||||
|
||||
return wrapper;
|
||||
|
|
|
@ -15,7 +15,7 @@ describe('<EditShortUrlModal />', () => {
|
|||
shortUrlEdition={shortUrlEdition}
|
||||
toggle={toggle}
|
||||
editShortUrl={editShortUrl}
|
||||
/>
|
||||
/>,
|
||||
);
|
||||
|
||||
return wrapper;
|
||||
|
|
|
@ -26,7 +26,7 @@ describe('<EditTagsModal />', () => {
|
|||
toggle={toggle}
|
||||
editShortUrlTags={editShortUrlTags}
|
||||
resetShortUrlsTags={resetShortUrlsTags}
|
||||
/>
|
||||
/>,
|
||||
);
|
||||
|
||||
return wrapper;
|
||||
|
|
|
@ -21,7 +21,7 @@ describe('<ShortUrlVisitsCount />', () => {
|
|||
const maxVisitsTooltip = wrapper.find(UncontrolledTooltip);
|
||||
|
||||
expect(wrapper.html()).toEqual(
|
||||
`<span><strong class="short-url-visits-count__amount">${visitsCount}</strong></span>`
|
||||
`<span><strong class="short-url-visits-count__amount">${visitsCount}</strong></span>`,
|
||||
);
|
||||
expect(maxVisitsHelper).toHaveLength(0);
|
||||
expect(maxVisitsTooltip).toHaveLength(0);
|
||||
|
|
|
@ -34,7 +34,7 @@ describe('<ShortUrlsRow />', () => {
|
|||
const ShortUrlsRow = createShortUrlsRow(ShortUrlsRowMenu, colorGenerator, useStateFlagTimeout);
|
||||
|
||||
wrapper = shallow(
|
||||
<ShortUrlsRow shortUrlsListParams={{}} refreshList={mockFunction} selecrtedServer={server} shortUrl={shortUrl} />
|
||||
<ShortUrlsRow shortUrlsListParams={{}} refreshList={mockFunction} selecrtedServer={server} shortUrl={shortUrl} />,
|
||||
);
|
||||
});
|
||||
afterEach(() => wrapper.unmount());
|
||||
|
|
|
@ -23,7 +23,7 @@ describe('<ShortUrlsRowMenu />', () => {
|
|||
EditTagsModal,
|
||||
EditMetaModal,
|
||||
EditShortUrlModal,
|
||||
() => ''
|
||||
() => '',
|
||||
);
|
||||
|
||||
wrapper = shallow(
|
||||
|
@ -31,7 +31,7 @@ describe('<ShortUrlsRowMenu />', () => {
|
|||
selectedServer={selectedServer}
|
||||
shortUrl={shortUrl}
|
||||
onCopyToClipboard={onCopyToClipboard}
|
||||
/>
|
||||
/>,
|
||||
);
|
||||
|
||||
return wrapper;
|
||||
|
|
|
@ -60,7 +60,7 @@ describe('shortUrlDeletionReducer', () => {
|
|||
});
|
||||
|
||||
it.each(
|
||||
[[ undefined ], [ null ], [ 'example.com' ]]
|
||||
[[ undefined ], [ null ], [ 'example.com' ]],
|
||||
)('dispatches proper actions if API client request succeeds', async (domain) => {
|
||||
const apiClientMock = {
|
||||
deleteShortUrl: jest.fn(() => ''),
|
||||
|
|
|
@ -70,7 +70,7 @@ describe('shortUrlTagsReducer', () => {
|
|||
expect(dispatch).toHaveBeenNthCalledWith(1, { type: EDIT_SHORT_URL_TAGS_START });
|
||||
expect(dispatch).toHaveBeenNthCalledWith(
|
||||
2,
|
||||
{ type: SHORT_URL_TAGS_EDITED, tags: normalizedTags, shortCode, domain }
|
||||
{ type: SHORT_URL_TAGS_EDITED, tags: normalizedTags, shortCode, domain },
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ describe('<TagsList />', () => {
|
|||
const TagsList = createTagsList(TagCard);
|
||||
|
||||
wrapper = shallow(
|
||||
<TagsList forceListTags={identity} filterTags={filterTags} match={{ params }} tagsList={tagsList} />
|
||||
<TagsList forceListTags={identity} filterTags={filterTags} match={{ params }} tagsList={tagsList} />,
|
||||
);
|
||||
|
||||
return wrapper;
|
||||
|
|
|
@ -17,7 +17,7 @@ describe('<DeleteTagConfirmModal />', () => {
|
|||
deleteTag={deleteTag}
|
||||
tagDeleted={tagDeleted}
|
||||
tagDelete={tagDelete}
|
||||
/>
|
||||
/>,
|
||||
);
|
||||
|
||||
return wrapper;
|
||||
|
|
|
@ -42,7 +42,7 @@ describe('ShlinkApiClient', () => {
|
|||
const { createShortUrl } = new ShlinkApiClient(axiosSpy);
|
||||
|
||||
await createShortUrl(
|
||||
{ foo: 'bar', empty: undefined, anotherEmpty: null }
|
||||
{ foo: 'bar', empty: undefined, anotherEmpty: null },
|
||||
);
|
||||
|
||||
expect(axiosSpy).toHaveBeenCalledWith(expect.objectContaining({ data: { foo: 'bar' } }));
|
||||
|
|
|
@ -30,7 +30,7 @@ describe('<ShortUrlVisits />', () => {
|
|||
shortUrlDetail={{}}
|
||||
cancelGetShortUrlVisits={identity}
|
||||
matchMedia={() => ({ matches: false })}
|
||||
/>
|
||||
/>,
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ describe('<ShortUrlVisitsHeader />', () => {
|
|||
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(
|
||||
<ShortUrlVisitsHeader shortUrlDetail={shortUrlDetail} shortUrlVisits={shortUrlVisits} goBack={goBack} />
|
||||
<ShortUrlVisitsHeader shortUrlDetail={shortUrlDetail} shortUrlVisits={shortUrlVisits} goBack={goBack} />,
|
||||
);
|
||||
});
|
||||
afterEach(() => wrapper.unmount());
|
||||
|
|
|
@ -25,7 +25,7 @@ describe('<TagVisits />', () => {
|
|||
history={history}
|
||||
tagVisits={{ loading: true, visits: [] }}
|
||||
cancelGetTagVisits={identity}
|
||||
/>
|
||||
/>,
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ describe('<TagVisitsHeader />', () => {
|
|||
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(
|
||||
<TagVisitsHeader tagVisits={tagVisits} goBack={goBack} colorGenerator={{}} />
|
||||
<TagVisitsHeader tagVisits={tagVisits} goBack={goBack} colorGenerator={{}} />,
|
||||
);
|
||||
});
|
||||
afterEach(() => wrapper.unmount());
|
||||
|
|
|
@ -10,7 +10,7 @@ describe('<VisitsHeader />', () => {
|
|||
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(
|
||||
<VisitsHeader visits={visits} goBack={goBack} title={title} />
|
||||
<VisitsHeader visits={visits} goBack={goBack} title={title} />,
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -21,7 +21,7 @@ describe('<VisitsHeader />', () => {
|
|||
const visitsBadge = wrapper.find('.badge');
|
||||
|
||||
expect(visitsBadge.html()).toContain(
|
||||
`Visits: <span><strong class="short-url-visits-count__amount">${visits.length}</strong></span>`
|
||||
`Visits: <span><strong class="short-url-visits-count__amount">${visits.length}</strong></span>`,
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ describe('<VisitStats />', () => {
|
|||
visitsInfo={visitsInfo}
|
||||
cancelGetVisits={identity}
|
||||
matchMedia={() => ({ matches: false })}
|
||||
/>
|
||||
/>,
|
||||
);
|
||||
|
||||
return wrapper;
|
||||
|
|
|
@ -16,7 +16,7 @@ describe('<VisitsTable />', () => {
|
|||
selectedVisits={selectedVisits}
|
||||
setSelectedVisits={setSelectedVisits}
|
||||
matchMedia={matchMedia}
|
||||
/>
|
||||
/>,
|
||||
);
|
||||
|
||||
return wrapper;
|
||||
|
@ -64,7 +64,7 @@ describe('<VisitsTable />', () => {
|
|||
});
|
||||
|
||||
it.each(
|
||||
rangeOf(20, (value) => [ value ])
|
||||
rangeOf(20, (value) => [ value ]),
|
||||
)('does not render footer when there is only one page to render', (visitsCount) => {
|
||||
const wrapper = createWrapper(rangeOf(visitsCount, () => ({ browser: '', date: '', referer: '' })));
|
||||
const tr = wrapper.find('tbody').find('tr');
|
||||
|
|
|
@ -24,7 +24,7 @@ describe('<SortableBarGraph />', () => {
|
|||
stats={{ ...stats, ...extraStats }}
|
||||
sortingItems={sortingItems}
|
||||
withPagination={withPagination}
|
||||
/>
|
||||
/>,
|
||||
);
|
||||
|
||||
return wrapper;
|
||||
|
@ -108,7 +108,7 @@ describe('<SortableBarGraph />', () => {
|
|||
</span>
|
||||
)}
|
||||
/>
|
||||
</span>
|
||||
</span>,
|
||||
).find(SortableBarGraph);
|
||||
const header = wrapper.renderProp('extraHeaderContent')();
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ describe('visitCreationReducer', () => {
|
|||
describe('createNewVisit', () => {
|
||||
it('just returns the action with proper type', () =>
|
||||
expect(createNewVisit({ shortUrl: {}, visit: {} })).toEqual(
|
||||
{ type: CREATE_VISIT, shortUrl: {}, visit: {} }
|
||||
{ type: CREATE_VISIT, shortUrl: {}, visit: {} },
|
||||
));
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue