Skip to content

Commit

Permalink
Argo App creation via Isd changes
Browse files Browse the repository at this point in the history
  • Loading branch information
NagendraOpsmx committed Jan 24, 2024
1 parent 68ea727 commit c380817
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 8 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 @@ -297,11 +297,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 @@ -573,7 +584,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 @@ -586,7 +601,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 @@ -601,6 +620,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
18 changes: 16 additions & 2 deletions 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,11 +13,24 @@ export interface LayoutProps {
isExtension?: boolean;
}

export const Layout = (props: LayoutProps) => (
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 Layout = (props: LayoutProps) => {
const context = React.useContext(Context);
const locationPath = context.history.location.pathname;
const pathHasOpsmx = checkUrlIncludesOpsmx(locationPath);
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'}`}>{props.children}</div>
</div>
</div>
);
}
7 changes: 3 additions & 4 deletions ui/src/app/sidebar/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,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 c380817

Please sign in to comment.