Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
62 changes: 49 additions & 13 deletions bin/check-review-dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import logging
from slack_sdk import WebClient
from datetime import timedelta, date, datetime
import json
import re
import ast

DEFAULT_VAL_FREQ = 6
FILEPATH = "./" ## for local testing use "../" and shift filepath_list[] indexes +1
Expand All @@ -22,18 +23,53 @@ def get_prod_cat_ref():

product_categories = {}

# Load the menu file
with open(FILEPATH + 'menu/navigation.json', 'r') as file:
data = json.load(file) # Parse the JSON content into a Python dictionary or list

for grouping in data:
for category in grouping["items"]:
category_label = category["label"]
for product in category["items"]:
product_label = product["label"]
product_slug = product["slug"]

product_categories[product_slug] = [category_label, product_label]
# Read the menu file
with open(FILEPATH + "menu/navigation.ts", "r", encoding="utf-8") as f:
js = f.read()

# remove all lines up to "export default"
js = re.sub(r"^import .*", "", js, flags=re.M) # remove import lines
js = re.sub(r"//.*", "", js) # strip line comments
js = re.sub(r"/\*.*?\*/", "", js, flags=re.S) # strip block comments
js = js.replace("export default", "").strip() # strip "export default" and cleanup

# Convert items - [accountMenu, billingMenu] → ['account', 'billing']
js = re.sub(r"\b([a-zA-Z0-9_]+)Menu\b(?!')", r"'\1'", js)

# Convert icons - OrganizationDashboardCategoryIcon → 'OrganizationDashboardCategory'
js = re.sub(r"\b([A-Z][A-Za-z0-9]+)Icon\b(?!')", r"'\1'", js)

# Normalize JS → Python syntax ---
js = re.sub(r"(\w+):", r"'\1':", js) # quote keys
js = js.replace("null", "None") # replace nulls with Nones
js = re.sub(r",(\s*[}\]])", r"\1", js) # remove trailing commas

# Convert the js string now containing Python literal syntax, into an actual Python object.
data = ast.literal_eval(js)

# Helper function
def camel_to_kebab(name: str) -> str:
"""Convert camelCase or PascalCase to kebab-case."""
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1-\2', name)
s2 = re.sub('([a-z0-9])([A-Z])', r'\1-\2', s1)
return s2.lower()

# Helper function
def prettify_label(slug: str) -> str:
"""Convert kebab-case to title case."""
return slug.replace("-", " ").title()

# Walk structure and make new dict

product_categories = {}

for section in data:
for category in section["items"]:
category_label = category["label"]
for item in category["items"]:
key = camel_to_kebab(item).lower().replace("_", "-")
label = prettify_label(key)
product_categories[key] = [category_label, label]

return(product_categories)

Expand Down
8 changes: 4 additions & 4 deletions menu/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import { partnerSpaceMenu } from "../pages/partner-space/menu"
import { publicGatewaysMenu } from "../pages/public-gateways/menu"
import { queuesMenu } from "../pages/queues/menu"
import { scalewayCliMenu } from "../pages/scaleway-cli/menu"
import { scalewySdkMenu } from "../pages/scaleway-sdk/menu"
import { scalewaySdkMenu } from "../pages/scaleway-sdk/menu"
import { secretManagerMenu } from "../pages/secret-manager/menu"
import { serverlessContainersMenu } from "../pages/serverless-containers/menu"
import { serverlessFunctionsMenu } from "../pages/serverless-functions/menu"
Expand All @@ -61,7 +61,7 @@ import { terraformMenu } from "../pages/terraform/menu"
import { topicsAndEventsMenu } from "../pages/topics-and-events/menu"
import { transactionalEmailMenu } from "../pages/transactional-email/menu"
import { vpcMenu } from "../pages/vpc/menu"
import { webHostingMenu } from "../pages/webhosting/menu"
import { webhostingMenu } from "../pages/webhosting/menu"

export default [
{
Expand Down Expand Up @@ -162,7 +162,7 @@ export default [
icon: 'DevToolsCategoryIcon',
items: [
scalewayCliMenu,
scalewySdkMenu,
scalewaySdkMenu,
terraformMenu,
],
label: 'Developer Tools',
Expand All @@ -173,7 +173,7 @@ export default [
items: [
domainsAndDnsMenu,
transactionalEmailMenu,
webHostingMenu,
webhostingMenu,
],
label: 'Domains & Web Hosting',
category: 'domains-and-web-hosting',
Expand Down
2 changes: 1 addition & 1 deletion pages/scaleway-sdk/menu.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const scalewySdkMenu = {
export const scalewaySdkMenu = {
items: [
{
label: 'Python SDK quickstart',
Expand Down
2 changes: 1 addition & 1 deletion pages/webhosting/menu.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const webHostingMenu = {
export const webhostingMenu = {
items: [
{
label: 'Overview',
Expand Down