From 942b5b7e2914f9418fff5f8efeeed5c9c58edf57 Mon Sep 17 00:00:00 2001 From: Jo Humphrey <31373245+jamdelion@users.noreply.github.com> Date: Thu, 7 Nov 2024 16:02:53 +0000 Subject: [PATCH 1/3] Display feedback score in feedback log --- .../Flow/FeedbackLog/FeedbackLog.tsx | 3 ++ .../FeedbackLog/components/CollapsibleRow.tsx | 12 ++++++++ editor.planx.uk/src/routes/feedback.tsx | 4 ++- hasura.planx.uk/metadata/tables.yaml | 27 +++++++++-------- .../1730991162717_run_sql_migration/down.sql | 29 +++++++++++++++++++ .../1730991162717_run_sql_migration/up.sql | 26 +++++++++++++++++ 6 files changed, 88 insertions(+), 13 deletions(-) create mode 100644 hasura.planx.uk/migrations/1730991162717_run_sql_migration/down.sql create mode 100644 hasura.planx.uk/migrations/1730991162717_run_sql_migration/up.sql diff --git a/editor.planx.uk/src/pages/FlowEditor/components/Flow/FeedbackLog/FeedbackLog.tsx b/editor.planx.uk/src/pages/FlowEditor/components/Flow/FeedbackLog/FeedbackLog.tsx index 473bbe19e1..eebc21c5d0 100644 --- a/editor.planx.uk/src/pages/FlowEditor/components/Flow/FeedbackLog/FeedbackLog.tsx +++ b/editor.planx.uk/src/pages/FlowEditor/components/Flow/FeedbackLog/FeedbackLog.tsx @@ -52,6 +52,9 @@ export const FeedbackLog: React.FC = ({ feedback }) => { Date + + Feedback score + Comment diff --git a/editor.planx.uk/src/pages/FlowEditor/components/Flow/FeedbackLog/components/CollapsibleRow.tsx b/editor.planx.uk/src/pages/FlowEditor/components/Flow/FeedbackLog/components/CollapsibleRow.tsx index 0bfc852501..4ff984ba1c 100644 --- a/editor.planx.uk/src/pages/FlowEditor/components/Flow/FeedbackLog/components/CollapsibleRow.tsx +++ b/editor.planx.uk/src/pages/FlowEditor/components/Flow/FeedbackLog/components/CollapsibleRow.tsx @@ -126,6 +126,17 @@ export const CollapsibleRow: React.FC = (item) => { userContext: "What were you doing?", }; + enum EmojiRating { + Terrible, + Poor, + Average, + Good, + Excellent, + } + + const feedbackScore = + item.feedbackScore && EmojiRating[parseInt(item.feedbackScore) + 1]; // enums are 0-indexed + const renderContent = (key: string, value: any) => { if (key === "combinedHelp" && value) { return ; @@ -144,6 +155,7 @@ export const CollapsibleRow: React.FC = (item) => { {format(new Date(item.createdAt), "dd/MM/yy hh:mm:ss")} + {feedbackScore} {commentSummary} ({ query: gql` - query GetFeebackForFlow($teamSlug: String!, $flowSlug: String!) { + query GetFeedbackForFlow($teamSlug: String!, $flowSlug: String!) { feedback: feedback_summary( order_by: { created_at: asc } where: { @@ -57,6 +58,7 @@ const feedbackRoutes = compose( nodeType: node_type userComment: user_comment userContext: user_context + feedbackScore: feedback_score createdAt: created_at address } diff --git a/hasura.planx.uk/metadata/tables.yaml b/hasura.planx.uk/metadata/tables.yaml index f07ac12be2..e1e4632c98 100644 --- a/hasura.planx.uk/metadata/tables.yaml +++ b/hasura.planx.uk/metadata/tables.yaml @@ -305,15 +305,17 @@ - role: demoUser permission: columns: - - feedback_id - - device - - node_data - address + - created_at + - device + - feedback_id + - feedback_score - feedback_type - help_definition - help_sources - help_text - intersecting_constraints + - node_data - node_id - node_text - node_title @@ -325,7 +327,6 @@ - uprn - user_comment - user_context - - created_at filter: team: flows: @@ -335,15 +336,17 @@ - role: platformAdmin permission: columns: - - feedback_id - - device - - node_data - address + - created_at + - device + - feedback_id + - feedback_score - feedback_type - help_definition - help_sources - help_text - intersecting_constraints + - node_data - node_id - node_text - node_title @@ -355,21 +358,22 @@ - uprn - user_comment - user_context - - created_at filter: {} comment: "" - role: teamEditor permission: columns: - - feedback_id - - device - - node_data - address + - created_at + - device + - feedback_id + - feedback_score - feedback_type - help_definition - help_sources - help_text - intersecting_constraints + - node_data - node_id - node_text - node_title @@ -381,7 +385,6 @@ - uprn - user_comment - user_context - - created_at filter: team: members: diff --git a/hasura.planx.uk/migrations/1730991162717_run_sql_migration/down.sql b/hasura.planx.uk/migrations/1730991162717_run_sql_migration/down.sql new file mode 100644 index 0000000000..bf862e171b --- /dev/null +++ b/hasura.planx.uk/migrations/1730991162717_run_sql_migration/down.sql @@ -0,0 +1,29 @@ +-- Drop the existing feedback_summary view +DROP VIEW IF EXISTS public.feedback_summary; + +-- Recreate the feedback_summary view without feedback_score +CREATE OR REPLACE VIEW "public"."feedback_summary" AS + SELECT fb.id AS feedback_id, + t.slug AS team_slug, + f.slug AS service_slug, + fb.created_at, + fb.node_id, + fb.device, + fb.user_context, + fb.user_comment, + fb.feedback_type, + fb.status, + fb.node_type, + fb.node_data, + COALESCE((fb.node_data ->> 'title'::text), (fb.node_data ->> 'text'::text), (fb.node_data ->> 'flagSet'::text)) AS node_title, + (fb.node_data ->> 'description'::text) AS node_text, + (fb.node_data ->> 'info'::text) AS help_text, + (fb.node_data ->> 'policyRef'::text) AS help_sources, + (fb.node_data ->> 'howMeasured'::text) AS help_definition, + COALESCE(((((fb.user_data -> 'passport'::text) -> 'data'::text) -> '_address'::text) ->> 'single_line_address'::text), ((((fb.user_data -> 'passport'::text) -> 'data'::text) -> '_address'::text) ->> 'title'::text)) AS address, + ((((fb.user_data -> 'passport'::text) -> 'data'::text) -> '_address'::text) ->> 'uprn'::text) AS uprn, + (((fb.user_data -> 'passport'::text) -> 'data'::text) ->> 'proposal.projectType'::text) AS project_type, + (((fb.user_data -> 'passport'::text) -> 'data'::text) ->> 'property.constraints.planning'::text) AS intersecting_constraints + FROM ((feedback fb + LEFT JOIN flows f ON ((f.id = fb.flow_id))) + LEFT JOIN teams t ON ((t.id = fb.team_id))); diff --git a/hasura.planx.uk/migrations/1730991162717_run_sql_migration/up.sql b/hasura.planx.uk/migrations/1730991162717_run_sql_migration/up.sql new file mode 100644 index 0000000000..7aee6db1e7 --- /dev/null +++ b/hasura.planx.uk/migrations/1730991162717_run_sql_migration/up.sql @@ -0,0 +1,26 @@ +CREATE OR REPLACE VIEW "public"."feedback_summary" AS + SELECT fb.id AS feedback_id, + t.slug AS team_slug, + f.slug AS service_slug, + fb.created_at, + fb.node_id, + fb.device, + fb.user_context, + fb.user_comment, + fb.feedback_type, + fb.status, + fb.node_type, + fb.node_data, + COALESCE((fb.node_data ->> 'title'::text), (fb.node_data ->> 'text'::text), (fb.node_data ->> 'flagSet'::text)) AS node_title, + (fb.node_data ->> 'description'::text) AS node_text, + (fb.node_data ->> 'info'::text) AS help_text, + (fb.node_data ->> 'policyRef'::text) AS help_sources, + (fb.node_data ->> 'howMeasured'::text) AS help_definition, + COALESCE(((((fb.user_data -> 'passport'::text) -> 'data'::text) -> '_address'::text) ->> 'single_line_address'::text), ((((fb.user_data -> 'passport'::text) -> 'data'::text) -> '_address'::text) ->> 'title'::text)) AS address, + ((((fb.user_data -> 'passport'::text) -> 'data'::text) -> '_address'::text) ->> 'uprn'::text) AS uprn, + (((fb.user_data -> 'passport'::text) -> 'data'::text) ->> 'proposal.projectType'::text) AS project_type, + (((fb.user_data -> 'passport'::text) -> 'data'::text) ->> 'property.constraints.planning'::text) AS intersecting_constraints, + fb.feedback_score + FROM ((feedback fb + LEFT JOIN flows f ON ((f.id = fb.flow_id))) + LEFT JOIN teams t ON ((t.id = fb.team_id))); From 286a78d6f5ff34095860c9b4f10c3c3ba566b043 Mon Sep 17 00:00:00 2001 From: Jo Humphrey <31373245+jamdelion@users.noreply.github.com> Date: Thu, 7 Nov 2024 16:19:09 +0000 Subject: [PATCH 2/3] slight rename in storybook --- .../components/Feedback/Editor/FeedbackEditor.stories.tsx | 2 +- editor.planx.uk/src/components/Feedback/types.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/editor.planx.uk/src/@planx/components/Feedback/Editor/FeedbackEditor.stories.tsx b/editor.planx.uk/src/@planx/components/Feedback/Editor/FeedbackEditor.stories.tsx index 238eedb3bd..241842dafd 100644 --- a/editor.planx.uk/src/@planx/components/Feedback/Editor/FeedbackEditor.stories.tsx +++ b/editor.planx.uk/src/@planx/components/Feedback/Editor/FeedbackEditor.stories.tsx @@ -4,7 +4,7 @@ import React from "react"; import { FeedbackEditor } from "./Editor"; const meta = { - title: "Editor Components/Feedback", + title: "Editor Components/Feedback modal", component: FeedbackEditor, } satisfies Meta; diff --git a/editor.planx.uk/src/components/Feedback/types.ts b/editor.planx.uk/src/components/Feedback/types.ts index 3b9adb9784..cd01757155 100644 --- a/editor.planx.uk/src/components/Feedback/types.ts +++ b/editor.planx.uk/src/components/Feedback/types.ts @@ -21,6 +21,7 @@ export type FeedbackCategory = | "comment" | "inaccuracy" | "component"; + export type FeedbackView = "banner" | "triage" | FeedbackCategory | "thanks"; export type ClickEvents = "close" | "back" | "triage" | FeedbackCategory; From 4b96353c1b026b0b5f2c7c1a5edc492a76f136cc Mon Sep 17 00:00:00 2001 From: Jo Humphrey <31373245+jamdelion@users.noreply.github.com> Date: Mon, 11 Nov 2024 17:04:55 +0000 Subject: [PATCH 3/3] Change feedback type to number --- .../components/Flow/FeedbackLog/components/CollapsibleRow.tsx | 2 +- editor.planx.uk/src/routes/feedback.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/editor.planx.uk/src/pages/FlowEditor/components/Flow/FeedbackLog/components/CollapsibleRow.tsx b/editor.planx.uk/src/pages/FlowEditor/components/Flow/FeedbackLog/components/CollapsibleRow.tsx index 4ff984ba1c..818eb397f3 100644 --- a/editor.planx.uk/src/pages/FlowEditor/components/Flow/FeedbackLog/components/CollapsibleRow.tsx +++ b/editor.planx.uk/src/pages/FlowEditor/components/Flow/FeedbackLog/components/CollapsibleRow.tsx @@ -135,7 +135,7 @@ export const CollapsibleRow: React.FC = (item) => { } const feedbackScore = - item.feedbackScore && EmojiRating[parseInt(item.feedbackScore) + 1]; // enums are 0-indexed + item.feedbackScore && EmojiRating[item.feedbackScore + 1]; // enums are 0-indexed const renderContent = (key: string, value: any) => { if (key === "combinedHelp" && value) { diff --git a/editor.planx.uk/src/routes/feedback.tsx b/editor.planx.uk/src/routes/feedback.tsx index 7f13292d0a..309c2eb7ad 100644 --- a/editor.planx.uk/src/routes/feedback.tsx +++ b/editor.planx.uk/src/routes/feedback.tsx @@ -18,7 +18,7 @@ export interface Feedback { nodeTitle: string | null; nodeType: keyof typeof ComponentType | null; userComment: string | null; - feedbackScore: string | null; + feedbackScore: number; userContext: string | null; createdAt: string; address: string | null;