/* * Copyright 2023 Harness, Inc. * * 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 React from 'react' import cx from 'classnames' import { PageBody, Container, Tabs } from '@harnessio/uicore' import { useHistory } from 'react-router-dom' import { useGetRepositoryMetadata } from 'hooks/useGetRepositoryMetadata' import { useDisableCodeMainLinks } from 'hooks/useDisableCodeMainLinks' import { useGetResourceContent } from 'hooks/useGetResourceContent' import { useStrings } from 'framework/strings' import { RepositoryPageHeader } from 'components/RepositoryPageHeader/RepositoryPageHeader' import { LabelsPageScope, getErrorMessage, voidFn } from 'utils/Utils' import { LoadingSpinner } from 'components/LoadingSpinner/LoadingSpinner' // import Webhooks from 'pages/Webhooks/Webhooks' import { useAppContext } from 'AppContext' import BranchProtectionListing from 'components/BranchProtection/BranchProtectionListing' import { SettingsTab, normalizeGitRef } from 'utils/GitUtils' import SecurityScanSettings from 'pages/RepositorySettings/SecurityScanSettings/SecurityScanSettings' import LabelsListing from 'pages/Labels/LabelsListing' import { useGetSpaceParam } from 'hooks/useGetSpaceParam' import GeneralSettingsContent from './GeneralSettingsContent/GeneralSettingsContent' import css from './RepositorySettings.module.scss' export default function RepositorySettings() { const { repoMetadata, error, loading, refetch, settingSection, gitRef, resourcePath } = useGetRepositoryMetadata() const space = useGetSpaceParam() const history = useHistory() const { routes, hooks, standalone } = useAppContext() const { CODE_PULLREQ_LABELS: isLabelEnabled } = hooks?.useFeatureFlags() const [activeTab, setActiveTab] = React.useState(settingSection || SettingsTab.general) const { getString } = useStrings() const { isRepositoryEmpty } = useGetResourceContent({ repoMetadata, gitRef: normalizeGitRef(gitRef) as string, resourcePath }) useDisableCodeMainLinks(!!isRepositoryEmpty) const tabListArray = [ { id: SettingsTab.general, title: getString('settings'), panel: ( ) }, { id: SettingsTab.branchProtection, title: getString('branchProtection.title'), panel: }, { id: SettingsTab.security, title: getString('security'), panel: }, ...(isLabelEnabled || standalone ? [ { id: SettingsTab.labels, title: getString('labels.labels'), panel: ( ) } ] : []) // { // id: SettingsTab.webhooks, // title: getString('webhooks'), // panel: ( // // // // ) // } ] return ( {repoMetadata && ( { setActiveTab(id) history.replace( routes.toCODESettings({ repoPath: repoMetadata?.path as string, settingSection: id !== SettingsTab.general ? (id as string) : '' }) ) }} tabList={tabListArray}> )} ) }