Skip to content

Commit f1e2c58

Browse files
authored
feat: Filter admin panel teams by A4 status (#4440)
1 parent 9d8d8f6 commit f1e2c58

File tree

11 files changed

+274
-89
lines changed

11 files changed

+274
-89
lines changed

api.planx.uk/modules/gis/routes.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import { Router } from "express";
22
import { locationSearch } from "./service/index.js";
3-
import { hasArticle4Schema } from "./service/article4Schema.js";
43
import { classifiedRoadsSearch } from "./service/classifiedRoads.js";
54

65
const router = Router();
76

87
router.get("/gis/:localAuthority", locationSearch);
9-
router.get("/gis/:localAuthority/article4-schema", hasArticle4Schema);
108
router.get("/roads", classifiedRoadsSearch);
119

1210
export default router;

api.planx.uk/modules/gis/service/article4Schema.ts

-43
This file was deleted.

api.planx.uk/modules/gis/service/digitalLand.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ export interface LocalAuthorityMetadata {
3636
};
3737
}
3838

39-
/** When a team publishes their granular Article 4 data, add them to this list. Key must match team slug */
39+
/**
40+
* When a team publishes their granular Article 4 data, add them to this list. Key must match team slug
41+
* The database column team_setting.has_article4_schema also needs to be updated via the Hasura console
42+
*/
4043
export const localAuthorityMetadata: Record<string, LocalAuthorityMetadata> = {
4144
"barking-and-dagenham": barkingAndDagenham,
4245
barnet,

doc/how-to/how-to-setup-planning-constraints-for-a-team.md

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ The dictionary of `records` should have one key/value pair per each unique granu
4747
The council should map their GIS identifiers themselves in the spreadsheet, but often this is partially complete or missing and simpler to quickly match against planning.data.gov.uk search results ourselves than start a communication back and forth (it's often not the same council person who knows the Article 4 rules as who understands the spatial data structure).
4848

4949
5. **Planx** - Add an entry for this council to the `localAuthorityMetadata` variable defined at the top of `api.planx.uk/modules/gis/service/digitalLand.ts`
50+
51+
6. **Planx** - Toggle the database column `team_settings.has_article4_schema` to be `true` via the Hasura console. This is used by the admin panel view for platform admins.
5052

5153
Confirm that granular A4 variables are now being returned by the /gis endpoint and written to the passport when navigating a flow.
5254

editor.planx.uk/src/pages/PlatformAdminPanel/PlatformAdminPanel.tsx

+1-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
False as NotConfigured,
1212
True as Configured,
1313
} from "../../ui/shared/DataTable/components/cellIcons";
14-
import { Article4Status } from "./components/Article4Status";
1514
import { getFlowNamesForFilter } from "./getFlowNamesForFilter";
1615

1716
const isCouncilTeam = () => {
@@ -63,11 +62,8 @@ export const PlatformAdminPanel = () => {
6362
},
6463
{
6564
field: "article4sEnabled",
66-
headerName: "Article 4s (API)",
65+
headerName: "Article 4s",
6766
type: ColumnFilterType.BOOLEAN,
68-
customComponent: (params) => {
69-
return <Article4Status teamSlug={params.row.slug} />;
70-
},
7167
},
7268
{
7369
field: "govpayEnabled",

editor.planx.uk/src/pages/PlatformAdminPanel/components/Article4Status.tsx

-19
This file was deleted.

editor.planx.uk/src/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export interface AdminPanelData {
105105
homepage?: string;
106106
subdomain?: string;
107107
planningDataEnabled: boolean;
108-
article4sEnabled: string;
108+
article4sEnabled: boolean;
109109
govnotifyPersonalisation?: TeamContactSettings;
110110
govpayEnabled: boolean;
111111
powerAutomateEnabled: boolean;

editor.planx.uk/src/ui/shared/DataTable/mockTeams.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const mockTeams: AdminPanelData[] = [
2020
actionColour: "#000000",
2121
homepage: undefined,
2222
subdomain: undefined,
23-
article4sEnabled: "@todo",
23+
article4sEnabled: true,
2424
govnotifyPersonalisation: {
2525
helpEmail: "[email protected]",
2626
helpPhone: "(01234) 567890",
@@ -46,7 +46,7 @@ export const mockTeams: AdminPanelData[] = [
4646
govpayEnabled: true,
4747
logo: "https://path.to.logo.com/theopensystemslab/planx-team-logos/main/logo.svg",
4848
slug: "doncaster",
49-
article4sEnabled: "@todo",
49+
article4sEnabled: false,
5050
powerAutomateEnabled: false,
5151
},
5252
{
@@ -66,7 +66,7 @@ export const mockTeams: AdminPanelData[] = [
6666
govpayEnabled: false,
6767
logo: "https://path.to.logo.com/theopensystemslab/planx-team-logos/main/logo.svg",
6868
slug: "newcastle",
69-
article4sEnabled: "@todo",
69+
article4sEnabled: true,
7070
powerAutomateEnabled: true,
7171
},
7272
{
@@ -83,7 +83,7 @@ export const mockTeams: AdminPanelData[] = [
8383
govpayEnabled: true,
8484
logo: "https://path.to.logo.com/theopensystemslab/planx-team-logos/main/logo.svg",
8585
slug: "tewkesbury",
86-
article4sEnabled: "@todo",
86+
article4sEnabled: false,
8787
powerAutomateEnabled: false,
8888
},
8989
];

hasura.planx.uk/metadata/tables.yaml

+21-14
Original file line numberDiff line numberDiff line change
@@ -2441,6 +2441,7 @@
24412441
- email_reply_to_id
24422442
- external_planning_site_name
24432443
- external_planning_site_url
2444+
- has_article4_schema
24442445
- help_email
24452446
- help_opening_hours
24462447
- help_phone
@@ -2459,6 +2460,7 @@
24592460
- email_reply_to_id
24602461
- external_planning_site_name
24612462
- external_planning_site_url
2463+
- has_article4_schema
24622464
- help_email
24632465
- help_opening_hours
24642466
- help_phone
@@ -2472,19 +2474,20 @@
24722474
- role: demoUser
24732475
permission:
24742476
columns:
2475-
- id
2477+
- boundary_bbox
2478+
- boundary_url
2479+
- email_reply_to_id
24762480
- external_planning_site_name
24772481
- external_planning_site_url
2478-
- homepage
2482+
- has_article4_schema
24792483
- help_email
24802484
- help_opening_hours
24812485
- help_phone
2482-
- email_reply_to_id
2483-
- team_id
2484-
- boundary_bbox
2485-
- submission_email
2486+
- homepage
2487+
- id
24862488
- reference_code
2487-
- boundary_url
2489+
- submission_email
2490+
- team_id
24882491
filter: {}
24892492
comment: ""
24902493
- role: platformAdmin
@@ -2495,6 +2498,7 @@
24952498
- email_reply_to_id
24962499
- external_planning_site_name
24972500
- external_planning_site_url
2501+
- has_article4_schema
24982502
- help_email
24992503
- help_opening_hours
25002504
- help_phone
@@ -2513,6 +2517,7 @@
25132517
- email_reply_to_id
25142518
- external_planning_site_name
25152519
- external_planning_site_url
2520+
- has_article4_schema
25162521
- help_email
25172522
- help_opening_hours
25182523
- help_phone
@@ -2530,6 +2535,7 @@
25302535
- email_reply_to_id
25312536
- external_planning_site_name
25322537
- external_planning_site_url
2538+
- has_article4_schema
25332539
- help_email
25342540
- help_opening_hours
25352541
- help_phone
@@ -2544,19 +2550,20 @@
25442550
- role: platformAdmin
25452551
permission:
25462552
columns:
2547-
- id
2553+
- boundary_bbox
2554+
- boundary_url
2555+
- email_reply_to_id
25482556
- external_planning_site_name
25492557
- external_planning_site_url
2550-
- homepage
2558+
- has_article4_schema
25512559
- help_email
25522560
- help_opening_hours
25532561
- help_phone
2554-
- email_reply_to_id
2555-
- team_id
2556-
- boundary_bbox
2557-
- submission_email
2562+
- homepage
2563+
- id
25582564
- reference_code
2559-
- boundary_url
2565+
- submission_email
2566+
- team_id
25602567
filter: {}
25612568
check: null
25622569
comment: ""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
ALTER TABLE "public"."team_settings" DROP COLUMN "has_article4_schema";
2+
3+
-- Recreate view from hasura.planx.uk/migrations/1738843003829_run_sql_migration/up.sql
4+
CREATE
5+
OR REPLACE VIEW "public"."teams_summary" AS
6+
SELECT
7+
t.id,
8+
t.name,
9+
t.slug,
10+
ts.reference_code,
11+
ts.homepage,
12+
t.domain AS subdomain,
13+
ti.has_planning_data AS planning_data_enabled,
14+
'@todo' :: text AS article_4s_enabled,
15+
jsonb_build_object(
16+
'helpEmail',
17+
ts.help_email,
18+
'helpPhone',
19+
ts.help_phone,
20+
'emailReplyToId',
21+
ts.email_reply_to_id,
22+
'helpOpeningHours',
23+
ts.help_opening_hours
24+
) AS govnotify_personalisation,
25+
CASE
26+
WHEN (
27+
COALESCE(
28+
ti.production_govpay_secret,
29+
ti.staging_govpay_secret
30+
) IS NOT NULL
31+
) THEN true
32+
ELSE false
33+
END AS govpay_enabled,
34+
ts.submission_email AS send_to_email_address,
35+
COALESCE(
36+
ti.production_bops_submission_url,
37+
ti.staging_bops_submission_url
38+
) AS bops_submission_url,
39+
tt.logo,
40+
tt.favicon,
41+
tt.primary_colour,
42+
tt.link_colour,
43+
tt.action_colour,
44+
CASE
45+
WHEN (
46+
(
47+
COALESCE(
48+
ti.production_file_api_key,
49+
ti.staging_file_api_key
50+
) IS NOT NULL
51+
)
52+
AND (
53+
COALESCE(
54+
ti.production_power_automate_api_key,
55+
ti.staging_power_automate_api_key
56+
) IS NOT NULL
57+
)
58+
AND (ti.power_automate_webhook_url IS NOT NULL)
59+
) THEN true
60+
ELSE false
61+
END AS power_automate_enabled,
62+
ARRAY_AGG(f.name) FILTER (
63+
WHERE
64+
f.status = 'online'
65+
) AS live_flows
66+
FROM
67+
(
68+
(
69+
(
70+
teams t
71+
JOIN team_integrations ti ON ((ti.team_id = t.id))
72+
)
73+
JOIN team_themes tt ON ((tt.team_id = t.id))
74+
)
75+
JOIN team_settings ts ON ((ts.team_id = t.id))
76+
)
77+
JOIN flows f ON ((f.team_id = t.id))
78+
GROUP BY
79+
t.id,
80+
t.name,
81+
t.slug,
82+
ts.reference_code,
83+
ts.homepage,
84+
ts.help_email,
85+
ts.help_phone,
86+
ts.email_reply_to_id,
87+
ts.help_opening_hours,
88+
ts.submission_email,
89+
ts.has_article4_schema,
90+
ti.has_planning_data,
91+
ti.production_govpay_secret,
92+
ti.staging_govpay_secret,
93+
ti.production_bops_submission_url,
94+
ti.staging_bops_submission_url,
95+
ti.production_file_api_key,
96+
ti.staging_file_api_key,
97+
ti.power_automate_webhook_url,
98+
ti.production_power_automate_api_key,
99+
ti.staging_power_automate_api_key,
100+
tt.logo,
101+
tt.favicon,
102+
tt.primary_colour,
103+
tt.link_colour,
104+
tt.action_colour
105+
ORDER BY
106+
t.name;

0 commit comments

Comments
 (0)