• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

scriptype / writ-cms / 21530394636

30 Jan 2026 08:57PM UTC coverage: 38.638% (-0.08%) from 38.719%
21530394636

push

github

scriptype
Add basic UI for default content type selection

Extract onboarding and editProject flows into separate modules, as they
will grow.

Inside editProject, right away prompt this new dialog popup if no
contentTypes are found in the project. It's a percepted next step of the
onboarding flow.

Some default contentTypes are hardcoded.

621 of 3672 branches covered (16.91%)

Branch coverage included in aggregate %.

0 of 27 new or added lines in 3 files covered. (0.0%)

2171 of 3554 relevant lines covered (61.09%)

1762.38 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/cms/server/public/app/editProject.js
1
import api from '../api.js'
2
import { setIframeSrc } from '../common.js'
3
import dialog from './components/dialog.js'
4

NEW
5
const defaultContentTypes = [{
×
6
  name: 'Homepage',
7
  model: 'homepage',
8
  description: 'A generic landing page',
9
  attributes: {
10
    title: 'title',
11
    description: 'text',
12
    content: 'content'
13
  }
14
}, {
15
  name: 'Subpage',
16
  model: 'subpage',
17
  description: 'A generic subpage',
18
  attributes: {
19
    title: 'title',
20
    description: 'text',
21
    content: 'content'
22
  }
23
}, {
24
  name: 'Blog',
25
  model: 'collection',
26
  description: 'A collection of blog posts',
27
  facets: ['tags', 'date', 'author'],
28
  collectionAlias: 'blog',
29
  categoryContentType: '',
30
  categoryAlias: '',
31
  categoriesAlias: '',
32
  entryContentType: 'BlogPost',
33
  entryAlias: 'post',
34
  entriesAlias: 'posts',
35
  attributes: {
36
    title: 'title',
37
    description: 'text',
38
    content: 'content'
39
  }
40
}, {
41
  name: 'Category',
42
  model: 'category',
43
  description: 'A group of entries in a collection',
44
  attributes: {
45
    title: 'title',
46
    description: 'text',
47
    content: 'content'
48
  }
49
}, {
50
  name: 'BlogPost',
51
  model: 'entry',
52
  description: 'Article in a blog',
53
  attributes: {
54
    title: 'title',
55
    tags: 'strings',
56
    author: 'Person',
57
    date: 'date',
58
    summary: 'text',
59
    content: 'content',
60
    coverImage: 'imageAttachment'
61
  }
62
}, {
63
  name: 'Person',
64
  model: 'entry',
65
  description: 'A person',
66
  attributes: {
67
    title: 'title',
68
    email: 'email',
69
    bio: 'text',
70
    blogPosts: ['+BlogPost:author']
71
  }
72
}]
73

NEW
74
const editProject = async ({ ssgOptions }) => {
×
NEW
75
  console.log('starting editor with ssgOptions', ssgOptions)
×
NEW
76
  await api.ssg.watch(ssgOptions)
×
NEW
77
  setIframeSrc()
×
78

NEW
79
  const contentTypes = await api.contentTypes.get()
×
NEW
80
  if (contentTypes.length) {
×
NEW
81
    return console.log('contentTypes', contentTypes)
×
82
  }
NEW
83
  console.log('no contentTypes')
×
84

NEW
85
  dialog.html(
×
86

87
`<h1>content types</h1>
88

89
<form>
NEW
90
${defaultContentTypes.map(contentType => `
×
91
<label><input type="checkbox" name="${contentType.name}">${contentType.name}</label>
92
`
93
).join('')}
94

95
  <button>Ok</button>
96
</form>`
97
  ).show()
98

NEW
99
  const form = dialog.find('form')
×
NEW
100
  form.addEventListener('submit', e => {
×
NEW
101
    const formData = new FormData(form)
×
NEW
102
    const keyValues = Array.from(formData.entries())
×
NEW
103
    const selectedKeys = keyValues.filter(([key, value]) => value === 'on').map(([key]) => key)
×
NEW
104
    const selectedContentTypes = defaultContentTypes.filter(ct => selectedKeys.includes(ct.name))
×
NEW
105
    console.log('selectedContentTypes', selectedContentTypes)
×
NEW
106
    e.preventDefault()
×
NEW
107
    selectedContentTypes.forEach(async contentType => {
×
NEW
108
      await api.contentTypes.create(contentType)
×
109
    })
NEW
110
    dialog.hide()
×
111
  })
112
}
113

114
export default editProject
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc