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

fix: Kill task permission on interactive page #8358

Merged
merged 5 commits into from
Nov 22, 2023
Merged

fix: Kill task permission on interactive page #8358

merged 5 commits into from
Nov 22, 2023

Conversation

gt2345
Copy link
Contributor

@gt2345 gt2345 commented Nov 7, 2023

Description

Interactive task used to not have access to the workspace id, so the permission check for killing task is always false for non-admin.

Test Plan

Log in as a user with workspace admin role
Create a notebook in that workspace
Notebook can be killed from /det/tasks page, as well as on /det/interactive page

Commentary (optional)

Checklist

  • Changes have been manually QA'd
  • User-facing API changes need the "User-facing API Change" label.
  • Release notes should be added as a separate file under docs/release-notes/.
    See Release Note for details.
  • Licenses should be included for new code which was copied and/or modified from any external code.

Ticket

WEB-1268

@gt2345 gt2345 requested a review from a team as a code owner November 7, 2023 21:04
@gt2345 gt2345 requested a review from ashtonG November 7, 2023 21:04
@cla-bot cla-bot bot added the cla-signed label Nov 7, 2023
Copy link

netlify bot commented Nov 7, 2023

Deploy Preview for determined-ui ready!

Name Link
🔨 Latest commit cb34b9b
🔍 Latest deploy log https://app.netlify.com/sites/determined-ui/deploys/6557ad6dd6541e000899365f
😎 Deploy Preview https://deploy-preview-8358--determined-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@gt2345 gt2345 requested a review from mapmeld November 13, 2023 18:05
Copy link
Contributor

@ashtonG ashtonG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left a nit -- we should handle the task loading as a Loadable.

Comment on lines 37 to 58
const [task, setTask] = useState<CommandTask>();

const getTaskById = useCallback(async (taskType: CommandType, commandId: string) => {
switch (taskType) {
case 'command':
setTask(await getCommand({ commandId }));
break;
case 'jupyter-lab':
setTask(await getJupyterLab({ commandId }));
break;
case 'shell':
setTask(await getShell({ commandId }));
break;
case 'tensor-board':
setTask(await getTensorBoard({ commandId }));
break;
}
}, []);

useEffect(() => {
getTaskById(type, id);
}, [type, id, getTaskById]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider using useAsync here -- it wraps the value in a Loadable (which we should do here because now it's possible for the task to not load) and handles race conditions:

Suggested change
const [task, setTask] = useState<CommandTask>();
const getTaskById = useCallback(async (taskType: CommandType, commandId: string) => {
switch (taskType) {
case 'command':
setTask(await getCommand({ commandId }));
break;
case 'jupyter-lab':
setTask(await getJupyterLab({ commandId }));
break;
case 'shell':
setTask(await getShell({ commandId }));
break;
case 'tensor-board':
setTask(await getTensorBoard({ commandId }));
break;
}
}, []);
useEffect(() => {
getTaskById(type, id);
}, [type, id, getTaskById]);
const task = useAsync(() => {
const call = {
command: getCommand,
'jupyter-lab': getJupyterLab
shell: getShell,
'tensor-board': getTensorBoard
}[type]
return call({ commandId: id });
}, [type, id])

Copy link
Contributor

@ashtonG ashtonG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

had two small nits -- approved pending tests passing

webui/react/src/components/TaskBar.tsx Outdated Show resolved Hide resolved
webui/react/src/components/TaskBar.tsx Outdated Show resolved Hide resolved
@gt2345 gt2345 merged commit 815f5ae into main Nov 22, 2023
72 of 82 checks passed
@gt2345 gt2345 deleted the gt/1268 branch November 22, 2023 15:22
@dannysauer dannysauer added this to the 0.26.5 milestone Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants