mirror of
https://github.com/strapi/strapi.git
synced 2025-11-16 18:19:34 +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,
|
useGlobalContext,
|
||||||
} from 'strapi-helper-plugin';
|
} from 'strapi-helper-plugin';
|
||||||
import pluginId from '../../pluginId';
|
import pluginId from '../../pluginId';
|
||||||
|
import { removePublishedAtFromMetas } from '../../utils';
|
||||||
import Block from '../Block';
|
import Block from '../Block';
|
||||||
import Container from '../Container';
|
import Container from '../Container';
|
||||||
import SectionTitle from '../SectionTitle';
|
import SectionTitle from '../SectionTitle';
|
||||||
@ -35,8 +36,8 @@ const SettingsViewWrapper = ({
|
|||||||
const [showWarningCancel, setWarningCancel] = useState(false);
|
const [showWarningCancel, setWarningCancel] = useState(false);
|
||||||
const [showWarningSubmit, setWarningSubmit] = useState(false);
|
const [showWarningSubmit, setWarningSubmit] = useState(false);
|
||||||
|
|
||||||
const getAttributes = useMemo(() => {
|
const attributes = useMemo(() => {
|
||||||
return get(modifiedData, ['schema', 'attributes'], {});
|
return removePublishedAtFromMetas(get(modifiedData, ['schema', 'attributes'], {}));
|
||||||
}, [modifiedData]);
|
}, [modifiedData]);
|
||||||
|
|
||||||
const toggleWarningCancel = () => setWarningCancel(prevState => !prevState);
|
const toggleWarningCancel = () => setWarningCancel(prevState => !prevState);
|
||||||
@ -96,15 +97,14 @@ const SettingsViewWrapper = ({
|
|||||||
'id',
|
'id',
|
||||||
...displayedFields.filter(
|
...displayedFields.filter(
|
||||||
name =>
|
name =>
|
||||||
get(getAttributes, [name, 'type'], '') !== 'media' &&
|
get(attributes, [name, 'type'], '') !== 'media' &&
|
||||||
name !== 'id' &&
|
name !== 'id' &&
|
||||||
get(getAttributes, [name, 'type'], '') !== 'richtext'
|
get(attributes, [name, 'type'], '') !== 'richtext'
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input.name === 'settings.mainField') {
|
if (input.name === 'settings.mainField') {
|
||||||
const attributes = getAttributes;
|
|
||||||
const options = Object.keys(attributes).filter(attr => {
|
const options = Object.keys(attributes).filter(attr => {
|
||||||
const type = get(attributes, [attr, 'type'], '');
|
const type = get(attributes, [attr, 'type'], '');
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import React, { useEffect, useMemo, useReducer, useState } from 'react';
|
import React, { useEffect, useMemo, useReducer, useState } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { cloneDeep, get, omit } from 'lodash';
|
import { cloneDeep, get } from 'lodash';
|
||||||
import {
|
import {
|
||||||
// utils
|
// utils
|
||||||
request,
|
request,
|
||||||
@ -12,8 +12,7 @@ import { useDrop } from 'react-dnd';
|
|||||||
import { DropdownItem } from 'reactstrap';
|
import { DropdownItem } from 'reactstrap';
|
||||||
import { Inputs as Input } from '@buffetjs/custom';
|
import { Inputs as Input } from '@buffetjs/custom';
|
||||||
import pluginId from '../../pluginId';
|
import pluginId from '../../pluginId';
|
||||||
import ItemTypes from '../../utils/ItemTypes';
|
import { ItemTypes, getRequestUrl, removePublishedAtFromMetas } from '../../utils';
|
||||||
import getRequestUrl from '../../utils/getRequestUrl';
|
|
||||||
import PopupForm from '../../components/PopupForm';
|
import PopupForm from '../../components/PopupForm';
|
||||||
import SettingsViewWrapper from '../../components/SettingsViewWrapper';
|
import SettingsViewWrapper from '../../components/SettingsViewWrapper';
|
||||||
import SortWrapper from '../../components/SortWrapper';
|
import SortWrapper from '../../components/SortWrapper';
|
||||||
@ -82,7 +81,7 @@ const ListSettingsView = ({ deleteLayout, slug }) => {
|
|||||||
|
|
||||||
const listRemainingFields = useMemo(() => {
|
const listRemainingFields = useMemo(() => {
|
||||||
const metadatas = get(modifiedData, ['metadatas'], {});
|
const metadatas = get(modifiedData, ['metadatas'], {});
|
||||||
const filteredMetadatas = omit(metadatas, ['published_at']);
|
const filteredMetadatas = removePublishedAtFromMetas(metadatas);
|
||||||
|
|
||||||
return Object.keys(filteredMetadatas)
|
return Object.keys(filteredMetadatas)
|
||||||
.filter(key => {
|
.filter(key => {
|
||||||
|
|||||||
@ -2,14 +2,13 @@ import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from '
|
|||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { bindActionCreators, compose } from 'redux';
|
import { bindActionCreators, compose } from 'redux';
|
||||||
import { get, sortBy, omit } from 'lodash';
|
import { get, sortBy } from 'lodash';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage, useIntl } from 'react-intl';
|
||||||
import { useLocation } from 'react-router-dom';
|
import { useLocation } from 'react-router-dom';
|
||||||
import { Header } from '@buffetjs/custom';
|
import { Header } from '@buffetjs/custom';
|
||||||
import {
|
import {
|
||||||
PopUpWarning,
|
PopUpWarning,
|
||||||
generateFiltersFromSearch,
|
generateFiltersFromSearch,
|
||||||
useGlobalContext,
|
|
||||||
request,
|
request,
|
||||||
CheckPermissions,
|
CheckPermissions,
|
||||||
useUserPermissions,
|
useUserPermissions,
|
||||||
@ -17,7 +16,12 @@ import {
|
|||||||
} from 'strapi-helper-plugin';
|
} from 'strapi-helper-plugin';
|
||||||
import pluginId from '../../pluginId';
|
import pluginId from '../../pluginId';
|
||||||
import pluginPermissions from '../../permissions';
|
import pluginPermissions from '../../permissions';
|
||||||
import { generatePermissionsObject, getRequestUrl } from '../../utils';
|
import {
|
||||||
|
generatePermissionsObject,
|
||||||
|
getRequestUrl,
|
||||||
|
getTrad,
|
||||||
|
removePublishedAtFromMetas,
|
||||||
|
} from '../../utils';
|
||||||
|
|
||||||
import DisplayedFieldsDropdown from '../../components/DisplayedFieldsDropdown';
|
import DisplayedFieldsDropdown from '../../components/DisplayedFieldsDropdown';
|
||||||
import Container from '../../components/Container';
|
import Container from '../../components/Container';
|
||||||
@ -83,7 +87,7 @@ function ListView({
|
|||||||
const query = useQuery();
|
const query = useQuery();
|
||||||
const { search } = useLocation();
|
const { search } = useLocation();
|
||||||
const isFirstRender = useRef(true);
|
const isFirstRender = useRef(true);
|
||||||
const { formatMessage } = useGlobalContext();
|
const { formatMessage } = useIntl();
|
||||||
|
|
||||||
const [isLabelPickerOpen, setLabelPickerState] = useState(false);
|
const [isLabelPickerOpen, setLabelPickerState] = useState(false);
|
||||||
const [isFilterPickerOpen, setFilterPickerState] = useState(false);
|
const [isFilterPickerOpen, setFilterPickerState] = useState(false);
|
||||||
@ -209,11 +213,16 @@ function ListView({
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (hasDraftAndPublish) {
|
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;
|
return headers;
|
||||||
}, [getMetaDatas, hasDraftAndPublish, listLayout]);
|
}, [formatMessage, getMetaDatas, hasDraftAndPublish, listLayout]);
|
||||||
|
|
||||||
const getFirstSortableElement = useCallback(
|
const getFirstSortableElement = useCallback(
|
||||||
(name = '') => {
|
(name = '') => {
|
||||||
@ -229,7 +238,7 @@ function ListView({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const allLabels = useMemo(() => {
|
const allLabels = useMemo(() => {
|
||||||
const filteredMetadatas = omit(getMetaDatas(), ['published_at']);
|
const filteredMetadatas = removePublishedAtFromMetas(getMetaDatas());
|
||||||
|
|
||||||
return sortBy(
|
return sortBy(
|
||||||
Object.keys(filteredMetadatas)
|
Object.keys(filteredMetadatas)
|
||||||
|
|||||||
@ -73,6 +73,7 @@
|
|||||||
"containers.List.pluginHeaderDescription": "{label} entries found",
|
"containers.List.pluginHeaderDescription": "{label} entries found",
|
||||||
"containers.List.pluginHeaderDescription.singular": "{label} entry found",
|
"containers.List.pluginHeaderDescription.singular": "{label} entry found",
|
||||||
"containers.List.published": "Published",
|
"containers.List.published": "Published",
|
||||||
|
"containers.ListPage.table-headers.published_at": "State",
|
||||||
"containers.ListPage.displayedFields": "Displayed Fields",
|
"containers.ListPage.displayedFields": "Displayed Fields",
|
||||||
"containers.ListSettingsView.modal-form.edit-label": "Edit the label",
|
"containers.ListSettingsView.modal-form.edit-label": "Edit the label",
|
||||||
"containers.SettingPage.add.field": "Insert another field",
|
"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 getRequestUrl } from './getRequestUrl';
|
||||||
export { default as getTrad } from './getTrad';
|
export { default as getTrad } from './getTrad';
|
||||||
export { default as ItemTypes } from './ItemTypes';
|
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