Skip to content

Commit

Permalink
merge: #4015
Browse files Browse the repository at this point in the history
4015: detach func fix, close fns windows appropriately, abandon changeset fix r=jobelenus a=jobelenus

<img src="https://media3.giphy.com/media/JPrOv9bCKdcP3tJuS3/giphy.gif"/>

Co-authored-by: John Obelenus <[email protected]>
  • Loading branch information
si-bors-ng[bot] and jobelenus authored Jun 21, 2024
2 parents a7edea5 + 69cdd2c commit a992510
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 15 deletions.
6 changes: 4 additions & 2 deletions app/web/src/components/AssetFuncAttachModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,10 @@ const attachNewFunc = async () => {
name: name.value,
options,
});
if (result.result.success && props.assetId) {
await reloadAssetAndRoute(props.assetId);
if (result.result.success) {
funcStore.selectedFuncId = result.result.data.id;
assetStore.addFuncSelection(result.result.data.id);
if (props.assetId) await reloadAssetAndRoute(props.assetId);
}
}
};
Expand Down
5 changes: 2 additions & 3 deletions app/web/src/components/FuncEditor/AttributeBindings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ import { VButton } from "@si/vue-lib/design-system";
import {
AttributeAssociations,
AttributePrototypeBag,
FuncAssociations,
} from "@/store/func/types";
import { useFuncStore } from "@/store/func/funcs.store";
import { nilId } from "@/utils/nilId";
Expand Down Expand Up @@ -254,7 +253,7 @@ const prototypeViews = computed(() => {
});
});
const detachFunc = (): FuncAssociations | undefined => {
const detachFunc = async (): Promise<undefined> => {
if (props.schemaVariantId) {
const prototype = associations.value.prototypes.find(
(proto) =>
Expand All @@ -263,7 +262,7 @@ const detachFunc = (): FuncAssociations | undefined => {
] === props.schemaVariantId,
);
// todo: remove the binding when the user hits the detach button
removeBinding(prototype?.id as string);
await removeBinding(prototype?.id as string);
return;
}
};
Expand Down
18 changes: 16 additions & 2 deletions app/web/src/components/FuncEditor/FuncDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ import {
import clsx from "clsx";
import { FuncKind } from "@/api/sdf/dal/func";
import { FuncId, useFuncStore } from "@/store/func/funcs.store";
import { useAssetStore } from "@/store/asset.store";
import AuthenticationDetails from "@/components/FuncEditor/AuthenticationDetails.vue";
import FuncArguments from "./FuncArguments.vue";
import ActionDetails from "./ActionDetails.vue";
Expand All @@ -301,6 +302,7 @@ const props = defineProps<{
const funcDetailsTabGroupRef = ref();
const funcStore = useFuncStore();
const assetStore = useAssetStore();
const emit = defineEmits<{
(e: "detached"): void;
Expand Down Expand Up @@ -394,7 +396,19 @@ const execFunc = () => {
const isDetaching = ref(false);
const detachFunc = async () => {
if (detachRef.value && "detachFunc" in detachRef.value) {
const associations = detachRef.value.detachFunc();
await detachRef.value.detachFunc();
if (assetStore.selectedAssetId)
assetStore.LOAD_ASSET(assetStore.selectedAssetId); // reloads the fn list
if (funcStore.selectedFuncId)
assetStore.removeFuncSelection(funcStore.selectedFuncId);
if (funcStore.selectedFuncId && assetStore.selectedAssetId)
assetStore.closeFunc(
assetStore.selectedAssetId,
funcStore.selectedFuncId,
);
funcStore.selectedFuncId = undefined; // brings you back to the asset detail
/* this code was never reachable
if (associations && editingFunc.value) {
isDetaching.value = true;
await funcStore.UPDATE_FUNC({
Expand All @@ -403,7 +417,7 @@ const detachFunc = async () => {
});
emit("detached");
isDetaching.value = false;
}
} */
}
};
Expand Down
4 changes: 4 additions & 0 deletions app/web/src/store/asset.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ export const useAssetStore = () => {
removeFuncSelection(id: FuncId) {
const idx = this.selectedFuncs.indexOf(id);
if (idx !== -1) this.selectedFuncs.splice(idx, 1);

const idxx = funcsStore.openFuncIds.indexOf(id);
if (idxx !== -1) funcsStore.openFuncIds.splice(idxx, 1);
this.syncSelectionIntoUrl();
},
syncSelectionIntoUrl(returnQuery?: boolean) {
let selectedIds: string[] = [];
Expand Down
16 changes: 8 additions & 8 deletions app/web/src/store/change_sets.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,21 +126,21 @@ export function useChangeSetsStore() {
else if (this.headSelected) {
throw new Error("You cannot abandon HEAD!");
}
if (
router.currentRoute.value.name &&
["workspace-lab-packages", "workspace-lab-assets"].includes(
router.currentRoute.value.name.toString(),
)
) {
router.push({ name: "workspace-lab" });
}
return new ApiRequest<{ changeSet: ChangeSet }>({
method: "post",
url: "change_set/abandon_change_set",
params: {
changeSetId: this.selectedChangeSet.id,
},
onSuccess: (response) => {
if (
router.currentRoute.value.name &&
["workspace-lab-packages", "workspace-lab-assets"].includes(
router.currentRoute.value.name.toString(),
)
) {
router.push({ name: "workspace-lab" });
}
// this.changeSetsById[response.changeSet.pk] = response.changeSet;
},
});
Expand Down

0 comments on commit a992510

Please sign in to comment.