+ client: Validate adding of absolute path to the filtering lists

This commit is contained in:
ArtemBaskal
2020-04-06 20:07:32 +03:00
parent fc03ca4bb8
commit 421ad744cb
5 changed files with 31 additions and 15 deletions

View File

@@ -4,7 +4,7 @@ import { Field, reduxForm } from 'redux-form';
import { Trans, withNamespaces } from 'react-i18next';
import flow from 'lodash/flow';
import { renderInputField, required, isValidUrl } from '../../helpers/form';
import { renderInputField, required, isValidPath } from '../../helpers/form';
const Form = (props) => {
const {
@@ -37,8 +37,8 @@ const Form = (props) => {
type="text"
component={renderInputField}
className="form-control"
placeholder={t('enter_url_hint')}
validate={[required, isValidUrl]}
placeholder={t('enter_url_or_path_hint')}
validate={[required, isValidPath]}
/>
</div>
<div className="form__description">

View File

@@ -2,11 +2,10 @@ import React, { Component } from 'react';
import PropTypes from 'prop-types';
import ReactTable from 'react-table';
import { withNamespaces, Trans } from 'react-i18next';
import CellWrap from '../ui/CellWrap';
import { MODAL_TYPE } from '../../helpers/constants';
import { formatDetailedDateTime } from '../../helpers/helpers';
import { isValidAbsolutePath } from '../../helpers/form';
class Table extends Component {
getDateCell = row => CellWrap(row, formatDetailedDateTime);
@@ -50,14 +49,15 @@ class Table extends Component {
minWidth: 200,
Cell: ({ value }) => (
<div className="logs__row logs__row--overflow">
<a
href={value}
target="_blank"
rel="noopener noreferrer"
className="link logs__text"
>
{value}
</a>
{isValidAbsolutePath(value) ? value :
<a
href={value}
target="_blank"
rel="noopener noreferrer"
className="link logs__text"
>
{value}
</a>}
</div>
),
},