mirror of
https://github.com/strapi/strapi.git
synced 2025-12-26 14:44:31 +00:00
Merge pull request #6354 from strapi/chore/fix-front-issues
Chore/fix front issues
This commit is contained in:
commit
4bf3501b69
@ -11,9 +11,13 @@ const Layout = styled(SvgCompo)`
|
||||
}
|
||||
&.colored {
|
||||
> g {
|
||||
fill: #007eff;
|
||||
fill: ${({ fill }) => fill};
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
Layout.defaultProps = {
|
||||
fill: '#007eff',
|
||||
};
|
||||
|
||||
export default Layout;
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
/* eslint-disable react-hooks/exhaustive-deps */
|
||||
import React, { useState, useEffect, useRef, memo } from 'react';
|
||||
import React, { useState, useEffect, useMemo, useRef, memo } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
import { Link, useLocation } from 'react-router-dom';
|
||||
import { cloneDeep, get, isArray, isEmpty } from 'lodash';
|
||||
import { cloneDeep, findIndex, get, isArray, isEmpty } from 'lodash';
|
||||
import { request } from 'strapi-helper-plugin';
|
||||
import pluginId from '../../pluginId';
|
||||
import useDataManager from '../../hooks/useDataManager';
|
||||
@ -42,6 +42,22 @@ function SelectWrapper({
|
||||
const ref = useRef();
|
||||
const startRef = useRef();
|
||||
|
||||
const filteredOptions = useMemo(() => {
|
||||
return options.filter(option => {
|
||||
if (!isEmpty(value)) {
|
||||
// SelectMany
|
||||
if (Array.isArray(value)) {
|
||||
return findIndex(value, o => o.id === option.value.id) === -1;
|
||||
}
|
||||
|
||||
// SelectOne
|
||||
return get(value, 'id', '') !== option.value.id;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}, [options, value]);
|
||||
|
||||
startRef.current = state._start;
|
||||
|
||||
ref.current = async () => {
|
||||
@ -193,7 +209,7 @@ function SelectWrapper({
|
||||
move={moveRelation}
|
||||
name={name}
|
||||
nextSearch={nextSearch}
|
||||
options={options}
|
||||
options={filteredOptions}
|
||||
onChange={value => {
|
||||
onChange({ target: { name, value: value ? value.value : value } });
|
||||
}}
|
||||
|
||||
@ -53,6 +53,7 @@ const ListView = () => {
|
||||
const firstMainDataPath = isInContentTypeView ? 'contentType' : 'component';
|
||||
const mainDataTypeAttributesPath = [firstMainDataPath, 'schema', 'attributes'];
|
||||
const targetUid = get(modifiedData, [firstMainDataPath, 'uid']);
|
||||
const isTemporary = get(modifiedData, [firstMainDataPath, 'isTemporary'], false);
|
||||
const contentTypeKind = get(modifiedData, [firstMainDataPath, 'schema', 'kind'], null);
|
||||
|
||||
const attributes = get(modifiedData, mainDataTypeAttributesPath, {});
|
||||
@ -259,15 +260,18 @@ const ListView = () => {
|
||||
? `/plugins/content-manager/${contentTypeKind}/${targetUid}/ctm-configurations/edit-settings/content-types`
|
||||
: `/plugins/content-manager/ctm-configurations/edit-settings/components/${targetUid}/`;
|
||||
|
||||
push(endPoint);
|
||||
if (!isTemporary) {
|
||||
push(endPoint);
|
||||
}
|
||||
};
|
||||
|
||||
const configureButtonProps = {
|
||||
icon: <LayoutIcon className="colored" fill="#007eff" />,
|
||||
icon: <LayoutIcon className="colored" fill={isTemporary ? '#B4B6BA' : '#007eff'} />,
|
||||
color: 'secondary',
|
||||
label: formatMessage({ id: `${pluginId}.form.button.configure-view` }),
|
||||
onClick: goToCMSettingsPage,
|
||||
style: { marginTop: '2px' },
|
||||
disabled: isTemporary,
|
||||
};
|
||||
|
||||
const listActions = isInDevelopmentMode
|
||||
|
||||
@ -80,9 +80,10 @@ export class HomePage extends React.Component {
|
||||
};
|
||||
|
||||
openCurrentDocumentation = () => {
|
||||
const { currentDocVersion } = this.props;
|
||||
const { currentDocVersion, prefix } = this.props;
|
||||
const slash = prefix.startsWith('/') ? '' : '/';
|
||||
|
||||
return openWithNewTab(`/documentation/v${currentDocVersion}`);
|
||||
return openWithNewTab(`${slash}${prefix}/v${currentDocVersion}`);
|
||||
};
|
||||
|
||||
shouldHideInput = inputName => {
|
||||
@ -218,6 +219,7 @@ HomePage.defaultProps = {
|
||||
onConfirmDeleteDoc: () => {},
|
||||
onSubmit: () => {},
|
||||
onUpdateDoc: () => {},
|
||||
prefix: '/documentation',
|
||||
versionToDelete: '',
|
||||
};
|
||||
|
||||
@ -234,6 +236,7 @@ HomePage.propTypes = {
|
||||
onConfirmDeleteDoc: PropTypes.func,
|
||||
onSubmit: PropTypes.func,
|
||||
onUpdateDoc: PropTypes.func,
|
||||
prefix: PropTypes.string,
|
||||
versionToDelete: PropTypes.string,
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user