From add30754397ac16bbd4e17e916fe6f12872b1457 Mon Sep 17 00:00:00 2001 From: asharonbaltazar Date: Wed, 7 Dec 2022 11:52:18 -0500 Subject: [PATCH 01/11] feat: create prop for Notification; small readability changes --- .../context/Notifications/NotificationProvider.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/frontend/components/context/Notifications/NotificationProvider.tsx b/frontend/components/context/Notifications/NotificationProvider.tsx index 723319615..644cb4fa9 100644 --- a/frontend/components/context/Notifications/NotificationProvider.tsx +++ b/frontend/components/context/Notifications/NotificationProvider.tsx @@ -7,6 +7,7 @@ type NotificationType = "success" | "error"; export type Notification = { text: string; type: NotificationType; + timeoutMs?: number; }; type NotificationContextState = { @@ -36,14 +37,20 @@ const NotificationProvider = ({ children }: NotificationProviderProps) => { return setNotifications([]); }; - const createNotification = ({ text, type = "success" }: Notification) => { + const createNotification = ({ + text, + type = "success", + timeoutMs = 2000, + }: Notification) => { const doesNotifExist = notifications.some((notif) => notif.text === text); if (doesNotifExist) { return; } - return setNotifications((state) => [...state, { text, type }]); + const newNotification: Notification = { text, type, timeoutMs }; + + return setNotifications((state) => [...state, newNotification]); }; return ( From 349865e6efa4d78930debd86548a7ec8fe089ddf Mon Sep 17 00:00:00 2001 From: asharonbaltazar Date: Wed, 7 Dec 2022 11:52:51 -0500 Subject: [PATCH 02/11] fix: clearNotification now requires string --- .../context/Notifications/Notification.tsx | 2 +- .../context/Notifications/NotificationProvider.tsx | 14 +++++--------- .../context/Notifications/Notifications.tsx | 2 +- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/frontend/components/context/Notifications/Notification.tsx b/frontend/components/context/Notifications/Notification.tsx index 974843cf6..1ee52d797 100644 --- a/frontend/components/context/Notifications/Notification.tsx +++ b/frontend/components/context/Notifications/Notification.tsx @@ -6,7 +6,7 @@ import { Notification as NotificationType } from "./NotificationProvider"; interface NotificationProps { notification: NotificationType; - clearNotification: (text?: string) => void; + clearNotification: (text: string) => void; } const Notification = ({ diff --git a/frontend/components/context/Notifications/NotificationProvider.tsx b/frontend/components/context/Notifications/NotificationProvider.tsx index 644cb4fa9..0f5c174d0 100644 --- a/frontend/components/context/Notifications/NotificationProvider.tsx +++ b/frontend/components/context/Notifications/NotificationProvider.tsx @@ -11,7 +11,7 @@ export type Notification = { }; type NotificationContextState = { - createNotification: ({ text, type }: Notification) => void; + createNotification: (newNotification: Notification) => void; }; const NotificationContext = createContext({ @@ -27,14 +27,10 @@ interface NotificationProviderProps { const NotificationProvider = ({ children }: NotificationProviderProps) => { const [notifications, setNotifications] = useState([]); - const clearNotification = (text?: string) => { - if (text) { - return setNotifications((state) => - state.filter((notif) => notif.text !== text) - ); - } - - return setNotifications([]); + const clearNotification = (text: string) => { + return setNotifications((state) => + state.filter((notif) => notif.text !== text) + ); }; const createNotification = ({ diff --git a/frontend/components/context/Notifications/Notifications.tsx b/frontend/components/context/Notifications/Notifications.tsx index 856331e24..947032730 100644 --- a/frontend/components/context/Notifications/Notifications.tsx +++ b/frontend/components/context/Notifications/Notifications.tsx @@ -3,7 +3,7 @@ import { Notification as NotificationType } from "./NotificationProvider"; interface NoticationsProps { notifications: NotificationType[]; - clearNotification: (text?: string) => void; + clearNotification: (text: string) => void; } const Notifications = ({ From 251426b5597e40d5628afb2da1bc36a8e58f8e65 Mon Sep 17 00:00:00 2001 From: asharonbaltazar Date: Wed, 7 Dec 2022 11:57:39 -0500 Subject: [PATCH 03/11] feat: Add notification timeout --- .../context/Notifications/Notification.tsx | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/frontend/components/context/Notifications/Notification.tsx b/frontend/components/context/Notifications/Notification.tsx index 1ee52d797..5afacc010 100644 --- a/frontend/components/context/Notifications/Notification.tsx +++ b/frontend/components/context/Notifications/Notification.tsx @@ -1,3 +1,4 @@ +import { useEffect, useRef } from "react"; import { faXmarkCircle } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import classnames from "classnames"; @@ -13,6 +14,27 @@ const Notification = ({ notification, clearNotification, }: NotificationProps) => { + const timeout = useRef(); + + const handleClearNotification = () => clearNotification(notification.text); + + const setNotifTimeout = () => { + timeout.current = window.setTimeout( + handleClearNotification, + notification.timeoutMs + ); + }; + + const cancelNotifTimeout = () => { + clearTimeout(timeout.current); + }; + + useEffect(() => { + setNotifTimeout(); + + return cancelNotifTimeout; + }, []); + return (
Date: Wed, 7 Dec 2022 11:58:17 -0500 Subject: [PATCH 04/11] refactor: Change type to ensure notifs within state are Required<> --- frontend/components/context/Notifications/Notification.tsx | 2 +- .../context/Notifications/NotificationProvider.tsx | 6 ++++-- frontend/components/context/Notifications/Notifications.tsx | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/frontend/components/context/Notifications/Notification.tsx b/frontend/components/context/Notifications/Notification.tsx index 5afacc010..0263a05c1 100644 --- a/frontend/components/context/Notifications/Notification.tsx +++ b/frontend/components/context/Notifications/Notification.tsx @@ -6,7 +6,7 @@ import classnames from "classnames"; import { Notification as NotificationType } from "./NotificationProvider"; interface NotificationProps { - notification: NotificationType; + notification: Required; clearNotification: (text: string) => void; } diff --git a/frontend/components/context/Notifications/NotificationProvider.tsx b/frontend/components/context/Notifications/NotificationProvider.tsx index 0f5c174d0..15287e909 100644 --- a/frontend/components/context/Notifications/NotificationProvider.tsx +++ b/frontend/components/context/Notifications/NotificationProvider.tsx @@ -25,7 +25,9 @@ interface NotificationProviderProps { } const NotificationProvider = ({ children }: NotificationProviderProps) => { - const [notifications, setNotifications] = useState([]); + const [notifications, setNotifications] = useState[]>( + [] + ); const clearNotification = (text: string) => { return setNotifications((state) => @@ -44,7 +46,7 @@ const NotificationProvider = ({ children }: NotificationProviderProps) => { return; } - const newNotification: Notification = { text, type, timeoutMs }; + const newNotification: Required = { text, type, timeoutMs }; return setNotifications((state) => [...state, newNotification]); }; diff --git a/frontend/components/context/Notifications/Notifications.tsx b/frontend/components/context/Notifications/Notifications.tsx index 947032730..e0a9afbf2 100644 --- a/frontend/components/context/Notifications/Notifications.tsx +++ b/frontend/components/context/Notifications/Notifications.tsx @@ -2,7 +2,7 @@ import Notification from "./Notification"; import { Notification as NotificationType } from "./NotificationProvider"; interface NoticationsProps { - notifications: NotificationType[]; + notifications: Required[]; clearNotification: (text: string) => void; } From 6050e65a59d0f5e07988a29afdd359e5c93ebaed Mon Sep 17 00:00:00 2001 From: asharonbaltazar Date: Wed, 7 Dec 2022 12:02:01 -0500 Subject: [PATCH 05/11] fix: notif type is optional --- .../components/context/Notifications/NotificationProvider.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/components/context/Notifications/NotificationProvider.tsx b/frontend/components/context/Notifications/NotificationProvider.tsx index 15287e909..d0dd7a1fb 100644 --- a/frontend/components/context/Notifications/NotificationProvider.tsx +++ b/frontend/components/context/Notifications/NotificationProvider.tsx @@ -6,7 +6,7 @@ type NotificationType = "success" | "error"; export type Notification = { text: string; - type: NotificationType; + type?: NotificationType; timeoutMs?: number; }; From 9e1112eb52d421128c897159b543fa96ed464a69 Mon Sep 17 00:00:00 2001 From: asharonbaltazar Date: Wed, 7 Dec 2022 12:04:53 -0500 Subject: [PATCH 06/11] fix: hide notifs wrapper if no notifs --- frontend/components/context/Notifications/Notifications.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/frontend/components/context/Notifications/Notifications.tsx b/frontend/components/context/Notifications/Notifications.tsx index e0a9afbf2..82dcc3e14 100644 --- a/frontend/components/context/Notifications/Notifications.tsx +++ b/frontend/components/context/Notifications/Notifications.tsx @@ -10,6 +10,10 @@ const Notifications = ({ notifications, clearNotification, }: NoticationsProps) => { + if (!notifications.length) { + return null; + } + return (
From 91c8fd14df5e07280ab6f64dabff296ebc37e0e6 Mon Sep 17 00:00:00 2001 From: asharonbaltazar Date: Wed, 7 Dec 2022 12:15:17 -0500 Subject: [PATCH 07/11] feat: add notif type --- frontend/components/context/Notifications/Notification.tsx | 1 + .../components/context/Notifications/NotificationProvider.tsx | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/components/context/Notifications/Notification.tsx b/frontend/components/context/Notifications/Notification.tsx index 0263a05c1..e473ddb52 100644 --- a/frontend/components/context/Notifications/Notification.tsx +++ b/frontend/components/context/Notifications/Notification.tsx @@ -42,6 +42,7 @@ const Notification = ({ { "bg-green-600": notification.type === "success", "bg-red-500": notification.type === "error", + "bg-blue-500": notification.type === "info", } )} role="alert" diff --git a/frontend/components/context/Notifications/NotificationProvider.tsx b/frontend/components/context/Notifications/NotificationProvider.tsx index d0dd7a1fb..b029dc6c6 100644 --- a/frontend/components/context/Notifications/NotificationProvider.tsx +++ b/frontend/components/context/Notifications/NotificationProvider.tsx @@ -2,7 +2,7 @@ import { createContext, ReactNode, useContext, useState } from "react"; import Notifications from "./Notifications"; -type NotificationType = "success" | "error"; +type NotificationType = "success" | "error" | "info"; export type Notification = { text: string; From 7bbaf4fee8d04dbabb804d651b6f56425d3774cd Mon Sep 17 00:00:00 2001 From: asharonbaltazar Date: Wed, 7 Dec 2022 12:16:53 -0500 Subject: [PATCH 08/11] feat: move notifs to bottom right --- .../context/Notifications/Notifications.tsx | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/frontend/components/context/Notifications/Notifications.tsx b/frontend/components/context/Notifications/Notifications.tsx index 82dcc3e14..6940c3345 100644 --- a/frontend/components/context/Notifications/Notifications.tsx +++ b/frontend/components/context/Notifications/Notifications.tsx @@ -15,16 +15,14 @@ const Notifications = ({ } return ( -
-
- {notifications.map((notif) => ( - - ))} -
+
+ {notifications.map((notif) => ( + + ))}
); }; From 27353848c1cbbef32beed2dacd06e1ec72fb6d0c Mon Sep 17 00:00:00 2001 From: Reginald Bondoc Date: Wed, 7 Dec 2022 23:25:41 +0100 Subject: [PATCH 09/11] Add PR gate workflows --- .github/workflows/check-be-pull-request.yml | 41 +++++++++++++++++++++ .github/workflows/check-fe-pull-request.yml | 41 +++++++++++++++++++++ .github/workflows/docker-image.yml | 8 ++-- 3 files changed, 86 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/check-be-pull-request.yml create mode 100644 .github/workflows/check-fe-pull-request.yml diff --git a/.github/workflows/check-be-pull-request.yml b/.github/workflows/check-be-pull-request.yml new file mode 100644 index 000000000..f17d8c5c8 --- /dev/null +++ b/.github/workflows/check-be-pull-request.yml @@ -0,0 +1,41 @@ +name: Check Backend Pull Request + +on: + pull_request: + types: [ opened, synchronize ] + paths: + - 'backend/**' + - '!backend/README.md' + - '!backend/.*' + - 'backend/.eslintrc.js' + + +jobs: + + check-be-pr: + name: Check + runs-on: ubuntu-latest + + steps: + - + name: โ˜๏ธ Checkout source + uses: actions/checkout@v3 + - + name: ๐Ÿ”ง Setup Node 16 + uses: actions/setup-node@v3 + with: + node-version: '16' + cache: 'npm' + cache-dependency-path: backend/package-lock.json + - + name: ๐Ÿ“ฆ Install dependencies + run: npm ci --only-production --ignore-scripts + working-directory: backend + # - + # name: ๐Ÿงช Run tests + # run: npm run test:ci + # working-directory: backend + - + name: ๐Ÿ—๏ธ Run build + run: npm run build + working-directory: backend diff --git a/.github/workflows/check-fe-pull-request.yml b/.github/workflows/check-fe-pull-request.yml new file mode 100644 index 000000000..b91e6f060 --- /dev/null +++ b/.github/workflows/check-fe-pull-request.yml @@ -0,0 +1,41 @@ +name: Check Frontend Pull Request + +on: + pull_request: + types: [ opened, synchronize ] + paths: + - 'frontend/**' + - '!frontend/README.md' + - '!frontend/.*' + - 'frontend/.eslintrc.js' + + +jobs: + + check-fe-pr: + name: Check + runs-on: ubuntu-latest + + steps: + - + name: โ˜๏ธ Checkout source + uses: actions/checkout@v3 + - + name: ๐Ÿ”ง Setup Node 16 + uses: actions/setup-node@v3 + with: + node-version: '16' + cache: 'npm' + cache-dependency-path: frontend/package-lock.json + - + name: ๐Ÿ“ฆ Install dependencies + run: npm ci --only-production --ignore-scripts + working-directory: frontend + # - + # name: ๐Ÿงช Run tests + # run: npm run test:ci + # working-directory: frontend + - + name: ๐Ÿ—๏ธ Run build + run: npm run build + working-directory: frontend diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 769a5f7a3..3856122f1 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -11,7 +11,7 @@ jobs: steps: - name: โ˜๏ธ Checkout source - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: ๐Ÿ”ง Set up QEMU uses: docker/setup-qemu-action@v2 @@ -36,7 +36,7 @@ jobs: # run: | # docker run --rm infisical/backend:test - - name: ๐Ÿ“ฆ Build backend and push + name: ๐Ÿ—๏ธ Build backend and push uses: docker/build-push-action@v3 with: push: true @@ -52,7 +52,7 @@ jobs: steps: - name: โ˜๏ธ Checkout source - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: ๐Ÿ”ง Set up QEMU uses: docker/setup-qemu-action@v2 @@ -79,7 +79,7 @@ jobs: # run: | # docker run --rm infisical/frontend:test - - name: ๐Ÿ“ฆ Build frontend and push + name: ๐Ÿ—๏ธ Build frontend and push uses: docker/build-push-action@v3 with: push: true From ec85bfca04df532b5cb7506ebcf40c85ba425b02 Mon Sep 17 00:00:00 2001 From: Reginald Bondoc Date: Wed, 7 Dec 2022 23:45:19 +0100 Subject: [PATCH 10/11] Fix frontend build-arg --- .github/workflows/docker-image.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 3856122f1..e85ddcfd5 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -86,3 +86,5 @@ jobs: context: frontend tags: infisical/frontend:latest platforms: linux/amd64,linux/arm64 + build-args: | + POSTHOG_API_KEY=${{ secrets.PUBLIC_POSTHOG_API_KEY }} From 7b1be82bace1d1f2fb39868d61d7ff6811a4b81c Mon Sep 17 00:00:00 2001 From: mv-turtle <78047717+mv-turtle@users.noreply.github.com> Date: Wed, 7 Dec 2022 23:45:29 -0500 Subject: [PATCH 11/11] Update README.md --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index eadd4723f..4e0b7a053 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,12 @@ And more. To quickly get started, visit our [get started guide](https://infisical.com/docs/getting-started/introduction). +

+ + + +

+ ## ๐Ÿ”ฅ What's cool about this? Infisical makes secret management simple and end-to-end encrypted by default. We're on a mission to make it more accessible to all developers, not just security teams. @@ -279,4 +285,4 @@ Looking to report a security vulnerability? Please don't post about it in GitHub - +