Skip to content

Commit

Permalink
DEVPROD-9579: Disable reconfigure button for GitHub merge queue patch…
Browse files Browse the repository at this point in the history
…es (#540)
  • Loading branch information
minnakt authored Dec 13, 2024
1 parent 30c4f62 commit 36959f5
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,21 @@ import {

interface Props {
hasVersion: boolean;
isMergeQueuePatch: boolean;
isPatchHidden: boolean;
patchId: string;
}
export const DropdownMenu: React.FC<Props> = ({
hasVersion,
isMergeQueuePatch,
isPatchHidden,
patchId,
}) => {
const restartModalVisibilityControl = useState(false);
const dropdownItems = [
<LinkToReconfigurePage
key="reconfigure"
disabled={isMergeQueuePatch}
hasVersion={hasVersion}
patchId={patchId}
/>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { GroupedTaskStatusBadge } from "components/GroupedTaskStatusBadge";
import { PatchStatusBadge } from "components/PatchStatusBadge";
import { StyledRouterLink } from "components/styles";
import { unlinkedPRUsers } from "constants/patch";
import { Requester } from "constants/requesters";
import {
getProjectPatchesRoute,
getVersionRoute,
Expand Down Expand Up @@ -50,10 +51,11 @@ const PatchCard: React.FC<PatchCardProps> = ({ pageType, patch }) => {
} = patch;
// @ts-expect-error: FIXME. This comment was added by an automated script.
const createDate = new Date(createTime);
const { id: versionId, taskStatusStats } = versionFull || {};
const { id: versionId, requester, taskStatusStats } = versionFull || {};
const { stats } = groupStatusesByUmbrellaStatus(
taskStatusStats?.counts ?? [],
);
const isMergeQueuePatch = requester === Requester.GitHubMergeQueue;

let patchProject = null;
if (pageType === "project") {
Expand Down Expand Up @@ -127,6 +129,7 @@ const PatchCard: React.FC<PatchCardProps> = ({ pageType, patch }) => {
{hidden && <Badge data-cy="hidden-badge">Hidden</Badge>}
<DropdownMenu
hasVersion={!!versionId}
isMergeQueuePatch={isMergeQueuePatch}
isPatchHidden={hidden}
patchId={id}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const patchData = {
versionFull: {
id: "667b2f7f7a878200076f23d1",
status: "failed",
requester: "patch_request",
taskStatusStats: {
counts: [
{
Expand Down
1 change: 1 addition & 0 deletions apps/spruce/src/gql/fragments/patchesPage.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ fragment PatchesPagePatches on Patches {
status
versionFull {
id
requester
status
taskStatusStats(options: {}) {
counts {
Expand Down
3 changes: 3 additions & 0 deletions apps/spruce/src/gql/generated/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3802,6 +3802,7 @@ export type PatchesPagePatchesFragment = {
versionFull?: {
__typename?: "Version";
id: string;
requester: string;
status: string;
taskStatusStats?: {
__typename?: "TaskStats";
Expand Down Expand Up @@ -7730,6 +7731,7 @@ export type ProjectPatchesQuery = {
versionFull?: {
__typename?: "Version";
id: string;
requester: string;
status: string;
taskStatusStats?: {
__typename?: "TaskStats";
Expand Down Expand Up @@ -9388,6 +9390,7 @@ export type UserPatchesQuery = {
versionFull?: {
__typename?: "Version";
id: string;
requester: string;
status: string;
taskStatusStats?: {
__typename?: "TaskStats";
Expand Down
10 changes: 6 additions & 4 deletions apps/spruce/src/pages/Version.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
PageLayout,
PageSider,
} from "components/styles";
import { Requester } from "constants/requesters";
import { slugs } from "constants/routes";
import { useToastContext } from "context/toast";
import { VersionQuery, VersionQueryVariables } from "gql/generated/types";
Expand Down Expand Up @@ -65,6 +66,7 @@ export const VersionPage: React.FC = () => {
order,
patch,
projectIdentifier,
requester,
revision,
status,
warnings,
Expand Down Expand Up @@ -102,10 +104,10 @@ export const VersionPage: React.FC = () => {
badge={<PatchStatusBadge status={status} />}
buttons={
<ActionButtons
// @ts-expect-error: FIXME. This comment was added by an automated script.
canReconfigure={isPatch}
// @ts-expect-error: FIXME. This comment was added by an automated script.
isPatch={isPatch}
canReconfigure={
!!isPatch && requester !== Requester.GitHubMergeQueue
}
isPatch={!!isPatch}
// @ts-expect-error: FIXME. This comment was added by an automated script.
versionId={versionId}
/>
Expand Down

0 comments on commit 36959f5

Please sign in to comment.