Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Display feedback score in feedback log #3941

Closed
wants to merge 3 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof FeedbackEditor>;

Expand Down
1 change: 1 addition & 0 deletions editor.planx.uk/src/components/Feedback/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export type FeedbackCategory =
| "comment"
| "inaccuracy"
| "component";

export type FeedbackView = "banner" | "triage" | FeedbackCategory | "thanks";
export type ClickEvents = "close" | "back" | "triage" | FeedbackCategory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ export const FeedbackLog: React.FC<FeedbackLogProps> = ({ feedback }) => {
<TableCell sx={{ width: 100 }}>
<strong>Date</strong>
</TableCell>
<TableCell sx={{ width: 140 }}>
<strong>Feedback score</strong>
</TableCell>
<TableCell sx={{ width: 340 }}>
<strong>Comment</strong>
</TableCell>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,17 @@ export const CollapsibleRow: React.FC<CollapsibleRowProps> = (item) => {
userContext: "What were you doing?",
};

enum EmojiRating {
Terrible,
Poor,
Average,
Good,
Excellent,
}

const feedbackScore =
item.feedbackScore && EmojiRating[item.feedbackScore + 1]; // enums are 0-indexed

const renderContent = (key: string, value: any) => {
if (key === "combinedHelp" && value) {
return <ReactMarkdownOrHtml source={value} openLinksOnNewTab />;
Expand All @@ -144,6 +155,7 @@ export const CollapsibleRow: React.FC<CollapsibleRowProps> = (item) => {
<TableCell>
{format(new Date(item.createdAt), "dd/MM/yy hh:mm:ss")}
</TableCell>
<TableCell sx={{ textAlign: "center" }}>{feedbackScore}</TableCell>
<TableCell>{commentSummary}</TableCell>
<TableCell sx={{ textAlign: "right" }}>
<IconButton
Expand Down
4 changes: 3 additions & 1 deletion editor.planx.uk/src/routes/feedback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface Feedback {
nodeTitle: string | null;
nodeType: keyof typeof ComponentType | null;
userComment: string | null;
feedbackScore: number;
userContext: string | null;
createdAt: string;
address: string | null;
Expand All @@ -43,7 +44,7 @@ const feedbackRoutes = compose(
data: { feedback },
} = await client.query<{ feedback: Feedback[] }>({
query: gql`
query GetFeebackForFlow($teamSlug: String!, $flowSlug: String!) {
query GetFeedbackForFlow($teamSlug: String!, $flowSlug: String!) {
feedback: feedback_summary(
order_by: { created_at: asc }
where: {
Expand All @@ -57,6 +58,7 @@ const feedbackRoutes = compose(
nodeType: node_type
userComment: user_comment
userContext: user_context
feedbackScore: feedback_score
createdAt: created_at
address
}
Expand Down
27 changes: 15 additions & 12 deletions hasura.planx.uk/metadata/tables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -325,7 +327,6 @@
- uprn
- user_comment
- user_context
- created_at
filter:
team:
flows:
Expand All @@ -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
Expand All @@ -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
Expand All @@ -381,7 +385,6 @@
- uprn
- user_comment
- user_context
- created_at
filter:
team:
members:
Expand Down
Original file line number Diff line number Diff line change
@@ -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)));
26 changes: 26 additions & 0 deletions hasura.planx.uk/migrations/1730991162717_run_sql_migration/up.sql
Original file line number Diff line number Diff line change
@@ -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)));
Loading