Skip to content

Commit

Permalink
Merge pull request #208 from rciam/devel
Browse files Browse the repository at this point in the history
Added Review prompt after submitting deregistration requests
  • Loading branch information
linathedog authored Aug 21, 2024
2 parents d7bc8ce + 332ab0d commit b28bc70
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 12 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes in Federation Registry will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.3.4]

### Fixed
- Added Review prompt after submitting deregistration requests

## [1.3.3]

### Fixed
Expand Down
61 changes: 49 additions & 12 deletions federation-registry-frontend/src/ServiceList.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {Link,useParams,useLocation,useHistory} from "react-router-dom";
import Badge from 'react-bootstrap/Badge';
import Pagination from 'react-bootstrap/Pagination';
import {LoadingBar,ProcessingRequest} from './Components/LoadingBar';
import {ListResponseModal,Logout,NotFound} from './Components/Modals.js';
import {ListResponseModal,Logout,NotFound,PetitionSubmittedModal} from './Components/Modals.js';
import CopyDialog from './Components/CopyDialog.js';
import ManageTags from './Components/ManageTags.js';
import { useTranslation } from 'react-i18next';
Expand Down Expand Up @@ -87,7 +87,7 @@ const ServiceList= (props)=> {
const [searchInputString,setSearchInputString] = useState((query.tags?(":tag="+ query.tags):'')+(query.created_after?(":reg_after="+query.created_after):"")+(query.created_before?(":owner="+query.created_before):"")+(query.owner?(":owner="+query.owner):"")+(query.search_string||""))
const pageSize = 10;
const [showResetButton,setShowResetButton] = useState(false);

const [petitionSubmittedModalData,setPetitionSubmittedModalData] = useState({});



Expand Down Expand Up @@ -421,10 +421,21 @@ const ServiceList= (props)=> {
setPaginationItems(items);
};

const canReview = (integration_environment) => {
return (
// Allow when user can review service requests targeting a restricted ennvironment
(user.actions.includes('review_restricted')&& tenant?.config?.restricted_env.includes(integration_environment))
||
// Allow when user can review their own petition and service request targets a testing environment
(tenant?.config?.test_env.includes(integration_environment) && user.actions.includes('review_own_petition'))
||
// Allow when user can review all petitions and service request does not target a restricted environment
(user.actions.includes('review_petition')&& !tenant?.config?.restricted_env.includes(integration_environment))
);
}



const deleteService = (service_id,petition_id)=>{
const deleteService = (service_id,petition_id,integration_environment)=>{
setAsyncResponse(true);
if(petition_id){
fetch(config.host[tenant_name]+'tenants/'+tenant_name+'/petitions/'+petition_id, {
Expand All @@ -436,10 +447,17 @@ const ServiceList= (props)=> {
body:JSON.stringify({service_id:service_id,type:'delete'})
}).then(response=> {
getServices();
setResponseTitle(t('request_submit_title'));
setAsyncResponse(false);
if(response.status===200){
setMessage(t('request_submit_success_msg'));
let reviewEnabled = canReview(integration_environment);
setPetitionSubmittedModalData({
title:t('new_petition_title'),
message: reviewEnabled? t('request_submit_success_review_msg'):t('request_submit_success_msg'),
service_id: service_id,
tenant: tenant_name,
petition_id: petition_id,
reviewEnabled
});
}else if(response.status===401){
setLogout(true);
return false;
Expand All @@ -449,7 +467,12 @@ const ServiceList= (props)=> {
return false;
}
else{
setMessage(t('request_submit_failed_msg') + response.status);
setPetitionSubmittedModalData({
title:t('request_submit_title'),
message:t('request_submit_failed_msg') + response.status,
tenant: tenant_name,
reviewEnabled:false
});
}
});
}
Expand All @@ -461,12 +484,20 @@ const ServiceList= (props)=> {
'Content-Type': 'application/json'
},
body:JSON.stringify({service_id:service_id,type:'delete'})
}).then(response=> {
}).then(async response=> {
getServices();
setResponseTitle(t('request_submit_title'));
let responseData = await response.json();
setAsyncResponse(false);
if(response.status===200){
setMessage(t('request_submit_success_msg'));
let reviewEnabled = canReview(integration_environment);
setPetitionSubmittedModalData({
title:t('new_petition_title'),
message: reviewEnabled? t('request_submit_success_review_msg'):t('request_submit_success_msg'),
service_id: service_id,
tenant: tenant_name,
petition_id: responseData.id,
reviewEnabled
});
}else if(response.status===401){
setLogout(true);
return false;
Expand All @@ -476,7 +507,12 @@ const ServiceList= (props)=> {
return false;
}
else{
setMessage(t('request_submit_failed_msg') + response.status);
setPetitionSubmittedModalData({
title:t('request_submit_title'),
message:t('request_submit_failed_msg') + response.status,
tenant: tenant_name,
reviewEnabled:false
});
}
});
}
Expand Down Expand Up @@ -513,6 +549,7 @@ const ServiceList= (props)=> {
return(
<React.Fragment>
<Logout logout={logout}/>
<PetitionSubmittedModal modalData={petitionSubmittedModalData} setModalData={setPetitionSubmittedModalData}/>
<NotFound notFound={notFound?true:false} setNotFound={setNotFound}/>
<ListResponseModal message={message} modalTitle={responseTitle} setMessage={setMessage}/>
<ConfirmationModal active={confirmationData.action?true:false} close={()=>{setConfirmationData({})}} action={()=>{if(confirmationData.action==='delete_service'){deleteService(...confirmationData.args)}else{deletePetition(...confirmationData.args)} setConfirmationData({});}} title={confirmationData.title} accept={'Yes'} decline={'No'}/>
Expand Down Expand Up @@ -1051,7 +1088,7 @@ function TableItem(props) {
onClick={()=>{
props.setConfirmationData({
action:'delete_service',
args:[props.service.service_id,props.service.petition_id],
args:[props.service.service_id,props.service.petition_id,props.service.integration_environment],
title:t('confirmation_title')+' '+t('confirmation_delete')
})
}}>
Expand Down
1 change: 1 addition & 0 deletions federation-registry-frontend/src/locate/en/translate.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"production_filter":"Production",
"development_filter":"Development",
"request_submit_success_msg":"Was submitted successfully and is currently pending approval from an administrator.",
"request_submit_success_review_msg":"Was submitted successfully, you can review the request now or leave it for later.",
"request_submit_fail_msg":"Was not submitted Status:",
"request_submit_title":"Your deregistration request",
"request_cancel_success_msg":"Was canceled successfully.",
Expand Down

0 comments on commit b28bc70

Please sign in to comment.