Skip to content

Commit 0613cb7

Browse files
committed
contenful validation extension
1 parent d5da0c6 commit 0613cb7

File tree

16 files changed

+1010
-0
lines changed

16 files changed

+1010
-0
lines changed

.github/workflows/on-push-app-extensions.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ jobs:
7878
- clear-on-change
7979
- working-group-deliverables
8080
- partial-last-updated
81+
- project-role-validator
8182
steps:
8283
- name: Checkout
8384
uses: actions/checkout@v3

.pnp.cjs

Lines changed: 37 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
# ✅ Contentful Project Role Validator - Implementation Complete
2+
3+
## Summary
4+
5+
Successfully created a Contentful App Extension for validating project member roles based on project type. The app has been integrated into the existing Contentful app extensions structure for consistency and simpler deployment.
6+
7+
## 📁 Final Location
8+
9+
```
10+
packages/contentful-app-extensions/project-role-validator/
11+
├── src/
12+
│ ├── locations/
13+
│ │ └── Sidebar.tsx # Main validation component
14+
│ ├── test/
15+
│ │ └── locations/
16+
│ │ └── Sidebar.test.tsx
17+
│ ├── App.tsx # Location routing
18+
│ ├── index.tsx # Entry point
19+
│ ├── types.ts # TypeScript definitions
20+
│ ├── validation.ts # Validation logic
21+
│ └── react-app-env.d.ts
22+
├── public/
23+
│ └── index.html
24+
├── package.json
25+
├── tsconfig.json
26+
├── README.md
27+
└── MIGRATION_NOTES.md
28+
```
29+
30+
## ✨ Features
31+
32+
### Validation Rules
33+
34+
**Discovery & Resource Projects:**
35+
- Contributor
36+
- Investigator
37+
- Project CoLead
38+
- Project Lead
39+
- Project Manager
40+
41+
**Trainee Projects:**
42+
- trainee
43+
- trainer
44+
45+
### Real-time Validation
46+
- ✅ Monitors `type` and `members` fields
47+
- ✅ Fetches member entries and validates roles
48+
- ✅ Updates immediately on changes
49+
- ✅ Clear, actionable error messages
50+
51+
### UI States
52+
-**Valid**: All roles appropriate for project type
53+
- ⚠️ **No Type**: Project type not selected
54+
- ℹ️ **No Members**: No members added yet
55+
-**Invalid**: Lists invalid roles and shows allowed roles
56+
57+
## 🚀 Deployment
58+
59+
### Automatic via GitHub Actions
60+
61+
**Workflow**: `.github/workflows/on-push-app-extensions.yml`
62+
63+
```yaml
64+
matrix:
65+
app:
66+
- project-role-validator # Added to existing apps
67+
```
68+
69+
### Deployment Flow
70+
71+
```
72+
Push to master
73+
74+
Detects changes in packages/contentful-app-extensions/
75+
76+
Runs tests
77+
78+
Builds with react-scripts
79+
80+
Deploys to Contentful hosting
81+
82+
✅ Live automatically
83+
```
84+
85+
### Required Configuration
86+
87+
1. **GitHub Secrets** (already configured):
88+
- `CONTENTFUL_MANAGEMENT_TOKEN`
89+
- Contentful organization ID
90+
- App definition ID
91+
92+
2. **Contentful App Definition**:
93+
- Create app in Contentful
94+
- Enable "Entry sidebar" location
95+
- Assign to "Project" content type
96+
97+
## 🔧 Development
98+
99+
### Local Development
100+
101+
```bash
102+
cd packages/contentful-app-extensions/project-role-validator
103+
yarn install
104+
yarn start
105+
```
106+
107+
App runs on `http://localhost:3000`
108+
109+
### Testing
110+
111+
```bash
112+
yarn test
113+
yarn test:no-watch # CI mode
114+
```
115+
116+
### Building
117+
118+
```bash
119+
yarn build
120+
```
121+
122+
Output: `build/` directory
123+
124+
## 📝 Changes Made
125+
126+
### Created
127+
- ✅ Full app in `packages/contentful-app-extensions/project-role-validator/`
128+
- ✅ Validation logic and UI components
129+
- ✅ Tests
130+
- ✅ README and documentation
131+
132+
### Updated
133+
-`.github/workflows/on-push-app-extensions.yml` - Added to app matrix
134+
135+
### Deleted
136+
-`apps/contentful-validation-app/` (old location)
137+
-`.github/workflows/on-push-contentful-validation-app.yml` (standalone workflow)
138+
- ❌ All AWS/Serverless infrastructure files
139+
140+
## 🎯 Benefits of Final Approach
141+
142+
1. **✅ Consistency**: Matches 15+ existing Contentful apps
143+
2. **✅ Simpler**: No AWS infrastructure to manage
144+
3. **✅ Faster**: Uses existing proven deployment pipeline
145+
4. **✅ Cost-effective**: Contentful hosting included (no AWS costs)
146+
5. **✅ Maintainable**: Same structure as other apps
147+
148+
## 🧪 Testing Checklist
149+
150+
After deployment:
151+
152+
- [ ] App appears in Contentful sidebar for Project entries
153+
- [ ] Validation works for "discovery" projects
154+
- [ ] Validation works for "resource" projects
155+
- [ ] Validation works for "trainee" projects
156+
- [ ] Real-time updates when changing project type
157+
- [ ] Real-time updates when adding/removing members
158+
- [ ] Error messages are clear and actionable
159+
- [ ] Shows allowed roles for each project type
160+
161+
## 📚 Documentation
162+
163+
- **Main README**: `packages/contentful-app-extensions/project-role-validator/README.md`
164+
- **Migration Notes**: `packages/contentful-app-extensions/project-role-validator/MIGRATION_NOTES.md`
165+
- **This Summary**: Can be deleted after review
166+
167+
## 🎉 Ready to Deploy
168+
169+
The app is ready to deploy! When you push this to master:
170+
171+
1. GitHub Actions will detect changes
172+
2. Run tests automatically
173+
3. Build the app
174+
4. Deploy to Contentful
175+
5. App will be live in your Contentful space
176+
177+
## Next Steps
178+
179+
1. **Push to master**: `git push origin master`
180+
2. **Monitor workflow**: Check GitHub Actions tab
181+
3. **Create app in Contentful**: If not already created
182+
4. **Install app**: In your Contentful space
183+
5. **Test**: Open a Project entry and verify validation
184+
185+
---
186+
187+
**Implementation Date**: 2025-11-12
188+
**Status**: ✅ Complete and Ready to Deploy
189+
**Hosting**: Contentful (automatic)
190+
**Cost**: $0 (uses existing Contentful hosting)
191+
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Migration Notes
2+
3+
## What Changed
4+
5+
The Project Role Validator app has been moved from `apps/contentful-validation-app/` to `packages/contentful-app-extensions/project-role-validator/` to align with existing Contentful app extensions.
6+
7+
## Key Changes
8+
9+
### 1. Location
10+
- **Before**: `apps/contentful-validation-app/`
11+
- **After**: `packages/contentful-app-extensions/project-role-validator/`
12+
13+
### 2. Hosting
14+
- **Before**: Self-hosted on AWS (S3 + CloudFront via Serverless Framework)
15+
- **After**: Hosted by Contentful (via `contentful/actions-app-deploy`)
16+
17+
### 3. Build System
18+
- **Before**: Vite
19+
- **After**: react-scripts (Create React App) - matches other extensions
20+
21+
### 4. Deployment
22+
- **Before**: Custom GitHub Actions workflow + AWS infrastructure
23+
- **After**: Included in existing `on-push-app-extensions.yml` workflow
24+
25+
### 5. Files Removed
26+
- `apps/contentful-validation-app/` (entire directory)
27+
- `.github/workflows/on-push-contentful-validation-app.yml`
28+
- `serverless.ts` (AWS infrastructure config)
29+
- All AWS/Serverless related files and docs
30+
31+
### 6. Files Kept/Migrated
32+
- ✅ Core validation logic (`validation.ts`)
33+
- ✅ TypeScript types (`types.ts`)
34+
- ✅ React components (adapted for CRA)
35+
- ✅ Business logic (unchanged)
36+
37+
## Benefits of New Structure
38+
39+
1. **Consistency**: Follows the pattern of all other Contentful apps
40+
2. **Simpler Deployment**: No AWS infrastructure to manage
41+
3. **Automatic Hosting**: Contentful handles hosting and CDN
42+
4. **Existing Workflow**: Uses proven deployment pipeline
43+
5. **No AWS Costs**: No S3, CloudFront, or other AWS charges
44+
6. **Easier Maintenance**: Same structure as 15+ other apps
45+
46+
## Deployment Process
47+
48+
### Automatic (on push to master)
49+
```
50+
Push to master
51+
52+
GitHub Actions detects changes
53+
54+
Builds with react-scripts
55+
56+
Deploys to Contentful
57+
58+
✅ Live
59+
```
60+
61+
### Required Secrets (already configured)
62+
- `CONTENTFUL_MANAGEMENT_TOKEN`
63+
- `CONTENTFUL_ORG_ID`
64+
- App definition ID (in environment setup)
65+
66+
## For Future Reference
67+
68+
If you need to create another Contentful app extension:
69+
70+
1. **Create directory**: `packages/contentful-app-extensions/your-app-name/`
71+
2. **Copy structure** from any existing app (like `project-role-validator`)
72+
3. **Add to workflow matrix**: Update `.github/workflows/on-push-app-extensions.yml`
73+
4. **Add app definition ID** to environment setup
74+
5. **Push to master**: Automatic deployment
75+
76+
## Clean Up Completed
77+
78+
- ❌ Deleted `apps/contentful-validation-app/`
79+
- ❌ Deleted standalone workflow file
80+
- ❌ Reverted temporary workflow changes
81+
- ✅ Added `project-role-validator` to existing workflow
82+
- ✅ All functionality preserved
83+
- ✅ Same validation logic
84+
- ✅ Same UI/UX
85+
86+
## Testing
87+
88+
After deployment, verify:
89+
1. App appears in Contentful sidebar for Project entries
90+
2. Validation works for all project types
91+
3. Real-time updates on field changes
92+
4. Error messages are clear and actionable
93+
94+
---
95+
96+
**Migration Date**: 2025-11-12
97+
**Migrated By**: Automated setup
98+
**Status**: ✅ Complete
99+

0 commit comments

Comments
 (0)