mirror of
https://github.com/strapi/strapi.git
synced 2025-11-03 11:25:17 +00:00
Fix feedback settings view
Signed-off-by: soupette <cyril.lpz@gmail.com>
This commit is contained in:
parent
1bf63ef388
commit
5abab1d9c5
@ -12,6 +12,7 @@ import {
|
||||
useGlobalContext,
|
||||
} from 'strapi-helper-plugin';
|
||||
import pluginId from '../../pluginId';
|
||||
import { removePublishedAtFromMetas } from '../../utils';
|
||||
import Block from '../Block';
|
||||
import Container from '../Container';
|
||||
import SectionTitle from '../SectionTitle';
|
||||
@ -35,8 +36,8 @@ const SettingsViewWrapper = ({
|
||||
const [showWarningCancel, setWarningCancel] = useState(false);
|
||||
const [showWarningSubmit, setWarningSubmit] = useState(false);
|
||||
|
||||
const getAttributes = useMemo(() => {
|
||||
return get(modifiedData, ['schema', 'attributes'], {});
|
||||
const attributes = useMemo(() => {
|
||||
return removePublishedAtFromMetas(get(modifiedData, ['schema', 'attributes'], {}));
|
||||
}, [modifiedData]);
|
||||
|
||||
const toggleWarningCancel = () => setWarningCancel(prevState => !prevState);
|
||||
@ -96,15 +97,14 @@ const SettingsViewWrapper = ({
|
||||
'id',
|
||||
...displayedFields.filter(
|
||||
name =>
|
||||
get(getAttributes, [name, 'type'], '') !== 'media' &&
|
||||
get(attributes, [name, 'type'], '') !== 'media' &&
|
||||
name !== 'id' &&
|
||||
get(getAttributes, [name, 'type'], '') !== 'richtext'
|
||||
get(attributes, [name, 'type'], '') !== 'richtext'
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
if (input.name === 'settings.mainField') {
|
||||
const attributes = getAttributes;
|
||||
const options = Object.keys(attributes).filter(attr => {
|
||||
const type = get(attributes, [attr, 'type'], '');
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import React, { useEffect, useMemo, useReducer, useState } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { cloneDeep, get, omit } from 'lodash';
|
||||
import { cloneDeep, get } from 'lodash';
|
||||
import {
|
||||
// utils
|
||||
request,
|
||||
@ -12,8 +12,7 @@ import { useDrop } from 'react-dnd';
|
||||
import { DropdownItem } from 'reactstrap';
|
||||
import { Inputs as Input } from '@buffetjs/custom';
|
||||
import pluginId from '../../pluginId';
|
||||
import ItemTypes from '../../utils/ItemTypes';
|
||||
import getRequestUrl from '../../utils/getRequestUrl';
|
||||
import { ItemTypes, getRequestUrl, removePublishedAtFromMetas } from '../../utils';
|
||||
import PopupForm from '../../components/PopupForm';
|
||||
import SettingsViewWrapper from '../../components/SettingsViewWrapper';
|
||||
import SortWrapper from '../../components/SortWrapper';
|
||||
@ -82,7 +81,7 @@ const ListSettingsView = ({ deleteLayout, slug }) => {
|
||||
|
||||
const listRemainingFields = useMemo(() => {
|
||||
const metadatas = get(modifiedData, ['metadatas'], {});
|
||||
const filteredMetadatas = omit(metadatas, ['published_at']);
|
||||
const filteredMetadatas = removePublishedAtFromMetas(metadatas);
|
||||
|
||||
return Object.keys(filteredMetadatas)
|
||||
.filter(key => {
|
||||
|
||||
@ -2,14 +2,13 @@ import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from '
|
||||
import PropTypes from 'prop-types';
|
||||
import { connect } from 'react-redux';
|
||||
import { bindActionCreators, compose } from 'redux';
|
||||
import { get, sortBy, omit } from 'lodash';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
import { get, sortBy } from 'lodash';
|
||||
import { FormattedMessage, useIntl } from 'react-intl';
|
||||
import { useLocation } from 'react-router-dom';
|
||||
import { Header } from '@buffetjs/custom';
|
||||
import {
|
||||
PopUpWarning,
|
||||
generateFiltersFromSearch,
|
||||
useGlobalContext,
|
||||
request,
|
||||
CheckPermissions,
|
||||
useUserPermissions,
|
||||
@ -17,7 +16,12 @@ import {
|
||||
} from 'strapi-helper-plugin';
|
||||
import pluginId from '../../pluginId';
|
||||
import pluginPermissions from '../../permissions';
|
||||
import { generatePermissionsObject, getRequestUrl } from '../../utils';
|
||||
import {
|
||||
generatePermissionsObject,
|
||||
getRequestUrl,
|
||||
getTrad,
|
||||
removePublishedAtFromMetas,
|
||||
} from '../../utils';
|
||||
|
||||
import DisplayedFieldsDropdown from '../../components/DisplayedFieldsDropdown';
|
||||
import Container from '../../components/Container';
|
||||
@ -83,7 +87,7 @@ function ListView({
|
||||
const query = useQuery();
|
||||
const { search } = useLocation();
|
||||
const isFirstRender = useRef(true);
|
||||
const { formatMessage } = useGlobalContext();
|
||||
const { formatMessage } = useIntl();
|
||||
|
||||
const [isLabelPickerOpen, setLabelPickerState] = useState(false);
|
||||
const [isFilterPickerOpen, setFilterPickerState] = useState(false);
|
||||
@ -209,11 +213,16 @@ function ListView({
|
||||
});
|
||||
|
||||
if (hasDraftAndPublish) {
|
||||
headers.push({ label: 'State', searchable: false, sortable: true, name: 'published_at' });
|
||||
headers.push({
|
||||
label: formatMessage({ id: getTrad('containers.ListPage.table-headers.published_at') }),
|
||||
searchable: false,
|
||||
sortable: true,
|
||||
name: 'published_at',
|
||||
});
|
||||
}
|
||||
|
||||
return headers;
|
||||
}, [getMetaDatas, hasDraftAndPublish, listLayout]);
|
||||
}, [formatMessage, getMetaDatas, hasDraftAndPublish, listLayout]);
|
||||
|
||||
const getFirstSortableElement = useCallback(
|
||||
(name = '') => {
|
||||
@ -229,7 +238,7 @@ function ListView({
|
||||
);
|
||||
|
||||
const allLabels = useMemo(() => {
|
||||
const filteredMetadatas = omit(getMetaDatas(), ['published_at']);
|
||||
const filteredMetadatas = removePublishedAtFromMetas(getMetaDatas());
|
||||
|
||||
return sortBy(
|
||||
Object.keys(filteredMetadatas)
|
||||
|
||||
@ -73,6 +73,7 @@
|
||||
"containers.List.pluginHeaderDescription": "{label} entries found",
|
||||
"containers.List.pluginHeaderDescription.singular": "{label} entry found",
|
||||
"containers.List.published": "Published",
|
||||
"containers.ListPage.table-headers.published_at": "State",
|
||||
"containers.ListPage.displayedFields": "Displayed Fields",
|
||||
"containers.ListSettingsView.modal-form.edit-label": "Edit the label",
|
||||
"containers.SettingPage.add.field": "Insert another field",
|
||||
|
||||
@ -4,3 +4,4 @@ export { default as getFieldName } from './getFieldName';
|
||||
export { default as getRequestUrl } from './getRequestUrl';
|
||||
export { default as getTrad } from './getTrad';
|
||||
export { default as ItemTypes } from './ItemTypes';
|
||||
export { default as removePublishedAtFromMetas } from './removePublishedAtFromMetas';
|
||||
|
||||
@ -0,0 +1,5 @@
|
||||
import { omit } from 'lodash';
|
||||
|
||||
const removePublishedAtFromMetas = metas => omit(metas, ['published_at']);
|
||||
|
||||
export default removePublishedAtFromMetas;
|
||||
@ -0,0 +1,12 @@
|
||||
import removePublishedAtFromMetas from '../removePublishedAtFromMetas';
|
||||
|
||||
describe('CONTENT MANAGER | utils | removePublishedAtFromMetas', () => {
|
||||
it('should remove the published_at key from the given object', () => {
|
||||
const data = {
|
||||
ok: true,
|
||||
published_at: true,
|
||||
};
|
||||
|
||||
expect(removePublishedAtFromMetas(data)).toEqual({ ok: true });
|
||||
});
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user