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

feat: Delete popup handled with a message #3

Merged
merged 2 commits into from
Jan 30, 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 @@ -745,7 +745,7 @@ export class ApplicationDetails extends React.Component<RouteComponentProps<{app

private onAppDeleted() {
this.appContext.apis.notifications.show({type: NotificationType.Success, content: `Application '${this.props.match.params.name}' was deleted`});
this.appContext.apis.navigation.goto('/applications');
// this.appContext.apis.navigation.goto('/applications'); // To avoid redirecting to the listing page
}

private async updateApp(app: appModels.Application, query: {validate?: boolean}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import * as models from '../../../shared/models';
import {services} from '../../../shared/services';
import {ApplicationSyncWindowStatusIcon, ComparisonStatusIcon, getAppOperationState, getConditionCategory, HealthStatusIcon, OperationState, syncStatusMessage} from '../utils';
import {RevisionMetadataPanel} from './revision-metadata-panel';
import * as AppUtils from '../utils'
import { Observable } from 'rxjs';

require('./application-status-panel.scss');

Expand Down Expand Up @@ -166,7 +168,11 @@ export const ApplicationStatusPanel = ({application, showOperation, showConditio
noLoaderOnInputChange={true}
input={application}
load={async app => {
return await services.applications.getApplicationSyncWindowState(app.metadata.name, app.metadata.namespace);
if(!AppUtils.isPopupFn()){
return await services.applications.getApplicationSyncWindowState(app.metadata.name, app.metadata.namespace);
}
return new Observable();

}}>
{(data: models.ApplicationSyncWindowState) => (
<React.Fragment>
Expand Down
11 changes: 9 additions & 2 deletions ui/src/app/applications/components/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ export const ExternalLinkAnnotation = 'link.argocd.argoproj.io/external-link';

type ActionMenuItem = MenuItem & {disabled?: boolean};

export let popupConfirmed: boolean = false;

export function isPopupFn() {
return popupConfirmed;
}

export function nodeKey(node: NodeId) {
return [node.group, node.kind, node.namespace, node.name].join('/');
}
Expand Down Expand Up @@ -104,6 +110,7 @@ export async function deleteApplication(appName: string, appNamespace: string, a
try {
await services.applications.delete(appName, appNamespace, vals.propagationPolicy);
confirmed = true;
popupConfirmed = confirmed;
close();
} catch (e) {
apis.notifications.show({
Expand All @@ -113,8 +120,8 @@ export async function deleteApplication(appName: string, appNamespace: string, a
}
}
},
{name: 'argo-icon-warning', color: 'warning'},
'yellow',
{name: 'argo-icon-warning', color: 'info'},
'',
{propagationPolicy: 'foreground'}
);
return confirmed;
Expand Down
7 changes: 7 additions & 0 deletions ui/src/app/shared/components/page/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {map} from 'rxjs/operators';
import {Context, ContextApis} from '../../context';
import {services} from '../../services';
import requests from '../../services/requests';
import * as AppUtils from '../../../applications/components/utils'
import PopupModal from '../simplePopup/popup';

const mostRecentLoggedIn = new BehaviorSubject<boolean>(false);

Expand Down Expand Up @@ -62,6 +64,11 @@ export const Page = (props: PageProps) => {
useTitleOnly={props.useTitleOnly}
toolbar={!props.hideAuth ? AddAuthToToolbar(props.toolbar, ctx) : props.toolbar}
/>
{AppUtils.isPopupFn() &&
<PopupModal isOpen={true}
header="Deleted Successfully"
content="Application Deleted Successfully. Please navigate to ISD Dashboard."></PopupModal>
}
</div>
)}
</DataLoader>
Expand Down
63 changes: 63 additions & 0 deletions ui/src/app/shared/components/simplePopup/popup.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/* Popup style */
.popup-box {
position: fixed;
display: flex;
background: #00000050;
display: flex;
width: 100%;
height: 100vh;
top: 0;
left: 0;
z-index: 10;
align-items: center;

}

.alignBox{
margin: 0 auto;
}

.header{
color: #fff;
font-weight: bold;
position: relative;
width: 700px;
margin: 0 auto;
height: auto;
max-height: 70vh;
margin-top: calc(100vh - 85vh - 30vh);
background-color: #5fba6e;
padding: 10px 20px;
overflow: auto;

}

.content-box {
font-size: 18px;
position: relative;
width: 700px;
margin: 0 auto;
height: auto;
max-height: 70vh;
/* margin-top: calc(100vh - 85vh - 20px); */
background: #fff;
padding: 20px;
/* border: 1px solid #999; */
overflow: auto;
}

.close-icon {
content: 'x';
cursor: pointer;
position: fixed;
right: calc(15% - 30px);
top: calc(100vh - 85vh - 33px);
background: #ededed;
width: 25px;
height: 25px;
border-radius: 50%;
line-height: 20px;
text-align: center;
border: 1px solid #999;
font-size: 20px;
}
33 changes: 33 additions & 0 deletions ui/src/app/shared/components/simplePopup/popup.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import * as React from 'react';
import { useState } from 'react';
require('./popup.css');


const PopupModal = (props: {
isOpen: boolean;
content: string | number | boolean | {} | React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactNodeArray | React.ReactPortal;
header: string;
}) => {
const [isOpen, setIsOpen] = useState(false);
const handleClose =()=> setIsOpen(false);

React.useEffect(() => {
setIsOpen(props.isOpen)
}, [props.isOpen])

return (
isOpen && (<div className="popup-box">
<div className='alignBox'>
<div className='header'>
{props.header}
</div>
<div className="content-box">
{/* <span className="close-icon" onClick={handleClose}>x</span> */}
{props.content}
</div>
</div>
</div>)
);
};

export default PopupModal;