Skip to content
This repository was archived by the owner on May 4, 2023. It is now read-only.

Commit f5cb0db

Browse files
Merge pull request #30 from codiga/daniel/update-user-links
daniel/update user links
2 parents 27c5795 + faae7c1 commit f5cb0db

File tree

7 files changed

+71
-23
lines changed

7 files changed

+71
-23
lines changed

public/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
"name": "Codiga",
55
"description": "Create, share and use Code Snippets from your browser",
6-
"version": "0.0.12",
6+
"version": "0.0.13",
77

88
"options_ui": {
99
"page": "options.html",

src/assets/CodigaIcon.tsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import React from "react";
2+
3+
export default function CodigaIcon() {
4+
return (
5+
<svg
6+
width="24"
7+
height="24"
8+
viewBox="0 0 24 24"
9+
fill="none"
10+
xmlns="http://www.w3.org/2000/svg"
11+
>
12+
<path
13+
d="M12.2087 18L22.3306 12V18L12.2087 24L2.08691 18V6L12.2087 0L22.3306 6L12.2087 12L7.14785 9.00004V15L12.2087 18Z"
14+
fill="url(#paint0_linear_1312_15167)"
15+
/>
16+
<path
17+
opacity="0.6"
18+
d="M17.2698 8.99996L12.2088 12L7.14795 8.99996L12.2088 6L17.2698 8.99996Z"
19+
fill="white"
20+
/>
21+
<defs>
22+
<linearGradient
23+
id="paint0_linear_1312_15167"
24+
x1="4.22591"
25+
y1="20.1962"
26+
x2="20.6125"
27+
y2="4.23602"
28+
gradientUnits="userSpaceOnUse"
29+
>
30+
<stop stopColor="#F71C9D" />
31+
<stop offset="1" stopColor="#FC8926" />
32+
</linearGradient>
33+
</defs>
34+
</svg>
35+
);
36+
}

src/components/panel/Panel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import "react-modern-drawer/dist/index.css";
1212

1313
import PanelContent from "./PanelContent";
1414
import Header from "../header";
15-
import { ForChromeWithoutCodigaText } from "../common/CodigaForChrome";
1615
import { CODIGA_API_TOKEN, API_URL } from "../../lib/constants";
16+
import CodigaIcon from "../../assets/CodigaIcon";
1717

1818
const httpLink = new HttpLink({
1919
uri: API_URL,
@@ -53,7 +53,7 @@ const Panel = () => {
5353
{client && (
5454
<ApolloProvider client={client}>
5555
<button onClick={toggleDrawer} className="codiga-panel-opener">
56-
<ForChromeWithoutCodigaText />
56+
<CodigaIcon />
5757
</button>
5858

5959
<Drawer

src/components/panel/PanelContent.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,17 @@ export default function PanelContent({ isOpen }: PanelContentProps) {
7474
) : (
7575
<>
7676
Logged in as{" "}
77-
<a
78-
target="_blank"
79-
rel="noreferrer"
80-
href={`https://app.codiga.io/hub/user/${userData.user.accountType}/${userData.user.username}/assistant`.toLowerCase()}
81-
>
82-
{userData.user.username.toLowerCase()}
83-
</a>
77+
{userData.user.hasSlug && userData.user?.slug ? (
78+
<a
79+
target="_blank"
80+
rel="noreferrer"
81+
href={`https://app.codiga.io/hub/user/${userData.user.slug}/assistant`.toLowerCase()}
82+
>
83+
{userData.user.username}
84+
</a>
85+
) : (
86+
userData.user.username
87+
)}
8488
</>
8589
)}
8690
</p>

src/components/panel/PanelSnippetCard.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,17 @@ const PanelSnippetCard = ({
103103
<div className="card-subheading">
104104
<p className="card-subheading--group" title="The snippet owner">
105105
<UserIcon />
106-
<a
107-
target="_blank"
108-
rel="noreferrer"
109-
href={`https://app.codiga.io/hub/user/${snippet.owner.accountType}/${snippet.owner.username}/assistant`.toLowerCase()}
110-
>
111-
{snippet.owner.username.toLowerCase()}
112-
</a>
106+
{snippet.owner.hasSlug && snippet.owner.slug ? (
107+
<a
108+
target="_blank"
109+
rel="noreferrer"
110+
href={`https://app.codiga.io/hub/user/${snippet.owner.slug}/assistant`.toLowerCase()}
111+
>
112+
{snippet.owner.displayName}
113+
</a>
114+
) : (
115+
<>{snippet.owner.displayName}</>
116+
)}
113117
</p>
114118
{snippet.groups.length > 0 && (
115119
<p

src/graphql/queries.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,9 @@ export const GET_RECIPES_SEMANTIC = gql`
7373
downvotes
7474
upvotes
7575
owner {
76-
username
77-
accountType
76+
displayName
77+
hasSlug
78+
slug
7879
}
7980
groups {
8081
id
@@ -91,16 +92,18 @@ export const GET_RECIPES_SEMANTIC = gql`
9192

9293
export type UserResponse = {
9394
user: {
94-
accountType: string;
9595
username: string;
96+
hasSlug: boolean;
97+
slug?: string;
9698
};
9799
};
98100

99101
export const GET_USER = gql`
100102
query getUser {
101103
user {
102-
accountType
103104
username
105+
hasSlug
106+
slug
104107
}
105108
}
106109
`;

src/lib/types.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ export type AssistantRecipe = {
2020
isPublic: boolean;
2121
isSubscribed: boolean;
2222
owner: {
23-
username: string;
24-
accountType: string;
23+
displayName: string;
24+
hasSlug: boolean;
25+
slug?: string;
2526
};
2627
groups: {
2728
id: number;

0 commit comments

Comments
 (0)