Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const ResourceDetails = (props: ResourceDetailsProps) => {
extensionTabs: ResourceTabExtension[],
tabs: Tab[],
execEnabled: boolean,
execAllowed: boolean,
logsAllowed: boolean
) => {
if (!node || node === undefined) {
Expand Down Expand Up @@ -113,7 +114,7 @@ export const ResourceDetails = (props: ResourceDetailsProps) => {
}
]);
}
if (execEnabled) {
if (execEnabled && execAllowed) {
tabs = tabs.concat([
{
key: 'exec',
Expand Down Expand Up @@ -270,7 +271,8 @@ export const ResourceDetails = (props: ResourceDetailsProps) => {
const settings = await services.authService.settings();
const execEnabled = settings.execEnabled;
const logsAllowed = await services.accounts.canI('logs', 'get', application.spec.project + '/' + application.metadata.name);
return {controlledState, liveState, events, podState, execEnabled, logsAllowed};
const execAllowed = await services.accounts.canI('exec', 'create', application.spec.project + '/' + application.metadata.name);
return {controlledState, liveState, events, podState, execEnabled, execAllowed, logsAllowed};
}}>
{data => (
<React.Fragment>
Expand Down Expand Up @@ -315,6 +317,7 @@ export const ResourceDetails = (props: ResourceDetailsProps) => {
}
],
data.execEnabled,
data.execAllowed,
data.logsAllowed
)}
selectedTabKey={props.tab}
Expand Down
28 changes: 20 additions & 8 deletions ui/src/app/applications/components/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -430,16 +430,28 @@ function getActionItems(
action: () => appContext.apis.navigation.goto('.', {node: nodeKey(resource), tab: 'logs'}, {replace: true})
});
}
if (resource.kind === 'Pod') {
items.push({
title: 'Exec',
iconClassName: 'fa fa-terminal',
action: () => appContext.apis.navigation.goto('.', {node: nodeKey(resource), tab: 'exec'}, {replace: true})
});
}

if (isQuickStart) {
return from([items]);
}

const execAction = services.authService
.settings()
.then(async settings => {
const execAllowed = await services.accounts.canI('exec', 'create', application.spec.project + '/' + application.metadata.name);
if (resource.kind === 'Pod' && settings.execEnabled && execAllowed) {
return items.concat([
{
title: 'Exec',
iconClassName: 'fa fa-terminal',
action: async () => appContext.apis.navigation.goto('.', {node: nodeKey(resource), tab: 'exec'}, {replace: true})
}
]);
}
return items;
})
.catch(() => items);

const resourceActions = services.applications
.getResourceActions(application.metadata.name, resource)
.then(actions => {
Expand All @@ -464,7 +476,7 @@ function getActionItems(
);
})
.catch(() => items);
menuItems = merge(from([items]), from(resourceActions));
menuItems = merge(from([items]), from(resourceActions), from(execAction));
return menuItems;
}

Expand Down