|
| 1 | +# Edit Existing Collection Feature Flag Cleanup Guide |
| 2 | + |
| 3 | +This document outlines all the changes needed to remove the `ENABLE_EXISTING_COLLECTION_EDIT` feature flag and make the Edit Existing Collection functionality permanently available. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The feature flag was implemented to control visibility and access to the "Edit Existing Collection" feature across: |
| 8 | + |
| 9 | +- UI components (MenuBar, CollectionsClient) |
| 10 | +- API endpoints (/api/existing-collection/\*) |
| 11 | +- Test configurations |
| 12 | + |
| 13 | +## Files to Update |
| 14 | + |
| 15 | +### 1. Environment Configuration |
| 16 | + |
| 17 | +#### `.env.example` |
| 18 | + |
| 19 | +**Remove these lines:** |
| 20 | + |
| 21 | +```env |
| 22 | +# Enable or disable the Edit Existing Collection feature |
| 23 | +# Set to 'true' to show Edit Existing Collection options and allow API access |
| 24 | +ENABLE_EXISTING_COLLECTION_EDIT=true |
| 25 | +NEXT_PUBLIC_ENABLE_EXISTING_COLLECTION_EDIT=true |
| 26 | +``` |
| 27 | + |
| 28 | +### 2. Test Configuration Files |
| 29 | + |
| 30 | +#### `playwright.config.ts` |
| 31 | + |
| 32 | +**Remove** `ENABLE_EXISTING_COLLECTION_EDIT=true` from the command: |
| 33 | + |
| 34 | +```typescript |
| 35 | +// FROM: |
| 36 | +command: 'NEXT_PUBLIC_DISABLE_AUTH=true NEXT_PUBLIC_MOCK_SCOPES="dataset:update stac:collection:update dataset:create" ENABLE_EXISTING_COLLECTION_EDIT=true yarn dev', |
| 37 | + |
| 38 | +// TO: |
| 39 | +command: 'NEXT_PUBLIC_DISABLE_AUTH=true NEXT_PUBLIC_MOCK_SCOPES="dataset:update stac:collection:update dataset:create" yarn dev', |
| 40 | +``` |
| 41 | + |
| 42 | +#### `vitest.config.mts` |
| 43 | + |
| 44 | +**Remove the env configuration:** |
| 45 | + |
| 46 | +```typescript |
| 47 | +// REMOVE this entire env block: |
| 48 | +env: { |
| 49 | + ENABLE_EXISTING_COLLECTION_EDIT: 'true', |
| 50 | + NEXT_PUBLIC_ENABLE_EXISTING_COLLECTION_EDIT: 'true', |
| 51 | +}, |
| 52 | +``` |
| 53 | + |
| 54 | +### 3. UI Components |
| 55 | + |
| 56 | +#### `components/layout/MenuBar.tsx` |
| 57 | + |
| 58 | +**Remove the environment variable check:** |
| 59 | + |
| 60 | +```typescript |
| 61 | +// REMOVE this line: |
| 62 | +const isEditExistingCollectionEnabled = |
| 63 | + process.env.NEXT_PUBLIC_ENABLE_EXISTING_COLLECTION_EDIT === 'true'; |
| 64 | +``` |
| 65 | + |
| 66 | +**Simplify the menu items array:** |
| 67 | + |
| 68 | +```typescript |
| 69 | +// FROM conditional spread syntax: |
| 70 | +...(isEditExistingCollectionEnabled ? [{ |
| 71 | + key: '/edit-existing-collection', |
| 72 | + // ... menu item definition |
| 73 | +}] : []), |
| 74 | + |
| 75 | +// TO permanent menu item: |
| 76 | +{ |
| 77 | + key: '/edit-existing-collection', |
| 78 | + label: |
| 79 | + hasLimitedAccess || !hasEditStacCollectionPermission ? ( |
| 80 | + <Tooltip |
| 81 | + title="Contact the VEDA Data Services team for access" |
| 82 | + placement="right" |
| 83 | + > |
| 84 | + <span style={{ cursor: 'not-allowed' }}> |
| 85 | + <Link href="/edit-existing-collection"> |
| 86 | + Edit Existing Collection |
| 87 | + </Link> |
| 88 | + </span> |
| 89 | + </Tooltip> |
| 90 | + ) : ( |
| 91 | + <Link href="/edit-existing-collection"> |
| 92 | + Edit Existing Collection |
| 93 | + </Link> |
| 94 | + ), |
| 95 | + icon: <DatabaseOutlined />, |
| 96 | + disabled: hasLimitedAccess || !hasEditStacCollectionPermission, |
| 97 | +}, |
| 98 | +``` |
| 99 | + |
| 100 | +#### `app/collections/_components/CollectionsClient.tsx` |
| 101 | + |
| 102 | +**Remove the environment variable check:** |
| 103 | + |
| 104 | +```typescript |
| 105 | +// REMOVE this line: |
| 106 | +const isEditExistingCollectionEnabled = |
| 107 | + process.env.NEXT_PUBLIC_ENABLE_EXISTING_COLLECTION_EDIT === 'true'; |
| 108 | +``` |
| 109 | + |
| 110 | +**Remove conditional rendering - make sections permanent:** |
| 111 | + |
| 112 | +For **Limited Access View**: |
| 113 | + |
| 114 | +```typescript |
| 115 | +// FROM: |
| 116 | +{isEditExistingCollectionEnabled && ( |
| 117 | + <> |
| 118 | + <Title level={3} style={{ marginTop: 40 }}> |
| 119 | + Existing STAC Collections |
| 120 | + </Title> |
| 121 | + <Row gutter={16} style={{ marginTop: 16 }}> |
| 122 | + {/* ... card content */} |
| 123 | + </Row> |
| 124 | + </> |
| 125 | +)} |
| 126 | + |
| 127 | +// TO: |
| 128 | +<> |
| 129 | + <Title level={3} style={{ marginTop: 40 }}> |
| 130 | + Existing STAC Collections |
| 131 | + </Title> |
| 132 | + <Row gutter={16} style={{ marginTop: 16 }}> |
| 133 | + {/* ... card content */} |
| 134 | + </Row> |
| 135 | +</> |
| 136 | +``` |
| 137 | + |
| 138 | +For **Main View**: |
| 139 | + |
| 140 | +```typescript |
| 141 | +// FROM: |
| 142 | +{isEditExistingCollectionEnabled && ( |
| 143 | + <> |
| 144 | + <Title level={3} style={{ marginTop: 40 }}> |
| 145 | + Existing STAC Collections |
| 146 | + </Title> |
| 147 | + <Row gutter={16} style={{ marginTop: 16 }}> |
| 148 | + {/* ... card content */} |
| 149 | + </Row> |
| 150 | + </> |
| 151 | +)} |
| 152 | + |
| 153 | +// TO: |
| 154 | +<> |
| 155 | + <Title level={3} style={{ marginTop: 40 }}> |
| 156 | + Existing STAC Collections |
| 157 | + </Title> |
| 158 | + <Row gutter={16} style={{ marginTop: 16 }}> |
| 159 | + {/* ... card content */} |
| 160 | + </Row> |
| 161 | +</> |
| 162 | +``` |
| 163 | + |
| 164 | +### 4. API Endpoints |
| 165 | + |
| 166 | +#### `app/api/existing-collection/route.ts` |
| 167 | + |
| 168 | +**Remove the feature flag check:** |
| 169 | + |
| 170 | +```typescript |
| 171 | +// REMOVE this entire block: |
| 172 | +// Check if the Edit Existing Collection feature is enabled |
| 173 | +if (process.env.ENABLE_EXISTING_COLLECTION_EDIT !== 'true') { |
| 174 | + return NextResponse.json( |
| 175 | + { error: 'Edit Existing Collection feature is disabled' }, |
| 176 | + { status: 403 } |
| 177 | + ); |
| 178 | +} |
| 179 | +``` |
| 180 | + |
| 181 | +#### `app/api/existing-collection/[collectionId]/route.ts` |
| 182 | + |
| 183 | +**Remove the feature flag check from both GET and PUT methods:** |
| 184 | + |
| 185 | +```typescript |
| 186 | +// REMOVE this entire block from both functions: |
| 187 | +// Check if the Edit Existing Collection feature is enabled |
| 188 | +if (process.env.ENABLE_EXISTING_COLLECTION_EDIT !== 'true') { |
| 189 | + return NextResponse.json( |
| 190 | + { error: 'Edit Existing Collection feature is disabled' }, |
| 191 | + { status: 403 } |
| 192 | + ); |
| 193 | +} |
| 194 | +``` |
| 195 | + |
| 196 | +## Cleanup Steps |
| 197 | + |
| 198 | +1. **Update environment files** - Remove feature flag variables |
| 199 | +2. **Update test configurations** - Remove env vars from test configs |
| 200 | +3. **Update UI components** - Remove conditional rendering logic |
| 201 | +4. **Update API endpoints** - Remove feature flag checks |
| 202 | +5. **Test thoroughly** - Ensure Edit Existing Collection works in all scenarios |
| 203 | +6. **Update documentation** - Remove references to the feature flag |
| 204 | +7. **Clean up any remaining environment variables** in production/staging configs |
| 205 | + |
| 206 | +## Verification Checklist |
| 207 | + |
| 208 | +After cleanup, verify: |
| 209 | + |
| 210 | +- [ ] Edit Existing Collection appears in MenuBar for users with `stac:collection:update` scope |
| 211 | +- [ ] Edit Existing Collection section shows in Collections page when feature flag env vars are absent |
| 212 | +- [ ] API endpoints `/api/existing-collection/*` work without feature flag |
| 213 | +- [ ] Unit tests pass without feature flag environment variables |
| 214 | +- [ ] Playwright tests work without feature flag in command |
| 215 | +- [ ] No console errors about missing environment variables |
| 216 | + |
| 217 | +## Notes |
| 218 | + |
| 219 | +- The feature flag was a **client-side and server-side** implementation |
| 220 | +- **Client-side**: `NEXT_PUBLIC_ENABLE_EXISTING_COLLECTION_EDIT` (visible in browser) |
| 221 | +- **Server-side**: `ENABLE_EXISTING_COLLECTION_EDIT` (API routes only) |
| 222 | +- Both must be removed for complete cleanup |
| 223 | +- Consider doing this cleanup in a dedicated PR for easier review and rollback if needed |
0 commit comments