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: redirect to overview page if you removed an asset that's currently opened #2254

Merged
merged 1 commit into from
Nov 17, 2023
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 @@ -169,8 +169,11 @@ const activeAccordionTabs = ref(
const assetItemsMap = computed(() => generateProjectAssetsMap(searchAsset.value));

function removeAsset() {
emit('remove-asset', assetToDelete.value);
isRemovalModal.value = false;
if (assetToDelete.value) {
const { assetId, pageType } = assetToDelete.value;
emit('remove-asset', { assetId, pageType } as AssetRoute); // Pass as AssetRoute
isRemovalModal.value = false;
}
}

function saveAccordionTabsState() {
Expand Down
12 changes: 5 additions & 7 deletions packages/client/hmi-client/src/page/project/tera-project.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ const pageType = computed(
() => (route.params.pageType as ProjectPages | AssetType) ?? ProjectPages.EMPTY
);
const assetId = computed(() => (route.params.assetId as string) ?? '');
const openedAssetRoute = computed(() => ({ pageType: pageType.value, assetId: assetId.value }));
const assetName = computed<string>(() => {
if (pageType.value === ProjectPages.OVERVIEW) return 'Overview';

Expand All @@ -116,12 +117,7 @@ const assetName = computed<string>(() => {
});

function openAsset(assetRoute: AssetRoute) {
if (
!isEqual(assetRoute, {
pageType: pageType.value,
assetId: assetId.value
})
) {
if (!isEqual(assetRoute, openedAssetRoute.value)) {
router.push({
name: RouteName.Project,
params: assetRoute
Expand All @@ -141,8 +137,10 @@ async function removeAsset(assetRoute: AssetRoute) {
assetRoute.pageType as AssetType,
assetRoute.assetId
);

if (isRemoved) {
if (isEqual(assetRoute, openedAssetRoute.value)) {
openAsset({ assetId: '', pageType: ProjectPages.OVERVIEW });
}
logger.info(`${assetRoute.assetId} was removed.`, { showToast: true });
return;
}
Expand Down