From 3945728c033c040d015a5b2db937b9b6d47f7800 Mon Sep 17 00:00:00 2001 From: Jacek Chmielewski Date: Mon, 12 Aug 2024 11:13:50 +0200 Subject: [PATCH] Add CI linting on dev branch --- .github/workflows/lint-e2e.yml | 2 ++ .github/workflows/lint-web.yml | 2 ++ web/src/components/App/App.tsx | 2 +- web/src/i18n/en/index.ts | 17 +++++++----- web/src/i18n/pl/index.ts | 20 +++++++++----- web/src/pages/auth/AuthPage.tsx | 2 +- web/src/pages/auth/Callback/Callback.tsx | 16 ++++++------ .../auth/Login/components/OidcButtons.tsx | 2 ++ .../pages/auth/Login/components/style.scss | 26 +++++++++++++------ .../components/OpenIdGeneralSettings.tsx | 2 +- .../components/OpenIdSettingsForm.tsx | 11 ++++---- 11 files changed, 64 insertions(+), 38 deletions(-) diff --git a/.github/workflows/lint-e2e.yml b/.github/workflows/lint-e2e.yml index 9ab23a86f1..ac4257c7f7 100644 --- a/.github/workflows/lint-e2e.yml +++ b/.github/workflows/lint-e2e.yml @@ -2,11 +2,13 @@ on: push: branches: - main + - dev paths: - "e2e/**" pull_request: branches: - main + - dev paths: - "e2e/**" diff --git a/.github/workflows/lint-web.yml b/.github/workflows/lint-web.yml index 0b76809405..6ed96e2917 100644 --- a/.github/workflows/lint-web.yml +++ b/.github/workflows/lint-web.yml @@ -2,11 +2,13 @@ on: push: branches: - main + - dev paths: - "web/**" pull_request: branches: - main + - dev paths: - "web/**" diff --git a/web/src/components/App/App.tsx b/web/src/components/App/App.tsx index 56fa6e5eef..6e94143410 100644 --- a/web/src/components/App/App.tsx +++ b/web/src/components/App/App.tsx @@ -1,7 +1,7 @@ import 'react-loading-skeleton/dist/skeleton.css'; import './App.scss'; -import { Navigate, Route, BrowserRouter as Router, Routes } from 'react-router-dom'; +import { BrowserRouter as Router, Navigate, Route, Routes } from 'react-router-dom'; import { AddDevicePage } from '../../pages/addDevice/AddDevicePage'; import { OpenidAllowPage } from '../../pages/allow/OpenidAllowPage'; diff --git a/web/src/i18n/en/index.ts b/web/src/i18n/en/index.ts index a5ed451099..0b7e4221d5 100644 --- a/web/src/i18n/en/index.ts +++ b/web/src/i18n/en/index.ts @@ -926,20 +926,24 @@ const en: BaseTranslation = { title: 'External OpenID Settings', helper: 'Here you can change general OpenID behavior in your Defguard instance.', createAccount: { - label: 'Automatically create user account when logging in for the first time through external OpenID.', - helper: 'If this option is enabled, Defguard automatically creates new accounts for users who log in for the first time using an external OpenID provider. Otherwise, the user account must first be created by an administrator.', + label: + 'Automatically create user account when logging in for the first time through external OpenID.', + helper: + 'If this option is enabled, Defguard automatically creates new accounts for users who log in for the first time using an external OpenID provider. Otherwise, the user account must first be created by an administrator.', }, }, form: { title: 'External OpenID Client Settings', - helper: 'Here you can configure the OpenID client settings with values provided by your external OpenID provider.', - custom: "Custom", + helper: + 'Here you can configure the OpenID client settings with values provided by your external OpenID provider.', + custom: 'Custom', documentation: 'Documentation', delete: 'Delete provider', labels: { provider: { label: 'Provider', - helper: 'Select your OpenID provider. You can use custom provider and fill in the base URL by yourself.', + helper: + 'Select your OpenID provider. You can use custom provider and fill in the base URL by yourself.', }, client_id: { label: 'Client ID', @@ -951,7 +955,8 @@ const en: BaseTranslation = { }, base_url: { label: 'Base URL', - helper: 'Base URL of your OpenID provider, e.g. https://accounts.google.com. Make sure to check our documentation for more information and examples.', + helper: + 'Base URL of your OpenID provider, e.g. https://accounts.google.com. Make sure to check our documentation for more information and examples.', }, }, }, diff --git a/web/src/i18n/pl/index.ts b/web/src/i18n/pl/index.ts index e557a292c7..53484b6311 100644 --- a/web/src/i18n/pl/index.ts +++ b/web/src/i18n/pl/index.ts @@ -910,22 +910,27 @@ Uwaga, podane tutaj konfiguracje nie posiadają klucza prywatnego. Musisz uzupe openIdSettings: { general: { title: 'Ustawienia zewnętrznego OpenID', - helper: 'Możesz tu zmienić ogólną mechanikę działania zewnętrznego OpenID w twojej instancji Defguarda.', + helper: + 'Możesz tu zmienić ogólną mechanikę działania zewnętrznego OpenID w twojej instancji Defguarda.', createAccount: { - label: 'Automatycznie twórz konta w momencie logowania przez zewnętrznego dostawcę OpenID', - helper: 'Jeśli ta opcja jest włączona, Defguard automatycznie tworzy nowe konta dla użytkowników, którzy logują się po raz pierwszy za pomocą zewnętrznego dostawcy OpenID. W innym przypadku konto użytkownika musi zostać najpierw utworzone przez administratora.', + label: + 'Automatycznie twórz konta w momencie logowania przez zewnętrznego dostawcę OpenID', + helper: + 'Jeśli ta opcja jest włączona, Defguard automatycznie tworzy nowe konta dla użytkowników, którzy logują się po raz pierwszy za pomocą zewnętrznego dostawcy OpenID. W innym przypadku konto użytkownika musi zostać najpierw utworzone przez administratora.', }, }, form: { title: 'Ustawienia klienta zewnętrznego OpenID', - helper: 'Tutaj możesz skonfigurować ustawienia klienta OpenID z wartościami dostarczonymi przez zewnętrznego dostawcę OpenID.', - custom: "Niestandardowy", + helper: + 'Tutaj możesz skonfigurować ustawienia klienta OpenID z wartościami dostarczonymi przez zewnętrznego dostawcę OpenID.', + custom: 'Niestandardowy', documentation: 'Dokumentacja', delete: 'Usuń dostawcę', labels: { provider: { label: 'Dostawca', - helper: 'Wybierz swojego dostawcę OpenID. Możesz użyć dostawcy niestandardowego i samodzielnie wypełnić pole URL bazowego.', + helper: + 'Wybierz swojego dostawcę OpenID. Możesz użyć dostawcy niestandardowego i samodzielnie wypełnić pole URL bazowego.', }, client_id: { label: 'ID klienta', @@ -937,7 +942,8 @@ Uwaga, podane tutaj konfiguracje nie posiadają klucza prywatnego. Musisz uzupe }, base_url: { label: 'URL bazowy', - helper: 'Podstawowy adres URL twojego dostawcy OpenID, np. https://accounts.google.com. Sprawdź naszą dokumentację, aby uzyskać więcej informacji i zobaczyć przykłady.', + helper: + 'Podstawowy adres URL twojego dostawcy OpenID, np. https://accounts.google.com. Sprawdź naszą dokumentację, aby uzyskać więcej informacji i zobaczyć przykłady.', }, }, }, diff --git a/web/src/pages/auth/AuthPage.tsx b/web/src/pages/auth/AuthPage.tsx index ff734aed3a..950934b20e 100644 --- a/web/src/pages/auth/AuthPage.tsx +++ b/web/src/pages/auth/AuthPage.tsx @@ -13,10 +13,10 @@ import useApi from '../../shared/hooks/useApi'; import { useToaster } from '../../shared/hooks/useToaster'; import { UserMFAMethod } from '../../shared/types'; import { RedirectPage } from '../redirect/RedirectPage'; +import { OpenIDCallback } from './Callback/Callback'; import { Login } from './Login/Login'; import { MFARoute } from './MFARoute/MFARoute'; import { useMFAStore } from './shared/hooks/useMFAStore'; -import { OpenIDCallback } from './Callback/Callback'; export const AuthPage = () => { const { diff --git a/web/src/pages/auth/Callback/Callback.tsx b/web/src/pages/auth/Callback/Callback.tsx index 92256abc29..d376b8d63a 100644 --- a/web/src/pages/auth/Callback/Callback.tsx +++ b/web/src/pages/auth/Callback/Callback.tsx @@ -2,17 +2,17 @@ import './style.scss'; import { useMutation } from '@tanstack/react-query'; import { AxiosError } from 'axios'; - import { useEffect, useState } from 'react'; +import { useNavigate } from 'react-router'; + +import { useI18nContext } from '../../../i18n/i18n-react'; +import { Button } from '../../../shared/defguard-ui/components/Layout/Button/Button'; +import { LoaderSpinner } from '../../../shared/defguard-ui/components/Layout/LoaderSpinner/LoaderSpinner'; +import { useAuthStore } from '../../../shared/hooks/store/useAuthStore'; import useApi from '../../../shared/hooks/useApi'; +import { useToaster } from '../../../shared/hooks/useToaster'; import { MutationKeys } from '../../../shared/mutations'; import { CallbackData } from '../../../shared/types'; -import { useAuthStore } from '../../../shared/hooks/store/useAuthStore'; -import { LoaderSpinner } from '../../../shared/defguard-ui/components/Layout/LoaderSpinner/LoaderSpinner'; -import { useToaster } from '../../../shared/hooks/useToaster'; -import { useI18nContext } from '../../../i18n/i18n-react'; -import { Button } from '../../../shared/defguard-ui/components/Layout/Button/Button'; -import { useNavigate } from 'react-router'; export const OpenIDCallback = () => { const { @@ -61,7 +61,7 @@ export const OpenIDCallback = () => { callbackMutation.mutate(data); } } - }, []); + }, [LL.messages, callbackMutation, toaster]); // TODO: Perhaphs make it a bit more user friendly return error ? ( diff --git a/web/src/pages/auth/Login/components/OidcButtons.tsx b/web/src/pages/auth/Login/components/OidcButtons.tsx index a073a238ec..d2e339c58c 100644 --- a/web/src/pages/auth/Login/components/OidcButtons.tsx +++ b/web/src/pages/auth/Login/components/OidcButtons.tsx @@ -1,4 +1,6 @@ +/* eslint-disable max-len */ import './style.scss'; + import { Button } from '../../../../shared/defguard-ui/components/Layout/Button/Button'; import { ButtonSize, diff --git a/web/src/pages/auth/Login/components/style.scss b/web/src/pages/auth/Login/components/style.scss index dd798a7518..422c0fcec8 100644 --- a/web/src/pages/auth/Login/components/style.scss +++ b/web/src/pages/auth/Login/components/style.scss @@ -21,8 +21,14 @@ padding: 0 12px; position: relative; text-align: center; - -webkit-transition: background-color .218s, border-color .218s, box-shadow .218s; - transition: background-color .218s, border-color .218s, box-shadow .218s; + -webkit-transition: + background-color 0.218s, + border-color 0.218s, + box-shadow 0.218s; + transition: + background-color 0.218s, + border-color 0.218s, + box-shadow 0.218s; vertical-align: middle; white-space: nowrap; width: auto; @@ -62,8 +68,8 @@ } .gsi-material-button .gsi-material-button-state { - -webkit-transition: opacity .218s; - transition: opacity .218s; + -webkit-transition: opacity 0.218s; + transition: opacity 0.218s; bottom: 0; left: 0; opacity: 0; @@ -86,15 +92,19 @@ opacity: 38%; } -.gsi-material-button:not(:disabled):active .gsi-material-button-state, +.gsi-material-button:not(:disabled):active .gsi-material-button-state, .gsi-material-button:not(:disabled):focus .gsi-material-button-state { background-color: #303030; opacity: 12%; } .gsi-material-button:not(:disabled):hover { - -webkit-box-shadow: 0 1px 2px 0 rgba(60, 64, 67, .30), 0 1px 3px 1px rgba(60, 64, 67, .15); - box-shadow: 0 1px 2px 0 rgba(60, 64, 67, .30), 0 1px 3px 1px rgba(60, 64, 67, .15); + -webkit-box-shadow: + 0 1px 2px 0 rgba(60, 64, 67, 0.3), + 0 1px 3px 1px rgba(60, 64, 67, 0.15); + box-shadow: + 0 1px 2px 0 rgba(60, 64, 67, 0.3), + 0 1px 3px 1px rgba(60, 64, 67, 0.15); } .gsi-material-button:not(:disabled):hover .gsi-material-button-state { @@ -107,4 +117,4 @@ border: none; cursor: pointer; padding: 0; -} \ No newline at end of file +} diff --git a/web/src/pages/settings/components/OpenIdSettings/components/OpenIdGeneralSettings.tsx b/web/src/pages/settings/components/OpenIdSettings/components/OpenIdGeneralSettings.tsx index e768e9f80c..f3d0a600c9 100644 --- a/web/src/pages/settings/components/OpenIdSettings/components/OpenIdGeneralSettings.tsx +++ b/web/src/pages/settings/components/OpenIdSettings/components/OpenIdGeneralSettings.tsx @@ -1,8 +1,8 @@ import './style.scss'; import { useMutation, useQueryClient } from '@tanstack/react-query'; - import parse from 'html-react-parser'; + import { useI18nContext } from '../../../../../i18n/i18n-react'; import { Helper } from '../../../../../shared/defguard-ui/components/Layout/Helper/Helper'; import { LabeledCheckbox } from '../../../../../shared/defguard-ui/components/Layout/LabeledCheckbox/LabeledCheckbox'; diff --git a/web/src/pages/settings/components/OpenIdSettings/components/OpenIdSettingsForm.tsx b/web/src/pages/settings/components/OpenIdSettings/components/OpenIdSettingsForm.tsx index 336d9c0fad..e027f861b0 100644 --- a/web/src/pages/settings/components/OpenIdSettings/components/OpenIdSettingsForm.tsx +++ b/web/src/pages/settings/components/OpenIdSettings/components/OpenIdSettingsForm.tsx @@ -2,11 +2,11 @@ import './style.scss'; import { zodResolver } from '@hookform/resolvers/zod'; import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'; +import parse from 'html-react-parser'; import { useCallback, useEffect, useMemo, useState } from 'react'; import { SubmitHandler, useForm } from 'react-hook-form'; import { z } from 'zod'; -import parse from 'html-react-parser'; import { useI18nContext } from '../../../../../i18n/i18n-react'; import IconCheckmarkWhite from '../../../../../shared/components/svg/IconCheckmarkWhite'; import { FormInput } from '../../../../../shared/defguard-ui/components/Form/FormInput/FormInput'; @@ -34,6 +34,8 @@ export const OpenIdSettingsForm = () => { const localLL = LL.settingsPage.openIdSettings; const [currentProvider, setCurrentProvider] = useState(null); const queryClient = useQueryClient(); + const docsLink = + 'https://defguard.gitbook.io/defguard/admin-and-features/external-openid-providers'; const { settings: { fetchOpenIdProviders, addOpenIdProvider, deleteOpenIdProvider }, @@ -141,7 +143,7 @@ export const OpenIdSettingsForm = () => { key: 3, }, ], - [], + [localLL.form], ); const renderSelected = useCallback( @@ -239,10 +241,7 @@ export const OpenIdSettingsForm = () => { type="password" /> - + {localLL.form.documentation()}