Skip to content

Commit

Permalink
Argo App creation via Isd changes (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
NagendraOpsmx committed Apr 3, 2024
1 parent 375f7e1 commit c97f0c2
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {ApplicationsList} from './applications-list/applications-list';
export const ApplicationsContainer = (props: RouteComponentProps<any>) => (
<Switch>
<Route exact={true} path={`${props.match.path}`} component={ApplicationsList} />
<Route exact={true} path={`${props.match.path}/opsmx/creation`} component={ApplicationsList} />
<Route exact={true} path={`${props.match.path}/:name`} component={ApplicationDetails} />
<Route exact={true} path={`${props.match.path}/:name/opsmx/details`} component={ApplicationDetails} />
<Route exact={true} path={`${props.match.path}/:appnamespace/:name`} component={ApplicationDetails} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,22 @@ const FlexTopBar = (props: {toolbar: Toolbar | Observable<Toolbar>}) => {
);
};

const checkUrlIncludesOpsmx = (param: string) => {
let urlSplit = param?.split('/')
if(urlSplit && urlSplit[urlSplit.length-2] == 'opsmx' && urlSplit[urlSplit.length-1] == 'creation'){
return true;
}
return false;
}

export const ApplicationsList = (props: RouteComponentProps<{}>) => {
const query = new URLSearchParams(props.location.search);
const appInput = tryJsonParse(query.get('new'));
const syncAppsInput = tryJsonParse(query.get('syncApps'));
const refreshAppsInput = tryJsonParse(query.get('refreshApps'));
const context = React.useContext(Context);
const locationPath = context.history.location.pathname;
const pathHasOpsmx = checkUrlIncludesOpsmx(locationPath);
const [createApi, setCreateApi] = React.useState(null);
const clusters = React.useMemo(() => services.clusters.list(), []);
const [isAppCreatePending, setAppCreatePending] = React.useState(false);
Expand Down Expand Up @@ -598,7 +609,11 @@ export const ApplicationsList = (props: RouteComponentProps<{}>) => {
</ObservableQuery>
<SlidingPanel
isShown={!!appInput}
onClose={() => ctx.navigation.goto('.', {new: null}, {replace: true})}
onClose={() => {
if(pathHasOpsmx){
window.parent.postMessage({msg:'closeEvent'},'*')
}
ctx.navigation.goto('.', {new: null}, {replace: true})}}
header={
<div>
<button
Expand All @@ -611,7 +626,11 @@ export const ApplicationsList = (props: RouteComponentProps<{}>) => {
</button>{' '}
<button
qe-id='applications-list-button-cancel'
onClick={() => ctx.navigation.goto('.', {new: null}, {replace: true})}
onClick={() => {
if(pathHasOpsmx){
window.parent.postMessage({msg:'closeEvent'},'*')
}
ctx.navigation.goto('.', {new: null}, {replace: true})}}
className='argo-button argo-button--base-o'>
Cancel
</button>
Expand All @@ -626,6 +645,10 @@ export const ApplicationsList = (props: RouteComponentProps<{}>) => {
setAppCreatePending(true);
try {
await services.applications.create(app);
//iframe msg alert needed
if(pathHasOpsmx){
window.parent.postMessage({msg:'saveEvent'},'*')
}
ctx.navigation.goto('.', {new: null}, {replace: true});
} catch (e) {
ctx.notifications.show({
Expand Down
15 changes: 14 additions & 1 deletion ui/src/app/shared/components/layout/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';
import {Sidebar} from '../../../sidebar/sidebar';
import {ViewPreferences} from '../../services';
import { Context } from '../../context';

require('./layout.scss');

Expand All @@ -12,9 +13,21 @@ export interface LayoutProps {
isExtension?: boolean;
}

const checkUrlIncludesOpsmx = (param: string) => {
let urlSplit = param?.split('/')
if(urlSplit && urlSplit[urlSplit.length-2] == 'opsmx' && urlSplit[urlSplit.length-1] == 'creation'){
return true;
}
return false;
}

const getBGColor = (theme: string): string => (theme === 'light' ? '#dee6eb' : '#100f0f');

export const Layout = (props: LayoutProps) => {
const context = React.useContext(Context);
const locationPath = context.history.location.pathname;
const pathHasOpsmx = checkUrlIncludesOpsmx(locationPath);

React.useEffect(() => {
if (props.pref.theme) {
document.body.style.background = getBGColor(props.pref.theme);
Expand All @@ -23,7 +36,7 @@ export const Layout = (props: LayoutProps) => {

return (
<div className={props.pref.theme ? 'theme-' + props.pref.theme : 'theme-light'}>
<div className={`cd-layout ${props.isExtension ? 'cd-layout--extension' : ''}`}>
<div className={`cd-layout ${props.isExtension ? 'cd-layout--extension' : ''} ${pathHasOpsmx ? 'opsmx_hide': ''}`}>
<Sidebar onVersionClick={props.onVersionClick} navItems={props.navItems} pref={props.pref} />
<div className={`cd-layout__content ${props.pref.hideSidebar ? 'cd-layout__content--sb-collapsed' : 'cd-layout__content--sb-expanded'} custom-styles`}>
{props.children}
Expand Down
7 changes: 3 additions & 4 deletions ui/src/app/sidebar/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,11 @@ export const useSidebarTarget = () => {
};

const checkUrlIncludesOpsmx = (param: string) => {
let urlSplit = param.split('/')
if(urlSplit[urlSplit.length-2] == 'opsmx' && urlSplit[urlSplit.length-1] == 'details'){
let urlSplit = param?.split('/')
if(urlSplit && urlSplit[urlSplit.length-2] == 'opsmx' && (urlSplit[urlSplit.length-1] == 'details' || urlSplit[urlSplit.length-1] == 'creation')){
return true;
}else{
return false;
}
return false;
}

export const Sidebar = (props: SidebarProps) => {
Expand Down
8 changes: 8 additions & 0 deletions ui/src/assets/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,12 @@ input.autocomplete__input.input {
}
.settings-overview__redirect-panel, .user-info-overview__panel, .argo-table-list__row {
box-shadow: 0px 0px 4px 1px rgb(0 0 0 / 10%) !important;
}

.opsmx_hide .sliding-panel__wrapper{
width:100% !important
}

.opsmx_hide .page__top-bar, .opsmx_hide .sidebar {
display: none;
}

0 comments on commit c97f0c2

Please sign in to comment.