Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed add new entity button to just use getName for consistency (#5… #5633

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,17 @@ import React, { memo, useCallback, useEffect, useRef, useState } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { bindActionCreators, compose } from 'redux';
import { capitalize, get, sortBy } from 'lodash';
import { get, sortBy } from 'lodash';
import { FormattedMessage } from 'react-intl';
import { Header } from '@buffetjs/custom';
import {
PopUpWarning,
getQueryParameters,
useGlobalContext,
request,
} from 'strapi-helper-plugin';
import { PopUpWarning, getQueryParameters, useGlobalContext, request } from 'strapi-helper-plugin';
import pluginId from '../../pluginId';
import DisplayedFieldsDropdown from '../../components/DisplayedFieldsDropdown';
import Container from '../../components/Container';
import CustomTable from '../../components/CustomTable';
import FilterPicker from '../../components/FilterPicker';
import Search from '../../components/Search';
import {
generateFiltersFromSearch,
generateSearchFromFilters,
} from '../../utils/search';
import { generateFiltersFromSearch, generateSearchFromFilters } from '../../utils/search';
import ListViewProvider from '../ListViewProvider';
import { onChangeListLabels, resetListLabels } from '../Main/actions';
import { AddFilterCta, FilterIcon, Wrapper } from './components';
Expand Down Expand Up @@ -100,16 +92,14 @@ function ListView({
const getSearchParams = useCallback(
(updatedParams = {}) => {
return {
_limit:
getQueryParameters(search, '_limit') ||
getLayoutSettingRef.current('pageSize'),
_limit: getQueryParameters(search, '_limit') || getLayoutSettingRef.current('pageSize'),
_page: getQueryParameters(search, '_page') || 1,
_q: getQueryParameters(search, '_q') || '',
_sort:
getQueryParameters(search, '_sort') ||
`${getLayoutSettingRef.current(
'defaultSortBy'
)}:${getLayoutSettingRef.current('defaultSortOrder')}`,
`${getLayoutSettingRef.current('defaultSortBy')}:${getLayoutSettingRef.current(
'defaultSortOrder'
)}`,
filters: generateFiltersFromSearch(search),
...updatedParams,
};
Expand Down Expand Up @@ -176,11 +166,9 @@ function ListView({
};

// Helpers
const getMetaDatas = (path = []) =>
get(layouts, [...contentTypePath, 'metadatas', ...path], {});
const getMetaDatas = (path = []) => get(layouts, [...contentTypePath, 'metadatas', ...path], {});

const getListLayout = () =>
get(layouts, [...contentTypePath, 'layouts', 'list'], []);
const getListLayout = () => get(layouts, [...contentTypePath, 'layouts', 'list'], []);

const getListSchema = () => get(layouts, [...contentTypePath, 'schema'], {});

Expand All @@ -193,13 +181,9 @@ function ListView({
Object.keys(getMetaDatas())
.filter(
key =>
![
'json',
'component',
'dynamiczone',
'relation',
'richtext',
].includes(get(getListSchema(), ['attributes', key, 'type'], ''))
!['json', 'component', 'dynamiczone', 'relation', 'richtext'].includes(
get(getListSchema(), ['attributes', key, 'type'], '')
)
)
.map(label => ({
name: label,
Expand Down Expand Up @@ -227,9 +211,7 @@ function ListView({
const currentSort = getSearchParams()._sort;

if (value && getListLayout().length === 1) {
strapi.notification.error(
'content-manager.notification.error.displayedFields'
);
strapi.notification.error('content-manager.notification.error.displayedFields');

return;
}
Expand Down Expand Up @@ -298,7 +280,7 @@ function ListView({
id: 'content-manager.containers.List.addAnEntry',
},
{
entity: capitalize(getName()) || 'Content Manager',
entity: getName() || 'Content Manager',
}
),
onClick: () => {
Expand Down Expand Up @@ -376,14 +358,9 @@ function ListView({
<div className="row" style={{ marginLeft: 0, marginRight: 0 }}>
{getLayoutSettingRef.current('filterable') && (
<>
<AddFilterCta
type="button"
onClick={toggleFilterPickerState}
>
<AddFilterCta type="button" onClick={toggleFilterPickerState}>
<FilterIcon />
<FormattedMessage
id={`${pluginId}.components.AddFilterCTA.add`}
/>
<FormattedMessage id={`${pluginId}.components.AddFilterCTA.add`} />
</AddFilterCta>
{getSearchParams().filters.map((filter, key) => (
<Filter
Expand Down