Skip to content

Commit

Permalink
Add branding color quality checks
Browse files Browse the repository at this point in the history
  • Loading branch information
razzeee committed Feb 23, 2024
1 parent 97c497b commit b5db9a5
Show file tree
Hide file tree
Showing 6 changed files with 227 additions and 74 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
"""Add branding quality guideline
Revision ID: 248a867312b4
Revises: e87774655843
Create Date: 2024-02-19 00:31:43.064367
"""

import datetime
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

from app.models import Guideline, GuidelineCategory

# revision identifiers, used by Alembic.
revision = "248a867312b4"
down_revision = "e87774655843"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###

op.bulk_insert(
sa.table(
"guideline_category",
sa.Column("id", sa.String(), nullable=False),
sa.Column("order", sa.Integer(), nullable=False),
),
[
{"id": "branding", "order": 2},
],
)

op.bulk_insert(
sa.table(
"guideline",
sa.Column("id", sa.String(), nullable=False),
sa.Column("url", sa.String(), nullable=False),
sa.Column("needed_to_pass_since", sa.Date(), nullable=False),
sa.Column("read_only", sa.Boolean(), nullable=False),
sa.Column("guideline_category_id", sa.String(), nullable=False),
sa.Column("show_on_fullscreen_app", sa.Boolean(), nullable=False),
sa.Column("order", sa.Integer(), nullable=False),
),
[
{
"id": "branding-has-primary-brand-colors",
"url": "https://docs.flathub.org/docs/for-app-authors/metainfo-guidelines/quality-guidelines#has-primary-brand-colors",
"needed_to_pass_since": datetime.datetime(2024, 3, 1),
"read_only": True,
"guideline_category_id": "branding",
"show_on_fullscreen_app": True,
"order": 1,
},
{
"id": "branding-good-primary-brand-colors",
"url": "https://docs.flathub.org/docs/for-app-authors/metainfo-guidelines/quality-guidelines#good-brand-colors",
"needed_to_pass_since": datetime.datetime(2024, 3, 1),
"read_only": False,
"guideline_category_id": "branding",
"show_on_fullscreen_app": True,
"order": 2,
},
],
)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
sa.delete(Guideline).where(Guideline.id == "branding-has-primary-brand-colors")
sa.delete(Guideline).where(Guideline.id == "branding-good-primary-brand-colors")

sa.delete(GuidelineCategory).where(GuidelineCategory.id == "branding")
# ### end Alembic commands ###
26 changes: 26 additions & 0 deletions backend/app/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,32 @@ def update_quality_moderation():
None,
)

models.QualityModeration.upsert(
sqldb,
app_id,
"branding-has-primary-brand-colors",
"branding" in value
and any(
branding
for branding in value["branding"]
if "type" in branding
and "scheme_preference" in branding
and "value" in branding
and branding["type"] == "primary"
and branding["scheme_preference"] == "light"
)
and any(
branding
for branding in value["branding"]
if "type" in branding
and "scheme_preference" in branding
and "value" in branding
and branding["type"] == "primary"
and branding["scheme_preference"] == "dark"
),
None,
)


@dramatiq.actor
def refresh_github_repo_list(gh_access_token: str, accountId: int):
Expand Down
3 changes: 1 addition & 2 deletions frontend/pages/apps/[appDetails].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ export default function Details({
}}
/>
<QualityModeration
appId={app.id}
appIcon={app.icon}
app={app}
isQualityModalOpen={isQualityModalOpen}
setIsQualityModalOpen={setIsQualityModalOpen}
/>
Expand Down
5 changes: 4 additions & 1 deletion frontend/public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,9 @@
"quality-guideline": {
"general": "General",
"general-no-trademark-violations": "No trademark violations (name or icon)",
"branding": "Branding",
"branding-has-primary-brand-colors": "Has primary brand colors",
"branding-good-primary-brand-colors": "Good primary brand colors",
"app-icon": "App Icon",
"app-icon-size": "SVG or PNG of at least 256px",
"app-icon-footprint": "Doesn't fill too much or too little of the canvas",
Expand Down Expand Up @@ -555,4 +558,4 @@
"failing-x-checks_one": "Failing {{count}} check",
"failing-x-checks_other": "Failing {{count}} checks"
}
}
}
18 changes: 8 additions & 10 deletions frontend/src/components/application/QualityModeration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { qualityModerationApi } from "src/api"
import { QualityModerationStatus } from "src/codegen"
import { useTranslation } from "next-i18next"
import Modal from "../Modal"
import { DesktopAppstream } from "src/types/Appstream"

const QualityModerationStatusComponent = ({
status,
Expand Down Expand Up @@ -148,13 +149,11 @@ const ReviewButton = ({
}

export const QualityModeration = ({
appId,
appIcon,
app,
isQualityModalOpen,
setIsQualityModalOpen,
}: {
appId: string
appIcon: string
app: DesktopAppstream
isQualityModalOpen: boolean
setIsQualityModalOpen: (isOpen: boolean) => void
}) => {
Expand All @@ -163,13 +162,13 @@ export const QualityModeration = ({
const [isQualityModerator, setIsQualityModerator] = useState(false)

const requirement =
isQualityModerator || user.info?.dev_flatpaks.includes(appId)
isQualityModerator || user.info?.dev_flatpaks.includes(app.id)

const query = useQuery({
queryKey: ["/quality-moderation-app-status", { appId }],
queryKey: ["/quality-moderation-app-status", { appId: app.id }],
queryFn: ({ signal }) =>
qualityModerationApi.getQualityModerationStatusForAppQualityModerationAppIdStatusGet(
appId,
app.id,
{
withCredentials: true,
signal: signal,
Expand Down Expand Up @@ -213,7 +212,7 @@ export const QualityModeration = ({
</div>
<div className="ms-auto flex">
<ReviewButton
app_id={appId}
app_id={app.id}
status={query?.data?.data}
review_requested_at={query?.data?.data?.review_requested_at}
buttonClicked={() => {
Expand Down Expand Up @@ -247,8 +246,7 @@ export const QualityModeration = ({

<QualityModerationSlideOver
mode={mode}
appId={appId}
appIcon={appIcon}
app={app}
isQualityModalOpen={isQualityModalOpen}
setIsQualityModalOpen={setIsQualityModalOpen}
/>
Expand Down
Loading

0 comments on commit b5db9a5

Please sign in to comment.