Compare commits

...

6 Commits

Author SHA1 Message Date
nivedin
b5e7577024 fix: saving teamRequest not inheriting properties 2023-12-23 16:12:55 +05:30
nivedin
9bd7961c15 chore: minor padding update 2023-12-22 12:29:06 +05:30
nivedin
4f74cd8f89 chore: minor code update 2023-12-22 12:07:17 +05:30
nivedin
cf4ecd326e chore: minor update for team header-auth properties 2023-12-20 22:22:05 +05:30
nivedin
2ed43f03e1 fix: add loading and error state 2023-12-20 22:19:17 +05:30
nivedin
1ac518ef87 fix: update i18n text 2023-12-20 22:18:27 +05:30
8 changed files with 94 additions and 6 deletions

View File

@@ -33,6 +33,7 @@
@select="onSelect" @select="onSelect"
@update-team="updateTeam" @update-team="updateTeam"
@update-collection-type="updateCollectionType" @update-collection-type="updateCollectionType"
@set-team-collection-adapter="teamCollectionAdapter = $event"
/> />
</div> </div>
</template> </template>
@@ -86,6 +87,7 @@ import { platform } from "~/platform"
import { useService } from "dioc/vue" import { useService } from "dioc/vue"
import { RESTTabService } from "~/services/tab/rest" import { RESTTabService } from "~/services/tab/rest"
import { GQLTabService } from "~/services/tab/graphql" import { GQLTabService } from "~/services/tab/graphql"
import TeamCollectionAdapter from "~/helpers/teams/TeamCollectionAdapter"
const t = useI18n() const t = useI18n()
const toast = useToast() const toast = useToast()
@@ -93,6 +95,8 @@ const toast = useToast()
const RESTTabs = useService(RESTTabService) const RESTTabs = useService(RESTTabService)
const GQLTabs = useService(GQLTabService) const GQLTabs = useService(GQLTabService)
const teamCollectionAdapter = ref<TeamCollectionAdapter>()
type SelectedTeam = GetMyTeamsQuery["myTeams"][number] | undefined type SelectedTeam = GetMyTeamsQuery["myTeams"][number] | undefined
type CollectionType = type CollectionType =
@@ -380,7 +384,6 @@ const saveRequestAs = async () => {
platform: "rest", platform: "rest",
workspaceType: "team", workspaceType: "team",
}) })
pipe( pipe(
updateTeamRequest(picked.value.requestID, data), updateTeamRequest(picked.value.requestID, data),
TE.match( TE.match(
@@ -388,7 +391,31 @@ const saveRequestAs = async () => {
toast.error(`${getErrorMessage(err)}`) toast.error(`${getErrorMessage(err)}`)
modalLoadingState.value = false modalLoadingState.value = false
}, },
() => { (result) => {
const { updateRequest } = result
RESTTabs.currentActiveTab.value.document = {
request: requestUpdated,
isDirty: false,
saveContext: {
originLocation: "team-collection",
requestID: updateRequest.id,
collectionID: updateRequest.collectionID,
},
}
if (teamCollectionAdapter.value) {
const { auth, headers } =
teamCollectionAdapter.value.cascadeParentCollectionForHeaderAuth(
updateRequest.collectionID
)
RESTTabs.currentActiveTab.value.document.inheritedProperties = {
auth,
headers,
}
}
modalLoadingState.value = false modalLoadingState.value = false
requestSaved() requestSaved()
} }
@@ -516,6 +543,18 @@ const updateTeamCollectionOrFolder = (
}, },
} }
if (teamCollectionAdapter.value) {
const { auth, headers } =
teamCollectionAdapter.value.cascadeParentCollectionForHeaderAuth(
createRequestInCollection.collection.id
)
RESTTabs.currentActiveTab.value.document.inheritedProperties = {
auth,
headers,
}
}
modalLoadingState.value = false modalLoadingState.value = false
requestSaved() requestSaved()
} }

View File

@@ -262,6 +262,7 @@ const emit = defineEmits<{
(event: "select", payload: Picked | null): void (event: "select", payload: Picked | null): void
(event: "update-team", team: SelectedTeam): void (event: "update-team", team: SelectedTeam): void
(event: "update-collection-type", type: CollectionType["type"]): void (event: "update-collection-type", type: CollectionType["type"]): void
(event: "set-team-collection-adapter", adapter: TeamCollectionAdapter): void
}>() }>()
type SelectedTeam = GetMyTeamsQuery["myTeams"][number] | undefined type SelectedTeam = GetMyTeamsQuery["myTeams"][number] | undefined
@@ -354,6 +355,7 @@ watch(
(newTeam) => { (newTeam) => {
if (newTeam) { if (newTeam) {
teamCollectionAdapter.changeTeamID(newTeam.id) teamCollectionAdapter.changeTeamID(newTeam.id)
emit("set-team-collection-adapter", teamCollectionAdapter)
} }
} }
) )

View File

