-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DON"T MERGE 1367 multiple env select #1372
Open
marySalvi
wants to merge
9
commits into
main
Choose a base branch
from
1367-multiple-env-select
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4763c29
Update exisiting packageNames and schema
marySalvi a31ddb3
Change UI to allow multi-select for env packages
marySalvi bc63beb
Change verbage to match GSC
marySalvi a4e7db6
Update fakes for tests
marySalvi b170e6d
Update template logic to use an environment array
marySalvi 96ca625
Adjust disabling button to array length
marySalvi b166534
Preserve environment data on tab change
marySalvi aacca77
Update synchronization for multiple environments
marySalvi 784eba1
Change environment disable logic
marySalvi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
57 changes: 57 additions & 0 deletions
57
nmdc_server/migrations/versions/afa1ff687968_convert_packagename_to_an_array.py
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,57 @@ | ||
"""Convert packageName to an array | ||
|
||
Revision ID: afa1ff687968 | ||
Revises: 317274ad8137 | ||
Create Date: 2024-08-28 22:27:28.622234 | ||
|
||
""" | ||
|
||
from typing import Optional | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
from sqlalchemy.dialects.postgresql import JSONB | ||
from sqlalchemy.sql import column, table | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "afa1ff687968" | ||
down_revision: Optional[str] = "317274ad8137" | ||
branch_labels: Optional[str] = None | ||
depends_on: Optional[str] = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
submission_metadata = table( | ||
"submission_metadata", | ||
column("id", sa.String), | ||
column("metadata_submission", JSONB), | ||
column("study_name", sa.String), | ||
column("templates", JSONB), | ||
) | ||
|
||
connection = op.get_bind() | ||
submissions = connection.execute( | ||
sa.select([submission_metadata.c.id, submission_metadata.c.metadata_submission]) | ||
) | ||
|
||
for submission in submissions: | ||
metadata_submission = submission.metadata_submission | ||
package_name = metadata_submission.get("packageName") | ||
|
||
if isinstance(package_name, str): | ||
metadata_submission["packageName"] = [package_name] | ||
|
||
update_stmt = ( | ||
submission_metadata.update() | ||
.where(submission_metadata.c.id == submission.id) | ||
.values(metadata_submission=metadata_submission) | ||
) | ||
connection.execute(update_stmt) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
pass | ||
# ### end Alembic commands ### |
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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -132,8 +132,10 @@ export default defineComponent({ | |||||
// WARNING: It's important to do the column settings update /before/ data. Otherwise, | ||||||
// columns will not be rendered with the correct width. | ||||||
harmonizerApi.setColumnsReadOnly(ALWAYS_READ_ONLY_COLUMNS); | ||||||
// if we're not on the first tab, the common columns should be read-only | ||||||
if (activeTemplateKey.value !== templateList.value[0]) { | ||||||
|
||||||
// If the environment tab selected is a misin it should be readonly | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
const environmentList = templateList.value.filter((t) => HARMONIZER_TEMPLATES[t].status === 'mixin'); | ||||||
if (environmentList.includes(activeTemplateKey.value)) { | ||||||
harmonizerApi.setColumnsReadOnly(COMMON_COLUMNS); | ||||||
harmonizerApi.setMaxRows(activeTemplateData.value.length); | ||||||
} | ||||||
|
@@ -294,7 +296,8 @@ export default defineComponent({ | |||||
}); | ||||||
|
||||||
function rowIsVisibleForTemplate(row: Record<string, any>, templateKey: string) { | ||||||
if (templateKey === templateList.value[0]) { | ||||||
const environmentKeys = templateList.value.filter((t) => HARMONIZER_TEMPLATES[t].status === 'published'); | ||||||
if (environmentKeys.includes(templateKey)) { | ||||||
return true; | ||||||
} | ||||||
const row_types = row[TYPE_FIELD]; | ||||||
|
@@ -319,53 +322,65 @@ export default defineComponent({ | |||||
} | ||||||
|
||||||
function synchronizeTabData(templateKey: string) { | ||||||
if (templateKey === templateList.value[0]) { | ||||||
const environmentKeys = templateList.value.filter((t) => HARMONIZER_TEMPLATES[t].status === 'published'); | ||||||
if (environmentKeys.includes(templateKey)) { | ||||||
return; | ||||||
} | ||||||
const nextData = { ...sampleData.value }; | ||||||
const templateSlot = HARMONIZER_TEMPLATES[templateKey].sampleDataSlot; | ||||||
const environmentSlot = HARMONIZER_TEMPLATES[templateList.value[0]].sampleDataSlot; | ||||||
|
||||||
if (!templateSlot || !environmentSlot) { | ||||||
const environmentSlots = templateList.value | ||||||
.filter((t) => HARMONIZER_TEMPLATES[t].status === 'published') | ||||||
.map((t) => HARMONIZER_TEMPLATES[t].sampleDataSlot); | ||||||
|
||||||
if (!templateSlot || !environmentSlots) { | ||||||
return; | ||||||
} | ||||||
|
||||||
// ensure the necessary keys exist in the data object | ||||||
if (!nextData[environmentSlot]) { | ||||||
nextData[environmentSlot] = []; | ||||||
} | ||||||
environmentSlots.forEach((slot) => { | ||||||
if (!nextData[slot as string]) { | ||||||
nextData[slot as string] = []; | ||||||
} | ||||||
}); | ||||||
|
||||||
if (!nextData[templateSlot]) { | ||||||
nextData[templateSlot] = []; | ||||||
} | ||||||
|
||||||
// add/update any rows from the first tab to the active tab if they apply and if | ||||||
// add/update any rows from the environment tabs to the active tab if they apply and if | ||||||
// they aren't there already. | ||||||
nextData[environmentSlot].forEach((row) => { | ||||||
const rowId = row[SCHEMA_ID]; | ||||||
const existing = nextData[templateSlot] && nextData[templateSlot].find((r) => r[SCHEMA_ID] === rowId); | ||||||
if (!existing && rowIsVisibleForTemplate(row, templateKey)) { | ||||||
const newRow = {} as Record<string, any>; | ||||||
COMMON_COLUMNS.forEach((col) => { | ||||||
newRow[col] = row[col]; | ||||||
}); | ||||||
nextData[templateSlot].push(newRow); | ||||||
} | ||||||
if (existing) { | ||||||
COMMON_COLUMNS.forEach((col) => { | ||||||
existing[col] = row[col]; | ||||||
}); | ||||||
} | ||||||
environmentSlots.forEach((environmentSlot) => { | ||||||
nextData[environmentSlot as string].forEach((row) => { | ||||||
const rowId = row[SCHEMA_ID]; | ||||||
|
||||||
const existing = nextData[templateSlot] && nextData[templateSlot].find((r) => r[SCHEMA_ID] === rowId); | ||||||
if (!existing && rowIsVisibleForTemplate(row, templateKey)) { | ||||||
const newRow = {} as Record<string, any>; | ||||||
COMMON_COLUMNS.forEach((col) => { | ||||||
newRow[col] = row[col]; | ||||||
}); | ||||||
nextData[templateSlot].push(newRow); | ||||||
} | ||||||
if (existing) { | ||||||
COMMON_COLUMNS.forEach((col) => { | ||||||
existing[col] = row[col]; | ||||||
}); | ||||||
} | ||||||
}); | ||||||
}); | ||||||
// remove any rows from the active tab if they were removed from the first tab | ||||||
// remove any rows from the active tab if they were removed from the environment tabs | ||||||
// or no longer apply to the active tab | ||||||
if (nextData[templateSlot].length > 0) { | ||||||
nextData[templateSlot] = nextData[templateSlot].filter((row) => { | ||||||
if (!rowIsVisibleForTemplate(row, templateKey)) { | ||||||
return false; | ||||||
} | ||||||
const rowId = row[SCHEMA_ID]; | ||||||
const environmentRow = nextData[environmentSlot].findIndex((r) => r[SCHEMA_ID] === rowId); | ||||||
return environmentRow >= 0; | ||||||
return environmentSlots.some((environmentSlot) => { | ||||||
const environmentRow = nextData[environmentSlot as string].findIndex((r) => r[SCHEMA_ID] === rowId); | ||||||
return environmentRow >= 0; | ||||||
}); | ||||||
}); | ||||||
} | ||||||
sampleData.value = nextData; | ||||||
|
@@ -464,9 +479,8 @@ export default defineComponent({ | |||||
} | ||||||
|
||||||
await validate(); | ||||||
|
||||||
// When changing templates we may need to populate the common columns | ||||||
// from the first tab | ||||||
// from the environment tabs | ||||||
const nextTemplate = templateList.value[index]; | ||||||
synchronizeTabData(nextTemplate); | ||||||
|
||||||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any submissions in dev that are missing the
packageName
, but it might be safer to add a default here just in case.