Skip to content

chore: move refresh dbs button up to be inline #6929

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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 @@ -114,7 +114,7 @@ const ConnectionsNavigationTree: React.FunctionComponent<

const getCollapseAfterForConnectedItem = useCallback(
(actions: NavigationItemActions) => {
const [firstAction, secondAction] = actions;
const [, secondAction, thirdAction] = actions;

const actionCanBeShownInline = (
action: NavigationItemActions[number]
Expand All @@ -123,31 +123,32 @@ const ConnectionsNavigationTree: React.FunctionComponent<
return false;
}

return ['create-database', 'open-shell'].includes(
return ['refresh-databases', 'create-database', 'open-shell'].includes(
(action as ItemAction<Actions>).action
);
};

// this is the normal case for a connection that is writable and when we
// also have shell enabled
if (
actionCanBeShownInline(firstAction) &&
actionCanBeShownInline(secondAction)
actionCanBeShownInline(secondAction) &&
actionCanBeShownInline(thirdAction)
) {
return 2;
return 3;
}

// this will happen when the either the connection is not writable or the
// preference is readonly, or shell is not enabled in which case we either
// do not show create-database action or open-shell action
if (
actionCanBeShownInline(firstAction) ||
actionCanBeShownInline(secondAction)
actionCanBeShownInline(secondAction) ||
actionCanBeShownInline(thirdAction)
) {
return 1;
return 2;
}

return 0;
// always display the refresh action (firstAction)
return 1;
},
[]
);
Expand Down
10 changes: 5 additions & 5 deletions packages/compass-connections-navigation/src/item-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ export const connectedConnectionItemActions = ({
connectionInfo,
});
return stripNullActions([
{
action: 'refresh-databases',
label: 'Refresh databases',
icon: 'Refresh',
},
hasWriteActionsDisabled
? null
: {
Expand Down Expand Up @@ -123,11 +128,6 @@ export const connectedConnectionItemActions = ({
icon: 'InfoWithCircle',
label: 'Show connection info',
},
{
action: 'refresh-databases',
label: 'Refresh databases',
icon: 'Refresh',
},
{
action: 'connection-disconnect',
icon: 'Disconnect',
Expand Down