Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions migrations/versions/1d1c609b8c23_merged_multiple_heads.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""merged multiple heads

Revision ID: 1d1c609b8c23
Revises: 2e86822886aa, b8bc4f2fc314
Create Date: 2025-07-01 08:01:23.351477

"""

# revision identifiers, used by Alembic.
revision = '1d1c609b8c23'
down_revision = ('2e86822886aa', 'b8bc4f2fc314')
branch_labels = None
depends_on = None


def upgrade():
pass


def downgrade():
pass
26 changes: 26 additions & 0 deletions migrations/versions/b8bc4f2fc314_add_content_jira_id_to_webpage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""add content_jira_id to webpage

Revision ID: b8bc4f2fc314
Revises: ac63c9eebbec
Create Date: 2025-06-02 11:17:01.443861

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'b8bc4f2fc314'
down_revision = 'ac63c9eebbec'
branch_labels = None
depends_on = None


def upgrade():
op.add_column(
"webpages", sa.Column("content_jira_id", sa.String(), nullable=True)
)


def downgrade():
op.drop_column("webpages", "content_jira_id")
6 changes: 6 additions & 0 deletions static/client/helpers/hooks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { useLocation } from "react-router-dom";

export const useQueryParams = () => {
const location = useLocation();
return new URLSearchParams(location.search);
};
6 changes: 5 additions & 1 deletion static/client/pages/NewWebpage/NewWebpage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import NavigationItems from "@/components/Navigation/NavigationItems";
import OwnerAndReviewers from "@/components/OwnerAndReviewers";
import Products from "@/components/Products";
import SiteSelector from "@/components/SiteSelector";
import { useQueryParams } from "@/helpers/hooks";
import { usePages } from "@/services/api/hooks/pages";
import { PagesServices } from "@/services/api/services/pages";
import type { IUser } from "@/services/api/types/users";
Expand Down Expand Up @@ -34,6 +35,8 @@ const NewWebpage = (): JSX.Element => {
const [selectedProject, setSelectedProject] = useStore((state) => [state.selectedProject, state.setSelectedProject]);
const { data, isFetching, refetch } = usePages(true);

const queryParams = useQueryParams();

useEffect(() => {
if (titleValue && location && owner) {
setButtonDisabled(false);
Expand Down Expand Up @@ -79,6 +82,7 @@ const NewWebpage = (): JSX.Element => {
project: selectedProject.name,
parent: location,
product_ids: products,
content_jira_id: queryParams.get("content_jira_id") || "",
};
PagesServices.createPage(newPage).then(() => {
// refetch the tree from the backend after a new webpage is added to the database
Expand All @@ -88,7 +92,7 @@ const NewWebpage = (): JSX.Element => {
});
});
}
}, [titleValue, owner, selectedProject, location, finalUrl, copyDoc, reviewers, products, refetch]);
}, [titleValue, owner, selectedProject, location, finalUrl, copyDoc, reviewers, products, queryParams, refetch]);

// update navigation after new page is added to the tree on the backend
useEffect(() => {
Expand Down
3 changes: 2 additions & 1 deletion static/client/pages/Webpage/Webpage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const Webpage = ({ page, project }: IWebpageProps): JSX.Element => {
const isNew = useMemo(() => page.status === PageStatus.NEW, [page]);
const pageName = useMemo(() => page.name.split("/").reverse()[0], [page]);
const hasJiraTasks = useMemo(() => page.jira_tasks?.length, [page]);
const isContentBoardPage = useMemo(() => page.content_jira_id, [page]);

return (
<div className="l-webpage">
Expand Down Expand Up @@ -79,7 +80,7 @@ const Webpage = ({ page, project }: IWebpageProps): JSX.Element => {
</div>
<div className="l-webpage--buttons">
<>
{isNew && !hasJiraTasks && (
{isNew && !hasJiraTasks && !isContentBoardPage && (
<Button appearance="positive" onClick={createNewPage}>
Submit for publication...
</Button>
Expand Down
1 change: 1 addition & 0 deletions static/client/services/api/types/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export interface IPage {
updated_at: string;
};
ext?: string;
content_jira_id?: string;
}

export interface IPagesResponse {
Expand Down
21 changes: 21 additions & 0 deletions webapp/jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,27 @@ def unlink_parent_issue(self, issue_id: str) -> bool:
data=payload,
)

def link_copydoc_with_content_page(self, copydoc, jira_id):
"""Link a copydoc with a content page in Jira.

Args:
copydoc (str): The URL of the copydoc.
jira_id (str): The ID of the Jira issue.

Returns:
dict: The response from the Jira API.
"""

payload = {
"fields": {
"customfield_11133": copydoc,
},
}

return self.__request__(
method="PUT", path=f"issue/{jira_id}", data=payload
)


def init_jira(app):
try:
Expand Down
1 change: 1 addition & 0 deletions webapp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class Webpage(db.Model, DateTimeMixin):
owner_id: int = Column(Integer, ForeignKey("users.id"))
status: str = Column(Enum(WebpageStatus), default=WebpageStatus.AVAILABLE)
ext: str = Column(String, nullable=True)
content_jira_id: str = Column(String, nullable=True)

project = relationship("Project", back_populates="webpages")
owner = relationship("User", back_populates="webpages")
Expand Down
5 changes: 5 additions & 0 deletions webapp/routes/jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ def create_page(body: CreatePageModel):
parent_id=get_webpage_id(data["parent"], project_id),
owner_id=owner_id,
status=WebpageStatus.NEW,
content_jira_id=data["content_jira_id"],
)

# Create new reviewer rows
Expand Down Expand Up @@ -301,6 +302,10 @@ def create_page(body: CreatePageModel):
product_id=product_id,
)

if data["content_jira_id"]:
jira = current_app.config["JIRA"]
jira.link_copydoc_with_content_page(copy_doc, data["content_jira_id"])

return jsonify({"copy_doc": copy_doc}), 201


Expand Down
1 change: 1 addition & 0 deletions webapp/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class CreatePageModel(BaseModel):
reviewers: Optional[List[UserModel]]
parent: str
product_ids: List[int]
content_jira_id: Optional[str] = None


class SetProductsModel(BaseModel):
Expand Down
Loading