@@ -21,7 +21,7 @@
/> />
</div> </div>
<div class="flex flex-col"> <div class="flex flex-col">
<div v-if="loading" class="flex flex-col items-center justify-center"> <div v-if="loading" class="flex flex-col items-center justify-center p-4">
<HoppSmartSpinner class="mb-4" /> <HoppSmartSpinner class="mb-4" />
<span class="text-secondaryLight">{{ t("state.loading") }}</span> <span class="text-secondaryLight">{{ t("state.loading") }}</span>
</div> </div>
@@ -451,7 +451,7 @@ const getErrorMessage = (err: GQLError<string>) => {
} }
switch (err.error) { switch (err.error) {
case "shortcode/not_found": case "shortcode/not_found":
return t("shared_request.not_found") return t("shared_requests.not_found")
default: default:
return t("error.something_went_wrong") return t("error.something_went_wrong")
} }

View File

@@ -2,5 +2,6 @@ mutation UpdateRequest($data: UpdateTeamRequestInput!, $requestID: ID!) {
updateRequest(data: $data, requestID: $requestID) { updateRequest(data: $data, requestID: $requestID) {
id id
title title
collectionID
} }
} }

View File

@@ -156,6 +156,7 @@ export default class ShortcodeListAdapter {
const [shortcodeCreated$, shortcodeCreatedSub] = runAuthOnlyGQLSubscription( const [shortcodeCreated$, shortcodeCreatedSub] = runAuthOnlyGQLSubscription(
{ {
query: ShortcodeCreatedDocument, query: ShortcodeCreatedDocument,
variables: {},
} }
) )
@@ -172,6 +173,7 @@ export default class ShortcodeListAdapter {
const [shortcodeRevoked$, shortcodeRevokedSub] = runAuthOnlyGQLSubscription( const [shortcodeRevoked$, shortcodeRevokedSub] = runAuthOnlyGQLSubscription(
{ {
query: ShortcodeDeletedDocument, query: ShortcodeDeletedDocument,
variables: {},
} }
) )
@@ -188,6 +190,7 @@ export default class ShortcodeListAdapter {
const [shortcodeUpdated$, shortcodeUpdatedSub] = runAuthOnlyGQLSubscription( const [shortcodeUpdated$, shortcodeUpdatedSub] = runAuthOnlyGQLSubscription(
{ {
query: ShortcodeUpdatedDocument, query: ShortcodeUpdatedDocument,
variables: {},
} }
) )

View File

@@ -1034,6 +1034,11 @@ export default class NewTeamCollectionAdapter {
} }
} }
/**
* Used to obtain the inherited auth and headers for a given folder path, used for both REST and GraphQL team collections
* @param folderPath the path of the folder to cascade the auth from
* @returns the inherited auth and headers for the given folder path
*/
public cascadeParentCollectionForHeaderAuth(folderPath: string) { public cascadeParentCollectionForHeaderAuth(folderPath: string) {
let auth: HoppInheritedProperty["auth"] = { let auth: HoppInheritedProperty["auth"] = {
parentID: folderPath ?? "", parentID: folderPath ?? "",
@@ -1089,7 +1094,10 @@ export default class NewTeamCollectionAdapter {
const parentFolderAuth = data.auth const parentFolderAuth = data.auth
const parentFolderHeaders = data.headers const parentFolderHeaders = data.headers
if (parentFolderAuth?.authType === "inherit" && path.length === 1) { if (
parentFolderAuth?.authType === "inherit" &&
[...path.slice(0, i + 1)].length === 1
) {
auth = { auth = {
parentID: [...path.slice(0, i + 1)].join("/"), parentID: [...path.slice(0, i + 1)].join("/"),
parentName: parentFolder.title, parentName: parentFolder.title,

View File

@@ -68,7 +68,7 @@ export function navigateToFolderWithIndexPath(
} }
/** /**
* Used to obtain the inherited auth and headers for a given folder path, used for both REST and GraphQL * Used to obtain the inherited auth and headers for a given folder path, used for both REST and GraphQL personal collections
* @param folderPath the path of the folder to cascade the auth from * @param folderPath the path of the folder to cascade the auth from
* @param type the type of collection * @param type the type of collection
* @returns the inherited auth and headers for the given folder path * @returns the inherited auth and headers for the given folder path

View File

@@ -18,6 +18,41 @@
:properties="properties" :properties="properties"
:shared-request-i-d="sharedRequestID" :shared-request-i-d="sharedRequestID"
/> />
<div v-else class="flex flex-1 flex-col items-center justify-center p-4">
<div
v-if="sharedRequestDetails.loading"
class="flex flex-1 flex-col items-center justify-center p-4"
>
<HoppSmartSpinner />
</div>
<div v-else>
<div
v-if="
!sharedRequestDetails.loading && E.isLeft(sharedRequestDetails.data)
"
class="flex flex-col items-center p-4"
>
<icon-lucide-alert-triangle class="svg-icons mb-2 opacity-75" />
<h1 class="heading text-center">
{{ t("error.invalid_link") }}
</h1>
<p class="mt-2 text-center">
{{ t("error.invalid_embed_link") }}
</p>
</div>
<div
v-if="
!sharedRequestDetails.loading &&
E.isRight(sharedRequestDetails.data)
"
class="flex flex-1 flex-col items-center justify-center p-4"
>
<h1 class="heading">
{{ t("state.loading") }}
</h1>
</div>
</div>
</div>
</div> </div>
</template> </template>