This is an automated email from the ASF dual-hosted git repository. porcelli pushed a commit to branch KOGITO-8015-feature-preview in repository https://gitbox.apache.org/repos/asf/incubator-kie-tools-temporary-rnd-do-not-use.git
commit e0d6379b2a685b690485aa331932bbec7af9a943 Author: Fabrizio Antonangeli <[email protected]> AuthorDate: Fri Feb 10 11:16:00 2023 +0100 KOGITO-8628: Remove old settings modal (#1457) * Replaced use of old settings components * Removed old settings dir * Empty commit * Fix lint warnings --- packages/serverless-logic-web-tools/src/App.tsx | 2 - .../src/editor/Deploy/DeployDropdownItems.tsx | 9 +- .../src/editor/EditorToolbar.tsx | 27 +- .../src/homepage/pageTemplate/OnlineEditorPage.tsx | 2 +- .../KieSandboxExtendedServicesIcon.tsx | 10 +- .../src/navigation/RoutesSwitch.tsx | 2 +- .../src/newSettings/SettingsButton.tsx | 35 --- .../src/newSettings/SettingsContext.tsx | 322 -------------------- .../featurePreview/FeaturePreviewConfig.tsx | 42 --- .../src/newSettings/github/Hooks.tsx | 34 --- .../src/newSettings/kafka/KafkaSettingsConfig.tsx | 70 ----- .../openshift/OpenShiftSettingsConfig.tsx | 58 ---- .../serviceAccount/ServiceAccountConfig.tsx | 66 ---- .../serviceRegistry/ServiceRegistryConfig.tsx | 66 ---- .../dropdown/OpenshiftDeploymentsDropdown.tsx | 8 +- .../src/settings/SettingsButton.tsx | 17 +- .../src/settings/SettingsContext.tsx | 79 +---- .../src/settings/SettingsModalBody.tsx | 100 ------- .../KieSandboxExtendedServicesSettings.tsx | 0 .../KieSandboxExtendedServicesSettingsTab.tsx | 225 -------------- .../featurePreview/FeaturePreviewConfig.tsx | 2 +- .../featurePreview/FeaturePreviewSettings.tsx | 0 .../featurePreview/FeaturePreviewSettingsTab.tsx | 71 ----- .../github/GitHubSettings.tsx | 0 .../src/settings/github/GitHubSettingsTab.tsx | 216 -------------- .../kafka/ApacheKafkaSettings.tsx | 0 .../src/settings/kafka/ApacheKafkaSettingsTab.tsx | 246 --------------- .../openshift/OpenShiftSettings.tsx | 0 .../openshift/OpenShiftSettingsSimpleConfig.tsx | 0 .../settings/openshift/OpenShiftSettingsTab.tsx | 88 ------ .../openshift/OpenShiftSettingsTabSimpleConfig.tsx | 332 --------------------- .../routes/SettingsPageRoutes.tsx | 0 .../serviceAccount/ServiceAccountConfig.tsx | 2 +- .../serviceAccount/ServiceAccountSettings.tsx | 0 .../serviceAccount/ServiceAccountSettingsTab.tsx | 261 ---------------- .../serviceRegistry/ServiceRegistryConfig.tsx | 2 +- .../serviceRegistry/ServiceRegistrySettings.tsx | 7 +- .../serviceRegistry/ServiceRegistrySettingsTab.tsx | 257 ---------------- .../src/{newSettings => settings}/types.ts | 0 .../uiNav/SettingsPageNav.tsx | 0 40 files changed, 59 insertions(+), 2599 deletions(-) diff --git a/packages/serverless-logic-web-tools/src/App.tsx b/packages/serverless-logic-web-tools/src/App.tsx index 6041811fe6..f44b318453 100644 --- a/packages/serverless-logic-web-tools/src/App.tsx +++ b/packages/serverless-logic-web-tools/src/App.tsx @@ -24,7 +24,6 @@ import { NavigationContextProvider } from "./navigation/NavigationContextProvide import { RoutesSwitch } from "./navigation/RoutesSwitch"; import { OpenShiftContextProvider } from "./openshift/OpenShiftContextProvider"; import { SettingsContextProvider } from "./settings/SettingsContext"; -import { SettingsContextProvider as NewSettingsContextProvider } from "./newSettings/SettingsContext"; import { VirtualServiceRegistryContextProvider } from "./virtualServiceRegistry/VirtualServiceRegistryContextProvider"; import { WorkspacesContextProvider } from "@kie-tools-core/workspaces-git-fs/dist/context/WorkspacesContextProvider"; @@ -36,7 +35,6 @@ export const App = () => ( [EnvContextProvider, {}], [KieSandboxExtendedServicesContextProvider, {}], [SettingsContextProvider, {}], - [NewSettingsContextProvider, {}], [ WorkspacesContextProvider, { workspacesSharedWorkerScriptUrl: "workspace/worker/sharedWorker.js", shouldRequireCommitMessage: false }, diff --git a/packages/serverless-logic-web-tools/src/editor/Deploy/DeployDropdownItems.tsx b/packages/serverless-logic-web-tools/src/editor/Deploy/DeployDropdownItems.tsx index aa55b29edb..cf7fb21ca7 100644 --- a/packages/serverless-logic-web-tools/src/editor/Deploy/DeployDropdownItems.tsx +++ b/packages/serverless-logic-web-tools/src/editor/Deploy/DeployDropdownItems.tsx @@ -34,15 +34,16 @@ import { KieSandboxExtendedServicesStatus } from "../../kieSandboxExtendedServic import { useOpenShift } from "../../openshift/OpenShiftContext"; import { OpenShiftInstanceStatus } from "../../openshift/OpenShiftInstanceStatus"; import { useSettings, useSettingsDispatch } from "../../settings/SettingsContext"; -import { SettingsTabs } from "../../settings/SettingsModalBody"; import { useVirtualServiceRegistryDependencies } from "../../virtualServiceRegistry/hooks/useVirtualServiceRegistryDependencies"; import { FileLabel } from "../../workspace/components/FileLabel"; import { ActiveWorkspace } from "@kie-tools-core/workspaces-git-fs/dist/model/ActiveWorkspace"; +import { useHistory } from "react-router"; +import { routes } from "../../navigation/Routes"; export function useDeployDropdownItems(props: { workspace: ActiveWorkspace }) { const { i18n } = useAppI18n(); const settings = useSettings(); - const settingsDispatch = useSettingsDispatch(); + const history = useHistory(); const kieSandboxExtendedServices = useKieSandboxExtendedServices(); const openshift = useOpenShift(); const { needsDependencyDeployment } = useVirtualServiceRegistryDependencies({ @@ -60,8 +61,8 @@ export function useDeployDropdownItems(props: { workspace: ActiveWorkspace }) { ); const onSetup = useCallback(() => { - settingsDispatch.open(SettingsTabs.OPENSHIFT); - }, [settingsDispatch]); + history.push(routes.settings.openshift.path({})); + }, [history]); const onDeploy = useCallback(() => { if (isKieSandboxExtendedServicesRunning) { diff --git a/packages/serverless-logic-web-tools/src/editor/EditorToolbar.tsx b/packages/serverless-logic-web-tools/src/editor/EditorToolbar.tsx index d1d2620bf8..20348a49c8 100644 --- a/packages/serverless-logic-web-tools/src/editor/EditorToolbar.tsx +++ b/packages/serverless-logic-web-tools/src/editor/EditorToolbar.tsx @@ -71,7 +71,6 @@ import { import { useCancelableEffect } from "@kie-tools-core/react-hooks/dist/useCancelableEffect"; import { useGitHubAuthInfo } from "../settings/github/Hooks"; import { AuthStatus, GithubScopes, useSettings, useSettingsDispatch } from "../settings/SettingsContext"; -import { SettingsTabs } from "../settings/SettingsModalBody"; import { FileLabel } from "../workspace/components/FileLabel"; import { WorkspaceLabel } from "../workspace/components/WorkspaceLabel"; import { PromiseStateWrapper } from "@kie-tools-core/react-hooks/dist/PromiseState"; @@ -94,6 +93,8 @@ import { WorkspaceStatusIndicator } from "../workspace/components/WorkspaceStatu import { WorkspaceKind } from "@kie-tools-core/workspaces-git-fs/dist/worker/api/WorkspaceOrigin"; import { useEditorEnvelopeLocator } from "../envelopeLocator/EditorEnvelopeLocatorContext"; import { UrlType, useImportableUrl } from "../workspace/hooks/ImportableUrlHooks"; +import { Link } from "react-router-dom"; +import { routes } from "../navigation/Routes"; export interface Props { alerts: AlertsController | undefined; @@ -727,10 +728,12 @@ If you are, it means that creating this Gist failed and it can safely be deleted {!canPushToGitRepository && ( <> <Divider /> - <DropdownItem onClick={() => settingsDispatch.open(SettingsTabs.GITHUB)}> - <Button isInline={true} variant={ButtonVariant.link}> - Configure GitHub token... - </Button> + <DropdownItem> + <Link to={routes.settings.github.path({})}> + <Button isInline={true} variant={ButtonVariant.link}> + Configure GitHub token... + </Button> + </Link> </DropdownItem> </> )} @@ -748,7 +751,7 @@ If you are, it means that creating this Gist failed and it can safely be deleted downloadWorkspaceZip, i18n, canCreateGitRepository, - settingsDispatch, + routes, ] ); @@ -1072,7 +1075,7 @@ If you are, it means that creating this Gist failed and it can safely be deleted )} {!canPushToGitRepository && ( - <AlertActionLink onClick={() => settingsDispatch.open(SettingsTabs.GITHUB)}> + <AlertActionLink onClick={() => history.push(routes.settings.github.path({}))}> {`Configure GitHub token...`} </AlertActionLink> )} @@ -1088,7 +1091,7 @@ If you are, it means that creating this Gist failed and it can safely be deleted </Alert> ); }, - [canPushToGitRepository, pushNewBranch, settingsDispatch, workspacePromise] + [canPushToGitRepository, pushNewBranch, workspacePromise, history, routes] ) ); @@ -1603,7 +1606,7 @@ If you are, it means that creating this Gist failed and it can safely be deleted {!canPushToGitRepository && ( <> <Divider /> - <DropdownItem onClick={() => settingsDispatch.open(SettingsTabs.GITHUB)}> + <DropdownItem onClick={() => history.push(routes.settings.github.path({}))}> <Button isInline={true} variant={ButtonVariant.link}> Configure GitHub token... </Button> @@ -1661,7 +1664,7 @@ If you are, it means that creating this Gist failed and it can safely be deleted {!canPushToGitRepository && ( <> <Divider /> - <DropdownItem onClick={() => settingsDispatch.open(SettingsTabs.GITHUB)}> + <DropdownItem onClick={() => history.push(routes.settings.github.path({}))}> <Button isInline={true} variant={ButtonVariant.link}> Configure GitHub token... </Button> @@ -1752,7 +1755,7 @@ export function PushToGitHubAlertActionLinks(props: { kind?: WorkspaceKind; remoteRef?: string; }) { - const settingsDispatch = useSettingsDispatch(); + const history = useHistory(); if (props.kind === WorkspaceKind.GIT && !props.remoteRef) { throw new Error("Should specify remoteRef for GIT workspaces"); @@ -1761,7 +1764,7 @@ export function PushToGitHubAlertActionLinks(props: { return ( <> {!props.canPush && ( - <AlertActionLink onClick={() => settingsDispatch.open(SettingsTabs.GITHUB)}> + <AlertActionLink onClick={() => history.push(routes.settings.github.path({}))}> {`Configure GitHub token...`} </AlertActionLink> )} diff --git a/packages/serverless-logic-web-tools/src/homepage/pageTemplate/OnlineEditorPage.tsx b/packages/serverless-logic-web-tools/src/homepage/pageTemplate/OnlineEditorPage.tsx index af763471da..4251df69db 100644 --- a/packages/serverless-logic-web-tools/src/homepage/pageTemplate/OnlineEditorPage.tsx +++ b/packages/serverless-logic-web-tools/src/homepage/pageTemplate/OnlineEditorPage.tsx @@ -39,7 +39,7 @@ import { useHistory, useRouteMatch } from "react-router"; import { useLocation } from "react-router-dom"; import { KieSandboxExtendedServicesIcon } from "../../kieSandboxExtendedServices/KieSandboxExtendedServicesIcon"; import { useRoutes } from "../../navigation/Hooks"; -import { SettingsPageNav } from "../../newSettings/uiNav/SettingsPageNav"; +import { SettingsPageNav } from "../../settings/uiNav/SettingsPageNav"; import { OpenshiftDeploymentsDropdown } from "../../openshift/dropdown/OpenshiftDeploymentsDropdown"; import { ApplicationServicesIntegrationQuickStart, diff --git a/packages/serverless-logic-web-tools/src/kieSandboxExtendedServices/KieSandboxExtendedServicesIcon.tsx b/packages/serverless-logic-web-tools/src/kieSandboxExtendedServices/KieSandboxExtendedServicesIcon.tsx index 80c1653d69..5e0b060b95 100644 --- a/packages/serverless-logic-web-tools/src/kieSandboxExtendedServices/KieSandboxExtendedServicesIcon.tsx +++ b/packages/serverless-logic-web-tools/src/kieSandboxExtendedServices/KieSandboxExtendedServicesIcon.tsx @@ -23,18 +23,18 @@ import { KieSandboxExtendedServicesStatus } from "./KieSandboxExtendedServicesSt import { ConnectedIcon } from "@patternfly/react-icons/dist/js/icons/connected-icon"; import { DisconnectedIcon } from "@patternfly/react-icons/dist/js/icons/disconnected-icon"; import { useKieSandboxExtendedServices } from "./KieSandboxExtendedServicesContext"; -import { useSettingsDispatch } from "../settings/SettingsContext"; -import { SettingsTabs } from "../settings/SettingsModalBody"; import { useAppI18n } from "../i18n"; +import { routes } from "../navigation/Routes"; +import { useHistory } from "react-router"; export function KieSandboxExtendedServicesIcon() { const kieSandboxExtendedServices = useKieSandboxExtendedServices(); const { i18n } = useAppI18n(); - const settingsDispatch = useSettingsDispatch(); + const history = useHistory(); const toggleKieSandboxExtendedServices = useCallback(() => { if (kieSandboxExtendedServices.status === KieSandboxExtendedServicesStatus.RUNNING) { - settingsDispatch.open(SettingsTabs.KIE_SANDBOX_EXTENDED_SERVICES); + history.push(routes.settings.kie_sandbox_extended_services.path({})); } if (!kieSandboxExtendedServices.outdated) { @@ -42,7 +42,7 @@ export function KieSandboxExtendedServicesIcon() { } kieSandboxExtendedServices.setInstallTriggeredBy(undefined); kieSandboxExtendedServices.setModalOpen(true); - }, [settingsDispatch, kieSandboxExtendedServices]); + }, [kieSandboxExtendedServices, history]); const dropdownToggleIcon = useMemo( () => ( diff --git a/packages/serverless-logic-web-tools/src/navigation/RoutesSwitch.tsx b/packages/serverless-logic-web-tools/src/navigation/RoutesSwitch.tsx index e4a33a202d..b4e2b5021c 100644 --- a/packages/serverless-logic-web-tools/src/navigation/RoutesSwitch.tsx +++ b/packages/serverless-logic-web-tools/src/navigation/RoutesSwitch.tsx @@ -21,7 +21,7 @@ import { useRoutes } from "./Hooks"; import { OnlineEditorPage } from "../homepage/pageTemplate/OnlineEditorPage"; import { Label } from "@patternfly/react-core/dist/js/components/Label"; import { HomePageRoutes } from "../homepage/routes/HomePageRoutes"; -import { SettingsPageRoutes } from "../newSettings/routes/SettingsPageRoutes"; +import { SettingsPageRoutes } from "../settings/routes/SettingsPageRoutes"; export function RoutesSwitch() { const routes = useRoutes(); diff --git a/packages/serverless-logic-web-tools/src/newSettings/SettingsButton.tsx b/packages/serverless-logic-web-tools/src/newSettings/SettingsButton.tsx deleted file mode 100644 index 7b1cde4e00..0000000000 --- a/packages/serverless-logic-web-tools/src/newSettings/SettingsButton.tsx +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2021 Red Hat, Inc. and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import * as React from "react"; -import { Button, ButtonVariant } from "@patternfly/react-core/dist/js/components/Button"; -import { CogIcon } from "@patternfly/react-icons/dist/js/icons/cog-icon"; -import { useSettingsDispatch } from "./SettingsContext"; -import { Link } from "react-router-dom"; -import { useRoutes } from "../navigation/Hooks"; - -export function SettingsButton() { - const settingsDispatch = useSettingsDispatch(); - const routes = useRoutes(); - - return ( - <Link to={routes.settings.home.path({})}> - <Button variant={ButtonVariant.plain} aria-label="Settings" className={"kie-tools--masthead-hoverable-dark"}> - <CogIcon /> - </Button> - </Link> - ); -} diff --git a/packages/serverless-logic-web-tools/src/newSettings/SettingsContext.tsx b/packages/serverless-logic-web-tools/src/newSettings/SettingsContext.tsx deleted file mode 100644 index 76a2eeb0bf..0000000000 --- a/packages/serverless-logic-web-tools/src/newSettings/SettingsContext.tsx +++ /dev/null @@ -1,322 +0,0 @@ -/* - * Copyright 2023 Red Hat, Inc. and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { OpenShiftConnection } from "@kie-tools-core/openshift/dist/service/OpenShiftConnection"; -import { OpenShiftService } from "@kie-tools-core/openshift/dist/service/OpenShiftService"; -import { Octokit } from "@octokit/rest"; -import * as React from "react"; -import { useContext, useEffect, useMemo, useState } from "react"; -import { getCookie, setCookie } from "../cookies"; -import { SwfServiceCatalogStore } from "../editor/api/SwfServiceCatalogStore"; -import { useKieSandboxExtendedServices } from "../kieSandboxExtendedServices/KieSandboxExtendedServicesContext"; -import { KieSandboxExtendedServicesStatus } from "../kieSandboxExtendedServices/KieSandboxExtendedServicesStatus"; -import { OpenShiftInstanceStatus } from "../openshift/OpenShiftInstanceStatus"; -import { FeaturePreviewSettingsConfig, readFeaturePreviewConfigCookie } from "./featurePreview/FeaturePreviewConfig"; -import { GITHUB_AUTH_TOKEN_COOKIE_NAME } from "./github/GitHubSettings"; -import { KafkaSettingsConfig, readKafkaConfigCookie } from "./kafka/KafkaSettingsConfig"; -import { readOpenShiftConfigCookie } from "./openshift/OpenShiftSettingsConfig"; -import { readServiceAccountConfigCookie, ServiceAccountSettingsConfig } from "./serviceAccount/ServiceAccountConfig"; -import { - readServiceRegistryConfigCookie, - ServiceRegistrySettingsConfig, -} from "./serviceRegistry/ServiceRegistryConfig"; - -export enum AuthStatus { - SIGNED_OUT, - TOKEN_EXPIRED, - LOADING, - SIGNED_IN, -} - -export enum GithubScopes { - GIST = "gist", - REPO = "repo", -} - -interface GithubUser { - login: string; - name: string; - email: string; -} - -export class ExtendedServicesConfig { - constructor(public readonly host: string, public readonly port: string) {} - - public buildUrl(): string { - if (this.port.trim().length === 0) { - return this.host; - } - return `${this.host}:${this.port}`; - } -} - -export interface SettingsContextType { - openshift: { - status: OpenShiftInstanceStatus; - config: OpenShiftConnection; - }; - kieSandboxExtendedServices: { - config: ExtendedServicesConfig; - }; - github: { - token?: string; - user?: GithubUser; - scopes?: string[]; - authStatus: AuthStatus; - }; - apacheKafka: { - config: KafkaSettingsConfig; - }; - serviceAccount: { - config: ServiceAccountSettingsConfig; - }; - serviceRegistry: { - config: ServiceRegistrySettingsConfig; - }; - featurePreview: { - config: FeaturePreviewSettingsConfig; - }; -} - -export interface SettingsDispatchContextType { - openshift: { - service: OpenShiftService; - setStatus: React.Dispatch<React.SetStateAction<OpenShiftInstanceStatus>>; - setConfig: React.Dispatch<React.SetStateAction<OpenShiftConnection>>; - }; - kieSandboxExtendedServices: { - setConfig: React.Dispatch<React.SetStateAction<ExtendedServicesConfig>>; - }; - github: { - authService: { reset: () => void; authenticate: (token: string) => Promise<void> }; - octokit: Octokit; - }; - apacheKafka: { - setConfig: React.Dispatch<React.SetStateAction<KafkaSettingsConfig>>; - }; - serviceAccount: { - setConfig: React.Dispatch<React.SetStateAction<ServiceAccountSettingsConfig>>; - }; - serviceRegistry: { - setConfig: React.Dispatch<React.SetStateAction<ServiceRegistrySettingsConfig>>; - catalogStore: SwfServiceCatalogStore; - }; - featurePreview: { - setConfig: React.Dispatch<React.SetStateAction<FeaturePreviewSettingsConfig>>; - }; -} - -export const SettingsContext = React.createContext<SettingsContextType>({} as any); -export const SettingsDispatchContext = React.createContext<SettingsDispatchContextType>({} as any); - -export function SettingsContextProvider(props: any) { - //github - const [githubAuthStatus, setGitHubAuthStatus] = useState(AuthStatus.LOADING); - const [githubOctokit, setGitHubOctokit] = useState<Octokit>(new Octokit()); - const [githubToken, setGitHubToken] = useState<string | undefined>(undefined); - const [githubUser, setGitHubUser] = useState<GithubUser | undefined>(undefined); - const [githubScopes, setGitHubScopes] = useState<string[] | undefined>(undefined); - - const githubAuthService = useMemo(() => { - return { - reset: () => { - setGitHubOctokit(new Octokit()); - setGitHubToken(undefined); - setGitHubUser(undefined); - setGitHubScopes(undefined); - setCookie(GITHUB_AUTH_TOKEN_COOKIE_NAME, ""); - setGitHubAuthStatus(AuthStatus.SIGNED_OUT); - }, - authenticate: async (token: string) => { - try { - setGitHubAuthStatus(AuthStatus.LOADING); - const octokit = new Octokit({ auth: token }); - const response = await octokit.users.getAuthenticated(); - await delay(1000); - const scopes = response.headers["x-oauth-scopes"]?.split(", ") ?? []; - if (!scopes.includes("repo")) { - throw new Error("Token doesn't have 'repo' scope."); - } - - setGitHubOctokit(octokit); - setGitHubToken(token); - setGitHubUser({ - login: response.data.login, - name: response.data.name ?? "", - email: response.data.email ?? "", - }); - setGitHubScopes(scopes); - setCookie(GITHUB_AUTH_TOKEN_COOKIE_NAME, token); - setGitHubAuthStatus(AuthStatus.SIGNED_IN); - } catch (e) { - setGitHubAuthStatus(AuthStatus.SIGNED_OUT); - throw e; - } - }, - }; - }, []); - - useEffect(() => { - const tokenCookie = getCookie(GITHUB_AUTH_TOKEN_COOKIE_NAME); - if (!tokenCookie) { - setGitHubAuthStatus(AuthStatus.SIGNED_OUT); - return; - } - - githubAuthService.authenticate(tokenCookie).catch(() => { - setGitHubAuthStatus(AuthStatus.TOKEN_EXPIRED); - }); - }, [githubAuthService]); - - const kieSandboxExtendedServices = useKieSandboxExtendedServices(); - const [openshiftConfig, setOpenShiftConfig] = useState(readOpenShiftConfigCookie()); - const [kafkaConfig, setKafkaConfig] = useState<KafkaSettingsConfig>(readKafkaConfigCookie()); - const [serviceAccountConfig, setServiceAccountConfig] = useState<ServiceAccountSettingsConfig>( - readServiceAccountConfigCookie() - ); - const [serviceRegistryConfig, setServiceRegistryConfig] = useState<ServiceRegistrySettingsConfig>( - readServiceRegistryConfigCookie() - ); - - const [featurePreviewConfig, setFeaturePreviewConfig] = useState<FeaturePreviewSettingsConfig>( - readFeaturePreviewConfigCookie() - ); - - const [openshiftStatus, setOpenshiftStatus] = useState( - kieSandboxExtendedServices.status === KieSandboxExtendedServicesStatus.AVAILABLE - ? OpenShiftInstanceStatus.DISCONNECTED - : OpenShiftInstanceStatus.UNAVAILABLE - ); - - const openshiftService = useMemo( - () => - new OpenShiftService({ - connection: openshiftConfig, - proxyUrl: `${kieSandboxExtendedServices.config.buildUrl()}/cors-proxy`, - }), - [openshiftConfig, kieSandboxExtendedServices.config] - ); - - const serviceCatalogStore = useMemo( - () => - new SwfServiceCatalogStore({ - serviceAccount: serviceAccountConfig, - serviceRegistry: serviceRegistryConfig, - extendedServicesConfig: kieSandboxExtendedServices.config, - }), - [kieSandboxExtendedServices.config, serviceAccountConfig, serviceRegistryConfig] - ); - - const dispatch = useMemo(() => { - return { - openshift: { - service: openshiftService, - setStatus: setOpenshiftStatus, - setConfig: setOpenShiftConfig, - }, - github: { - authService: githubAuthService, - octokit: githubOctokit, - }, - kieSandboxExtendedServices: { - setConfig: kieSandboxExtendedServices.saveNewConfig, - }, - apacheKafka: { - setConfig: setKafkaConfig, - }, - serviceAccount: { - setConfig: setServiceAccountConfig, - }, - serviceRegistry: { - setConfig: setServiceRegistryConfig, - catalogStore: serviceCatalogStore, - }, - featurePreview: { - setConfig: setFeaturePreviewConfig, - }, - }; - }, [ - githubAuthService, - githubOctokit, - openshiftService, - kieSandboxExtendedServices.saveNewConfig, - serviceCatalogStore, - ]); - - const value = useMemo(() => { - return { - openshift: { - status: openshiftStatus, - config: openshiftConfig, - }, - github: { - authStatus: githubAuthStatus, - token: githubToken, - user: githubUser, - scopes: githubScopes, - }, - kieSandboxExtendedServices: { - config: kieSandboxExtendedServices.config, - }, - apacheKafka: { - config: kafkaConfig, - }, - serviceAccount: { - config: serviceAccountConfig, - }, - serviceRegistry: { - config: serviceRegistryConfig, - }, - featurePreview: { - config: featurePreviewConfig, - }, - }; - }, [ - openshiftStatus, - openshiftConfig, - githubAuthStatus, - githubToken, - githubUser, - githubScopes, - kafkaConfig, - serviceAccountConfig, - serviceRegistryConfig, - kieSandboxExtendedServices.config, - featurePreviewConfig, - ]); - - return ( - <SettingsContext.Provider value={value}> - <SettingsDispatchContext.Provider value={dispatch}>{props.children}</SettingsDispatchContext.Provider> - </SettingsContext.Provider> - ); -} - -export function useSettings() { - return useContext(SettingsContext); -} - -export function useSettingsDispatch() { - return useContext(SettingsDispatchContext); -} - -function delay(ms: number) { - return new Promise<void>((res) => { - setTimeout(() => { - res(); - }, ms); - }); -} diff --git a/packages/serverless-logic-web-tools/src/newSettings/featurePreview/FeaturePreviewConfig.tsx b/packages/serverless-logic-web-tools/src/newSettings/featurePreview/FeaturePreviewConfig.tsx deleted file mode 100644 index 36cce4c180..0000000000 --- a/packages/serverless-logic-web-tools/src/newSettings/featurePreview/FeaturePreviewConfig.tsx +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2023 Red Hat, Inc. and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { getCookie, makeCookieName, setCookie } from "../../cookies"; - -export const FEATURE_PREVIEW_STUNNER_ENABLED_COOKIE_NAME = makeCookieName("feature-preview", "stunner-enabled"); - -export interface FeaturePreviewSettingsConfig { - stunnerEnabled: boolean; -} - -export const DEFAULT_CONFIG: FeaturePreviewSettingsConfig = { - stunnerEnabled: true, -}; - -export function readFeaturePreviewConfigCookie(): FeaturePreviewSettingsConfig { - const stunnerEnabledCookie = getCookie(FEATURE_PREVIEW_STUNNER_ENABLED_COOKIE_NAME); - return { - stunnerEnabled: stunnerEnabledCookie ? stunnerEnabledCookie === "true" : DEFAULT_CONFIG.stunnerEnabled, - }; -} - -export function saveStunnerEnabledCookie(isEnabled: boolean): void { - setCookie(FEATURE_PREVIEW_STUNNER_ENABLED_COOKIE_NAME, String(isEnabled)); -} - -export function saveConfigCookie(config: FeaturePreviewSettingsConfig): void { - saveStunnerEnabledCookie(config.stunnerEnabled); -} diff --git a/packages/serverless-logic-web-tools/src/newSettings/github/Hooks.tsx b/packages/serverless-logic-web-tools/src/newSettings/github/Hooks.tsx deleted file mode 100644 index f05fde5cd4..0000000000 --- a/packages/serverless-logic-web-tools/src/newSettings/github/Hooks.tsx +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2021 Red Hat, Inc. and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { useMemo } from "react"; -import { AuthStatus, useSettings } from "../SettingsContext"; - -export function useGitHubAuthInfo() { - const settings = useSettings(); - return useMemo(() => { - if (settings.github.authStatus !== AuthStatus.SIGNED_IN) { - return undefined; - } - - return { - name: settings.github.user!.name, - email: settings.github.user!.email, - username: settings.github.user!.login, - password: settings.github.token!, - }; - }, [settings.github]); -} diff --git a/packages/serverless-logic-web-tools/src/newSettings/kafka/KafkaSettingsConfig.tsx b/packages/serverless-logic-web-tools/src/newSettings/kafka/KafkaSettingsConfig.tsx deleted file mode 100644 index dde86edea1..0000000000 --- a/packages/serverless-logic-web-tools/src/newSettings/kafka/KafkaSettingsConfig.tsx +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2022 Red Hat, Inc. and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { makeCookieName, getCookie, setCookie } from "../../cookies"; - -export const KAFKA_BOOTSTRAP_SERVER_COOKIE_NAME = makeCookieName("kafka", "bootstrap-server"); -export const KAFKA_TOPIC_COOKIE_NAME = makeCookieName("kafka", "topic"); - -export interface KafkaSettingsConfig { - bootstrapServer: string; - topic: string; -} - -export const EMPTY_CONFIG: KafkaSettingsConfig = { - bootstrapServer: "", - topic: "", -}; - -export function isKafkaConfigValid(config: KafkaSettingsConfig): boolean { - return isBootstrapServerValid(config.bootstrapServer) && isTopicValid(config.topic); -} - -export function isBootstrapServerValid(bootstrapServer: string): boolean { - return bootstrapServer !== undefined && bootstrapServer.trim().length > 0; -} - -export function isOAuthEndpointUriValid(oauthEndpointUri: string): boolean { - return oauthEndpointUri !== undefined && oauthEndpointUri.trim().length > 0; -} - -export function isTopicValid(topic: string): boolean { - return topic !== undefined && topic.trim().length > 0; -} - -export function readKafkaConfigCookie(): KafkaSettingsConfig { - return { - bootstrapServer: getCookie(KAFKA_BOOTSTRAP_SERVER_COOKIE_NAME) ?? "", - topic: getCookie(KAFKA_TOPIC_COOKIE_NAME) ?? "", - }; -} - -export function resetConfigCookie(): void { - saveConfigCookie(EMPTY_CONFIG); -} - -export function saveBootstrapServerCookie(bootstrapServer: string): void { - setCookie(KAFKA_BOOTSTRAP_SERVER_COOKIE_NAME, bootstrapServer); -} - -export function saveTopicCookie(topic: string): void { - setCookie(KAFKA_TOPIC_COOKIE_NAME, topic); -} - -export function saveConfigCookie(config: KafkaSettingsConfig): void { - saveBootstrapServerCookie(config.bootstrapServer); - saveTopicCookie(config.topic); -} diff --git a/packages/serverless-logic-web-tools/src/newSettings/openshift/OpenShiftSettingsConfig.tsx b/packages/serverless-logic-web-tools/src/newSettings/openshift/OpenShiftSettingsConfig.tsx deleted file mode 100644 index 26ffc405ea..0000000000 --- a/packages/serverless-logic-web-tools/src/newSettings/openshift/OpenShiftSettingsConfig.tsx +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2022 Red Hat, Inc. and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { OpenShiftConnection } from "@kie-tools-core/openshift/dist/service/OpenShiftConnection"; -import { makeCookieName, getCookie, setCookie } from "../../cookies"; - -export const OPENSHIFT_NAMESPACE_COOKIE_NAME = makeCookieName("openshift", "namespace"); -export const OPENSHIFT_HOST_COOKIE_NAME = makeCookieName("openshift", "host"); -export const OPENSHIFT_TOKEN_COOKIE_NAME = makeCookieName("openshift", "token"); - -export const EMPTY_CONFIG: OpenShiftConnection = { - namespace: "", - host: "", - token: "", -}; - -export function readOpenShiftConfigCookie(): OpenShiftConnection { - return { - namespace: getCookie(OPENSHIFT_NAMESPACE_COOKIE_NAME) ?? "", - host: getCookie(OPENSHIFT_HOST_COOKIE_NAME) ?? "", - token: getCookie(OPENSHIFT_TOKEN_COOKIE_NAME) ?? "", - }; -} - -export function resetConfigCookie(): void { - saveConfigCookie(EMPTY_CONFIG); -} - -export function saveNamespaceCookie(namespace: string): void { - setCookie(OPENSHIFT_NAMESPACE_COOKIE_NAME, namespace); -} - -export function saveHostCookie(host: string): void { - setCookie(OPENSHIFT_HOST_COOKIE_NAME, host); -} - -export function saveTokenCookie(token: string): void { - setCookie(OPENSHIFT_TOKEN_COOKIE_NAME, token); -} - -export function saveConfigCookie(config: OpenShiftConnection): void { - saveNamespaceCookie(config.namespace); - saveHostCookie(config.host); - saveTokenCookie(config.token); -} diff --git a/packages/serverless-logic-web-tools/src/newSettings/serviceAccount/ServiceAccountConfig.tsx b/packages/serverless-logic-web-tools/src/newSettings/serviceAccount/ServiceAccountConfig.tsx deleted file mode 100644 index 1b9bb2d77a..0000000000 --- a/packages/serverless-logic-web-tools/src/newSettings/serviceAccount/ServiceAccountConfig.tsx +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2023 Red Hat, Inc. and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { makeCookieName, getCookie, setCookie } from "../../cookies"; - -export const SERVICE_ACCOUNT_CLIENT_ID_COOKIE_NAME = makeCookieName("service-account", "client-id"); -export const SERVICE_ACCOUNT_CLIENT_SECRET_COOKIE_NAME = makeCookieName("service-account", "client-secret"); - -export interface ServiceAccountSettingsConfig { - clientId: string; - clientSecret: string; -} - -export const EMPTY_CONFIG: ServiceAccountSettingsConfig = { - clientId: "", - clientSecret: "", -}; - -export function isServiceAccountConfigValid(config: ServiceAccountSettingsConfig): boolean { - return isClientIdValid(config.clientId) && isClientSecretValid(config.clientSecret); -} - -export function isClientIdValid(clientId: string): boolean { - return clientId !== undefined && clientId.trim().length > 0; -} - -export function isClientSecretValid(clientSecret: string): boolean { - return clientSecret !== undefined && clientSecret.trim().length > 0; -} - -export function readServiceAccountConfigCookie(): ServiceAccountSettingsConfig { - return { - clientId: getCookie(SERVICE_ACCOUNT_CLIENT_ID_COOKIE_NAME) ?? "", - clientSecret: getCookie(SERVICE_ACCOUNT_CLIENT_SECRET_COOKIE_NAME) ?? "", - }; -} - -export function resetConfigCookie(): void { - saveConfigCookie(EMPTY_CONFIG); -} - -export function saveClientIdCookie(clientId: string): void { - setCookie(SERVICE_ACCOUNT_CLIENT_ID_COOKIE_NAME, clientId); -} - -export function saveClientSecretCookie(clientSecret: string): void { - setCookie(SERVICE_ACCOUNT_CLIENT_SECRET_COOKIE_NAME, clientSecret); -} - -export function saveConfigCookie(config: ServiceAccountSettingsConfig): void { - saveClientIdCookie(config.clientId); - saveClientSecretCookie(config.clientSecret); -} diff --git a/packages/serverless-logic-web-tools/src/newSettings/serviceRegistry/ServiceRegistryConfig.tsx b/packages/serverless-logic-web-tools/src/newSettings/serviceRegistry/ServiceRegistryConfig.tsx deleted file mode 100644 index 49dad4fe02..0000000000 --- a/packages/serverless-logic-web-tools/src/newSettings/serviceRegistry/ServiceRegistryConfig.tsx +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2023 Red Hat, Inc. and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { getCookie, makeCookieName, setCookie } from "../../cookies"; - -export const SERVICE_REGISTRY_NAME_COOKIE_NAME = makeCookieName("service-registry", "name"); -export const SERVICE_REGISTRY_CORE_REGISTRY_API_COOKIE_NAME = makeCookieName("service-registry", "core-registry-api"); - -export interface ServiceRegistrySettingsConfig { - name: string; - coreRegistryApi: string; -} - -export const EMPTY_CONFIG: ServiceRegistrySettingsConfig = { - name: "", - coreRegistryApi: "", -}; - -export function isServiceRegistryConfigValid(config: ServiceRegistrySettingsConfig): boolean { - return isNameValid(config.name) && isCoreRegistryApiValid(config.coreRegistryApi); -} - -export function isNameValid(name: string): boolean { - return name !== undefined && name.trim().length > 0; -} - -export function isCoreRegistryApiValid(coreRegistryApi: string): boolean { - return coreRegistryApi !== undefined && coreRegistryApi.trim().length > 0; -} - -export function readServiceRegistryConfigCookie(): ServiceRegistrySettingsConfig { - return { - name: getCookie(SERVICE_REGISTRY_NAME_COOKIE_NAME) ?? "", - coreRegistryApi: getCookie(SERVICE_REGISTRY_CORE_REGISTRY_API_COOKIE_NAME) ?? "", - }; -} - -export function resetConfigCookie(): void { - saveConfigCookie(EMPTY_CONFIG); -} - -export function saveNameCookie(name: string): void { - setCookie(SERVICE_REGISTRY_NAME_COOKIE_NAME, name); -} - -export function saveCoreRegistryApiCookie(coreRegistryApi: string): void { - setCookie(SERVICE_REGISTRY_CORE_REGISTRY_API_COOKIE_NAME, coreRegistryApi); -} - -export function saveConfigCookie(config: ServiceRegistrySettingsConfig): void { - saveNameCookie(config.name); - saveCoreRegistryApiCookie(config.coreRegistryApi); -} diff --git a/packages/serverless-logic-web-tools/src/openshift/dropdown/OpenshiftDeploymentsDropdown.tsx b/packages/serverless-logic-web-tools/src/openshift/dropdown/OpenshiftDeploymentsDropdown.tsx index 86f24c5f3f..6a4c26392b 100644 --- a/packages/serverless-logic-web-tools/src/openshift/dropdown/OpenshiftDeploymentsDropdown.tsx +++ b/packages/serverless-logic-web-tools/src/openshift/dropdown/OpenshiftDeploymentsDropdown.tsx @@ -26,15 +26,17 @@ import { useCallback, useMemo } from "react"; import { ResponsiveDropdown } from "../../ResponsiveDropdown/ResponsiveDropdown"; import { ResponsiveDropdownToggle } from "../../ResponsiveDropdown/ResponsiveDropdownToggle"; import { useSettings, useSettingsDispatch } from "../../settings/SettingsContext"; -import { SettingsTabs } from "../../settings/SettingsModalBody"; import { useOpenShift } from "../OpenShiftContext"; import { OpenShiftDeploymentDropdownItem } from "./OpenShiftDeploymentDropdownItem"; import { OpenShiftInstanceStatus } from "../OpenShiftInstanceStatus"; +import { routes } from "../../navigation/Routes"; +import { useHistory } from "react-router"; export function OpenshiftDeploymentsDropdown() { const settings = useSettings(); const settingsDispatch = useSettingsDispatch(); const openshift = useOpenShift(); + const history = useHistory(); const isConnected = useMemo( () => settings.openshift.status === OpenShiftInstanceStatus.CONNECTED, @@ -42,8 +44,8 @@ export function OpenshiftDeploymentsDropdown() { ); const openOpenShiftSettings = useCallback(() => { - settingsDispatch.open(SettingsTabs.OPENSHIFT); - }, [settingsDispatch]); + history.push(routes.settings.openshift.path({})); + }, [history]); const items = useMemo(() => { const common = isConnected diff --git a/packages/serverless-logic-web-tools/src/settings/SettingsButton.tsx b/packages/serverless-logic-web-tools/src/settings/SettingsButton.tsx index 50c96c4566..7b1cde4e00 100644 --- a/packages/serverless-logic-web-tools/src/settings/SettingsButton.tsx +++ b/packages/serverless-logic-web-tools/src/settings/SettingsButton.tsx @@ -18,17 +18,18 @@ import * as React from "react"; import { Button, ButtonVariant } from "@patternfly/react-core/dist/js/components/Button"; import { CogIcon } from "@patternfly/react-icons/dist/js/icons/cog-icon"; import { useSettingsDispatch } from "./SettingsContext"; +import { Link } from "react-router-dom"; +import { useRoutes } from "../navigation/Hooks"; export function SettingsButton() { const settingsDispatch = useSettingsDispatch(); + const routes = useRoutes(); + return ( - <Button - variant={ButtonVariant.plain} - onClick={() => settingsDispatch.open()} - aria-label="Settings" - className={"kie-tools--masthead-hoverable-dark"} - > - <CogIcon /> - </Button> + <Link to={routes.settings.home.path({})}> + <Button variant={ButtonVariant.plain} aria-label="Settings" className={"kie-tools--masthead-hoverable-dark"}> + <CogIcon /> + </Button> + </Link> ); } diff --git a/packages/serverless-logic-web-tools/src/settings/SettingsContext.tsx b/packages/serverless-logic-web-tools/src/settings/SettingsContext.tsx index 2abccb1650..76a2eeb0bf 100644 --- a/packages/serverless-logic-web-tools/src/settings/SettingsContext.tsx +++ b/packages/serverless-logic-web-tools/src/settings/SettingsContext.tsx @@ -1,5 +1,5 @@ /* - * Copyright 2021 Red Hat, Inc. and/or its affiliates. + * Copyright 2023 Red Hat, Inc. and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,30 +14,25 @@ * limitations under the License. */ +import { OpenShiftConnection } from "@kie-tools-core/openshift/dist/service/OpenShiftConnection"; +import { OpenShiftService } from "@kie-tools-core/openshift/dist/service/OpenShiftService"; +import { Octokit } from "@octokit/rest"; import * as React from "react"; -import { useCallback, useContext, useEffect, useMemo, useState } from "react"; +import { useContext, useEffect, useMemo, useState } from "react"; import { getCookie, setCookie } from "../cookies"; -import { Octokit } from "@octokit/rest"; -import { useQueryParams } from "../queryParams/QueryParamsContext"; -import { Modal, ModalVariant } from "@patternfly/react-core/dist/js/components/Modal"; -import { SettingsModalBody, SettingsTabs } from "./SettingsModalBody"; -import { readOpenShiftConfigCookie } from "./openshift/OpenShiftSettingsConfig"; -import { OpenShiftConnection } from "@kie-tools-core/openshift/dist/service/OpenShiftConnection"; +import { SwfServiceCatalogStore } from "../editor/api/SwfServiceCatalogStore"; +import { useKieSandboxExtendedServices } from "../kieSandboxExtendedServices/KieSandboxExtendedServicesContext"; +import { KieSandboxExtendedServicesStatus } from "../kieSandboxExtendedServices/KieSandboxExtendedServicesStatus"; import { OpenShiftInstanceStatus } from "../openshift/OpenShiftInstanceStatus"; -import { OpenShiftService } from "@kie-tools-core/openshift/dist/service/OpenShiftService"; -import { useHistory, useRouteMatch } from "react-router"; -import { QueryParams, routes } from "../navigation/Routes"; -import { GITHUB_AUTH_TOKEN_COOKIE_NAME } from "./github/GitHubSettingsTab"; +import { FeaturePreviewSettingsConfig, readFeaturePreviewConfigCookie } from "./featurePreview/FeaturePreviewConfig"; +import { GITHUB_AUTH_TOKEN_COOKIE_NAME } from "./github/GitHubSettings"; import { KafkaSettingsConfig, readKafkaConfigCookie } from "./kafka/KafkaSettingsConfig"; +import { readOpenShiftConfigCookie } from "./openshift/OpenShiftSettingsConfig"; import { readServiceAccountConfigCookie, ServiceAccountSettingsConfig } from "./serviceAccount/ServiceAccountConfig"; import { readServiceRegistryConfigCookie, ServiceRegistrySettingsConfig, } from "./serviceRegistry/ServiceRegistryConfig"; -import { useKieSandboxExtendedServices } from "../kieSandboxExtendedServices/KieSandboxExtendedServicesContext"; -import { KieSandboxExtendedServicesStatus } from "../kieSandboxExtendedServices/KieSandboxExtendedServicesStatus"; -import { SwfServiceCatalogStore } from "../editor/api/SwfServiceCatalogStore"; -import { FeaturePreviewSettingsConfig, readFeaturePreviewConfigCookie } from "./featurePreview/FeaturePreviewConfig"; export enum AuthStatus { SIGNED_OUT, @@ -69,8 +64,6 @@ export class ExtendedServicesConfig { } export interface SettingsContextType { - isOpen: boolean; - activeTab: SettingsTabs; openshift: { status: OpenShiftInstanceStatus; config: OpenShiftConnection; @@ -99,8 +92,6 @@ export interface SettingsContextType { } export interface SettingsDispatchContextType { - open: (activeTab?: SettingsTabs) => void; - close: () => void; openshift: { service: OpenShiftService; setStatus: React.Dispatch<React.SetStateAction<OpenShiftInstanceStatus>>; @@ -132,32 +123,6 @@ export const SettingsContext = React.createContext<SettingsContextType>({} as an export const SettingsDispatchContext = React.createContext<SettingsDispatchContextType>({} as any); export function SettingsContextProvider(props: any) { - const queryParams = useQueryParams(); - const history = useHistory(); - const [isOpen, setOpen] = useState(false); - const [activeTab, setActiveTab] = useState(SettingsTabs.GITHUB); - const isRouteInSettingsSection = useRouteMatch(routes.settings.home.path({})); - - useEffect(() => { - setOpen(queryParams.has(QueryParams.SETTINGS)); - setActiveTab((queryParams.get(QueryParams.SETTINGS) as SettingsTabs) ?? SettingsTabs.GITHUB); - }, [queryParams]); - - const open = useCallback( - (activeTab = SettingsTabs.GITHUB) => { - history.replace({ - search: queryParams.with(QueryParams.SETTINGS, activeTab).toString(), - }); - }, - [history, queryParams] - ); - - const close = useCallback(() => { - history.replace({ - search: queryParams.without(QueryParams.SETTINGS).toString(), - }); - }, [history, queryParams]); - //github const [githubAuthStatus, setGitHubAuthStatus] = useState(AuthStatus.LOADING); const [githubOctokit, setGitHubOctokit] = useState<Octokit>(new Octokit()); @@ -257,8 +222,6 @@ export function SettingsContextProvider(props: any) { const dispatch = useMemo(() => { return { - open, - close, openshift: { service: openshiftService, setStatus: setOpenshiftStatus, @@ -286,10 +249,8 @@ export function SettingsContextProvider(props: any) { }, }; }, [ - close, githubAuthService, githubOctokit, - open, openshiftService, kieSandboxExtendedServices.saveNewConfig, serviceCatalogStore, @@ -297,8 +258,6 @@ export function SettingsContextProvider(props: any) { const value = useMemo(() => { return { - isOpen, - activeTab, openshift: { status: openshiftStatus, config: openshiftConfig, @@ -326,8 +285,6 @@ export function SettingsContextProvider(props: any) { }, }; }, [ - isOpen, - activeTab, openshiftStatus, openshiftConfig, githubAuthStatus, @@ -343,19 +300,7 @@ export function SettingsContextProvider(props: any) { return ( <SettingsContext.Provider value={value}> - <SettingsDispatchContext.Provider value={dispatch}> - {(isRouteInSettingsSection || githubAuthStatus !== AuthStatus.LOADING) && <>{props.children}</>} - <Modal - title="Settings" - isOpen={!isRouteInSettingsSection && isOpen} - onClose={close} - variant={ModalVariant.large} - > - <div style={{ height: "calc(100vh * 0.5)" }} className={"kie-tools--settings-modal-content"}> - <SettingsModalBody /> - </div> - </Modal> - </SettingsDispatchContext.Provider> + <SettingsDispatchContext.Provider value={dispatch}>{props.children}</SettingsDispatchContext.Provider> </SettingsContext.Provider> ); } diff --git a/packages/serverless-logic-web-tools/src/settings/SettingsModalBody.tsx b/packages/serverless-logic-web-tools/src/settings/SettingsModalBody.tsx deleted file mode 100644 index 3658090673..0000000000 --- a/packages/serverless-logic-web-tools/src/settings/SettingsModalBody.tsx +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright 2021 Red Hat, Inc. and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import * as React from "react"; -import { Tab, Tabs, TabTitleText } from "@patternfly/react-core/dist/js/components/Tabs"; -import { GitHubSettingsTab } from "./github/GitHubSettingsTab"; -import { useSettings, useSettingsDispatch } from "./SettingsContext"; -import { OpenShiftSettingsTab } from "./openshift/OpenShiftSettingsTab"; -import { ApacheKafkaSettingsTab } from "./kafka/ApacheKafkaSettingsTab"; -import { ServiceAccountSettingsTab } from "./serviceAccount/ServiceAccountSettingsTab"; -import { ServiceRegistrySettingsTab } from "./serviceRegistry/ServiceRegistrySettingsTab"; -import { KieSandboxExtendedServicesSettingsTab } from "./extendedServices/KieSandboxExtendedServicesSettingsTab"; -import { FeaturePreviewSettingsTab } from "./featurePreview/FeaturePreviewSettingsTab"; - -export enum SettingsTabs { - GITHUB = "github", - OPENSHIFT = "openshift", - KIE_SANDBOX_EXTENDED_SERVICES = "kie-sandbox-extended-services", - SERVICE_ACCOUNT = "serviceAccount", - SERVICE_REGISTRY = "serviceRegistry", - KAFKA = "kafka", - FEATURE_PREVIEW = "featurePreview", -} - -export function SettingsModalBody() { - const settings = useSettings(); - const settingsDispatch = useSettingsDispatch(); - - return ( - <Tabs - activeKey={settings.activeTab} - onSelect={(e, k) => settingsDispatch.open(k as SettingsTabs)} - isVertical={false} - isBox={false} - > - <Tab - className="kie-tools--settings-tab" - eventKey={SettingsTabs.GITHUB} - title={<TabTitleText>GitHub</TabTitleText>} - > - <GitHubSettingsTab /> - </Tab> - <Tab - className="kie-tools--settings-tab" - eventKey={SettingsTabs.KIE_SANDBOX_EXTENDED_SERVICES} - title={<TabTitleText>KIE Sandbox Extended Services</TabTitleText>} - > - <KieSandboxExtendedServicesSettingsTab /> - </Tab> - <Tab - className="kie-tools--settings-tab" - eventKey={SettingsTabs.OPENSHIFT} - title={<TabTitleText>OpenShift</TabTitleText>} - > - <OpenShiftSettingsTab /> - </Tab> - <Tab - className="kie-tools--settings-tab" - eventKey={SettingsTabs.SERVICE_ACCOUNT} - title={<TabTitleText>Service Account</TabTitleText>} - > - <ServiceAccountSettingsTab /> - </Tab> - <Tab - className="kie-tools--settings-tab" - eventKey={SettingsTabs.SERVICE_REGISTRY} - title={<TabTitleText>Service Registry</TabTitleText>} - > - <ServiceRegistrySettingsTab /> - </Tab> - <Tab - className="kie-tools--settings-tab" - eventKey={SettingsTabs.KAFKA} - title={<TabTitleText>Streams for Apache Kafka</TabTitleText>} - > - <ApacheKafkaSettingsTab /> - </Tab> - <Tab - className="kie-tools--settings-tab" - eventKey={SettingsTabs.FEATURE_PREVIEW} - title={<TabTitleText>Feature Preview</TabTitleText>} - > - <FeaturePreviewSettingsTab /> - </Tab> - </Tabs> - ); -} diff --git a/packages/serverless-logic-web-tools/src/newSettings/extendedServices/KieSandboxExtendedServicesSettings.tsx b/packages/serverless-logic-web-tools/src/settings/extendedServices/KieSandboxExtendedServicesSettings.tsx similarity index 100% rename from packages/serverless-logic-web-tools/src/newSettings/extendedServices/KieSandboxExtendedServicesSettings.tsx rename to packages/serverless-logic-web-tools/src/settings/extendedServices/KieSandboxExtendedServicesSettings.tsx diff --git a/packages/serverless-logic-web-tools/src/settings/extendedServices/KieSandboxExtendedServicesSettingsTab.tsx b/packages/serverless-logic-web-tools/src/settings/extendedServices/KieSandboxExtendedServicesSettingsTab.tsx deleted file mode 100644 index 4d25544a4b..0000000000 --- a/packages/serverless-logic-web-tools/src/settings/extendedServices/KieSandboxExtendedServicesSettingsTab.tsx +++ /dev/null @@ -1,225 +0,0 @@ -/* - * Copyright 2021 Red Hat, Inc. and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { Alert } from "@patternfly/react-core/dist/js/components/Alert"; -import { Button, ButtonVariant } from "@patternfly/react-core/dist/js/components/Button"; -import { EmptyState, EmptyStateBody, EmptyStateIcon } from "@patternfly/react-core/dist/js/components/EmptyState"; -import { ActionGroup, Form, FormAlert, FormGroup } from "@patternfly/react-core/dist/js/components/Form"; -import { InputGroup, InputGroupText } from "@patternfly/react-core/dist/js/components/InputGroup"; -import { Page, PageSection } from "@patternfly/react-core/dist/js/components/Page"; -import { Popover } from "@patternfly/react-core/dist/js/components/Popover"; -import { Text, TextContent, TextVariants } from "@patternfly/react-core/dist/js/components/Text"; -import { TextInput } from "@patternfly/react-core/dist/js/components/TextInput"; -import { CheckCircleIcon } from "@patternfly/react-icons/dist/js/icons/check-circle-icon"; -import HelpIcon from "@patternfly/react-icons/dist/js/icons/help-icon"; -import { TimesIcon } from "@patternfly/react-icons/dist/js/icons/times-icon"; -import * as React from "react"; -import { useCallback, useMemo, useState } from "react"; -import { useKieSandboxExtendedServices } from "../../kieSandboxExtendedServices/KieSandboxExtendedServicesContext"; -import { KieSandboxExtendedServicesStatus } from "../../kieSandboxExtendedServices/KieSandboxExtendedServicesStatus"; -import { ExtendedServicesConfig, useSettings, useSettingsDispatch } from "../SettingsContext"; - -export function KieSandboxExtendedServicesSettingsTab() { - const settings = useSettings(); - const settingsDispatch = useSettingsDispatch(); - const kieSandboxExtendedServices = useKieSandboxExtendedServices(); - const [config, setConfig] = useState(settings.kieSandboxExtendedServices.config); - - const isCurrentConfigValid = useMemo( - () => config.host.trim().length > 0 && config.buildUrl().trim().length > 0, - [config] - ); - - const onClearHost = useCallback(() => setConfig(new ExtendedServicesConfig("", config.port)), [config]); - const onClearPort = useCallback(() => setConfig(new ExtendedServicesConfig(config.host, "")), [config]); - - const onHostChanged = useCallback( - (newValue: string) => setConfig(new ExtendedServicesConfig(newValue, config.port)), - [config] - ); - const onPortChanged = useCallback( - (newValue: string) => setConfig(new ExtendedServicesConfig(config.host, newValue)), - [config] - ); - - const onConnect = useCallback(() => { - settingsDispatch.kieSandboxExtendedServices.setConfig(config); - }, [settingsDispatch.kieSandboxExtendedServices, config]); - - const onReset = useCallback(() => { - const emptyConfig = new ExtendedServicesConfig("", ""); - setConfig(emptyConfig); - settingsDispatch.kieSandboxExtendedServices.setConfig(emptyConfig); - }, [settingsDispatch.kieSandboxExtendedServices]); - - return ( - <> - <Page> - <PageSection> - {kieSandboxExtendedServices.status === KieSandboxExtendedServicesStatus.RUNNING ? ( - <EmptyState> - <EmptyStateIcon icon={CheckCircleIcon} color={"var(--pf-global--success-color--100)"} /> - <TextContent> - <Text component={"h2"}>{"You are connect to the KIE Sandbox Extended Services."}</Text> - </TextContent> - <EmptyStateBody> - <TextContent> - Deploying models is <b>enabled</b>. - </TextContent> - <br /> - <TextContent> - <b>URL: </b> - <i>{config.buildUrl()}</i> - </TextContent> - <br /> - <Button variant={ButtonVariant.tertiary} onClick={onReset}> - Reset - </Button> - </EmptyStateBody> - </EmptyState> - ) : ( - <PageSection variant={"light"} isFilled={true} style={{ height: "100%" }}> - <Form> - <FormAlert> - <Alert - variant="danger" - title={ - <Text> - You are not connected to KIE Sandbox Extended Services.{" "} - <a - onClick={() => { - kieSandboxExtendedServices.setInstallTriggeredBy(undefined); - kieSandboxExtendedServices.setModalOpen(true); - }} - > - Click to setup - </a> - </Text> - } - aria-live="polite" - isInline - /> - </FormAlert> - <TextContent> - <Text component={TextVariants.h3}>KIE Sandbox Extended Services</Text> - </TextContent> - <TextContent> - <Text component={TextVariants.small}> - Data you provide here is necessary for proxying Serverless Logic Web Tools requests to OpenShift, - thus making it possible to deploy models. All information is locally stored in your browser and - never shared with anyone. - </Text> - </TextContent> - <FormGroup - label={"Host"} - labelIcon={ - <Popover bodyContent={"The host associated with the KIE Sandbox Extended Services URL instance."}> - <button - type="button" - aria-label="More info for host field" - onClick={(e) => e.preventDefault()} - aria-describedby="host-server-field" - className="pf-c-form__group-label-help" - > - <HelpIcon noVerticalAlign /> - </button> - </Popover> - } - isRequired - fieldId="host-server-field" - > - <InputGroup className="pf-u-mt-sm"> - <TextInput - autoComplete={"off"} - isRequired - type="text" - id="host-server-field" - name="host-server-field" - aria-label="Host field" - aria-describedby="host-server-field-helper" - value={config.host} - onChange={onHostChanged} - tabIndex={1} - data-testid="host-text-field" - /> - <InputGroupText> - <Button isSmall variant="plain" aria-label="Clear host button" onClick={onClearHost}> - <TimesIcon /> - </Button> - </InputGroupText> - </InputGroup> - </FormGroup> - <FormGroup - label={"Port"} - labelIcon={ - <Popover - bodyContent={"The port number associated with the KIE Sandbox Extended Services URL instance."} - > - <button - type="button" - aria-label="More info for port field" - onClick={(e) => e.preventDefault()} - aria-describedby="port-field" - className="pf-c-form__group-label-help" - > - <HelpIcon noVerticalAlign /> - </button> - </Popover> - } - isRequired - fieldId="port-field" - > - <InputGroup className="pf-u-mt-sm"> - <TextInput - autoComplete={"off"} - isRequired - type="text" - id="port-field" - name="port-field" - aria-label="Port field" - aria-describedby="port-field-helper" - value={config.port} - onChange={onPortChanged} - tabIndex={2} - data-testid="port-text-field" - /> - <InputGroupText> - <Button isSmall variant="plain" aria-label="Clear port button" onClick={onClearPort}> - <TimesIcon /> - </Button> - </InputGroupText> - </InputGroup> - </FormGroup> - <ActionGroup> - <Button - isDisabled={!isCurrentConfigValid} - id="kie-sandbox-extended-services-config-connect-button" - key="connect" - variant="primary" - onClick={onConnect} - data-testid="connect-config-button" - > - Connect - </Button> - </ActionGroup> - </Form> - </PageSection> - )} - </PageSection> - </Page> - </> - ); -} diff --git a/packages/serverless-logic-web-tools/src/settings/featurePreview/FeaturePreviewConfig.tsx b/packages/serverless-logic-web-tools/src/settings/featurePreview/FeaturePreviewConfig.tsx index f7a383db92..36cce4c180 100644 --- a/packages/serverless-logic-web-tools/src/settings/featurePreview/FeaturePreviewConfig.tsx +++ b/packages/serverless-logic-web-tools/src/settings/featurePreview/FeaturePreviewConfig.tsx @@ -1,5 +1,5 @@ /* - * Copyright 2022 Red Hat, Inc. and/or its affiliates. + * Copyright 2023 Red Hat, Inc. and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/packages/serverless-logic-web-tools/src/newSettings/featurePreview/FeaturePreviewSettings.tsx b/packages/serverless-logic-web-tools/src/settings/featurePreview/FeaturePreviewSettings.tsx similarity index 100% rename from packages/serverless-logic-web-tools/src/newSettings/featurePreview/FeaturePreviewSettings.tsx rename to packages/serverless-logic-web-tools/src/settings/featurePreview/FeaturePreviewSettings.tsx diff --git a/packages/serverless-logic-web-tools/src/settings/featurePreview/FeaturePreviewSettingsTab.tsx b/packages/serverless-logic-web-tools/src/settings/featurePreview/FeaturePreviewSettingsTab.tsx deleted file mode 100644 index 61ca839ff1..0000000000 --- a/packages/serverless-logic-web-tools/src/settings/featurePreview/FeaturePreviewSettingsTab.tsx +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2021 Red Hat, Inc. and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import * as React from "react"; -import { Form } from "@patternfly/react-core/dist/js/components/Form"; -import { Page, PageSection } from "@patternfly/react-core/dist/js/components/Page"; -import { Text, TextContent, TextVariants } from "@patternfly/react-core/dist/js/components/Text"; -import { useCallback, useEffect, useState } from "react"; -import { useSettings, useSettingsDispatch } from "../SettingsContext"; -import { Checkbox } from "@patternfly/react-core/dist/js/components/Checkbox"; -import { saveConfigCookie } from "./FeaturePreviewConfig"; - -export function FeaturePreviewSettingsTab() { - const settings = useSettings(); - const settingsDispatch = useSettingsDispatch(); - const [config, setConfig] = useState(settings.featurePreview.config); - const [stunnerEnabled, setStunnerEnabled] = useState(config.stunnerEnabled); - - useEffect(() => { - settingsDispatch.featurePreview.setConfig(config); - saveConfigCookie(config); - }, [config, settingsDispatch.featurePreview]); - - const onStunnerEnabledChanged = useCallback( - (isEnabled: boolean) => { - setStunnerEnabled(isEnabled); - setConfig({ ...config, stunnerEnabled: isEnabled }); - }, - [config] - ); - - return ( - <Page> - <PageSection> - <PageSection variant={"light"} isFilled={true} style={{ height: "100%" }}> - <Form> - <TextContent> - <Text component={TextVariants.h3}>Feature Preview</Text> - </TextContent> - <TextContent> - <Text component={TextVariants.small}> - Data you provide here is necessary for configuring the preview of features that are not fully supported - yet. All information is locally stored in your browser and never shared with anyone. - </Text> - </TextContent> - <Checkbox - id="feature-preview-enable-stunner" - label="Kogito Serverless Workflow Visualization" - description={"Enable/disable Kogito Serverless Workflow Visualization for JSON files."} - isChecked={stunnerEnabled} - onChange={onStunnerEnabledChanged} - /> - </Form> - </PageSection> - </PageSection> - </Page> - ); -} diff --git a/packages/serverless-logic-web-tools/src/newSettings/github/GitHubSettings.tsx b/packages/serverless-logic-web-tools/src/settings/github/GitHubSettings.tsx similarity index 100% rename from packages/serverless-logic-web-tools/src/newSettings/github/GitHubSettings.tsx rename to packages/serverless-logic-web-tools/src/settings/github/GitHubSettings.tsx diff --git a/packages/serverless-logic-web-tools/src/settings/github/GitHubSettingsTab.tsx b/packages/serverless-logic-web-tools/src/settings/github/GitHubSettingsTab.tsx deleted file mode 100644 index 91e7937803..0000000000 --- a/packages/serverless-logic-web-tools/src/settings/github/GitHubSettingsTab.tsx +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright 2021 Red Hat, Inc. and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import * as React from "react"; -import { Page, PageSection } from "@patternfly/react-core/dist/js/components/Page"; -import { EmptyState, EmptyStateBody, EmptyStateIcon } from "@patternfly/react-core/dist/js/components/EmptyState"; -import { CheckCircleIcon } from "@patternfly/react-icons/dist/js/icons/check-circle-icon"; -import { Text, TextContent, TextVariants } from "@patternfly/react-core/dist/js/components/Text"; -import { Button, ButtonVariant } from "@patternfly/react-core/dist/js/components/Button"; -import { GithubIcon } from "@patternfly/react-icons/dist/js/icons/github-icon"; -import { Spinner } from "@patternfly/react-core/dist/js/components/Spinner"; -import { Form, FormGroup } from "@patternfly/react-core/dist/js/components/Form"; -import { InputGroup } from "@patternfly/react-core/dist/js/components/InputGroup"; -import { TextInput } from "@patternfly/react-core/dist/js/components/TextInput"; -import { useCallback, useMemo, useState } from "react"; -import { AuthStatus, useSettings, useSettingsDispatch } from "../SettingsContext"; -import { ExclamationTriangleIcon } from "@patternfly/react-icons/dist/js/icons/exclamation-triangle-icon"; -import { ExternalLinkAltIcon } from "@patternfly/react-icons/dist/js/icons/external-link-alt-icon"; -import { makeCookieName } from "../../cookies"; - -export const GITHUB_OAUTH_TOKEN_SIZE = 40; -export const GITHUB_TOKENS_URL = "https://github.com/settings/tokens"; -export const GITHUB_TOKENS_HOW_TO_URL = - "https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line"; -export const GITHUB_AUTH_TOKEN_COOKIE_NAME = makeCookieName("github", "oauth-token"); - -export enum GitHubSignInOption { - PERSONAL_ACCESS_TOKEN, - OAUTH, -} - -enum GitHubTokenScope { - GIST = "gist", - REPO = "repo", -} - -export function GitHubSettingsTab() { - const settings = useSettings(); - const settingsDispatch = useSettingsDispatch(); - - const [potentialGitHubToken, setPotentialGitHubToken] = useState<string | undefined>(undefined); - const [isGitHubTokenValid, setIsGitHubTokenValid] = useState(true); - - const githubTokenValidated = useMemo(() => { - return isGitHubTokenValid ? "default" : "error"; - }, [isGitHubTokenValid]); - - const githubTokenHelperText = useMemo(() => { - return isGitHubTokenValid ? undefined : "Invalid token. Check if it has the 'repo' scope."; - }, [isGitHubTokenValid]); - - const githubTokenToDisplay = useMemo(() => { - return obfuscate(potentialGitHubToken ?? settings.github.token); - }, [settings.github, potentialGitHubToken]); - - const onPasteGitHubToken = useCallback( - (e) => { - const token = e.clipboardData.getData("text/plain").slice(0, GITHUB_OAUTH_TOKEN_SIZE); - setPotentialGitHubToken(token); - settingsDispatch.github.authService - .authenticate(token) - .then(() => setIsGitHubTokenValid(true)) - .catch((e) => setIsGitHubTokenValid(false)); - }, - [settingsDispatch.github.authService] - ); - - const onSignOutFromGitHub = useCallback(() => { - settingsDispatch.github.authService.reset(); - setPotentialGitHubToken(undefined); - }, [settingsDispatch.github.authService]); - - return ( - <Page> - {settings.github.authStatus === AuthStatus.TOKEN_EXPIRED && ( - <PageSection> - <EmptyState> - <EmptyStateIcon icon={ExclamationTriangleIcon} /> - <TextContent> - <Text component={"h2"}>GitHub Token expired</Text> - </TextContent> - <br /> - <EmptyStateBody> - <TextContent>Reset your token to sign in with GitHub again.</TextContent> - <br /> - <Button variant={ButtonVariant.tertiary} onClick={onSignOutFromGitHub}> - Reset - </Button> - </EmptyStateBody> - </EmptyState> - </PageSection> - )} - {settings.github.authStatus === AuthStatus.LOADING && ( - <PageSection> - <EmptyState> - <EmptyStateIcon icon={GithubIcon} /> - <TextContent> - <Text component={"h2"}>Signing in with GitHub</Text> - </TextContent> - <br /> - <br /> - <Spinner /> - </EmptyState> - </PageSection> - )} - {settings.github.authStatus === AuthStatus.SIGNED_IN && ( - <PageSection> - <EmptyState> - <EmptyStateIcon icon={CheckCircleIcon} color={"var(--pf-global--success-color--100)"} /> - <TextContent> - <Text component={"h2"}>{"You're signed in with GitHub."}</Text> - </TextContent> - <EmptyStateBody> - <TextContent> - Gists are <b>{settings.github.scopes?.includes(GitHubTokenScope.GIST) ? "enabled" : "disabled"}.</b> - </TextContent> - <TextContent> - Private repositories are{" "} - <b>{settings.github.scopes?.includes(GitHubTokenScope.REPO) ? "enabled" : "disabled"}.</b> - </TextContent> - <br /> - <TextContent> - <b>Token: </b> - <i>{obfuscate(settings.github.token)}</i> - </TextContent> - <TextContent> - <b>User: </b> - <i>{settings.github.user?.login}</i> - </TextContent> - <TextContent> - <b>Scope: </b> - <i>{settings.github.scopes?.join(", ") || "(none)"}</i> - </TextContent> - <br /> - <Button variant={ButtonVariant.tertiary} onClick={onSignOutFromGitHub}> - Sign out - </Button> - </EmptyStateBody> - </EmptyState> - </PageSection> - )} - {settings.github.authStatus === AuthStatus.SIGNED_OUT && ( - <PageSection> - <PageSection variant={"light"} isFilled={true} style={{ height: "100%" }}> - <Form> - <TextContent> - <Text component={TextVariants.h3}>GitHub</Text> - </TextContent> - <TextContent> - <Text component={TextVariants.small}> - Data you provide here is necessary for creating repositories containing models you design, and syncing - changes with GitHub. All information is locally stored in your browser and never shared with anyone. - </Text> - </TextContent> - <h3> - <a href={GITHUB_TOKENS_URL} target={"_blank"} rel="noopener noreferrer"> - Create a new token - <ExternalLinkAltIcon /> - </a> - </h3> - <FormGroup - isRequired={true} - helperTextInvalid={githubTokenHelperText} - validated={githubTokenValidated} - label={"Token"} - fieldId={"github-pat"} - helperText={"Your token must include the 'repo' scope."} - > - <InputGroup> - <TextInput - autoComplete={"off"} - id="token-input" - name="tokenInput" - aria-describedby="token-text-input-helper" - placeholder={"Paste your GitHub token here"} - maxLength={GITHUB_OAUTH_TOKEN_SIZE} - validated={githubTokenValidated} - value={githubTokenToDisplay} - onPaste={onPasteGitHubToken} - /> - </InputGroup> - </FormGroup> - </Form> - </PageSection> - </PageSection> - )} - </Page> - ); -} - -export function obfuscate(token?: string) { - if (!token) { - return undefined; - } - - if (token.length <= 8) { - return token; - } - - const stars = new Array(token.length - 8).join("*"); - const pieceToObfuscate = token.substring(4, token.length - 4); - return token.replace(pieceToObfuscate, stars); -} diff --git a/packages/serverless-logic-web-tools/src/newSettings/kafka/ApacheKafkaSettings.tsx b/packages/serverless-logic-web-tools/src/settings/kafka/ApacheKafkaSettings.tsx similarity index 100% rename from packages/serverless-logic-web-tools/src/newSettings/kafka/ApacheKafkaSettings.tsx rename to packages/serverless-logic-web-tools/src/settings/kafka/ApacheKafkaSettings.tsx diff --git a/packages/serverless-logic-web-tools/src/settings/kafka/ApacheKafkaSettingsTab.tsx b/packages/serverless-logic-web-tools/src/settings/kafka/ApacheKafkaSettingsTab.tsx deleted file mode 100644 index 1d169b4376..0000000000 --- a/packages/serverless-logic-web-tools/src/settings/kafka/ApacheKafkaSettingsTab.tsx +++ /dev/null @@ -1,246 +0,0 @@ -/* - * Copyright 2021 Red Hat, Inc. and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { Alert } from "@patternfly/react-core/dist/js/components/Alert"; -import { Button, ButtonVariant } from "@patternfly/react-core/dist/js/components/Button"; -import { EmptyState, EmptyStateBody, EmptyStateIcon } from "@patternfly/react-core/dist/js/components/EmptyState"; -import { ActionGroup, Form, FormGroup, FormAlert } from "@patternfly/react-core/dist/js/components/Form"; -import { InputGroup, InputGroupText } from "@patternfly/react-core/dist/js/components/InputGroup"; -import { Page, PageSection } from "@patternfly/react-core/dist/js/components/Page"; -import { Popover } from "@patternfly/react-core/dist/js/components/Popover"; -import { Text, TextContent, TextVariants } from "@patternfly/react-core/dist/js/components/Text"; -import { TextInput } from "@patternfly/react-core/dist/js/components/TextInput"; -import { CheckCircleIcon } from "@patternfly/react-icons/dist/js/icons/check-circle-icon"; -import HelpIcon from "@patternfly/react-icons/dist/js/icons/help-icon"; -import { TimesIcon } from "@patternfly/react-icons/dist/js/icons/times-icon"; -import * as React from "react"; -import { useCallback, useMemo, useState } from "react"; -import { useKieSandboxExtendedServices } from "../../kieSandboxExtendedServices/KieSandboxExtendedServicesContext"; -import { KieSandboxExtendedServicesStatus } from "../../kieSandboxExtendedServices/KieSandboxExtendedServicesStatus"; -import { useSettings, useSettingsDispatch } from "../SettingsContext"; -import { SettingsTabs } from "../SettingsModalBody"; -import { EMPTY_CONFIG, isKafkaConfigValid, resetConfigCookie, saveConfigCookie } from "./KafkaSettingsConfig"; - -export function ApacheKafkaSettingsTab() { - const settings = useSettings(); - const settingsDispatch = useSettingsDispatch(); - const [config, setConfig] = useState(settings.apacheKafka.config); - const kieSandboxExtendedServices = useKieSandboxExtendedServices(); - - const isExtendedServicesRunning = useMemo( - () => kieSandboxExtendedServices.status === KieSandboxExtendedServicesStatus.RUNNING, - [kieSandboxExtendedServices.status] - ); - - const isStoredConfigValid = useMemo( - () => isExtendedServicesRunning && isKafkaConfigValid(settings.apacheKafka.config), - [isExtendedServicesRunning, settings.apacheKafka.config] - ); - - const isCurrentConfigValid = useMemo( - () => isExtendedServicesRunning && isKafkaConfigValid(config), - [isExtendedServicesRunning, config] - ); - - const onClearBootstraServer = useCallback(() => setConfig({ ...config, bootstrapServer: "" }), [config]); - const onClearTopic = useCallback(() => setConfig({ ...config, topic: "" }), [config]); - - const onBootstrapServerChanged = useCallback( - (newValue: string) => setConfig({ ...config, bootstrapServer: newValue }), - [config] - ); - - const onTopicChanged = useCallback((newValue: string) => setConfig({ ...config, topic: newValue }), [config]); - - const onReset = useCallback(() => { - setConfig(EMPTY_CONFIG); - settingsDispatch.apacheKafka.setConfig(EMPTY_CONFIG); - resetConfigCookie(); - }, [settingsDispatch.apacheKafka]); - - const onApply = useCallback(() => { - settingsDispatch.apacheKafka.setConfig(config); - saveConfigCookie(config); - }, [config, settingsDispatch.apacheKafka]); - - return ( - <Page> - <PageSection> - {isStoredConfigValid ? ( - <EmptyState> - <EmptyStateIcon icon={CheckCircleIcon} color={"var(--pf-global--success-color--100)"} /> - <TextContent> - <Text component={"h2"}>{"Your Streams for Apache Kafka information is set."}</Text> - </TextContent> - <EmptyStateBody> - <TextContent> - Deploying models with a KafkaSource attached to the service is <b>enabled</b>. - </TextContent> - <br /> - <TextContent> - <b>Bootstrap server: </b> - <i>{config.bootstrapServer}</i> - </TextContent> - <TextContent> - <b>Topic: </b> - <i>{config.topic}</i> - </TextContent> - <br /> - <Button variant={ButtonVariant.tertiary} onClick={onReset}> - Reset - </Button> - </EmptyStateBody> - </EmptyState> - ) : ( - <PageSection variant={"light"} isFilled={true} style={{ height: "100%" }}> - <Form> - {!isExtendedServicesRunning && ( - <FormAlert> - <Alert - variant="danger" - title={ - <Text> - Connect to{" "} - <a onClick={() => settingsDispatch.open(SettingsTabs.KIE_SANDBOX_EXTENDED_SERVICES)}> - KIE Sandbox Extended Services - </a>{" "} - before configuring your Streams for Apache Kafka instance - </Text> - } - aria-live="polite" - isInline - /> - </FormAlert> - )} - <TextContent> - <Text component={TextVariants.h3}>Streams for Apache Kafka</Text> - </TextContent> - <TextContent> - <Text component={TextVariants.small}> - Data you provide here is necessary for connecting serverless deployments with your Streams for Apache - Kafka instance through a KafkaSource. All information is locally stored in your browser and never - shared with anyone. - </Text> - </TextContent> - <FormGroup - label={"Bootstrap Server"} - labelIcon={ - <Popover bodyContent={"The bootstrap server associated with your Streams for Apache Kafka instance."}> - <button - type="button" - aria-label="More info for bootstrap server field" - onClick={(e) => e.preventDefault()} - aria-describedby="bootstrap-server-field" - className="pf-c-form__group-label-help" - > - <HelpIcon noVerticalAlign /> - </button> - </Popover> - } - isRequired - fieldId="bootstrap-server-field" - > - <InputGroup className="pf-u-mt-sm"> - <TextInput - autoComplete={"off"} - isRequired - type="text" - id="bootstrap-server-field" - name="bootstrap-server-field" - aria-label="Bootstrap server field" - aria-describedby="bootstrap-server-field-helper" - value={config.bootstrapServer} - onChange={onBootstrapServerChanged} - tabIndex={1} - data-testid="bootstrap-server-text-field" - /> - <InputGroupText> - <Button - isSmall - variant="plain" - aria-label="Clear bootstrap server button" - onClick={onClearBootstraServer} - > - <TimesIcon /> - </Button> - </InputGroupText> - </InputGroup> - </FormGroup> - <FormGroup - label={"Topic"} - labelIcon={ - <Popover bodyContent={"The topic that messages will flow in."}> - <button - type="button" - aria-label="More info for topic field" - onClick={(e) => e.preventDefault()} - aria-describedby="topic-field" - className="pf-c-form__group-label-help" - > - <HelpIcon noVerticalAlign /> - </button> - </Popover> - } - isRequired - fieldId="topic-field" - > - <InputGroup className="pf-u-mt-sm"> - <TextInput - autoComplete={"off"} - isRequired - type="text" - id="topic-field" - name="topic-field" - aria-label="Topic field" - aria-describedby="topic-field-helper" - value={config.topic} - onChange={onTopicChanged} - tabIndex={2} - data-testid="topic-text-field" - /> - <InputGroupText> - <Button isSmall variant="plain" aria-label="Clear topic button" onClick={onClearTopic}> - <TimesIcon /> - </Button> - </InputGroupText> - </InputGroup> - </FormGroup> - <TextContent> - <Text component={TextVariants.p}> - <b>Note</b>: You must also provide{" "} - <a onClick={() => settingsDispatch.open(SettingsTabs.SERVICE_ACCOUNT)}>Service Account</a> information - so the connection with your Streams for Apache Kafka instance can be properly established. - </Text> - </TextContent> - <ActionGroup> - <Button - isDisabled={!isCurrentConfigValid} - id="apache-kafka-config-apply-button" - key="save" - variant="primary" - onClick={onApply} - data-testid="apply-config-button" - > - Apply - </Button> - </ActionGroup> - </Form> - </PageSection> - )} - </PageSection> - </Page> - ); -} diff --git a/packages/serverless-logic-web-tools/src/newSettings/openshift/OpenShiftSettings.tsx b/packages/serverless-logic-web-tools/src/settings/openshift/OpenShiftSettings.tsx similarity index 100% rename from packages/serverless-logic-web-tools/src/newSettings/openshift/OpenShiftSettings.tsx rename to packages/serverless-logic-web-tools/src/settings/openshift/OpenShiftSettings.tsx diff --git a/packages/serverless-logic-web-tools/src/newSettings/openshift/OpenShiftSettingsSimpleConfig.tsx b/packages/serverless-logic-web-tools/src/settings/openshift/OpenShiftSettingsSimpleConfig.tsx similarity index 100% rename from packages/serverless-logic-web-tools/src/newSettings/openshift/OpenShiftSettingsSimpleConfig.tsx rename to packages/serverless-logic-web-tools/src/settings/openshift/OpenShiftSettingsSimpleConfig.tsx diff --git a/packages/serverless-logic-web-tools/src/settings/openshift/OpenShiftSettingsTab.tsx b/packages/serverless-logic-web-tools/src/settings/openshift/OpenShiftSettingsTab.tsx deleted file mode 100644 index 712ffab798..0000000000 --- a/packages/serverless-logic-web-tools/src/settings/openshift/OpenShiftSettingsTab.tsx +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2021 Red Hat, Inc. and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import * as React from "react"; -import { useCallback } from "react"; -import { Page, PageSection } from "@patternfly/react-core/dist/js/components/Page"; -import { useSettings, useSettingsDispatch } from "../SettingsContext"; -import { OpenShiftInstanceStatus } from "../../openshift/OpenShiftInstanceStatus"; -import { EmptyState, EmptyStateBody, EmptyStateIcon } from "@patternfly/react-core/dist/js/components/EmptyState"; -import { CheckCircleIcon } from "@patternfly/react-icons/dist/js/icons/check-circle-icon"; -import { Text, TextContent } from "@patternfly/react-core/dist/js/components/Text"; -import { Button, ButtonVariant } from "@patternfly/react-core/dist/js/components/Button"; -import { OpenShiftSettingsTabSimpleConfig } from "./OpenShiftSettingsTabSimpleConfig"; -import { obfuscate } from "../github/GitHubSettingsTab"; -import { saveConfigCookie } from "./OpenShiftSettingsConfig"; -import { OpenShiftConnection } from "@kie-tools-core/openshift/dist/service/OpenShiftConnection"; - -export function OpenShiftSettingsTab() { - const settings = useSettings(); - const settingsDispatch = useSettingsDispatch(); - - const onDisconnect = useCallback(() => { - settingsDispatch.openshift.setStatus(OpenShiftInstanceStatus.DISCONNECTED); - const newConfig: OpenShiftConnection = { - namespace: settings.openshift.config.namespace, - host: settings.openshift.config.host, - token: "", - }; - settingsDispatch.openshift.setConfig(newConfig); - saveConfigCookie(newConfig); - }, [settings.openshift.config, settingsDispatch.openshift]); - - return ( - <Page> - <PageSection> - {settings.openshift.status === OpenShiftInstanceStatus.CONNECTED && ( - <EmptyState> - <EmptyStateIcon icon={CheckCircleIcon} color={"var(--pf-global--success-color--100)"} /> - <TextContent> - <Text component={"h2"}>{"You're connected to OpenShift."}</Text> - </TextContent> - <EmptyStateBody> - <TextContent> - Deploying models is <b>enabled</b>. - </TextContent> - <br /> - <TextContent> - <b>Token: </b> - <i>{obfuscate(settings.openshift.config.token)}</i> - </TextContent> - <TextContent> - <b>Host: </b> - <i>{settings.openshift.config.host}</i> - </TextContent> - <TextContent> - <b>Namespace (project): </b> - <i>{settings.openshift.config.namespace}</i> - </TextContent> - <br /> - <Button variant={ButtonVariant.tertiary} onClick={onDisconnect}> - Disconnect - </Button> - </EmptyStateBody> - </EmptyState> - )} - {(settings.openshift.status === OpenShiftInstanceStatus.DISCONNECTED || - settings.openshift.status === OpenShiftInstanceStatus.EXPIRED) && ( - <PageSection variant={"light"} isFilled={true} style={{ height: "100%" }}> - <OpenShiftSettingsTabSimpleConfig /> - </PageSection> - )} - </PageSection> - </Page> - ); -} diff --git a/packages/serverless-logic-web-tools/src/settings/openshift/OpenShiftSettingsTabSimpleConfig.tsx b/packages/serverless-logic-web-tools/src/settings/openshift/OpenShiftSettingsTabSimpleConfig.tsx deleted file mode 100644 index 4e545f9213..0000000000 --- a/packages/serverless-logic-web-tools/src/settings/openshift/OpenShiftSettingsTabSimpleConfig.tsx +++ /dev/null @@ -1,332 +0,0 @@ -/* - * Copyright 2021 Red Hat, Inc. and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import * as React from "react"; -import { Alert } from "@patternfly/react-core/dist/js/components/Alert"; -import { Button } from "@patternfly/react-core/dist/js/components/Button"; -import { ActionGroup, Form, FormAlert, FormGroup } from "@patternfly/react-core/dist/js/components/Form"; -import { InputGroup, InputGroupText } from "@patternfly/react-core/dist/js/components/InputGroup"; -import { Popover } from "@patternfly/react-core/dist/js/components/Popover"; -import { Text, TextContent, TextVariants } from "@patternfly/react-core/dist/js/components/Text"; -import { TextInput } from "@patternfly/react-core/dist/js/components/TextInput"; -import HelpIcon from "@patternfly/react-icons/dist/js/icons/help-icon"; -import { TimesIcon } from "@patternfly/react-icons/dist/js/icons/times-icon"; -import { useCallback, useEffect, useState } from "react"; -import { useAppI18n } from "../../i18n"; -import { OpenShiftInstanceStatus } from "../../openshift/OpenShiftInstanceStatus"; -import { - isOpenShiftConnectionValid, - OpenShiftConnection, -} from "@kie-tools-core/openshift/dist/service/OpenShiftConnection"; -import { EMPTY_CONFIG, saveConfigCookie } from "./OpenShiftSettingsConfig"; -import { useSettings, useSettingsDispatch } from "../SettingsContext"; -import { useKieSandboxExtendedServices } from "../../kieSandboxExtendedServices/KieSandboxExtendedServicesContext"; -import { KieSandboxExtendedServicesStatus } from "../../kieSandboxExtendedServices/KieSandboxExtendedServicesStatus"; -import { SettingsTabs } from "../SettingsModalBody"; - -enum FormValiationOptions { - INITIAL = "INITIAL", - INVALID = "INVALID", - CONNECTION_ERROR = "CONNECTION_ERROR", - CONFIG_EXPIRED = "CONFIG_EXPIRED", -} - -export function OpenShiftSettingsTabSimpleConfig() { - const { i18n } = useAppI18n(); - const settings = useSettings(); - const settingsDispatch = useSettingsDispatch(); - const [config, setConfig] = useState(settings.openshift.config); - const [isConfigValidated, setConfigValidated] = useState(FormValiationOptions.INITIAL); - const [isConnecting, setConnecting] = useState(false); - const kieSandboxExtendedServices = useKieSandboxExtendedServices(); - - useEffect(() => { - setConfig(settings.openshift.config); - setConfigValidated( - settings.openshift.status === OpenShiftInstanceStatus.EXPIRED - ? FormValiationOptions.CONFIG_EXPIRED - : FormValiationOptions.INITIAL - ); - }, [settings.openshift.config, settings.openshift.status]); - - const resetConfig = useCallback( - (config: OpenShiftConnection) => { - setConfigValidated( - settings.openshift.status === OpenShiftInstanceStatus.EXPIRED && config !== EMPTY_CONFIG - ? FormValiationOptions.CONFIG_EXPIRED - : FormValiationOptions.INITIAL - ); - setConnecting(false); - setConfig(config); - }, - [settings.openshift.status] - ); - - const onConnect = useCallback(async () => { - if (isConnecting) { - return; - } - - if (!isOpenShiftConnectionValid(config)) { - setConfigValidated(FormValiationOptions.INVALID); - return; - } - - setConnecting(true); - const isConfigOk = await settingsDispatch.openshift.service.isConnectionEstablished(config); - - if (isConfigOk) { - saveConfigCookie(config); - settingsDispatch.openshift.setConfig(config); - settingsDispatch.openshift.setStatus(OpenShiftInstanceStatus.CONNECTED); - } - - setConnecting(false); - - if (!isConfigOk) { - setConfigValidated(FormValiationOptions.CONNECTION_ERROR); - return; - } - - resetConfig(config); - }, [config, isConnecting, resetConfig, settingsDispatch.openshift]); - - const onClearHost = useCallback(() => setConfig({ ...config, host: "" }), [config]); - const onClearNamespace = useCallback(() => setConfig({ ...config, namespace: "" }), [config]); - const onClearToken = useCallback(() => setConfig({ ...config, token: "" }), [config]); - - const onHostChanged = useCallback( - (newValue: string) => { - setConfig({ ...config, host: newValue }); - }, - [config] - ); - - const onNamespaceChanged = useCallback( - (newValue: string) => { - setConfig({ ...config, namespace: newValue }); - }, - [config] - ); - - const onTokenChanged = useCallback( - (newValue: string) => { - setConfig({ ...config, token: newValue }); - }, - [config] - ); - - return ( - <> - <Form> - {kieSandboxExtendedServices.status !== KieSandboxExtendedServicesStatus.RUNNING && ( - <FormAlert> - <Alert - variant="danger" - title={ - <Text> - Connect to{" "} - <a onClick={() => settingsDispatch.open(SettingsTabs.KIE_SANDBOX_EXTENDED_SERVICES)}> - KIE Sandbox Extended Services - </a>{" "} - before configuring your OpenShift instance - </Text> - } - aria-live="polite" - isInline - /> - </FormAlert> - )} - {isConfigValidated === FormValiationOptions.INVALID && ( - <FormAlert> - <Alert - variant="danger" - title={i18n.openshift.configModal.validationError} - aria-live="polite" - isInline - data-testid="alert-validation-error" - /> - </FormAlert> - )} - {isConfigValidated === FormValiationOptions.CONNECTION_ERROR && ( - <FormAlert> - <Alert - variant="danger" - title={i18n.openshift.configModal.connectionError} - aria-live="polite" - isInline - data-testid="alert-connection-error" - /> - </FormAlert> - )} - {isConfigValidated === FormValiationOptions.CONFIG_EXPIRED && ( - <FormAlert> - <Alert - variant="warning" - title={i18n.openshift.configModal.configExpiredWarning} - aria-live="polite" - isInline - data-testid="alert-config-expired-warning" - /> - </FormAlert> - )} - <TextContent> - <Text component={TextVariants.h3}>OpenShift</Text> - </TextContent> - <TextContent> - <Text component={TextVariants.small}> - Data you provide here is necessary for deploying models you design to your OpenShift instance. All - information is locally stored in your browser and never shared with anyone. - </Text> - </TextContent> - <FormGroup - label={i18n.terms.namespace} - labelIcon={ - <Popover bodyContent={i18n.openshift.configModal.namespaceInfo}> - <button - type="button" - aria-label="More info for namespace field" - onClick={(e) => e.preventDefault()} - aria-describedby="namespace-field" - className="pf-c-form__group-label-help" - > - <HelpIcon noVerticalAlign /> - </button> - </Popover> - } - isRequired - fieldId="namespace-field" - > - <InputGroup className="pf-u-mt-sm"> - <TextInput - autoComplete={"off"} - isRequired - type="text" - id="namespace-field" - name="namespace-field" - aria-label="Namespace field" - aria-describedby="namespace-field-helper" - value={config.namespace} - onChange={onNamespaceChanged} - isDisabled={isConnecting} - tabIndex={1} - data-testid="namespace-text-field" - /> - <InputGroupText> - <Button isSmall variant="plain" aria-label="Clear namespace button" onClick={onClearNamespace}> - <TimesIcon /> - </Button> - </InputGroupText> - </InputGroup> - </FormGroup> - <FormGroup - label={i18n.terms.host} - labelIcon={ - <Popover bodyContent={i18n.openshift.configModal.hostInfo}> - <button - type="button" - aria-label="More info for host field" - onClick={(e) => e.preventDefault()} - aria-describedby="host-field" - className="pf-c-form__group-label-help" - > - <HelpIcon noVerticalAlign /> - </button> - </Popover> - } - isRequired - fieldId="host-field" - > - <InputGroup className="pf-u-mt-sm"> - <TextInput - autoComplete={"off"} - isRequired - type="text" - id="host-field" - name="host-field" - aria-label="Host field" - aria-describedby="host-field-helper" - value={config.host} - onChange={onHostChanged} - isDisabled={isConnecting} - tabIndex={2} - data-testid="host-text-field" - /> - <InputGroupText> - <Button isSmall variant="plain" aria-label="Clear host button" onClick={onClearHost}> - <TimesIcon /> - </Button> - </InputGroupText> - </InputGroup> - </FormGroup> - <FormGroup - label={i18n.terms.token} - labelIcon={ - <Popover bodyContent={i18n.openshift.configModal.tokenInfo}> - <button - type="button" - aria-label="More info for token field" - onClick={(e) => e.preventDefault()} - aria-describedby="token-field" - className="pf-c-form__group-label-help" - > - <HelpIcon noVerticalAlign /> - </button> - </Popover> - } - isRequired - fieldId="token-field" - > - <InputGroup className="pf-u-mt-sm"> - <TextInput - autoComplete={"off"} - isRequired - type="text" - id="token-field" - name="token-field" - aria-label="Token field" - aria-describedby="token-field-helper" - value={config.token} - onChange={onTokenChanged} - isDisabled={isConnecting} - tabIndex={3} - data-testid="token-text-field" - /> - <InputGroupText> - <Button isSmall variant="plain" aria-label="Clear token button" onClick={onClearToken}> - <TimesIcon /> - </Button> - </InputGroupText> - </InputGroup> - </FormGroup> - <ActionGroup> - <Button - id="openshift-config-save-button" - key="save" - variant="primary" - onClick={onConnect} - data-testid="save-config-button" - isLoading={isConnecting} - isDisabled={kieSandboxExtendedServices.status !== KieSandboxExtendedServicesStatus.RUNNING} - spinnerAriaValueText={isConnecting ? "Loading" : undefined} - > - {isConnecting ? "Connecting" : "Connect"} - </Button> - </ActionGroup> - </Form> - </> - ); -} diff --git a/packages/serverless-logic-web-tools/src/newSettings/routes/SettingsPageRoutes.tsx b/packages/serverless-logic-web-tools/src/settings/routes/SettingsPageRoutes.tsx similarity index 100% rename from packages/serverless-logic-web-tools/src/newSettings/routes/SettingsPageRoutes.tsx rename to packages/serverless-logic-web-tools/src/settings/routes/SettingsPageRoutes.tsx diff --git a/packages/serverless-logic-web-tools/src/settings/serviceAccount/ServiceAccountConfig.tsx b/packages/serverless-logic-web-tools/src/settings/serviceAccount/ServiceAccountConfig.tsx index 781dcd609d..1b9bb2d77a 100644 --- a/packages/serverless-logic-web-tools/src/settings/serviceAccount/ServiceAccountConfig.tsx +++ b/packages/serverless-logic-web-tools/src/settings/serviceAccount/ServiceAccountConfig.tsx @@ -1,5 +1,5 @@ /* - * Copyright 2022 Red Hat, Inc. and/or its affiliates. + * Copyright 2023 Red Hat, Inc. and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/packages/serverless-logic-web-tools/src/newSettings/serviceAccount/ServiceAccountSettings.tsx b/packages/serverless-logic-web-tools/src/settings/serviceAccount/ServiceAccountSettings.tsx similarity index 100% rename from packages/serverless-logic-web-tools/src/newSettings/serviceAccount/ServiceAccountSettings.tsx rename to packages/serverless-logic-web-tools/src/settings/serviceAccount/ServiceAccountSettings.tsx diff --git a/packages/serverless-logic-web-tools/src/settings/serviceAccount/ServiceAccountSettingsTab.tsx b/packages/serverless-logic-web-tools/src/settings/serviceAccount/ServiceAccountSettingsTab.tsx deleted file mode 100644 index 58d61cf9ae..0000000000 --- a/packages/serverless-logic-web-tools/src/settings/serviceAccount/ServiceAccountSettingsTab.tsx +++ /dev/null @@ -1,261 +0,0 @@ -/* - * Copyright 2021 Red Hat, Inc. and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { Alert } from "@patternfly/react-core/dist/js/components/Alert"; -import { Button, ButtonVariant } from "@patternfly/react-core/dist/js/components/Button"; -import { EmptyState, EmptyStateBody, EmptyStateIcon } from "@patternfly/react-core/dist/js/components/EmptyState"; -import { ActionGroup, Form, FormGroup, FormAlert } from "@patternfly/react-core/dist/js/components/Form"; -import { InputGroup, InputGroupText } from "@patternfly/react-core/dist/js/components/InputGroup"; -import { Page, PageSection } from "@patternfly/react-core/dist/js/components/Page"; -import { Popover } from "@patternfly/react-core/dist/js/components/Popover"; -import { Text, TextContent, TextVariants } from "@patternfly/react-core/dist/js/components/Text"; -import { TextInput } from "@patternfly/react-core/dist/js/components/TextInput"; -import { CheckCircleIcon } from "@patternfly/react-icons/dist/js/icons/check-circle-icon"; -import HelpIcon from "@patternfly/react-icons/dist/js/icons/help-icon"; -import { TimesIcon } from "@patternfly/react-icons/dist/js/icons/times-icon"; -import * as React from "react"; -import { useCallback, useMemo, useState } from "react"; -import { useKieSandboxExtendedServices } from "../../kieSandboxExtendedServices/KieSandboxExtendedServicesContext"; -import { KieSandboxExtendedServicesStatus } from "../../kieSandboxExtendedServices/KieSandboxExtendedServicesStatus"; -import { useSettings, useSettingsDispatch } from "../SettingsContext"; -import { SettingsTabs } from "../SettingsModalBody"; -import { EMPTY_CONFIG, isServiceAccountConfigValid, resetConfigCookie, saveConfigCookie } from "./ServiceAccountConfig"; - -export function ServiceAccountSettingsTab() { - const settings = useSettings(); - const settingsDispatch = useSettingsDispatch(); - const [config, setConfig] = useState(settings.serviceAccount.config); - const kieSandboxExtendedServices = useKieSandboxExtendedServices(); - - const isExtendedServicesRunning = useMemo( - () => kieSandboxExtendedServices.status === KieSandboxExtendedServicesStatus.RUNNING, - [kieSandboxExtendedServices.status] - ); - - const isStoredConfigValid = useMemo( - () => isExtendedServicesRunning && isServiceAccountConfigValid(settings.serviceAccount.config), - [isExtendedServicesRunning, settings.serviceAccount.config] - ); - - const isCurrentConfigValid = useMemo( - () => isExtendedServicesRunning && isServiceAccountConfigValid(config), - [config, isExtendedServicesRunning] - ); - - const onClearClientId = useCallback(() => setConfig({ ...config, clientId: "" }), [config]); - const onClearClientSecret = useCallback(() => setConfig({ ...config, clientSecret: "" }), [config]); - - const onClientIdChanged = useCallback( - (newValue: string) => { - setConfig({ ...config, clientId: newValue }); - }, - [config] - ); - - const onClientSecretChanged = useCallback( - (newValue: string) => { - setConfig({ ...config, clientSecret: newValue }); - }, - [config] - ); - - const onReset = useCallback(() => { - setConfig(EMPTY_CONFIG); - settingsDispatch.serviceAccount.setConfig(EMPTY_CONFIG); - resetConfigCookie(); - }, [settingsDispatch.serviceAccount]); - - const onApply = useCallback(() => { - settingsDispatch.serviceAccount.setConfig(config); - saveConfigCookie(config); - }, [config, settingsDispatch.serviceAccount]); - - return ( - <Page> - <PageSection> - {isStoredConfigValid ? ( - <EmptyState> - <EmptyStateIcon icon={CheckCircleIcon} color={"var(--pf-global--success-color--100)"} /> - <TextContent> - <Text component={"h2"}>{"Your Service Account information is set."}</Text> - </TextContent> - <EmptyStateBody> - <TextContent> - Accessing your Service Registry and Streams for Apache Kafka is <b>enabled</b>. - </TextContent> - <br /> - <TextContent> - <b>Client ID: </b> - <i>{config.clientId}</i> - </TextContent> - <br /> - <TextContent> - <b>Client secret: </b> - <i>{obfuscate(config.clientSecret)}</i> - </TextContent> - <br /> - <Button variant={ButtonVariant.tertiary} onClick={onReset}> - Reset - </Button> - </EmptyStateBody> - </EmptyState> - ) : ( - <PageSection variant={"light"} isFilled={true} style={{ height: "100%" }}> - <Form> - {!isExtendedServicesRunning && ( - <FormAlert> - <Alert - variant="danger" - title={ - <Text> - Connect to{" "} - <a onClick={() => settingsDispatch.open(SettingsTabs.KIE_SANDBOX_EXTENDED_SERVICES)}> - KIE Sandbox Extended Services - </a>{" "} - before configuring your Service Account - </Text> - } - aria-live="polite" - isInline - /> - </FormAlert> - )} - <TextContent> - <Text component={TextVariants.h3}>Service Account</Text> - </TextContent> - <TextContent> - <Text component={TextVariants.small}> - Data you provide here is necessary for uploading Open API specs associated with models you design to - your Service Registry instance and also connecting deployments with your Streams for Apache Kafka - instance. All information is locally stored in your browser and never shared with anyone. - </Text> - </TextContent> - <FormGroup - label={"Client ID"} - labelIcon={ - <Popover bodyContent={"Client ID"}> - <button - type="button" - aria-label="More info for client id field" - onClick={(e) => e.preventDefault()} - aria-describedby="client-id-field" - className="pf-c-form__group-label-help" - > - <HelpIcon noVerticalAlign /> - </button> - </Popover> - } - isRequired - fieldId="client-id-field" - > - <InputGroup className="pf-u-mt-sm"> - <TextInput - autoComplete={"off"} - isRequired - type="text" - id="client-id-field" - name="client-id-field" - aria-label="Client ID field" - aria-describedby="client-id-field-helper" - value={config.clientId} - onChange={onClientIdChanged} - tabIndex={1} - data-testid="client-id-text-field" - /> - <InputGroupText> - <Button isSmall variant="plain" aria-label="Clear client id button" onClick={onClearClientId}> - <TimesIcon /> - </Button> - </InputGroupText> - </InputGroup> - </FormGroup> - <FormGroup - label={"Client Secret"} - labelIcon={ - <Popover bodyContent={"Client Secret"}> - <button - type="button" - aria-label="More info for client secret field" - onClick={(e) => e.preventDefault()} - aria-describedby="client-secret-field" - className="pf-c-form__group-label-help" - > - <HelpIcon noVerticalAlign /> - </button> - </Popover> - } - isRequired - fieldId="client-secret-field" - > - <InputGroup className="pf-u-mt-sm"> - <TextInput - autoComplete={"off"} - isRequired - type="text" - id="client-secret-field" - name="client-secret-field" - aria-label="Client secret field" - aria-describedby="client-secret-field-helper" - value={config.clientSecret} - onChange={onClientSecretChanged} - tabIndex={2} - data-testid="client-secret-text-field" - /> - <InputGroupText> - <Button - isSmall - variant="plain" - aria-label="Clear client secret button" - onClick={onClearClientSecret} - > - <TimesIcon /> - </Button> - </InputGroupText> - </InputGroup> - </FormGroup> - <ActionGroup> - <Button - isDisabled={!isCurrentConfigValid} - id="service-account-config-apply-button" - key="save" - variant="primary" - onClick={onApply} - data-testid="apply-config-button" - > - Apply - </Button> - </ActionGroup> - </Form> - </PageSection> - )} - </PageSection> - </Page> - ); -} - -export function obfuscate(token?: string) { - if (!token) { - return undefined; - } - - if (token.length <= 10) { - return new Array(10).join("*"); - } - - const stars = new Array(token.length - 4).join("*"); - const pieceToObfuscate = token.substring(0, token.length - 4); - return token.replace(pieceToObfuscate, stars); -} diff --git a/packages/serverless-logic-web-tools/src/settings/serviceRegistry/ServiceRegistryConfig.tsx b/packages/serverless-logic-web-tools/src/settings/serviceRegistry/ServiceRegistryConfig.tsx index 1ed89d6b07..49dad4fe02 100644 --- a/packages/serverless-logic-web-tools/src/settings/serviceRegistry/ServiceRegistryConfig.tsx +++ b/packages/serverless-logic-web-tools/src/settings/serviceRegistry/ServiceRegistryConfig.tsx @@ -1,5 +1,5 @@ /* - * Copyright 2022 Red Hat, Inc. and/or its affiliates. + * Copyright 2023 Red Hat, Inc. and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/packages/serverless-logic-web-tools/src/newSettings/serviceRegistry/ServiceRegistrySettings.tsx b/packages/serverless-logic-web-tools/src/settings/serviceRegistry/ServiceRegistrySettings.tsx similarity index 97% rename from packages/serverless-logic-web-tools/src/newSettings/serviceRegistry/ServiceRegistrySettings.tsx rename to packages/serverless-logic-web-tools/src/settings/serviceRegistry/ServiceRegistrySettings.tsx index 0954800caa..9736e7af5c 100644 --- a/packages/serverless-logic-web-tools/src/newSettings/serviceRegistry/ServiceRegistrySettings.tsx +++ b/packages/serverless-logic-web-tools/src/settings/serviceRegistry/ServiceRegistrySettings.tsx @@ -100,9 +100,8 @@ export function ServiceRegistrySettings(props: SettingsPageProps) { <TextContent> <Text component={TextVariants.h1}>Service Registry</Text> <Text component={TextVariants.p}> - Data you provide here is necessary for uploading Open API specs associated with models you design to your - Service Registry instance. - <br /> All information is locally stored in your browser and never shared with anyone. + Data you provide here is necessary for uploading specs associated with models you design to your Service + Registry instance. All information is locally stored in your browser and never shared with anyone. </Text> </TextContent> </PageSection> @@ -136,7 +135,7 @@ export function ServiceRegistrySettings(props: SettingsPageProps) { <Text component={"h2"}>{"Your Service Registry information is set."}</Text> </TextContent> <EmptyStateBody> - Uploading OpenAPI specs when deploying models is <b>enabled</b>. + Uploading specs when deploying models is <b>enabled</b>. <br /> <b>Service Registry Name: </b> <i>{config.name}</i> diff --git a/packages/serverless-logic-web-tools/src/settings/serviceRegistry/ServiceRegistrySettingsTab.tsx b/packages/serverless-logic-web-tools/src/settings/serviceRegistry/ServiceRegistrySettingsTab.tsx deleted file mode 100644 index aa9344ac5d..0000000000 --- a/packages/serverless-logic-web-tools/src/settings/serviceRegistry/ServiceRegistrySettingsTab.tsx +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Copyright 2021 Red Hat, Inc. and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { Alert } from "@patternfly/react-core/dist/js/components/Alert"; -import { Button, ButtonVariant } from "@patternfly/react-core/dist/js/components/Button"; -import { EmptyState, EmptyStateBody, EmptyStateIcon } from "@patternfly/react-core/dist/js/components/EmptyState"; -import { ActionGroup, Form, FormGroup, FormAlert } from "@patternfly/react-core/dist/js/components/Form"; -import { InputGroup, InputGroupText } from "@patternfly/react-core/dist/js/components/InputGroup"; -import { Page, PageSection } from "@patternfly/react-core/dist/js/components/Page"; -import { Popover } from "@patternfly/react-core/dist/js/components/Popover"; -import { Text, TextContent, TextVariants } from "@patternfly/react-core/dist/js/components/Text"; -import { TextInput } from "@patternfly/react-core/dist/js/components/TextInput"; -import { CheckCircleIcon } from "@patternfly/react-icons/dist/js/icons/check-circle-icon"; -import HelpIcon from "@patternfly/react-icons/dist/js/icons/help-icon"; -import { TimesIcon } from "@patternfly/react-icons/dist/js/icons/times-icon"; -import * as React from "react"; -import { useCallback, useMemo, useState } from "react"; -import { useKieSandboxExtendedServices } from "../../kieSandboxExtendedServices/KieSandboxExtendedServicesContext"; -import { KieSandboxExtendedServicesStatus } from "../../kieSandboxExtendedServices/KieSandboxExtendedServicesStatus"; -import { useSettings, useSettingsDispatch } from "../SettingsContext"; -import { SettingsTabs } from "../SettingsModalBody"; -import { - EMPTY_CONFIG, - isServiceRegistryConfigValid, - resetConfigCookie, - saveConfigCookie, -} from "./ServiceRegistryConfig"; - -export function ServiceRegistrySettingsTab() { - const settings = useSettings(); - const settingsDispatch = useSettingsDispatch(); - const [config, setConfig] = useState(settings.serviceRegistry.config); - const kieSandboxExtendedServices = useKieSandboxExtendedServices(); - - const isExtendedServicesRunning = useMemo( - () => kieSandboxExtendedServices.status === KieSandboxExtendedServicesStatus.RUNNING, - [kieSandboxExtendedServices.status] - ); - - const isStoredConfigValid = useMemo( - () => isExtendedServicesRunning && isServiceRegistryConfigValid(settings.serviceRegistry.config), - [isExtendedServicesRunning, settings.serviceRegistry.config] - ); - - const isCurrentConfigValid = useMemo( - () => isExtendedServicesRunning && isServiceRegistryConfigValid(config), - [isExtendedServicesRunning, config] - ); - - const onClearName = useCallback(() => setConfig({ ...config, name: "" }), [config]); - - const onClearCoreRegistryApi = useCallback(() => setConfig({ ...config, coreRegistryApi: "" }), [config]); - - const onNameChanged = useCallback((newValue: string) => setConfig({ ...config, name: newValue }), [config]); - - const onCoreRegistryApiChanged = useCallback( - (newValue: string) => setConfig({ ...config, coreRegistryApi: newValue }), - [config] - ); - - const onReset = useCallback(() => { - setConfig(EMPTY_CONFIG); - settingsDispatch.serviceRegistry.setConfig(EMPTY_CONFIG); - resetConfigCookie(); - }, [settingsDispatch.serviceRegistry]); - - const onApply = useCallback(() => { - settingsDispatch.serviceRegistry.setConfig(config); - saveConfigCookie(config); - }, [config, settingsDispatch.serviceRegistry]); - - return ( - <Page> - <PageSection> - {isStoredConfigValid ? ( - <EmptyState> - <EmptyStateIcon icon={CheckCircleIcon} color={"var(--pf-global--success-color--100)"} /> - <TextContent> - <Text component={"h2"}>{"Your Service Registry information is set."}</Text> - </TextContent> - <EmptyStateBody> - <TextContent> - Uploading specs when deploying models is <b>enabled</b>. - </TextContent> - <br /> - <TextContent> - <b>Service Registry Name: </b> - <i>{config.name}</i> - </TextContent> - <br /> - <TextContent> - <b>Core Registry Api: </b> - <i>{config.coreRegistryApi}</i> - </TextContent> - <br /> - <Button variant={ButtonVariant.tertiary} onClick={onReset}> - Reset - </Button> - </EmptyStateBody> - </EmptyState> - ) : ( - <PageSection variant={"light"} isFilled={true} style={{ height: "100%" }}> - <Form> - {!isExtendedServicesRunning && ( - <FormAlert> - <Alert - variant="danger" - title={ - <Text> - Connect to{" "} - <a onClick={() => settingsDispatch.open(SettingsTabs.KIE_SANDBOX_EXTENDED_SERVICES)}> - KIE Sandbox Extended Services - </a>{" "} - before configuring your Service Registry instance - </Text> - } - aria-live="polite" - isInline - /> - </FormAlert> - )} - <TextContent> - <Text component={TextVariants.h3}>Service Registry</Text> - </TextContent> - <TextContent> - <Text component={TextVariants.small}> - Data you provide here is necessary for uploading specs associated with models you design to your - Service Registry instance. All information is locally stored in your browser and never shared with - anyone. - </Text> - </TextContent> - <FormGroup - label={"Name"} - labelIcon={ - <Popover - bodyContent={ - "Name to identify your Service Registry instance across the Serverless Logic Web Tools." - } - > - <button - type="button" - aria-label="More info for name field" - onClick={(e) => e.preventDefault()} - aria-describedby="name-field" - className="pf-c-form__group-label-help" - > - <HelpIcon noVerticalAlign /> - </button> - </Popover> - } - isRequired - fieldId="name-field" - > - <InputGroup className="pf-u-mt-sm"> - <TextInput - autoComplete={"off"} - isRequired - type="text" - id="name-field" - name="name-field" - aria-label="Name field" - aria-describedby="name-field-helper" - value={config.name} - onChange={onNameChanged} - tabIndex={1} - data-testid="name-text-field" - /> - <InputGroupText> - <Button isSmall variant="plain" aria-label="Clear name button" onClick={onClearName}> - <TimesIcon /> - </Button> - </InputGroupText> - </InputGroup> - </FormGroup> - <FormGroup - label={"Core Registry API"} - labelIcon={ - <Popover bodyContent={"Core Registry API URL associated with your Service Registry instance."}> - <button - type="button" - aria-label="More info for core registry api field" - onClick={(e) => e.preventDefault()} - aria-describedby="core-registry-api-field" - className="pf-c-form__group-label-help" - > - <HelpIcon noVerticalAlign /> - </button> - </Popover> - } - isRequired - fieldId="core-registry-api-field" - > - <InputGroup className="pf-u-mt-sm"> - <TextInput - autoComplete={"off"} - isRequired - type="text" - id="core-registry-api-field" - name="core-registry-api-field" - aria-label="Core Registry API field" - aria-describedby="core-registry-api-field-helper" - value={config.coreRegistryApi} - onChange={onCoreRegistryApiChanged} - tabIndex={2} - data-testid="core-registry-api-text-field" - /> - <InputGroupText> - <Button - isSmall - variant="plain" - aria-label="Clear core registry api button" - onClick={onClearCoreRegistryApi} - > - <TimesIcon /> - </Button> - </InputGroupText> - </InputGroup> - </FormGroup> - <TextContent> - <Text component={TextVariants.p}> - <b>Note</b>: You must also provide{" "} - <a onClick={() => settingsDispatch.open(SettingsTabs.SERVICE_ACCOUNT)}>Service Account</a> information - so the connection with your Service Registry instance can be properly established. - </Text> - </TextContent> - <ActionGroup> - <Button - isDisabled={!isCurrentConfigValid} - id="service-registry-config-apply-button" - key="save" - variant="primary" - onClick={onApply} - data-testid="apply-config-button" - > - Apply - </Button> - </ActionGroup> - </Form> - </PageSection> - )} - </PageSection> - </Page> - ); -} diff --git a/packages/serverless-logic-web-tools/src/newSettings/types.ts b/packages/serverless-logic-web-tools/src/settings/types.ts similarity index 100% rename from packages/serverless-logic-web-tools/src/newSettings/types.ts rename to packages/serverless-logic-web-tools/src/settings/types.ts diff --git a/packages/serverless-logic-web-tools/src/newSettings/uiNav/SettingsPageNav.tsx b/packages/serverless-logic-web-tools/src/settings/uiNav/SettingsPageNav.tsx similarity index 100% rename from packages/serverless-logic-web-tools/src/newSettings/uiNav/SettingsPageNav.tsx rename to packages/serverless-logic-web-tools/src/settings/uiNav/SettingsPageNav.tsx --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
