Skip to content

Commit

Permalink
Revert "GitHub Deployments: Fix routing problems (#87860)" (#87862)
Browse files Browse the repository at this point in the history
This reverts commit 79fff71.
  • Loading branch information
zaguiini authored and pull[bot] committed Apr 22, 2024
1 parent 558247d commit 6898452
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const GitHubBrowseRepositories = ( {
onChange={ setInstallation }
/>
<SearchRepos value={ query } onChange={ handleQueryChange } />
<Button onClick={ handleCreateRepository } css={ { height: '100%', marginLeft: 'auto' } }>
<Button onClick={ handleCreateRepository } css={ { marginLeft: 'auto' } }>
{ __( 'Create new repository' ) }
</Button>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@ import FormSettingExplanation from 'calypso/components/forms/form-setting-explan
import FormTextInput from 'calypso/components/forms/form-text-input';
import { GitHubInstallationsDropdown } from 'calypso/my-sites/github-deployments/components/installations-dropdown';
import { useLiveInstallations } from 'calypso/my-sites/github-deployments/components/installations-dropdown/use-live-installations';
import {
FormRadioWithTemplateSelect,
ProjectType,
} from '../components/form-radio-with-template-select';
import { MutationVariables as CreateDeploymentMutationVariables } from '../../../deployment-creation/use-create-code-deployment';
import { FormRadioWithTemplateSelect, ProjectType } from '../../form-radio-with-template-select';
import {
RepositoryTemplate,
repositoryTemplates,
} from '../components/form-radio-with-template-select/templates';
import { MutationVariables as CreateDeploymentMutationVariables } from '../deployment-creation/use-create-code-deployment';
} from '../../form-radio-with-template-select/templates';
import { DeploymentStyleDescription } from './deployment-style-description';
import { MutationVariables as CreateRepositoryMutationVariables } from './use-create-repository';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Spinner } from '@automattic/components';
import { useI18n } from '@wordpress/react-i18n';
import { CodeHighlighter } from '../../components/code-highlighter';
import { useGetWorkflowContents } from '../../components/deployment-style/use-get-workflow-contents-query';
import { CodeHighlighter } from '../../../code-highlighter';
import { useGetWorkflowContents } from '../../../deployment-style/use-get-workflow-contents-query';

import './style.scss';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { useI18n } from '@wordpress/react-i18n';
import ActionPanel from 'calypso/components/action-panel';
import ActionPanelBody from 'calypso/components/action-panel/body';
import HeaderCake from 'calypso/components/header-cake';
import { createDeploymentPage, indexPage } from 'calypso/my-sites/github-deployments/routes';
import { indexPage } from 'calypso/my-sites/github-deployments/routes';
import { useDispatch, useSelector } from 'calypso/state/index';
import { errorNotice, successNotice } from 'calypso/state/notices/actions';
import { getSelectedSiteId, getSelectedSiteSlug } from 'calypso/state/ui/selectors/index';
import { PageShell } from '../components/page-shell';
import { useCreateCodeDeployment } from '../deployment-creation/use-create-code-deployment';
import { useCreateCodeDeployment } from '../../../deployment-creation/use-create-code-deployment';
import { PageShell } from '../../page-shell';
import { CreateRepositoryForm, OnRepositoryCreatedParams } from './create-repository-form';
import { useCreateRepository } from './use-create-repository';

Expand Down Expand Up @@ -77,7 +77,7 @@ export const CreateRepository = () => {

return (
<PageShell pageTitle={ __( 'Create repository' ) }>
<HeaderCake onClick={ () => page( createDeploymentPage( siteSlug! ) ) } isCompact>
<HeaderCake onClick={ () => history.back() } isCompact>
<h1>{ __( 'Create repository' ) }</h1>
</HeaderCake>
<ActionPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,11 @@ export const GitHubRepositoryListItem = ( {
onSelect,
}: GitHubRepositoryListItemProps ) => {
const locale = useLocale();

const repoUrl = `https://github.com/${ repository.owner }/${ repository.name }`;

return (
<tr>
<td>
<span css={ { fontWeight: 500 } }>
<a
className="github-deployments-repository-list-table__repo-name"
href={ repoUrl }
target="_blank"
rel="noopener noreferrer"
>
{ repository.name }
</a>{ ' ' }
{ repository.name }{ ' ' }
{ repository.private && (
<Icon icon={ lock } size={ 16 } css={ { verticalAlign: 'middle' } } />
) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,4 @@
tr td:last-child {
text-align: right;
}

&__repo-name {
color: inherit !important;

&:hover {
text-decoration: underline;
}
}
}
4 changes: 2 additions & 2 deletions client/my-sites/github-deployments/controller.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { __ } from '@wordpress/i18n';
import { PageViewTracker } from 'calypso/lib/analytics/page-view-tracker';
import { CreateRepository } from 'calypso/my-sites/github-deployments/components/repositories/create-repository/index';
import { DeploymentRunsLogs } from 'calypso/my-sites/github-deployments/deployment-run-logs/index';
import { errorNotice } from 'calypso/state/notices/actions';
import { isJetpackSite } from 'calypso/state/sites/selectors';
import { getSelectedSiteId, getSelectedSiteSlug } from 'calypso/state/ui/selectors';
import { canCurrentUser } from '../../state/selectors/can-current-user';
import { CreateRepository } from './create-repository';
import { GitHubDeploymentCreation } from './deployment-creation';
import { GitHubDeploymentManagement } from './deployment-management';
import { DeploymentRunsLogs } from './deployment-run-logs';
import { GitHubDeployments } from './deployments';
import { indexPage } from './routes';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const GitHubDeploymentCreationForm = ( {
installation={ installation }
repository={ repository }
changeRepository={ () => {
page( createDeploymentPage( siteSlug!, { installationId } ) );
page.replace( createDeploymentPage( siteSlug!, { installationId } ) );
} }
onSubmit={ ( {
externalRepositoryId,
Expand Down
29 changes: 5 additions & 24 deletions client/my-sites/github-deployments/deployment-creation/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import page from '@automattic/calypso-router';
import { __ } from '@wordpress/i18n';
import { useSelector } from 'calypso/state';
import { getSelectedSiteId, getSelectedSiteSlug } from 'calypso/state/ui/selectors';
import { getSelectedSiteSlug } from 'calypso/state/ui/selectors';
import ActionPanel from '../../../components/action-panel';
import HeaderCake from '../../../components/header-cake';
import { PageShell } from '../components/page-shell';
import { GitHubBrowseRepositories } from '../components/repositories/browse-repositories';
import { useCodeDeploymentsQuery } from '../deployments/use-code-deployments-query';
import { createDeploymentPage, indexPage } from '../routes';
import { GitHubDeploymentCreationForm } from './deployment-creation-form';

Expand All @@ -19,28 +18,10 @@ export const GitHubDeploymentCreation = ( {
installationId,
repositoryId,
}: GitHubConnectedProps ) => {
const siteId = useSelector( getSelectedSiteId );
const siteSlug = useSelector( getSelectedSiteSlug );

const { data } = useCodeDeploymentsQuery( siteId! );

const goToDeployments = () => page( indexPage( siteSlug! ) );

const goToRepositorySelection = () =>
page(
createDeploymentPage( siteSlug!, {
installationId: installationId,
} )
);

const getBackButton = () => {
if ( installationId && repositoryId ) {
return goToRepositorySelection;
}

if ( data?.length ) {
return goToDeployments;
}
const goToDeployments = () => {
page( indexPage( siteSlug! ) );
};

const renderContent = () => {
Expand All @@ -56,7 +37,7 @@ export const GitHubDeploymentCreation = ( {
<GitHubBrowseRepositories
initialInstallationId={ installationId }
onSelectRepository={ ( installation, repository ) => {
page(
page.replace(
createDeploymentPage( siteSlug!, {
installationId: installation.external_id,
repositoryId: repository.id,
Expand All @@ -71,7 +52,7 @@ export const GitHubDeploymentCreation = ( {

return (
<PageShell pageTitle={ __( 'Connect GitHub repository' ) }>
<HeaderCake onClick={ getBackButton() } isCompact>
<HeaderCake onClick={ goToDeployments } isCompact>
<h1>{ __( 'Connect repository' ) }</h1>
</HeaderCake>
<ActionPanel>{ renderContent() }</ActionPanel>
Expand Down

0 comments on commit 6898452

Please sign in to comment.