-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ASAP-853] Enable Hub Admin assign user role to a Lab in CMS (#4516)
* creates labPi field in labs & renames labs (labsMembership) field to oldLabs & creates new labs field (as lab) * script to transfer data from labMembership to labs * fixes linting issues * adds workflow to run data rollback script (assign users as PIs) * alligns gql and data structure with current users-labs rollback * takes previous labPi when assigning PI to a lab * fixes name of labPI field in migration * fixes labs reference * optimizes sent requests on labPi assignement
- Loading branch information
1 parent
1ce6259
commit a159732
Showing
18 changed files
with
674 additions
and
226 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
.github/workflows/on-demand-migrate-user-labs-rollback.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: Migrate user labs rollback | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
environment-name: | ||
required: true | ||
description: The environment name | ||
type: choice | ||
options: | ||
- Branch | ||
- Development | ||
- Production | ||
contentful-env: | ||
required: true | ||
type: string | ||
description: Choose the Contentful environment to migrate user labs | ||
|
||
jobs: | ||
migrate_user_labs_rollback: | ||
runs-on: ubuntu-latest | ||
environment: ${{ inputs.environment-name }} | ||
container: | ||
image: ghcr.io/yldio/asap-hub/node-python-sq:7b77d99657ab3718ed548ba366ffbcbb15315fd8 | ||
credentials: | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Setup | ||
id: setup | ||
uses: ./.github/actions/setup-environment | ||
with: | ||
environment-name: ${{ inputs.environment-name }} | ||
- name: Run User Assignment as Lab PI Migration | ||
run: | | ||
yarn workspace @asap-hub/contentful migrate-assign-users-as-lab-pi | ||
env: | ||
CONTENTFUL_MANAGEMENT_ACCESS_TOKEN: ${{ secrets.CONTENTFUL_MANAGEMENT_TOKEN }} | ||
CONTENTFUL_SPACE_ID: ${{ steps.setup.outputs.crn-contentful-space-id }} | ||
CONTENTFUL_ENV_ID: ${{ inputs.contentful-env }} | ||
|
||
notify_failure: | ||
runs-on: ubuntu-latest | ||
needs: [migrate_user_labs_rollback] | ||
if: ${{ failure() && inputs.environment-name=='Production' }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- uses: ./.github/actions/slack/ | ||
with: | ||
message: Migrate user labs rollback failed | ||
webhook: ${{ secrets.SLACK_WEBHOOK }} | ||
status: failure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...ontentful/migrations/crn/labs/20250202113054-rollback-lab-membership-and-adds-pi-field.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
module.exports.description = | ||
'Renames lab membership reference (labs to oldLabs) and creates new labs field (references labs) adds PI field'; | ||
|
||
module.exports.up = (migration) => { | ||
const labs = migration.editContentType('labs'); | ||
|
||
labs | ||
.createField('labPI') | ||
.name('Principle Investigator') | ||
.type('Link') | ||
.linkType('Entry') | ||
.validations([ | ||
{ | ||
linkContentType: ['users'], | ||
}, | ||
]); | ||
|
||
const users = migration.editContentType('users'); | ||
|
||
users.changeFieldId('labs', 'oldLabs'); | ||
users.editField('oldLabs', { name: 'Old Labs' }); | ||
users | ||
.createField('labs') | ||
.name('Labs') | ||
.type('Array') | ||
.items({ | ||
type: 'Link', | ||
linkType: 'Entry', | ||
validations: [ | ||
{ | ||
linkContentType: ['labs'], | ||
}, | ||
], | ||
}); | ||
users.moveField('labs').afterField('teams'); | ||
}; | ||
|
||
module.exports.down = (migration) => { | ||
const labs = migration.editContentType('labs'); | ||
labs.deleteField('labPI'); | ||
|
||
const users = migration.editContentType('users'); | ||
users.deleteField('labs'); | ||
users.changeFieldId('oldLabs', 'labs'); | ||
users.editField('oldLabs', { name: 'Labs' }); | ||
users.moveField('labs').afterField('teams'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.