Skip to content

Commit

Permalink
Fixing server switch list and default view
Browse files Browse the repository at this point in the history
  • Loading branch information
snyaggarwal committed Oct 18, 2022
1 parent df59f8e commit 376f487
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/common/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,8 @@ export const getAppliedServerConfig = () => {
}

export const isServerSwitched = () => {
const selectedConfig = getSelectedServerConfig();
return selectedConfig && selectedConfig.url !== (window.API_URL || process.env.API_URL);
const selectedServer = getSelectedServerConfig()
return selectedServer && selectedServer.id !== getDefaultServerConfig()?.id;
};

export const getDefaultServerConfig = () => {
Expand Down Expand Up @@ -513,7 +513,7 @@ export const getServerConfigsForCurrentUser = () => {
}

eligible = compact([defaultConfig, appliedConfig, ...eligible]);
return uniqBy(eligible, 'url');
return uniqBy(eligible, 'id');
}

export const arrayToSentence = (arr, separator, lastSeparator=' and ') => {
Expand Down
6 changes: 3 additions & 3 deletions src/components/common/ServerConfigList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const ServerConfigList = ({ onClose }) => {
const onChange = (event, config) => {
event.preventDefault();
event.stopPropagation();
if(get(selectedConfig, 'url') === config.url){
if(selectedConfig?.id ? selectedConfig.id === config.id : selectedConfig?.url === config.url){
onClose();
return;
}
Expand All @@ -45,8 +45,8 @@ const ServerConfigList = ({ onClose }) => {
<List component="div" disablePadding>
{
map(eligibleServerConfigs, config => {
const selected = get(selectedConfig, 'url') === config.url;
const isDefault = config.url === defaultConfig.url;
const selected = selectedConfig.id ? selectedConfig.id === config.id : get(selectedConfig, 'url') === config.url;
const isDefault = defaultConfig.id ? defaultConfig.id === config.id : config.url === defaultConfig.url;
return (
<ListItem disabled={config.disabled} selected={selected} className='btn' button key={config.id} onClick={event => onChange(event, config)} style={{cursor: config.disabled ? 'not-allowed' : 'pointer'}}>
<ListItemIcon style={{minWidth: 'auto', marginRight: '15px', width: '22px', height: '22px'}}>
Expand Down

0 comments on commit 376f487

Please sign in to comment.