Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit91d4f8b

Browse files
fix: use the selected version to check external auth (#20316)
Fixes#20315
1 parent6b990bd commit91d4f8b

File tree

2 files changed

+69
-12
lines changed

2 files changed

+69
-12
lines changed

‎site/src/modules/tasks/TaskPrompt/TaskPrompt.stories.tsx‎

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,6 @@ export const SelectTemplateVersion: Story = {
243243
exportconstOnError:Story={
244244
decorators:[withGlobalSnackbar],
245245
beforeEach:()=>{
246-
spyOn(API,"getTemplates").mockResolvedValue([MockTemplate]);
247246
spyOn(API,"getTemplate").mockResolvedValue(MockTemplate);
248247
spyOn(API.experimental,"getTasks").mockResolvedValue(MockTasks);
249248
spyOn(API.experimental,"createTask").mockRejectedValue(
@@ -349,3 +348,62 @@ export const ExternalAuthError: Story = {
349348
});
350349
},
351350
};
351+
352+
consttmplWithExternalAuth={
353+
...MockTemplateVersion,
354+
id:"2",
355+
name:"With external",
356+
};
357+
358+
exportconstCheckExternalAuthOnChangingVersions:Story={
359+
args:{
360+
templates:[
361+
{
362+
...MockTemplate,
363+
active_version_id:tmplWithExternalAuth.id,
364+
},
365+
],
366+
},
367+
beforeEach:()=>{
368+
spyOn(API,"getTemplateVersions").mockResolvedValue([
369+
{
370+
...MockTemplateVersion,
371+
id:"1",
372+
name:"No external",
373+
},
374+
tmplWithExternalAuth,
375+
]);
376+
spyOn(API,"getTemplateVersionExternalAuth").mockImplementation(
377+
(versionId:string)=>{
378+
returnPromise.resolve(
379+
versionId===tmplWithExternalAuth.id
380+
?[MockTemplateVersionExternalAuthGithub]
381+
:[],
382+
);
383+
},
384+
);
385+
},
386+
play:async({ canvasElement, step})=>{
387+
constcanvas=within(canvasElement);
388+
389+
awaitstep("Renders external authentication",async()=>{
390+
awaitcanvas.findByRole("button",{name:/connecttogithub/i});
391+
});
392+
393+
awaitstep("Change into version without external auth",async()=>{
394+
constbody=within(canvasElement.ownerDocument.body);
395+
constversionSelect=awaitcanvas.findByLabelText(/templateversion/i);
396+
awaituserEvent.click(versionSelect);
397+
constversionOption=awaitbody.findByRole("option",{
398+
name:/noexternal/i,
399+
});
400+
awaituserEvent.click(versionOption);
401+
});
402+
403+
awaitstep("Don't render external authentication",async()=>{
404+
expect(
405+
canvas.queryByRole("button",{name:/connecttogithub/i}),
406+
).not.toBeInTheDocument();
407+
});
408+
},
409+
};

‎site/src/modules/tasks/TaskPrompt/TaskPrompt.tsx‎

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,6 @@ const CreateTaskForm: FC<CreateTaskFormProps> = ({ templates, onSuccess }) => {
150150
(t)=>t.id===selectedTemplateId,
151151
)asTemplate;
152152

153-
const{
154-
externalAuth,
155-
externalAuthError,
156-
isPollingExternalAuth,
157-
isLoadingExternalAuth,
158-
}=useExternalAuth(selectedTemplate.active_version_id);
159-
160153
// Template versions
161154
const[selectedVersionId,setSelectedVersionId]=useState(
162155
selectedTemplate.active_version_id,
@@ -192,6 +185,12 @@ const CreateTaskForm: FC<CreateTaskFormProps> = ({ templates, onSuccess }) => {
192185
},[presetPrompt]);
193186

194187
// External Auth
188+
const{
189+
externalAuth,
190+
externalAuthError,
191+
isPollingExternalAuth,
192+
isLoadingExternalAuth,
193+
}=useExternalAuth(selectedVersionId);
195194
constmissedExternalAuth=externalAuth?.filter(
196195
(auth)=>!auth.optional&&!auth.authenticated,
197196
);
@@ -361,7 +360,7 @@ const CreateTaskForm: FC<CreateTaskFormProps> = ({ templates, onSuccess }) => {
361360
<divclassName="flex items-center gap-2">
362361
{missedExternalAuth&&(
363362
<ExternalAuthButtons
364-
template={selectedTemplate}
363+
versionId={selectedVersionId}
365364
missedExternalAuth={missedExternalAuth}
366365
/>
367366
)}
@@ -408,19 +407,19 @@ const PromptSelectTrigger: FC<SelectTriggerProps> = ({
408407
};
409408

410409
typeExternalAuthButtonProps={
411-
template:Template;
410+
versionId:string;
412411
missedExternalAuth:TemplateVersionExternalAuth[];
413412
};
414413

415414
constExternalAuthButtons:FC<ExternalAuthButtonProps>=({
416-
template,
415+
versionId,
417416
missedExternalAuth,
418417
})=>{
419418
const{
420419
startPollingExternalAuth,
421420
isPollingExternalAuth,
422421
externalAuthPollingState,
423-
}=useExternalAuth(template.active_version_id);
422+
}=useExternalAuth(versionId);
424423
constshouldRetry=externalAuthPollingState==="abandoned";
425424

426425
returnmissedExternalAuth.map((auth)=>{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp