feat(web): add public package browsing and organization redirect management
This commit is contained in:
@@ -20,6 +20,7 @@ export interface IOrganizationsState {
|
||||
currentOrg: interfaces.data.IOrganizationDetail | null;
|
||||
repositories: interfaces.data.IRepository[];
|
||||
members: interfaces.data.IOrganizationMember[];
|
||||
redirects: interfaces.data.IOrgRedirect[];
|
||||
}
|
||||
|
||||
export interface IPackagesState {
|
||||
@@ -70,6 +71,7 @@ export const organizationsStatePart = await appState.getStatePart<IOrganizations
|
||||
currentOrg: null,
|
||||
repositories: [],
|
||||
members: [],
|
||||
redirects: [],
|
||||
},
|
||||
'soft',
|
||||
);
|
||||
@@ -366,6 +368,53 @@ export const fetchMembersAction = organizationsStatePart.createAction<{
|
||||
}
|
||||
});
|
||||
|
||||
export const fetchRedirectsAction = organizationsStatePart.createAction<{
|
||||
organizationId: string;
|
||||
}>(async (statePartArg, dataArg) => {
|
||||
const context = getActionContext();
|
||||
if (!context.identity) return statePartArg.getState();
|
||||
try {
|
||||
const typedRequest = createTypedRequest<interfaces.requests.IReq_GetOrgRedirects>(
|
||||
'getOrgRedirects',
|
||||
);
|
||||
const response = await typedRequest.fire({
|
||||
identity: context.identity,
|
||||
organizationId: dataArg.organizationId,
|
||||
});
|
||||
return { ...statePartArg.getState(), redirects: response.redirects };
|
||||
} catch {
|
||||
return statePartArg.getState();
|
||||
}
|
||||
});
|
||||
|
||||
export const deleteRedirectAction = organizationsStatePart.createAction<{
|
||||
redirectId: string;
|
||||
organizationId: string;
|
||||
}>(async (statePartArg, dataArg) => {
|
||||
const context = getActionContext();
|
||||
if (!context.identity) return statePartArg.getState();
|
||||
try {
|
||||
const typedRequest = createTypedRequest<interfaces.requests.IReq_DeleteOrgRedirect>(
|
||||
'deleteOrgRedirect',
|
||||
);
|
||||
await typedRequest.fire({
|
||||
identity: context.identity,
|
||||
redirectId: dataArg.redirectId,
|
||||
});
|
||||
// Re-fetch redirects
|
||||
const listReq = createTypedRequest<interfaces.requests.IReq_GetOrgRedirects>(
|
||||
'getOrgRedirects',
|
||||
);
|
||||
const listResp = await listReq.fire({
|
||||
identity: context.identity,
|
||||
organizationId: dataArg.organizationId,
|
||||
});
|
||||
return { ...statePartArg.getState(), redirects: listResp.redirects };
|
||||
} catch {
|
||||
return statePartArg.getState();
|
||||
}
|
||||
});
|
||||
|
||||
// ============================================================================
|
||||
// Package Actions
|
||||
// ============================================================================
|
||||
|
||||
Reference in New Issue
Block a user