Skip to content

Commit

Permalink
feat: enhance dependency setup dialog and utility functions
Browse files Browse the repository at this point in the history
- Improved the logic in DependencySetupDialog.vue to better handle single and multiple node installations, providing clearer comments for maintainability.
- Updated the getRepoExternalPath function in dependency.ts to include browser-specific repository paths for Google Chrome and Chromedriver, enhancing the utility's functionality.
- Refined the useDependencyList.tsx to streamline the creation of repository tab items, ensuring proper handling of search and nodes tabs while improving readability.

These changes enhance the user experience and maintainability of the dependency management components.
  • Loading branch information
tikazyq committed Dec 23, 2024
1 parent 1187831 commit e574a50
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 15 deletions.
21 changes: 20 additions & 1 deletion src/components/core/dependency/DependencySetupDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,17 @@ const activeNodes = computed(() => nodeState.allList.filter(n => n.active));
const toInstallNodes = computed(() => {
const { mode, node_ids, node_id } = state.setupForm;
if (node_id) {
// Single node
return activeNodes.value.filter(n => n._id === node_id);
} else {
if (mode === 'all') return activeNodes.value;
// Multiple nodes
if (mode === 'all') {
// All nodes
return activeNodes.value;
}
// Selected nodes
return activeNodes.value.filter(n => node_ids?.includes(n._id!));
}
});
Expand All @@ -36,11 +43,23 @@ const confirmButtonDisabled = computed(() => {
return toInstallNodes.value.length === 0;
});
const onConfirm = async () => {
// Skip if the confirm button is disabled
if (confirmButtonDisabled.value) return;
// Install config setup
await store.dispatch(`${ns}/installConfigSetup`, {
id: activeConfigSetup.value?._id,
});
// Hide dialog
store.commit(`${ns}/hideDialog`);
// Switch to nodes tab
if (state.repoTabName !== 'nodes') {
store.commit(`${ns}/setRepoTabName`, 'nodes');
}
// Refresh config setup list
await store.dispatch(`${ns}/getConfigSetupList`);
};
Expand Down
11 changes: 11 additions & 0 deletions src/utils/dependency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,20 @@ export const getRepoExternalPath = (repo: DependencyRepo) => {
return `https://pkg.go.dev/${repo.name}`;
case 'java':
return `https://mvnrepository.com/artifact/${getRepoName(repo)}`;
case 'browser':
return getBrowserRepoExternalPath(repo);
default:
return '';
}

function getBrowserRepoExternalPath(repo: DependencyRepo) {
switch (repo.name) {
case 'google-chrome':
return 'https://www.chromium.org/getting-involved/download-chromium/';
case 'chromedriver':
return 'https://developer.chrome.com/docs/chromedriver/';
}
}
};

export const getRepoName = (repo: DependencyRepo) => {
Expand Down
37 changes: 23 additions & 14 deletions src/views/dependency/list/useDependencyList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -628,19 +628,20 @@ const useDependencyList = () => {

// repo tabs
const repoTabItems = computed<NavItem[]>(() => {
const items: NavItem[] = [];

// installed tab
const installedItem = {
id: 'installed',
title: `${t('views.env.deps.repos.tabs.installed')} (${state.tableTotal})`,
icon: ['fas', 'cubes'],
};
let searchItem: NavItem = {
items.push(installedItem);

// search tab
let searchItem: NavItem | undefined = {
id: 'search',
};
const nodesItem: NavItem = {
id: 'nodes',
title: t('views.env.deps.repos.tabs.nodes'),
icon: ['fas', 'server'],
};
switch (lang.value) {
case 'python':
searchItem = {
Expand Down Expand Up @@ -671,11 +672,7 @@ const useDependencyList = () => {
};
break;
case 'browser':
searchItem = {
...searchItem,
title: t('views.env.deps.repos.tabs.search.chromium'),
icon: ['svg', 'chromium'],
};
searchItem = undefined;
break;
default:
searchItem = {
Expand All @@ -684,10 +681,22 @@ const useDependencyList = () => {
icon: ['fas', 'search'],
};
}
if (state.searchQuery) {
searchItem.title = `${searchItem.title} (${state.searchRepoTableTotal})`;
if (searchItem) {
if (state.searchQuery) {
searchItem.title = `${searchItem.title} (${state.searchRepoTableTotal})`;
}
items.push(searchItem);
}
return [installedItem, searchItem, nodesItem] as NavItem[];

// nodes tab
const nodesItem: NavItem = {
id: 'nodes',
title: t('views.env.deps.repos.tabs.nodes'),
icon: ['fas', 'server'],
};
items.push(nodesItem);

return items;
});
const repoTabName = computed(() => state.repoTabName);

Expand Down

0 comments on commit e574a50

Please sign in to comment.