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

Multi Sync app feature #25

Merged
merged 1 commit into from
Jan 9, 2025
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 @@ -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/opsmxsyncronizeApp`} 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} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ 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'){
if(urlSplit && urlSplit[urlSplit.length-2] == 'opsmx' && (urlSplit[urlSplit.length-1] == 'creation' || urlSplit[urlSplit.length-1] == 'opsmxsyncronizeApp')){
return true;
}
return false;
Expand Down Expand Up @@ -390,7 +390,7 @@ export const ApplicationsList = (props: RouteComponentProps<{}>) => {
const {filteredApps, filterResults} = filterApps(applications, pref, pref.search);
return (
<React.Fragment>
<FlexTopBar
{ !pathHasOpsmx ? <> <FlexTopBar
toolbar={{
tools: (
<React.Fragment key='app-list-tools'>
Expand Down Expand Up @@ -558,7 +558,13 @@ export const ApplicationsList = (props: RouteComponentProps<{}>) => {
hide={() => ctx.navigation.goto('.', {refreshApps: null}, {replace: true})}
apps={filteredApps}
/>
</div>
</div></> : <ApplicationsSyncPanel
key='syncsPanel'
show={syncAppsInput}
hide={() => { if(pathHasOpsmx){window.parent.postMessage({msg:'closeEvent'},'*')}
ctx.navigation.goto('.', {syncApps: null}, {replace: true})}}
apps={filteredApps} pathHasOpsmx={pathHasOpsmx}
/>}
<ObservableQuery>
{q => (
<DataLoader
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,17 @@ interface Progress {
title: string;
}

export const ApplicationsSyncPanel = ({show, apps, hide}: {show: boolean; apps: models.Application[]; hide: () => void}) => {
export const ApplicationsSyncPanel = ({show, apps, hide, pathHasOpsmx}: {show: boolean; apps: models.Application[]; hide: () => void, pathHasOpsmx:boolean}) => {
const [form, setForm] = React.useState<FormApi>(null);
const [progress, setProgress] = React.useState<Progress>(null);
const getSelectedApps = (params: any) => apps.filter((_, i) => params['app/' + i]);
const [isPending, setPending] = React.useState(false);

React.useEffect(()=>{
if (pathHasOpsmx) {
window.parent.postMessage({msg:'loadEvent'},'*')
}
},[])
const syncHandler = (currentForm: FormApi, ctx: ContextApis, applications: models.Application[]) => {
const formValues = currentForm.getFormState().values;
const replaceChecked = formValues.syncOptions?.includes('Replace=true');
Expand Down Expand Up @@ -61,11 +67,13 @@ export const ApplicationsSyncPanel = ({show, apps, hide}: {show: boolean; apps:
<Spinner show={isPending} style={{marginRight: '5px'}} />
Sync
</button>{' '}
<button onClick={() => hide()} className='argo-button argo-button--base-o'>
{!pathHasOpsmx ? <button onClick={() => hide()} className='argo-button argo-button--base-o'>
Cancel
</button>
</button> : ''}
</div>
}>
}
pathHasOpsmx={pathHasOpsmx}
>
<Form
defaultValues={{syncFlags: []}}
onSubmit={async (params: any) => {
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/shared/components/layout/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface LayoutProps {

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