strapi-plugin-copy-any-component 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/INSTALLATION.md +179 -0
- package/QUICK_START.md +88 -0
- package/README.md +165 -0
- package/TESTING.md +193 -0
- package/USAGE.md +121 -0
- package/admin/src/components/ComponentCopyField.jsx +3 -0
- package/admin/src/components/Initializer.jsx +22 -0
- package/admin/src/components/PluginIcon.jsx +22 -0
- package/admin/src/index.js +27 -0
- package/admin/src/pages/HomePage.jsx +995 -0
- package/admin/src/pluginId.js +2 -0
- package/package.json +62 -0
- package/server/src/controllers/controller.ts +22 -0
- package/server/src/controllers/index.ts +5 -0
- package/server/src/index.ts +13 -0
- package/server/src/routes/admin.ts +11 -0
- package/server/src/routes/content-api.ts +19 -0
- package/server/src/routes/index.ts +13 -0
- package/server/src/services/component-copy.js +439 -0
- package/strapi-admin.js +2 -0
- package/strapi-server.js +685 -0
package/INSTALLATION.md
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
# Component Copy Plugin - Kurulum Rehberi
|
|
2
|
+
|
|
3
|
+
Bu rehber, Component Copy plugin'ini başka bir Strapi projesinde kullanmak için gerekli adımları içerir.
|
|
4
|
+
|
|
5
|
+
## Önkoşullar
|
|
6
|
+
|
|
7
|
+
- Strapi 5.0.0 veya üzeri
|
|
8
|
+
- Node.js 20.x veya üzeri
|
|
9
|
+
- Mevcut bir Page content type'ı (sections dynamic zone ile)
|
|
10
|
+
|
|
11
|
+
## Kurulum Adımları
|
|
12
|
+
|
|
13
|
+
### 1. Plugin'i Kopyalayın
|
|
14
|
+
|
|
15
|
+
Plugin klasörünü hedef Strapi projenizin `src/plugins/` dizinine kopyalayın:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# Mevcut projeden
|
|
19
|
+
cp -r /path/to/source/strapi/src/plugins/my-simple-plugin /path/to/target/strapi/src/plugins/
|
|
20
|
+
|
|
21
|
+
# veya Git kullanarak
|
|
22
|
+
git clone <repository-url> /path/to/target/strapi/src/plugins/my-simple-plugin
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### 2. Plugin'i Kaydedin
|
|
26
|
+
|
|
27
|
+
Hedef projede `config/plugins.ts` dosyasını düzenleyin:
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
export default () => ({
|
|
31
|
+
'my-simple-plugin': {
|
|
32
|
+
enabled: true,
|
|
33
|
+
resolve: './src/plugins/my-simple-plugin',
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Eğer `config/plugins.js` kullanıyorsanız:
|
|
39
|
+
|
|
40
|
+
```javascript
|
|
41
|
+
module.exports = {
|
|
42
|
+
'my-simple-plugin': {
|
|
43
|
+
enabled: true,
|
|
44
|
+
resolve: './src/plugins/my-simple-plugin',
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### 3. Gerekli Content Type'ı Kontrol Edin
|
|
50
|
+
|
|
51
|
+
Plugin, `api::page.page` content type'ını kullanır. Bu content type'ın şu özelliklere sahip olması gerekir:
|
|
52
|
+
|
|
53
|
+
- **Dynamic Zone**: `sections` adında bir dynamic zone field
|
|
54
|
+
- **Slug**: Sayfaları tanımlamak için slug field'ı
|
|
55
|
+
|
|
56
|
+
Eğer farklı bir content type kullanıyorsanız, plugin kodunu düzenlemeniz gerekebilir.
|
|
57
|
+
|
|
58
|
+
#### Örnek Page Schema:
|
|
59
|
+
|
|
60
|
+
```json
|
|
61
|
+
{
|
|
62
|
+
"kind": "collectionType",
|
|
63
|
+
"collectionName": "pages",
|
|
64
|
+
"info": {
|
|
65
|
+
"singularName": "page",
|
|
66
|
+
"pluralName": "pages",
|
|
67
|
+
"displayName": "Page"
|
|
68
|
+
},
|
|
69
|
+
"attributes": {
|
|
70
|
+
"title": {
|
|
71
|
+
"type": "string",
|
|
72
|
+
"required": true
|
|
73
|
+
},
|
|
74
|
+
"slug": {
|
|
75
|
+
"type": "uid",
|
|
76
|
+
"targetField": "title",
|
|
77
|
+
"required": true
|
|
78
|
+
},
|
|
79
|
+
"sections": {
|
|
80
|
+
"type": "dynamiczone",
|
|
81
|
+
"components": [
|
|
82
|
+
// Component listesi buraya gelecek
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### 4. İzinleri Ayarlayın
|
|
90
|
+
|
|
91
|
+
Strapi admin panelinde şu adımları izleyin:
|
|
92
|
+
|
|
93
|
+
1. **Settings > Users & Permissions > Roles** sayfasına gidin
|
|
94
|
+
2. İlgili role'ü seçin (örn: Authenticated, Public)
|
|
95
|
+
3. **My Simple Plugin** bölümünü bulun
|
|
96
|
+
4. Şu izinleri etkinleştirin:
|
|
97
|
+
- `find` - Sayfaları listelemek için
|
|
98
|
+
- `getPageSections` - Section'ları görmek için
|
|
99
|
+
- `copySections` - Component'leri kopyalamak için
|
|
100
|
+
- `updatePageSections` - Section'ları güncellemek için
|
|
101
|
+
- `publish` - Sayfaları yayınlamak için
|
|
102
|
+
|
|
103
|
+
### 5. Strapi'yi Yeniden Başlatın
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
npm run develop
|
|
107
|
+
# veya production için
|
|
108
|
+
npm run build
|
|
109
|
+
npm run start
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### 6. Plugin'i Kullanın
|
|
113
|
+
|
|
114
|
+
1. Strapi admin panelinde **Plugins** menüsüne gidin
|
|
115
|
+
2. **Component Copy** seçeneğini bulun
|
|
116
|
+
3. Plugin arayüzünü kullanarak component'leri kopyalayın
|
|
117
|
+
|
|
118
|
+
## Farklı Content Type Kullanımı
|
|
119
|
+
|
|
120
|
+
Eğer `page` yerine farklı bir content type kullanıyorsanız (örneğin `article`, `post`), plugin kodunda aşağıdaki dosyaları güncellemeniz gerekir:
|
|
121
|
+
|
|
122
|
+
1. `server/src/services/component-copy.js` - Tüm `api::page.page` referanslarını değiştirin
|
|
123
|
+
2. `strapi-server.js` - Controller'lardaki `api::page.page` referanslarını değiştirin
|
|
124
|
+
3. `admin/src/pages/HomePage.jsx` - API endpoint'lerini kontrol edin (genellikle değişmez)
|
|
125
|
+
|
|
126
|
+
**Örnek değişiklik:**
|
|
127
|
+
|
|
128
|
+
```javascript
|
|
129
|
+
// Eski
|
|
130
|
+
await strapi.entityService.findOne("api::page.page", pageId, ...)
|
|
131
|
+
|
|
132
|
+
// Yeni (article için)
|
|
133
|
+
await strapi.entityService.findOne("api::article.article", pageId, ...)
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Sorun Giderme
|
|
137
|
+
|
|
138
|
+
### Plugin görünmüyor
|
|
139
|
+
|
|
140
|
+
- `config/plugins.ts` dosyasının doğru yapılandırıldığından emin olun
|
|
141
|
+
- Strapi'yi yeniden başlatın
|
|
142
|
+
- `dist` klasörünü temizleyin: `rm -rf dist .cache`
|
|
143
|
+
|
|
144
|
+
### "Page not found" hatası
|
|
145
|
+
|
|
146
|
+
- Page content type'ının doğru şekilde oluşturulduğundan emin olun
|
|
147
|
+
- Slug field'ının mevcut olduğunu kontrol edin
|
|
148
|
+
- Sections dynamic zone'ın tanımlı olduğunu doğrulayın
|
|
149
|
+
|
|
150
|
+
### Component'ler kopyalanmıyor
|
|
151
|
+
|
|
152
|
+
- İzinlerin doğru ayarlandığından emin olun
|
|
153
|
+
- Browser console'da hata mesajlarını kontrol edin
|
|
154
|
+
- Network tab'inde API isteklerinin başarılı olduğunu doğrulayın
|
|
155
|
+
|
|
156
|
+
### Media dosyaları kopyalanmıyor
|
|
157
|
+
|
|
158
|
+
- Media library'de dosyaların mevcut olduğundan emin olun
|
|
159
|
+
- Media field'larının populate edildiğinden emin olun
|
|
160
|
+
- Component schema'larında media field'larının doğru tanımlandığını kontrol edin
|
|
161
|
+
|
|
162
|
+
## Önemli Notlar
|
|
163
|
+
|
|
164
|
+
1. **Bootstrap Fonksiyonu**: Mevcut projedeki `src/index.ts` dosyasında bootstrap kodu varsa, bu kod hedef projede çalışmayabilir. Bootstrap kodunu yalnızca test/development için kullanıyorsanız, production'da kaldırmak isteyebilirsiniz.
|
|
165
|
+
|
|
166
|
+
2. **Component'ler**: Plugin, dynamic zone içindeki tüm component'leri destekler. Kendi component'lerinizi kullanabilirsiniz.
|
|
167
|
+
|
|
168
|
+
3. **Performance**: Çok sayıda component'i kopyalarken performans etkilenebilir. Büyük component'ler için dikkatli olun.
|
|
169
|
+
|
|
170
|
+
4. **Backup**: Component kopyalama işleminden önce veritabanınızı yedeklemeyi unutmayın.
|
|
171
|
+
|
|
172
|
+
## Destek
|
|
173
|
+
|
|
174
|
+
Sorun yaşarsanız:
|
|
175
|
+
1. Browser console'da hata mesajlarını kontrol edin
|
|
176
|
+
2. Strapi log'larını inceleyin
|
|
177
|
+
3. Plugin'in doğru kurulduğundan emin olun
|
|
178
|
+
4. İzinlerin ayarlandığını doğrulayın
|
|
179
|
+
|
package/QUICK_START.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Component Copy Plugin - Hızlı Başlangıç
|
|
2
|
+
|
|
3
|
+
## ✅ Kurulum Checklist
|
|
4
|
+
|
|
5
|
+
Başka bir Strapi projesinde plugin'i kullanmak için şu adımları izleyin:
|
|
6
|
+
|
|
7
|
+
### 1. Plugin'i Kopyalayın
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# Mevcut projeden plugin klasörünü kopyalayın
|
|
11
|
+
cp -r /path/to/source/strapi/src/plugins/my-simple-plugin /path/to/target/strapi/src/plugins/
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
### 2. Plugin'i Kaydedin
|
|
15
|
+
|
|
16
|
+
`config/plugins.ts` dosyasına ekleyin:
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
export default () => ({
|
|
20
|
+
'my-simple-plugin': {
|
|
21
|
+
enabled: true,
|
|
22
|
+
resolve: './src/plugins/my-simple-plugin',
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### 3. İzinleri Ayarlayın
|
|
28
|
+
|
|
29
|
+
Strapi admin panelinde:
|
|
30
|
+
- **Settings > Users & Permissions > Roles**
|
|
31
|
+
- İlgili role seçin (Authenticated, Public, vb.)
|
|
32
|
+
- **My Simple Plugin** bölümündeki tüm izinleri etkinleştirin:
|
|
33
|
+
- `find`
|
|
34
|
+
- `getPageSections`
|
|
35
|
+
- `copySections`
|
|
36
|
+
- `updatePageSections`
|
|
37
|
+
- `publish`
|
|
38
|
+
|
|
39
|
+
### 4. Strapi'yi Yeniden Başlatın
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# Development
|
|
43
|
+
npm run develop
|
|
44
|
+
|
|
45
|
+
# Production
|
|
46
|
+
npm run build
|
|
47
|
+
npm run start
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### 5. Plugin'i Kullanın
|
|
51
|
+
|
|
52
|
+
- Admin panelinde **Plugins > Component Copy** menüsüne gidin
|
|
53
|
+
- Component'leri kopyalayın ve sıralayın
|
|
54
|
+
|
|
55
|
+
## ⚠️ Önemli Notlar
|
|
56
|
+
|
|
57
|
+
1. **Page Content Type Gerekli**: Plugin `api::page.page` content type'ını kullanır. Bu content type'ın:
|
|
58
|
+
- `sections` adında bir dynamic zone field'ı olmalıdır
|
|
59
|
+
- `slug` field'ı olmalıdır
|
|
60
|
+
|
|
61
|
+
2. **Farklı Content Type**: Eğer farklı bir content type kullanıyorsanız, plugin kodunda `api::page.page` referanslarını değiştirmeniz gerekir.
|
|
62
|
+
|
|
63
|
+
3. **Bootstrap Kodu**: Mevcut projedeki `src/index.ts` dosyasındaki bootstrap kodu bu plugin'e özel değildir. İsterseniz hedef projede kullanmayabilirsiniz.
|
|
64
|
+
|
|
65
|
+
4. **Component'ler**: Plugin herhangi bir dynamic zone component'ini destekler. Kendi component'lerinizi kullanabilirsiniz.
|
|
66
|
+
|
|
67
|
+
## 🔧 Farklı Content Type Kullanımı
|
|
68
|
+
|
|
69
|
+
Eğer `page` yerine başka bir content type kullanıyorsanız:
|
|
70
|
+
|
|
71
|
+
1. `server/src/services/component-copy.js` dosyasında tüm `api::page.page` referanslarını değiştirin
|
|
72
|
+
2. `strapi-server.js` dosyasında controller'lardaki `api::page.page` referanslarını değiştirin
|
|
73
|
+
|
|
74
|
+
**Örnek:**
|
|
75
|
+
```javascript
|
|
76
|
+
// Eski
|
|
77
|
+
api::page.page
|
|
78
|
+
|
|
79
|
+
// Yeni (örneğin article için)
|
|
80
|
+
api::article.article
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## 📚 Daha Fazla Bilgi
|
|
84
|
+
|
|
85
|
+
- **Detaylı Kurulum**: [INSTALLATION.md](./INSTALLATION.md)
|
|
86
|
+
- **Kullanım Rehberi**: [USAGE.md](./USAGE.md)
|
|
87
|
+
- **Genel Bilgiler**: [README.md](./README.md)
|
|
88
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# Copy Any Component Plugin for Strapi 5
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@strapi/plugin-copy-any-component)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
A powerful Strapi plugin that allows you to copy and reorder components (sections) between pages using an intuitive drag-and-drop interface. **No code required!** Works with any content type and dynamic zone.
|
|
7
|
+
|
|
8
|
+
## ✨ Features
|
|
9
|
+
|
|
10
|
+
- 🎯 **Drag & Drop Interface**: Intuitive visual interface for copying components
|
|
11
|
+
- 📋 **Component Copying**: Copy components from one page to another
|
|
12
|
+
- 🔄 **Component Reordering**: Reorder components within a page
|
|
13
|
+
- 🔍 **Auto-Detection**: Automatically detects all content types and dynamic zones
|
|
14
|
+
- ⚙️ **Zero-Code Configuration**: Configure via admin panel - settings persist across restarts
|
|
15
|
+
- 📸 **Media Support**: Properly handles media files and images
|
|
16
|
+
- 💾 **Draft/Publish System**: Changes are saved as drafts, publish when ready
|
|
17
|
+
- ✅ **Detailed Feedback**: See exactly what fields and media were copied
|
|
18
|
+
- 🌐 **Universal**: Works with any content type (Page, Article, Blog, etc.) and any dynamic zone field
|
|
19
|
+
|
|
20
|
+
## 🔍 Automatic Content Type Detection
|
|
21
|
+
|
|
22
|
+
This plugin works with **any content type** and **any dynamic zone**! The plugin automatically:
|
|
23
|
+
|
|
24
|
+
- Detects all custom content types (Page, Article, Blog, LandingPage, etc.)
|
|
25
|
+
- Finds all fields containing dynamic zones (sections, blocks, content, etc.)
|
|
26
|
+
- Provides a dropdown interface in the admin panel for easy selection
|
|
27
|
+
|
|
28
|
+
### Admin Panel Configuration (No Code Required!)
|
|
29
|
+
|
|
30
|
+
1. Go to the plugin page
|
|
31
|
+
2. Click the **⚙️ Content Type Settings** button in the top right
|
|
32
|
+
3. Select your desired **Content Type** and **Dynamic Zone**
|
|
33
|
+
4. Click **💾 Save**
|
|
34
|
+
|
|
35
|
+
Settings are **automatically saved** and persist even after Strapi restarts! No need to edit code.
|
|
36
|
+
|
|
37
|
+
## 📖 Documentation
|
|
38
|
+
|
|
39
|
+
- **[QUICK_START.md](./QUICK_START.md)** - Hızlı başlangıç rehberi (önerilen)
|
|
40
|
+
- **[INSTALLATION.md](./INSTALLATION.md)** - Detaylı kurulum rehberi
|
|
41
|
+
- **[USAGE.md](./USAGE.md)** - Kullanım rehberi ve örnekler
|
|
42
|
+
- **[TESTING.md](./TESTING.md)** - Test rehberi
|
|
43
|
+
|
|
44
|
+
## ✨ Features
|
|
45
|
+
|
|
46
|
+
- 🎯 **Drag & Drop Interface**: Intuitive visual interface for copying components
|
|
47
|
+
- 📋 **Component Copying**: Copy components from one page to another
|
|
48
|
+
- 🔄 **Component Reordering**: Reorder components within a page
|
|
49
|
+
- 🔍 **Auto-Detection**: Automatically detects all content types and dynamic zones
|
|
50
|
+
- ⚙️ **Zero-Code Configuration**: Configure via admin panel - settings persist across restarts
|
|
51
|
+
- 📸 **Media Support**: Properly handles media files and images
|
|
52
|
+
- 💾 **Draft/Publish System**: Changes are saved as drafts, publish when ready
|
|
53
|
+
- ✅ **Detailed Feedback**: See exactly what fields and media were copied
|
|
54
|
+
- 🌐 **Universal**: Works with any content type (Page, Article, Blog, etc.) and any dynamic zone field
|
|
55
|
+
|
|
56
|
+
## 📦 Installation
|
|
57
|
+
|
|
58
|
+
### NPM Install (Recommended)
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
npm install @strapi/plugin-copy-any-component
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Manual Install
|
|
65
|
+
|
|
66
|
+
1. **Install the plugin:**
|
|
67
|
+
```bash
|
|
68
|
+
npm install @strapi/plugin-copy-any-component
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
2. **Register the plugin** in `config/plugins.ts`:
|
|
72
|
+
```typescript
|
|
73
|
+
export default () => ({
|
|
74
|
+
'copy-any-component': {
|
|
75
|
+
enabled: true,
|
|
76
|
+
resolve: './node_modules/@strapi/plugin-copy-any-component',
|
|
77
|
+
// Optional: Set defaults (can be changed via admin panel)
|
|
78
|
+
config: {
|
|
79
|
+
contentType: 'api::page.page',
|
|
80
|
+
dynamicZoneField: 'sections',
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
3. **Set permissions:**
|
|
87
|
+
- Go to **Settings > Users & Permissions > Roles** in Strapi admin
|
|
88
|
+
- Enable permissions for **Copy Any Component** section:
|
|
89
|
+
- Access Component Copy pages
|
|
90
|
+
- Copy components
|
|
91
|
+
- Update page sections
|
|
92
|
+
- Publish pages
|
|
93
|
+
|
|
94
|
+
4. **Restart Strapi:**
|
|
95
|
+
```bash
|
|
96
|
+
npm run develop
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Configuration
|
|
100
|
+
|
|
101
|
+
The plugin can be configured in two ways:
|
|
102
|
+
|
|
103
|
+
1. **Via Admin Panel (Recommended)**: No code required! Settings persist automatically.
|
|
104
|
+
2. **Via Config File**: Edit `config/plugins.ts` as shown above.
|
|
105
|
+
|
|
106
|
+
For detailed installation instructions, see [INSTALLATION.md](./INSTALLATION.md).
|
|
107
|
+
|
|
108
|
+
## 🚀 Usage
|
|
109
|
+
|
|
110
|
+
For detailed usage instructions, see [USAGE.md](./USAGE.md).
|
|
111
|
+
|
|
112
|
+
### Basic Usage
|
|
113
|
+
|
|
114
|
+
1. Go to **Plugins > Copy Any Component** in Strapi admin panel
|
|
115
|
+
2. **Source Page** (left panel) - Select the page you want to copy components from
|
|
116
|
+
3. **Target Page** (right panel) - Select the page you want to copy components to
|
|
117
|
+
4. Drag components from Source Page and drop them on Target Page
|
|
118
|
+
5. Reorder components in Target Page by dragging them
|
|
119
|
+
6. Click **Publish** to save changes
|
|
120
|
+
|
|
121
|
+
### Configuration via Admin Panel
|
|
122
|
+
|
|
123
|
+
1. Click **⚙️ Content Type Settings** button in the plugin page
|
|
124
|
+
2. Select your **Content Type** (e.g., Page, Article, Blog)
|
|
125
|
+
3. Select your **Dynamic Zone Field** (e.g., sections, blocks, content)
|
|
126
|
+
4. Click **💾 Save** - settings persist automatically!
|
|
127
|
+
|
|
128
|
+
## 🔌 API Endpoints
|
|
129
|
+
|
|
130
|
+
### Admin Routes
|
|
131
|
+
|
|
132
|
+
- `GET /admin/plugins/copy-any-component/pages` - List all pages
|
|
133
|
+
- `GET /admin/plugins/copy-any-component/pages/:pageId/sections` - Get page sections
|
|
134
|
+
- `GET /admin/plugins/copy-any-component/content-types` - List available content types
|
|
135
|
+
- `PUT /admin/plugins/copy-any-component/config` - Update plugin configuration
|
|
136
|
+
- `POST /admin/plugins/copy-any-component/pages/:sourcePageId/copy-to/:targetPageId` - Copy sections
|
|
137
|
+
- `PUT /admin/plugins/copy-any-component/pages/:pageId/sections` - Update page sections (reorder)
|
|
138
|
+
- `POST /admin/plugins/copy-any-component/pages/:pageId/publish` - Publish page
|
|
139
|
+
|
|
140
|
+
### Content API Routes
|
|
141
|
+
|
|
142
|
+
- `GET /api/copy-any-component/pages/:pageId/sections` - Get page sections
|
|
143
|
+
- `POST /api/copy-any-component/pages/:sourcePageId/copy-to/:targetPageId` - Copy sections
|
|
144
|
+
|
|
145
|
+
## Permissions
|
|
146
|
+
|
|
147
|
+
Make sure to grant permissions in **Settings > Users & Permissions > Roles**:
|
|
148
|
+
- Access Component Copy pages
|
|
149
|
+
- Copy components
|
|
150
|
+
- Update page sections
|
|
151
|
+
- Publish pages
|
|
152
|
+
|
|
153
|
+
## Requirements
|
|
154
|
+
|
|
155
|
+
- Strapi 5.0.0 or higher
|
|
156
|
+
- Node.js 20.x or higher
|
|
157
|
+
|
|
158
|
+
## License
|
|
159
|
+
|
|
160
|
+
MIT
|
|
161
|
+
|
|
162
|
+
## Support
|
|
163
|
+
|
|
164
|
+
For issues and questions, please open an issue on GitHub.
|
|
165
|
+
|
package/TESTING.md
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# Copy Any Component Plugin - Test Rehberi
|
|
2
|
+
|
|
3
|
+
Bu rehber, plugin'i test etmek için adım adım talimatlar içerir.
|
|
4
|
+
|
|
5
|
+
## 1. Temel Test
|
|
6
|
+
|
|
7
|
+
### Adım 1: Strapi'yi Başlatın
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm run develop
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Adım 2: Admin Panelinde Plugin'e Erişin
|
|
14
|
+
|
|
15
|
+
1. Strapi admin panelinde giriş yapın
|
|
16
|
+
2. Sol menüden **Plugins > Copy Any Component 🎨** seçeneğine tıklayın
|
|
17
|
+
|
|
18
|
+
### Adım 3: Sayfaları Kontrol Edin
|
|
19
|
+
|
|
20
|
+
- Source Page (sol panel) ve Target Page (sağ panel) dropdown'larından sayfaları görebilmelisiniz
|
|
21
|
+
- Eğer sayfa yoksa, önce Content Manager'da birkaç sayfa oluşturun
|
|
22
|
+
|
|
23
|
+
### Adım 4: Component Kopyalama Testi
|
|
24
|
+
|
|
25
|
+
1. **Source Page** seçin (örneğin: "Ana Sayfa")
|
|
26
|
+
2. **Target Page** seçin (örneğin: "Hakkımızda")
|
|
27
|
+
3. Source Page panelinden bir component'i seçin
|
|
28
|
+
4. Component'i sürükleyip Target Page paneline bırakın
|
|
29
|
+
5. Başarı mesajını görmelisiniz
|
|
30
|
+
6. Target Page panelinde yeni component görünmeli
|
|
31
|
+
|
|
32
|
+
### Adım 5: Kopyalanan Component'i Kontrol Edin
|
|
33
|
+
|
|
34
|
+
1. Content Manager > Pages > Target Page'e gidin
|
|
35
|
+
2. Sayfayı düzenle modunda açın
|
|
36
|
+
3. Kopyalanan component'in tüm field'larının doğru kopyalandığını kontrol edin:
|
|
37
|
+
- Text field'lar
|
|
38
|
+
- Media dosyaları
|
|
39
|
+
- Nested component'ler (button, form-field, vb.)
|
|
40
|
+
- Relation field'lar
|
|
41
|
+
|
|
42
|
+
### Adım 6: Publish Testi
|
|
43
|
+
|
|
44
|
+
1. Plugin arayüzüne geri dönün
|
|
45
|
+
2. **Publish** butonuna tıklayın
|
|
46
|
+
3. Başarı mesajını görmelisiniz
|
|
47
|
+
4. Frontend'de değişikliklerin göründüğünü kontrol edin
|
|
48
|
+
|
|
49
|
+
## 2. Farklı Component Tipleri Testi
|
|
50
|
+
|
|
51
|
+
Her component tipini test edin:
|
|
52
|
+
|
|
53
|
+
- ✅ **Hero Section** - Basit component
|
|
54
|
+
- ✅ **CTA Section** - Button component'leri içeren
|
|
55
|
+
- ✅ **Stats Section** - Relation (siteSettings) içeren
|
|
56
|
+
- ✅ **Form Section** - Nested form-field component'leri içeren
|
|
57
|
+
- ✅ **Gallery Section** - Media array içeren
|
|
58
|
+
- ✅ **Accordion Section** - Nested accordion-item component'leri içeren
|
|
59
|
+
- ✅ **Pricing Section** - Nested pricing-plan component'leri içeren
|
|
60
|
+
- ✅ **Timeline Section** - Nested timeline-item component'leri içeren
|
|
61
|
+
|
|
62
|
+
Her bir component tipinde:
|
|
63
|
+
- Tüm field'ların kopyalandığını doğrulayın
|
|
64
|
+
- Nested component'lerin kopyalandığını doğrulayın
|
|
65
|
+
- Media dosyalarının referanslarının korunduğunu doğrulayın
|
|
66
|
+
|
|
67
|
+
## 3. Aynı Sayfada Kopyalama Testi
|
|
68
|
+
|
|
69
|
+
1. Aynı sayfayı hem Source hem de Target olarak seçin
|
|
70
|
+
2. Bir component'i kopyalayın
|
|
71
|
+
3. Component'in duplicate (çoğaltıldığını) doğrulayın
|
|
72
|
+
4. Publish edin ve sonucu kontrol edin
|
|
73
|
+
|
|
74
|
+
## 4. Component Sıralama Testi
|
|
75
|
+
|
|
76
|
+
1. Target Page panelinde component'leri seçin
|
|
77
|
+
2. Component'leri sürükleyerek sıralayın
|
|
78
|
+
3. Değişikliklerin otomatik kaydedildiğini kontrol edin
|
|
79
|
+
4. Publish edin ve sonucu kontrol edin
|
|
80
|
+
|
|
81
|
+
## 5. Farklı Content Type Testi (OPSİYONEL)
|
|
82
|
+
|
|
83
|
+
Eğer farklı bir content type kullanmak istiyorsanız:
|
|
84
|
+
|
|
85
|
+
### Adım 1: Config'i Güncelleyin
|
|
86
|
+
|
|
87
|
+
`config/plugins.ts` dosyasını düzenleyin:
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
export default () => ({
|
|
91
|
+
'copy-any-component': {
|
|
92
|
+
enabled: true,
|
|
93
|
+
resolve: './src/plugins/my-simple-plugin',
|
|
94
|
+
config: {
|
|
95
|
+
contentType: 'api::article.article', // Farklı content type
|
|
96
|
+
dynamicZoneField: 'blocks', // Farklı field name
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Adım 2: Strapi'yi Yeniden Başlatın
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
npm run develop
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Adım 3: Yeni Content Type ile Test Edin
|
|
109
|
+
|
|
110
|
+
1. Content Manager'da yeni content type'dan kayıtlar oluşturun
|
|
111
|
+
2. Plugin arayüzünde yeni kayıtları görebilmelisiniz
|
|
112
|
+
3. Component kopyalama işlemini test edin
|
|
113
|
+
|
|
114
|
+
## 6. Hata Senaryoları Testi
|
|
115
|
+
|
|
116
|
+
### Test 1: İzin Hatası
|
|
117
|
+
|
|
118
|
+
1. Gerekli izinleri kapatın (Settings > Users & Permissions > Roles)
|
|
119
|
+
2. Component kopyalamayı deneyin
|
|
120
|
+
3. Uygun hata mesajını görmelisiniz
|
|
121
|
+
|
|
122
|
+
### Test 2: Geçersiz Sayfa ID
|
|
123
|
+
|
|
124
|
+
1. Network tab'ını açın
|
|
125
|
+
2. Component kopyalama işlemini başlatın
|
|
126
|
+
3. API request'ini düzenleyip geçersiz ID gönderin
|
|
127
|
+
4. Uygun hata mesajını görmelisiniz
|
|
128
|
+
|
|
129
|
+
## 7. Performance Testi
|
|
130
|
+
|
|
131
|
+
1. Çok sayıda component içeren bir sayfa oluşturun (10+ component)
|
|
132
|
+
2. Tüm component'leri tek tek kopyalayın
|
|
133
|
+
3. İşlemlerin makul bir sürede tamamlandığını kontrol edin
|
|
134
|
+
|
|
135
|
+
## 8. Browser Console Testi
|
|
136
|
+
|
|
137
|
+
1. Browser Developer Tools'u açın (F12)
|
|
138
|
+
2. Console tab'ına geçin
|
|
139
|
+
3. Component kopyalama işlemini yapın
|
|
140
|
+
4. Herhangi bir JavaScript hatası olmadığını doğrulayın
|
|
141
|
+
5. Network tab'ında API isteklerinin başarılı olduğunu kontrol edin
|
|
142
|
+
|
|
143
|
+
## 9. Detaylı Bilgi Modal Testi
|
|
144
|
+
|
|
145
|
+
1. Bir component'i kopyalayın
|
|
146
|
+
2. Başarı mesajına tıklayın
|
|
147
|
+
3. Detaylı bilgi modal'ının açıldığını kontrol edin
|
|
148
|
+
4. Şu bilgileri doğrulayın:
|
|
149
|
+
- Kopyalanan field sayısı
|
|
150
|
+
- Media dosyaları
|
|
151
|
+
- Kaldırılan sistem field'ları (id, createdAt, vb.)
|
|
152
|
+
|
|
153
|
+
## 10. Frontend Render Testi
|
|
154
|
+
|
|
155
|
+
1. Component'leri kopyalayın ve publish edin
|
|
156
|
+
2. Frontend'de sayfayı açın
|
|
157
|
+
3. Tüm component'lerin doğru render edildiğini kontrol edin:
|
|
158
|
+
- Stil'ler doğru mu?
|
|
159
|
+
- İçerik doğru mu?
|
|
160
|
+
- Media dosyaları görünüyor mu?
|
|
161
|
+
- Nested component'ler çalışıyor mu?
|
|
162
|
+
|
|
163
|
+
## Beklenen Sonuçlar
|
|
164
|
+
|
|
165
|
+
✅ **Başarılı Senaryolar:**
|
|
166
|
+
- Component'ler sorunsuz kopyalanır
|
|
167
|
+
- Tüm field'lar korunur
|
|
168
|
+
- Media referansları korunur
|
|
169
|
+
- Nested component'ler kopyalanır
|
|
170
|
+
- Publish işlemi başarılı olur
|
|
171
|
+
|
|
172
|
+
❌ **Hata Senaryoları:**
|
|
173
|
+
- İzin hatası mesajı gösterilir
|
|
174
|
+
- Geçersiz sayfa hatası gösterilir
|
|
175
|
+
- Network hataları uygun şekilde handle edilir
|
|
176
|
+
|
|
177
|
+
## Sorun Giderme
|
|
178
|
+
|
|
179
|
+
### Component'ler görünmüyor
|
|
180
|
+
- Sayfaların publish edildiğinden emin olun
|
|
181
|
+
- Browser cache'ini temizleyin
|
|
182
|
+
- Strapi'yi yeniden başlatın
|
|
183
|
+
|
|
184
|
+
### Component kopyalanmıyor
|
|
185
|
+
- Browser console'da hata var mı kontrol edin
|
|
186
|
+
- Network tab'ında API isteklerini kontrol edin
|
|
187
|
+
- İzinlerin doğru ayarlandığını kontrol edin
|
|
188
|
+
|
|
189
|
+
### Field'lar kayboluyor
|
|
190
|
+
- Browser console log'larını kontrol edin
|
|
191
|
+
- Component schema'sını kontrol edin
|
|
192
|
+
- Media field'larının doğru populate edildiğinden emin olun
|
|
193
|
+
|