Skip to content

Commit 1c5aec0

Browse files
authored
Hide 'Cancel Run' Button on Runs that do not belong to the Current User (#1183)
## Description <!-- Please provide a brief description of the changes made in this pull request. Include any relevant context or reasoning for the changes. --> Users will no longer see the "cancel run" button for runs that are not theirs. NOTE: uses a test API. Api should be finalized before shipping this PR. ## Related Issue and Pull requests <!-- Link to any related issues using the format #<issue-number> --> Closes Shopify/oasis-frontend#274 ## Type of Change <!-- Please delete options that are not relevant --> - [x] Improvement ## Checklist <!-- Please ensure the following are completed before submitting the PR --> - [ ] I have tested this does not break current pipelines / runs functionality - [ ] I have tested the changes on staging ## Screenshots (if applicable) <!-- Include any screenshots that might help explain the changes or provide visual context --> ![image.png](https://app.graphite.dev/user-attachments/assets/a0ee71a7-e665-4fbe-86db-4fa291a4da9b.png) ## Test Instructions <!-- Detail steps and prerequisites for testing the changes in this PR --> ## Additional Comments <!-- Add any additional context or information that reviewers might need to know regarding this PR -->
1 parent 11d37bb commit 1c5aec0

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

src/components/PipelineRun/RunDetails.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { useEffect, useState } from "react";
33

44
import { Spinner } from "@/components/ui/spinner";
55
import { useCheckComponentSpecFromPath } from "@/hooks/useCheckComponentSpecFromPath";
6+
import { useUserDetails } from "@/hooks/useUserDetails";
67
import { useBackend } from "@/providers/BackendProvider";
78
import { useComponentSpec } from "@/providers/ComponentSpecProvider";
89
import { useExecutionData } from "@/providers/ExecutionDataProvider";
@@ -33,6 +34,7 @@ export const RunDetails = () => {
3334
isLoading,
3435
error,
3536
} = useExecutionData();
37+
const { data: currentUserDetails } = useUserDetails();
3638

3739
const editorRoute = componentSpec.name
3840
? `/editor/${encodeURIComponent(componentSpec.name)}`
@@ -45,6 +47,9 @@ export const RunDetails = () => {
4547

4648
const [metadata, setMetadata] = useState<PipelineRun | null>(null);
4749

50+
const isRunCreator =
51+
currentUserDetails.name && metadata?.created_by === currentUserDetails.name;
52+
4853
useEffect(() => {
4954
const fetchData = async () => {
5055
if (!runId) {
@@ -149,7 +154,9 @@ export const RunDetails = () => {
149154
<InspectPipelineButton pipelineName={componentSpec.name} />
150155
)}
151156
<ClonePipelineButton componentSpec={componentSpec} />
152-
{isInProgress && <CancelPipelineRunButton runId={runId} />}
157+
{isInProgress && isRunCreator && (
158+
<CancelPipelineRunButton runId={runId} />
159+
)}
153160
{isComplete && <RerunPipelineButton componentSpec={componentSpec} />}
154161
</div>
155162
</div>

src/components/shared/ManageComponent/PublishComponent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import { BlockStack } from "@/components/ui/layout";
55
import { ScrollArea } from "@/components/ui/scroll-area";
66
import { Skeleton } from "@/components/ui/skeleton";
77
import { Heading, Paragraph } from "@/components/ui/typography";
8+
import { useUserDetails } from "@/hooks/useUserDetails";
89
import type { HydratedComponentReference } from "@/utils/componentSpec";
910

1011
import { withSuspenseWrapper } from "../SuspenseWrapper";
1112
import { ComponentHistoryTimeline } from "./ComponentHistoryTimeline";
1213
import { ComponentSpecProperty } from "./ComponentSpecProperty";
1314
import { usePublishedComponentHistory } from "./hooks/usePublishedComponentHistory";
14-
import { useUserDetails } from "./hooks/useUserDetails";
1515

1616
interface ComponentPublishProps {
1717
component: HydratedComponentReference;

src/components/shared/ManageComponent/hooks/useUserDetails.ts renamed to src/hooks/useUserDetails.ts

File renamed without changes.

src/components/shared/ManageComponent/utils/user.ts renamed to src/utils/user.ts

File renamed without changes.

0 commit comments

Comments
 (0)