-
Notifications
You must be signed in to change notification settings - Fork 19
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
DESENG-670: Admin authoring header page #2593
Merged
Merged
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8874c5f
DESENG-670: Admin authoring header page
NatSquared 6eb268f
Update Changelog
NatSquared 3130b29
Clean up residual references to CTA in engagement models
NatSquared f1bdf43
Undo changes to AuthoringFeedback.tsx
NatSquared 05429dc
Reset accidental changes to authoringFeedback.tsx
NatSquared c4c6cb4
Add setValue to DetailsTabsProps
NatSquared 94f5a31
Address PR comments
NatSquared 528d9d0
Update developer documentation
NatSquared 019c734
Reduce visual flicker by memoizing + lazy loading breadcrumbs
NatSquared 7a2c21d
Update header documentation
NatSquared 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
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,25 @@ | ||
"""Merge heads | ||
|
||
Revision ID: 63890bdab166 | ||
Revises: df693f5ddaf9, 828b4f34734a | ||
Create Date: 2024-09-20 13:55:27.230188 | ||
|
||
""" | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = "63890bdab166" | ||
down_revision = ("df693f5ddaf9", "828b4f34734a") | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
pass | ||
|
||
|
||
def downgrade(): | ||
pass |
174 changes: 174 additions & 0 deletions
174
met-api/migrations/versions/828b4f34734a_status_block_updates.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,174 @@ | ||
"""Move cta_message and cta_url from engagement to engagement_status_block | ||
|
||
Revision ID: 828b4f34734a | ||
Revises: e706db763790 | ||
Create Date: 2024-09-16 10:18:49.858066 | ||
|
||
""" | ||
|
||
from enum import IntEnum, Enum | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
class SubmissionStatus(IntEnum): | ||
"""Enum of engagement submission status.""" | ||
|
||
Upcoming = 1 | ||
Open = 2 | ||
Closed = 3 | ||
ViewResults = 4 | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = "828b4f34734a" | ||
down_revision = "e706db763790" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
connection = op.get_bind() | ||
# Create a new enum type with the 'ViewResults' value | ||
op.execute("ALTER TYPE submissionstatus RENAME TO submissionstatus_old") | ||
op.execute( | ||
"CREATE TYPE submissionstatus AS ENUM ('Upcoming', 'Open', 'Closed', 'ViewResults')" | ||
) | ||
# Commit the enum change before dropping the old one | ||
op.execute("COMMIT") | ||
# Convert the existing data to the new enum type | ||
connection.execute( | ||
"ALTER TABLE engagement_status_block ALTER COLUMN survey_status TYPE submissionstatus USING survey_status::text::submissionstatus" | ||
) | ||
# Drop the old enum type | ||
op.execute("DROP TYPE submissionstatus_old") | ||
|
||
op.add_column( | ||
"engagement_status_block", | ||
sa.Column("button_text", sa.String(length=20), nullable=True), | ||
) | ||
op.add_column( | ||
"engagement_status_block", | ||
sa.Column( | ||
"link_type", sa.String(length=20), nullable=False, server_default="internal" | ||
), | ||
) | ||
op.add_column( | ||
"engagement_status_block", | ||
sa.Column("internal_link", sa.String(length=50), nullable=True), | ||
) | ||
op.add_column( | ||
"engagement_status_block", | ||
sa.Column("external_link", sa.String(length=300), nullable=True), | ||
) | ||
# Migrate data from engagement to engagement_status_block | ||
# Ad-hoc table definition for engagement | ||
engagement_table = sa.Table( | ||
"engagement", | ||
sa.MetaData(), | ||
sa.Column("id", sa.Integer), | ||
sa.Column("cta_message", sa.String(50)), | ||
sa.Column("cta_url", sa.String(500)), | ||
) | ||
# Ad-hoc table definition for engagement_status_block | ||
engagement_status_block_table = sa.Table( | ||
"engagement_status_block", | ||
sa.MetaData(), | ||
sa.Column("id", sa.Integer), | ||
sa.Column("engagement_id", sa.Integer), | ||
sa.Column( | ||
"survey_status", | ||
sa.Enum( | ||
SubmissionStatus, | ||
name="submissionstatus", | ||
metadata=sa.MetaData(), | ||
create_constraint=True, | ||
), | ||
), | ||
sa.Column("block_text", sa.JSON), | ||
sa.Column("button_text", sa.String(20)), | ||
sa.Column("link_type", sa.String(20)), | ||
sa.Column("internal_link", sa.String(50)), | ||
sa.Column("external_link", sa.String(300)), | ||
sa.Column("created_date", sa.DateTime), | ||
sa.Column("updated_date", sa.DateTime), | ||
) | ||
# For each engagement... | ||
for engagement in connection.execute(engagement_table.select()): | ||
# Update existing engagement_status_blocks... | ||
# If the URL starts with "http", it's an external link. | ||
if engagement.cta_url and engagement.cta_url.startswith("http"): | ||
link_type = "external" | ||
external_link = engagement.cta_url | ||
internal_link = None | ||
else: | ||
valid_statuses = ["hero", "description", "contentTabs", "provideFeedback"] | ||
link_type = "internal" | ||
external_link = None | ||
internal_link = None | ||
if engagement.cta_url in valid_statuses: | ||
internal_link = engagement.cta_url | ||
else: | ||
internal_link = "provideFeedback" | ||
connection.execute( | ||
engagement_status_block_table.update() | ||
.where(engagement_status_block_table.c.engagement_id == engagement.id) | ||
.where(engagement_status_block_table.c.survey_status == "Open") | ||
.values( | ||
button_text=engagement.cta_message or "Provide Feedback", | ||
link_type=link_type, | ||
external_link=external_link, | ||
internal_link=internal_link, | ||
) | ||
) | ||
# And add the "View Results" block type. | ||
connection.execute( | ||
engagement_status_block_table.insert().values( | ||
engagement_id=engagement.id, | ||
survey_status=SubmissionStatus.ViewResults, | ||
block_text={}, | ||
button_text="View Results", | ||
link_type="internal", | ||
internal_link="provideFeedback", | ||
external_link=None, | ||
created_date=sa.func.now(), | ||
updated_date=sa.func.now(), | ||
) | ||
) | ||
# Drop the columns from the engagement table | ||
op.drop_column("engagement", "cta_message") | ||
op.drop_column("engagement", "cta_url") | ||
|
||
|
||
def downgrade(): | ||
op.drop_column("engagement_status_block", "external_link") | ||
op.drop_column("engagement_status_block", "internal_link") | ||
op.drop_column("engagement_status_block", "link_type") | ||
op.drop_column("engagement_status_block", "button_text") | ||
op.add_column( | ||
"engagement", | ||
sa.Column( | ||
"cta_url", sa.VARCHAR(length=500), autoincrement=False, nullable=True | ||
), | ||
) | ||
op.add_column( | ||
"engagement", | ||
sa.Column( | ||
"cta_message", sa.VARCHAR(length=50), autoincrement=False, nullable=True | ||
), | ||
) | ||
# Create a new enum type without the 'ViewResults' value | ||
op.execute("ALTER TYPE submissionstatus RENAME TO submissionstatus_old") | ||
op.execute("CREATE TYPE submissionstatus AS ENUM ('Upcoming', 'Open', 'Closed')") | ||
# Commit the enum change before dropping the old one | ||
op.execute("COMMIT") | ||
# Convert the existing data to the new enum type | ||
connection = op.get_bind() | ||
connection.execute( | ||
"UPDATE engagement_status_block SET survey_status = 'Closed' WHERE survey_status = 'ViewResults'" | ||
) | ||
connection.execute( | ||
"ALTER TABLE engagement_status_block ALTER COLUMN survey_status TYPE submissionstatus USING survey_status::text::submissionstatus" | ||
) | ||
# Drop the old enum type | ||
op.execute("DROP TYPE submissionstatus_old") |
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
Oops, something went wrong.
Oops, something went wrong.
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.
Thanks for doing the work of updating each status block!
I feel like we may miss some URLs if folks omit the protocol, but it's pretty low stakes at this point since there are no live engagements or anything.