Skip to content

Commit

Permalink
feat: add admin description to collections and globals
Browse files Browse the repository at this point in the history
  • Loading branch information
DanRibbens committed Jul 27, 2021
1 parent dac60a0 commit 4544711
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions demo/collections/AllFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const AllFields: PayloadCollectionConfig = {

return null;
},
description: 'Every type of field in one place',
},
access: {
read: () => true,
Expand Down
3 changes: 3 additions & 0 deletions demo/globals/NavigationArray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ export default {
update: ({ req: { user } }) => checkRole(['admin', 'user'], user),
read: () => true,
},
admin: {
description: 'A description for the editor',
},
fields: [
{
name: 'array',
Expand Down
6 changes: 6 additions & 0 deletions src/admin/components/views/Global/Default.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ const DefaultGlobalView: React.FC<Props> = (props) => {
fields,
preview,
label,
admin: {
description,
} = {},
} = global;

const hasSavePermission = permissions?.update?.permission;
Expand Down Expand Up @@ -55,6 +58,9 @@ const DefaultGlobalView: React.FC<Props> = (props) => {
{' '}
{label}
</h1>
{description && (
<div className={`${baseClass}__sub-header`}>{description}</div>
)}
</header>
<RenderFields
operation="update"
Expand Down
6 changes: 6 additions & 0 deletions src/admin/components/views/Global/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
margin: 0;
}
margin-bottom: base(1);
}

&__sub-header {
margin-top: base(.25);
}

&__collection-actions {
Expand Down
6 changes: 6 additions & 0 deletions src/admin/components/views/collections/List/Default.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ const DefaultList: React.FC<Props> = (props) => {
singular: singularLabel,
plural: pluralLabel,
},
admin: {
description,
},
},
data,
newDocumentURL,
Expand Down Expand Up @@ -52,6 +55,9 @@ const DefaultList: React.FC<Props> = (props) => {
Create New
</Pill>
)}
{description && (
<div className={`${baseClass}__sub-header`}>{description}</div>
)}
</header>
<ListControls
handleChange={setListControls}
Expand Down
5 changes: 5 additions & 0 deletions src/admin/components/views/collections/List/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
}
}

&__sub-header {
flex-basis: 100%;
margin-top: base(.25);
}

.table {
table {
width: 100%;
Expand Down
2 changes: 1 addition & 1 deletion src/admin/components/views/collections/List/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const ListView: React.FC<ListIndexProps> = (props) => {
const { permissions } = useAuth();
const location = useLocation();
const { setStepNav } = useStepNav();
const { getPreference, setPreference } = usePreferences();
const { getPreference } = usePreferences();

const [fields] = useState(() => formatFields(collection));
const [listControls, setListControls] = useState<ListControls>({});
Expand Down
1 change: 1 addition & 0 deletions src/collections/config/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const collectionSchema = joi.object().keys({
admin: joi.object({
useAsTitle: joi.string(),
defaultColumns: joi.array().items(joi.string()),
description: joi.string(),
enableRichTextRelationship: joi.boolean(),
components: joi.object({
views: joi.object({
Expand Down
1 change: 1 addition & 0 deletions src/collections/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export type PayloadCollectionConfig = {
admin?: {
useAsTitle?: string;
defaultColumns?: string[];
description?: string;
disableDuplicate?: boolean;
components?: {
views?: {
Expand Down
3 changes: 3 additions & 0 deletions src/globals/config/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import joi from 'joi';
const globalSchema = joi.object().keys({
slug: joi.string().required(),
label: joi.string(),
admin: joi.object({
description: joi.string(),
}),
hooks: joi.object({
beforeValidate: joi.array().items(joi.func()),
beforeChange: joi.array().items(joi.func()),
Expand Down
1 change: 1 addition & 0 deletions src/globals/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export type PayloadGlobalConfig = {
}
fields: Field[];
admin?: {
description: string,
components?: {
views?: {
Edit?: React.ComponentType
Expand Down

0 comments on commit 4544711

Please sign in to comment.