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

Scm bulk operations UX improvements #1157

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions app/cdap/api/longRunningOperation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ export const LongRunningOperationApi = {
dataSrc,
'GET',
'REQUEST',
`${basePath}/?pageSize=1&filter=${PUSH_FILTER}`
`${basePath}/?pageSize=10&filter=${PUSH_FILTER}`
),
getLatestPull: apiCreator(
dataSrc,
'GET',
'REQUEST',
`${basePath}/?pageSize=1&filter=${PULL_FILTER}`
`${basePath}/?pageSize=10&filter=${PULL_FILTER}`
),
pollOperation: apiCreator(dataSrc, 'GET', 'POLL', `${basePath}/:operationId`),
stopOperation: apiCreator(dataSrc, 'POST', 'REQUEST', `${basePath}/:operationId/stop`),
Expand Down
41 changes: 41 additions & 0 deletions app/cdap/components/FooterContext/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright © 2024 Cask Data, 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 { createContext, useContext, useEffect } from 'react';

interface IFooterContext {
show: boolean;
setShow(val?: boolean): void;
}

export const FooterContext = createContext<IFooterContext>({
show: true,
setShow() {
return;
},
});

export function useHideFooterInPage() {
const { setShow } = useContext(FooterContext);

useEffect(() => {
setShow(false);

return () => setShow(true);
}, []);

return setShow;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +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, patConfigKeys, providers, scmAuthType } from './constants';
import {
authKeys,
patConfigKeys,
providers,
providersRequiringUsername,
scmAuthType,
} from './constants';
import { defaultSourceControlManagement, sourceControlManagementFormReducer } from './reducer';
import { addOrValidateSourceControlManagementForm } from '../store/ActionCreator';
import { getCurrentNamespace } from 'services/NamespaceStore';
Expand Down Expand Up @@ -283,63 +289,67 @@ const SourceControlManagementForm = ({
}}
/>
</StyledGroup>
<StyledGroup>
<BoldHeader>{T.translate(`${PREFIX}.authHeader`)}</BoldHeader>
<StyledHr />
<PropertyRow
value={formState.config?.auth?.type ? formState.config.auth.type : scmAuthType[0].id}
property={{
name: 'auth',
description: T.translate(`${PREFIX}.auth.helperText`).toString(),
label: T.translate(`${PREFIX}.auth.label`).toString(),
'widget-type': 'radio-group',
'widget-attributes': {
default: scmAuthType[0].id,
layout: 'inline',
options: scmAuthType,
},
}}
onChange={(val) => {
handleValueChange(val, 'type');
}}
/>
{formState.config?.auth?.type === scmAuthType[0].id && (
<>
<PropertyRow
value={formState.config?.auth?.patConfig?.passwordName}
property={{
name: 'tokenName',
description: T.translate(`${PREFIX}.auth.pat.tokenNameHelperText`).toString(),
label: T.translate(`${PREFIX}.auth.pat.tokenName`).toString(),
required: true,
}}
onChange={(val) => {
handleValueChange(val, 'passwordName');
}}
errors={
!formState.config?.auth?.patConfig?.passwordName && formState.error
? [{ msg: T.translate('commons.requiredFieldMissingMsg').toString() }]
: []
}
/>
<PropertyRow
value={formState.config?.auth?.token}
property={{
name: 'token',
description: T.translate(`${PREFIX}.auth.pat.tokenHelperText`).toString(),
label: T.translate(`${PREFIX}.auth.pat.token`).toString(),
required: !isEdit,
'widget-type': 'password',
}}
onChange={(val) => {
handleValueChange(val, 'token');
}}
errors={
!formState.config?.auth?.token && formState.error
? [{ msg: T.translate('commons.requiredFieldMissingMsg').toString() }]
: []
}
/>
{scmAuthType[formState.config?.provider] && (
<StyledGroup>
<BoldHeader>{T.translate(`${PREFIX}.authHeader`)}</BoldHeader>
<StyledHr />
<PropertyRow
value={
formState.config?.auth?.type
? formState.config.auth.type
: scmAuthType[formState.config?.provider][0].id
}
property={{
name: 'auth',
description: T.translate(`${PREFIX}.auth.helperText`).toString(),
label: T.translate(`${PREFIX}.auth.label`).toString(),
'widget-type': 'radio-group',
'widget-attributes': {
default: scmAuthType[formState.config?.provider][0].id,
layout: 'inline',
options: scmAuthType[formState.config?.provider],
},
}}
onChange={(val) => {
handleValueChange(val, 'type');
}}
/>
<PropertyRow
value={formState.config?.auth?.patConfig?.passwordName}
property={{
name: 'tokenName',
description: T.translate(`${PREFIX}.auth.pat.tokenNameHelperText`).toString(),
label: T.translate(`${PREFIX}.auth.pat.tokenName`).toString(),
required: true,
}}
onChange={(val) => {
handleValueChange(val, 'passwordName');
}}
errors={
!formState.config?.auth?.patConfig?.passwordName && formState.error
? [{ msg: T.translate('commons.requiredFieldMissingMsg').toString() }]
: []
}
/>
<PropertyRow
value={formState.config?.auth?.token}
property={{
name: 'token',
description: T.translate(`${PREFIX}.auth.pat.tokenHelperText`).toString(),
label: T.translate(`${PREFIX}.auth.pat.token`).toString(),
required: !isEdit,
'widget-type': 'password',
}}
onChange={(val) => {
handleValueChange(val, 'token');
}}
errors={
!formState.config?.auth?.token && formState.error
? [{ msg: T.translate('commons.requiredFieldMissingMsg').toString() }]
: []
}
/>
{providersRequiringUsername.includes(formState.config?.provider) && (
<PropertyRow
value={formState.config?.auth?.patConfig?.username}
property={{
Expand All @@ -351,9 +361,9 @@ const SourceControlManagementForm = ({
handleValueChange(val, 'username');
}}
/>
</>
)}
</StyledGroup>
)}
</StyledGroup>
)}
</StyledForm>
<StyledButtonGroup>
<PrimaryOutlinedLoadingButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,35 @@ import T from 'i18n-react';

const PREFIX = 'features.SourceControlManagement';

export const scmAuthType = [
export const scmAuthTypeGit = [
{ id: 'PAT', label: T.translate(`${PREFIX}.configModal.auth.pat.label`) },
];

export const scmAuthTypeBitbucket = [
{ id: 'PAT', label: T.translate(`${PREFIX}.configModal.auth.pat.label`) },
{
id: 'REPOSITORY_ACCESS_TOKEN',
label: T.translate(`${PREFIX}.configModal.auth.repositoryAccessToken.label`),
},
];

export const providers = {
github: 'GITHUB',
gitlab: 'GITLAB',
bitbucket: 'BITBUCKET',
bitbucketCloud: 'BITBUCKET CLOUD',
};

export const scmAuthType = {
[providers.github]: scmAuthTypeGit,
[providers.gitlab]: scmAuthTypeGit,
[providers.bitbucket]: scmAuthTypeBitbucket,
[providers.bitbucketCloud]: scmAuthTypeBitbucket,
};

export const authKeys = ['type', 'token'];

export const patConfigKeys = ['passwordName', 'username'];

export const providersRequiringUsername = [providers.bitbucket, providers.bitbucketCloud];
export const providersWithRepoToken = [providers.bitbucket, providers.bitbucketCloud];
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ 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 Expand Up @@ -58,6 +57,7 @@ export const SourceControlManagement = () => {
const sourceControlManagementConfig: ISourceControlManagementConfig = useSelector(
(state) => state.sourceControlManagementConfig
);

const toggleForm = () => {
setIsFormOpen(!isFormOpen);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const defaultSourceControlManagement: ISourceControlManagement = {
defaultBranch: '',
pathPrefix: '',
auth: {
type: scmAuthType[0].id,
type: scmAuthType[providers.github][0].id,
token: '',
patConfig: {
passwordName: '',
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} />
<RemotePipelineListView redirectOnSubmit={true} singlePipelineMode={true} />
</Provider>
</StandardModal>
</>
Expand Down
Loading