Skip to content

Commit

Permalink
Admin UI: explicit list config (#2874)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vultraz committed May 5, 2020
1 parent c3270e5 commit bfa3a28
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/curly-llamas-compare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystonejs/app-admin-ui': patch
---

Cleaned up duplicated and/or unnecessary list config data.
26 changes: 17 additions & 9 deletions packages/app-admin-ui/client/classes/List.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,22 @@ export const gqlCountQueries = lists => gql`{
}`;

export default class List {
constructor(config, adminMeta, views) {
this.config = config;
this.adminMeta = adminMeta;
constructor(
{ access, adminConfig, adminDoc, fields, gqlNames, key, label, path, plural, singular },
adminMeta,
views
) {
this.access = access;
this.adminConfig = adminConfig;
this.adminDoc = adminDoc;
this.gqlNames = gqlNames;
this.key = key;
this.label = label;
this.path = path;
this.plural = plural;
this.singular = singular;

// TODO: undo this
Object.assign(this, config);

this.fields = config.fields.map(fieldConfig => {
this.fields = fields.map(fieldConfig => {
const [Controller] = adminMeta.readViews([views[fieldConfig.path].Controller]);
return new Controller(fieldConfig, this, adminMeta, views[fieldConfig.path]);
});
Expand Down Expand Up @@ -144,9 +152,9 @@ export default class List {
return count === 1 ? `1 ${this.singular}` : `${count} ${this.plural}`;
}
getPersistedSearch() {
return localStorage.getItem(`search:${this.config.path}`);
return localStorage.getItem(`search:${this.path}`);
}
setPersistedSearch(value) {
localStorage.setItem(`search:${this.config.path}`, value);
localStorage.setItem(`search:${this.path}`, value);
}
}

0 comments on commit bfa3a28

Please sign in to comment.