Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "[🍒][CDAP-20917] Integrate the new SCM list apis" #1213

Merged
merged 1 commit into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions app/cdap/api/pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ var pipelineV1AppContextPath = `${pipelineV1AppPath}/contexts/:context`;

export const MyPipelineApi = {
list: apiCreator(dataSrc, 'GET', 'REQUEST', '/namespaces/:namespace/apps'),
listScm: apiCreator(dataSrc, 'GET', 'REQUEST', '/namespaces/:namespace/sourcecontrol/apps'),
publish: apiCreator(dataSrc, 'PUT', 'REQUEST', basepath),

schedule: apiCreator(dataSrc, 'POST', 'REQUEST', `${schedulePath}/resume`),
Expand Down Expand Up @@ -81,5 +80,4 @@ export const MyPipelineApi = {
),

getAppVersions: apiCreator(dataSrc, 'GET', 'REQUEST', `${basepath}/versions`),
getScmSyncStatus: apiCreator(dataSrc, 'GET', 'REQUEST', `${basepath}/sourcecontrol`),
};
41 changes: 0 additions & 41 deletions app/cdap/components/FooterContext/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@ import { ISourceControlManagementConfig } from './types';
import PrimaryContainedButton from 'components/shared/Buttons/PrimaryContainedButton';
import PrimaryOutlinedButton from 'components/shared/Buttons/PrimaryOutlinedButton';
import ButtonLoadingHoc from 'components/shared/Buttons/ButtonLoadingHoc';
import { authKeys, githubOnlyProviders, patConfigKeys, providers, scmAuthType } from './constants';
import { authKeys, patConfigKeys, providers, scmAuthType } from './constants';
import { defaultSourceControlManagement, sourceControlManagementFormReducer } from './reducer';
import { addOrValidateSourceControlManagementForm } from '../store/ActionCreator';
import { getCurrentNamespace } from 'services/NamespaceStore';
import { EntityTopPanel } from 'components/EntityTopPanel';
import Alert from 'components/shared/Alert';
import PropertyRow from './PropertyRow';
import { useFeatureFlagDefaultFalse } from 'services/react/customHooks/useFeatureFlag';

const PREFIX = 'features.SourceControlManagement.configModal';

Expand Down Expand Up @@ -87,9 +86,6 @@ const SourceControlManagementForm = ({
onToggle,
isEdit,
}: ISourceControlManagementFormProps) => {
const isGitlabAndBitbucketEnabled = useFeatureFlagDefaultFalse(
'source.control.management.gitlab.bitbucket.enabled'
);
const [formState, formStateDispatch] = useReducer(
sourceControlManagementFormReducer,
defaultSourceControlManagement
Expand Down Expand Up @@ -240,9 +236,7 @@ const SourceControlManagementForm = ({
'widget-type': 'select',
'widget-attributes': {
default: providers.github,
values: Object.values(
isGitlabAndBitbucketEnabled ? providers : githubOnlyProviders
),
values: Object.values(providers),
},
}}
onChange={(val) => {
Expand Down Expand Up @@ -332,9 +326,7 @@ const SourceControlManagementForm = ({
value={formState.config?.auth?.token}
property={{
name: 'token',
description: T.translate(`${PREFIX}.auth.pat.tokenHelperText`, {
provider: formState.config?.provider || providers.github,
}).toString(),
description: T.translate(`${PREFIX}.auth.pat.tokenHelperText`).toString(),
label: T.translate(`${PREFIX}.auth.pat.token`).toString(),
required: !isEdit,
'widget-type': 'password',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,8 @@ export const scmAuthType = [
{ id: 'PAT', label: T.translate(`${PREFIX}.configModal.auth.pat.label`) },
];

export const githubOnlyProviders = {
github: 'GITHUB',
};

export const providers = {
...githubOnlyProviders,
gitlab: 'GITLAB',
bitbucket: 'BITBUCKET_SERVER',
bitbucketCloud: 'BITBUCKET_CLOUD',
github: 'GITHUB',
};

export const authKeys = ['type', 'token'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import TableBody from 'components/shared/Table/TableBody';
import { useSelector } from 'react-redux';
import ActionsPopover from 'components/shared/ActionsPopover';
import { UnlinkSourceControlModal } from './UnlinkSourceControlModal';
import StyledPasswordWrapper from 'components/AbstractWidget/FormInputs/Password';
import { ISourceControlManagementConfig } from './types';
import SourceControlManagementForm from './SourceControlManagementForm';
import PrimaryTextButton from 'components/shared/Buttons/PrimaryTextButton';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import styled from 'styled-components';
import { LoadingAppLevel } from 'components/shared/LoadingAppLevel';
import Alert from 'components/shared/Alert';
import {
getScmSyncStatus,
pullPipeline,
setPullStatus,
setSourceControlMeta,
Expand Down Expand Up @@ -318,18 +317,13 @@ class PipelineDetailsActionsButton extends Component<IPipelineDetailsActionsButt
);
}

public onPipelinePush = (fileHash) => {
setSourceControlMeta(fileHash);
getScmSyncStatus(this.props.pipelineName);
};

public renderCommitModal = () => {
return (
<CommitModal
isOpen={this.state.showCommitModal}
onToggle={this.toggleCommitModal}
pipelineName={this.props.pipelineName}
updateFileHash={this.onPipelinePush}
updateFileHash={setSourceControlMeta}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,16 @@
* the License.
*/

import React, { useEffect } from 'react';
import React from 'react';
import { connect, Provider } from 'react-redux';
import T from 'i18n-react';
import styled from 'styled-components';
import { green, red } from '@material-ui/core/colors';
import CheckCircleIcon from '@material-ui/icons/CheckCircle';
import ErrorIcon from '@material-ui/icons/Error';

import PipelineDetailStore from 'components/PipelineDetails/store';
import Tags from 'components/shared/Tags';
import IconSVG from 'components/shared/IconSVG';
import Popover from 'components/shared/Popover';
import { GLOBALS } from 'services/global-constants';
import { Chip } from '@material-ui/core';
import { useFeatureFlagDefaultFalse } from 'services/react/customHooks/useFeatureFlag';
import { getScmSyncStatus } from '../store/ActionCreator';

const PREFIX = 'features.PipelineDetails.TopPanel';
const SCM_PREFIX = 'features.SourceControlManagement';
Expand All @@ -41,7 +35,6 @@ const StyledSpan = styled.span`

const StyledChip = styled(Chip)`
height: 20px;
margin-right: 10px;
`;

const mapStateToPipelineTagsProps = (state) => {
Expand All @@ -59,14 +52,13 @@ const mapStateToPipelineTagsProps = (state) => {
const ConnectedPipelineTags = connect(mapStateToPipelineTagsProps)(Tags);

const mapStateToPipelineDetailsMetadataProps = (state) => {
const { name, artifact, version, description, sourceControlMeta, scmSyncStatus } = state;
const { name, artifact, version, description, sourceControlMeta } = state;
return {
name,
artifactName: artifact.name,
version,
description,
sourceControlMeta,
scmSyncStatus,
};
};

Expand All @@ -78,10 +70,6 @@ interface IPipelineDetailsMetadata {
sourceControlMeta: {
fileHash: string;
};
scmSyncStatus?: {
isSynced?: boolean;
lastModified?: number;
};
}

const PipelineDetailsMetadata = ({
Expand All @@ -90,18 +78,7 @@ const PipelineDetailsMetadata = ({
version,
description,
sourceControlMeta,
scmSyncStatus,
}: IPipelineDetailsMetadata) => {
const scmMultiSyncEnabled = useFeatureFlagDefaultFalse(
'source.control.management.multi.app.enabled'
);

useEffect(() => {
if (name && scmMultiSyncEnabled) {
getScmSyncStatus(name);
}
}, [name]);

return (
<div className="pipeline-metadata">
<div className="pipeline-type-name-version">
Expand All @@ -124,7 +101,7 @@ const PipelineDetailsMetadata = ({
{description}
</Popover>
</span>
{!scmMultiSyncEnabled && sourceControlMeta && sourceControlMeta.fileHash && (
{sourceControlMeta && sourceControlMeta.fileHash && (
<StyledSpan>
<StyledChip variant="outlined" label={T.translate(`${SCM_PREFIX}.table.gitStatus`)} />
<Popover
Expand All @@ -136,30 +113,6 @@ const PipelineDetailsMetadata = ({
</Popover>
</StyledSpan>
)}
{scmMultiSyncEnabled && (
<StyledSpan>
{scmSyncStatus.isSynced ? (
<StyledChip
variant="outlined"
label={T.translate(`${SCM_PREFIX}.table.gitSyncStatusSynced`)}
icon={<CheckCircleIcon style={{ color: green[500] }} fontSize="small" />}
/>
) : (
<StyledChip
variant="outlined"
label={T.translate(`${SCM_PREFIX}.table.gitSyncStatusUnsynced`)}
icon={<ErrorIcon style={{ color: red[500] }} fontSize="small" />}
/>
)}
<Popover
target={() => <IconSVG name="icon-info-circle" />}
showOn="Hover"
placement="bottom"
>
{T.translate(`${SCM_PREFIX}.table.syncStatusHelperText`)}
</Popover>
</StyledSpan>
)}
<span className="pipeline-version">{T.translate(`${PREFIX}.version`, { version })}</span>
</div>
<div className="pipeline-tags">
Expand Down
15 changes: 0 additions & 15 deletions app/cdap/components/PipelineDetails/store/ActionCreator.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { MyPipelineApi } from 'api/pipeline';
import { SourceControlApi } from 'api/sourcecontrol';
import PipelineDetailStore, { ACTIONS } from 'components/PipelineDetails/store';
import { getHydratorUrl } from 'services/UiUtils/UrlGenerator';
import { getCurrentNamespace } from 'services/NamespaceStore';

const init = (pipeline) => {
PipelineDetailStore.dispatch({
Expand Down Expand Up @@ -489,19 +488,6 @@ const setSourceControlMeta = (fileHash) => {
});
};

const getScmSyncStatus = (appId) => {
const namespace = getCurrentNamespace();
MyPipelineApi.getScmSyncStatus({
namespace,
appId,
}).subscribe((res) => {
PipelineDetailStore.dispatch({
type: ACTIONS.SET_SCM_SYNC_STATUS,
payload: res,
});
});
};

const reset = () => {
PipelineDetailStore.dispatch({
type: ACTIONS.RESET,
Expand Down Expand Up @@ -536,7 +522,6 @@ export {
getRunsForVersion,
getRunDetails,
getAppVersion,
getScmSyncStatus,
pollRuns,
pollRunsCount,
getNextRunTime,
Expand Down
7 changes: 0 additions & 7 deletions app/cdap/components/PipelineDetails/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ const ACTIONS = {
SET_PULL_LOADING: 'SET_PULL_LOADING',
SET_PULL_STATUS: 'SET_PULL_STATUS',
SET_SOURCE_CONTROL_META: 'SET_SOURCE_CONTROL_META',
SET_SCM_SYNC_STATUS: 'SET_SCM_SYNC_STATUS',

RESET: 'RESET',
};
Expand Down Expand Up @@ -106,7 +105,6 @@ const DEFAULT_PIPELINE_DETAILS = {
sourceControlMeta: null,
pullLoading: false,
pullStatus: null,
scmSyncStatus: {},
};

const pipelineDetails = (state = DEFAULT_PIPELINE_DETAILS, action = defaultAction) => {
Expand Down Expand Up @@ -286,11 +284,6 @@ const pipelineDetails = (state = DEFAULT_PIPELINE_DETAILS, action = defaultActio
...state,
sourceControlMeta: action.payload.sourceControlMeta,
};
case ACTIONS.SET_SCM_SYNC_STATUS:
return {
...state,
scmSyncStatus: action.payload,
};
case ACTIONS.RESET:
return DEFAULT_PIPELINE_DETAILS;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const PullPipelineWizard = ({ isOpen, error, dispatch }: IPullPipelineWiz
toggle={() => dispatch({ type: 'TOGGLE_MODAL' })}
>
<Provider store={SourceControlManagementSyncStore}>
<RemotePipelineListView redirectOnSubmit={true} singlePipelineMode={true} />
<RemotePipelineListView redirectOnSubmit={true} />
</Provider>
</StandardModal>
</>
Expand Down
Loading
Loading