Skip to content

Commit

Permalink
Layout corrections specific to ISD 4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
satyakiran-opsmx committed Jul 20, 2022
1 parent e9aa52f commit 26d0829
Show file tree
Hide file tree
Showing 18 changed files with 97 additions and 162 deletions.
5 changes: 4 additions & 1 deletion packages/core/src/application/ApplicationComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type { Application } from './application.model';
import { RecentHistoryService } from '../history';
import { createApolloClient } from '../managed/graphql/client';
import { ApplicationNavigation } from './nav/ApplicationNavigation';
import { UrlParser } from '../navigation/urlParser';
import { DebugWindow } from '../utils/consoleDebug';

import './application.less';
Expand Down Expand Up @@ -59,10 +60,12 @@ export class ApplicationComponent extends React.Component<IApplicationComponentP

public render() {
const { app } = this.props;
const [, queryString] = window.location.href.split('?');
const queryParams = UrlParser.parseQueryString(queryString);

return (
<div className="application">
{!app.notFound && !app.hasError && <ApplicationNavigation app={app} />}
{!app.notFound && !app.hasError && !queryParams['fromISD'] && <ApplicationNavigation app={app} />}
{app.notFound && (
<div>
<h2 className="text-center">Application Not Found</h2>
Expand Down
17 changes: 0 additions & 17 deletions packages/core/src/application/service/ApplicationReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export class ApplicationReader {
});
}

<<<<<<< HEAD
public static getApplicationPermissions(applicationName: string): PromiseLike<any> {
return REST('/applications')
.path(applicationName)
Expand All @@ -56,22 +55,6 @@ export class ApplicationReader {
return REST('/applications')
.path(name)
.query({ expand: expand })
=======
public static getApplicationPermissions(applicationName: string): PromiseLike < any > {
return API.one('applications', applicationName)
.withParams({
expand: false,
})
.get()
.then((application: Application) => {
return application.attributes.permissions;
});
}

public static getApplication(name: string, expand = true): IPromise<Application> {
return API.one('applications', name)
.withParams({ expand: expand })
>>>>>>> 24dbe8d0e (Added manual judgment feature.)
.get()
.then((fromServer: Application) => {
const configs = ApplicationDataSourceRegistry.getDataSources();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class AuthenticationInitializer {
}

private static openLoggedOutModal(): void {
LoggedOutModal.show();
if (!$location.search().fromISD) LoggedOutModal.show();
}

public static loginRedirect(): void {
Expand Down
49 changes: 29 additions & 20 deletions packages/core/src/bootstrap/SpinnakerContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { RecoilRoot } from 'recoil';

import { SpinnakerHeader } from '../header/SpinnakerHeader';
import { CustomBanner } from '../header/customBanner/CustomBanner';
import { UrlParser } from '../navigation/urlParser';
import { SpinErrorBoundary } from '../presentation/SpinErrorBoundary';
import { Notifier } from '../widgets/notifier/Notifier';
import { Spinner } from '../widgets/spinners/Spinner';
Expand All @@ -14,24 +15,32 @@ export interface ISpinnakerContainerProps {
routing: boolean;
}

export const SpinnakerContainer = ({ authenticating, routing }: ISpinnakerContainerProps) => (
<SpinErrorBoundary category="SpinnakerContainer">
<RecoilRoot>
<div className="spinnaker-container grid-container">
{!authenticating && routing && (
<div className="transition-overlay">
<Spinner size="medium" />
</div>
)}
<div className="navbar-inverse grid-header">
<CustomBanner />
<UIRouterContextComponent>
<SpinnakerHeader />
</UIRouterContextComponent>
export const SpinnakerContainer = ({ authenticating, routing }: ISpinnakerContainerProps) => {
const [, queryString] = window.location.href.split('?');
const queryParams = UrlParser.parseQueryString(queryString);

return (
<SpinErrorBoundary category="SpinnakerContainer">
<RecoilRoot>
<div className="spinnaker-container grid-container">
{!authenticating && routing && (
<div className="transition-overlay">
<Spinner size="medium" />
</div>
)}
{!queryParams['fromISD'] && (
<div className="navbar-inverse grid-header">
<CustomBanner />
<UIRouterContextComponent>
<SpinnakerHeader />
</UIRouterContextComponent>
</div>
)}

<div className="spinnaker-content grid-contents">{!authenticating && <UIView name="main" />}</div>
</div>
<div className="spinnaker-content grid-contents">{!authenticating && <UIView name="main" />}</div>
</div>
<Notifier />
</RecoilRoot>
</SpinErrorBoundary>
);
<Notifier />
</RecoilRoot>
</SpinErrorBoundary>
);
};
4 changes: 0 additions & 4 deletions packages/core/src/help/help.contents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,11 +373,7 @@ const helpContents: { [key: string]: string } = {
'pipeline.config.trigger.runAsUser':
"The current user must have access to the specified service account, and the service account must have access to the current application. Otherwise, you'll receive an 'Access is denied' error.",
'pipeline.config.trigger.authorizedUser':
<<<<<<< HEAD
"The current user must have the permission to approve the manual judgment stage. Otherwise, you'll not be able continue to the next pipeline stage.",
=======
"The current user must have the permission to approve the manual judgment stage. Otherwise, you'll not be able continue to the next pipeline stage.",
>>>>>>> 24dbe8d0e (Added manual judgment feature.)
'pipeline.config.script.repoUrl':
'<p>Path to the repo hosting the scripts in Stash. (e.g. <samp>CDL/mimir-scripts</samp>). Leave empty to use the default.</p>',
'pipeline.config.script.repoBranch':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@ module(CORE_PIPELINE_CONFIG_PIPELINECONFIG_CONTROLLER, [UIROUTER_ANGULARJS]).con
'$state',
'$stateParams',
'app',
function ($scope, $state, $stateParams, app) {
'$location',
function ($scope, $state, $stateParams, app, $location) {
this.application = app;
this.state = {
pipelinesLoaded: false,
};

this.containsJinja = (source) => source && (source.includes('{{') || source.includes('{%'));

$scope.fromISD = $location.$$search.fromISD ? true : false;

this.initialize = () => {
this.pipelineConfig = _.find(app.pipelineConfigs.data, { id: $stateParams.pipelineId });
const isV2PipelineConfig =
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/pipeline/config/pipelineConfig.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="col-md-10 col-md-offset-1"></div>
</div>
<div class="row">
<div class="col-md-10 col-md-offset-1">
<div class="col-md-10 col-md-offset-1" ng-class="{'from-isd': fromISD}">
<pipeline-configurer
pipeline="vm.pipelineConfig"
plan="vm.pipelinePlan"
Expand Down
5 changes: 5 additions & 0 deletions packages/core/src/pipeline/config/pipelineConfig.less
Original file line number Diff line number Diff line change
Expand Up @@ -227,3 +227,8 @@ parameter,
.templated-pipeline-item__status {
pointer-events: auto;
}

.from-isd {
margin-left: 15px;
width: calc(100% - 30px);
}
6 changes: 3 additions & 3 deletions packages/core/src/pipeline/config/pipelineConfigurer.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="pipeline-config-heading">
<div class="config-heading-row">
<h3>
<a class="btn btn-configure" ui-sref="^.executions" uib-tooltip="Back to Executions">
<a ng-if="!fromISD" class="btn btn-configure" ui-sref="^.executions" uib-tooltip="Back to Executions">
<span class="glyphicon glyphicon glyphicon-circle-arrow-left"></span>
</a>
<a
Expand All @@ -16,7 +16,7 @@ <h3>
</a>
</h3>
<div class="config-heading-actions">
<div class="permalink">
<div class="permalink" ng-if="!fromISD">
<a
target="_blank"
analytics-on="click"
Expand All @@ -30,7 +30,7 @@ <h3>
tool-tip="'Copy permalink to clipboard'"
></copy-to-clipboard>
</div>
<div class="create-action">
<div class="create-action" ng-if="!fromISD">
<create-pipeline application="application"></create-pipeline>
</div>
<div class="pipeline-actions text-right">
Expand Down
5 changes: 5 additions & 0 deletions packages/core/src/pipeline/config/pipelineConfigurer.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ angular
}
this.setViewState({ isDirty: $scope.viewState.original !== angular.toJson($scope.pipeline) });
};

$scope.fromISD = false;

// For standard pipelines, a 'renderablePipeline' is just the pipeline config.
// For both v1 and v2 templated pipelines, a 'renderablePipeline' is the pipeline template plan, and '$scope.pipeline' is the template config.
$scope.renderablePipeline = $scope.plan || $scope.pipeline;
Expand Down Expand Up @@ -97,6 +100,8 @@ angular
showMenu: false,
};

$scope.fromISD = $location.$$search.fromISD ? true : false;

this.hideNavigationMenu = () => {
// give the navigate method a chance to fire before hiding the menu
$timeout(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,13 @@ import React from 'react';
import type { Option } from 'react-select';
import Select from 'react-select';

<<<<<<< HEAD:packages/core/src/pipeline/config/stages/manualJudgment/ManualJudgmentApproval.tsx
import type { Application } from '../../../../application/application.model';
import { ApplicationReader } from '../../../../application/service/ApplicationReader';
import { AuthenticationService } from '../../../../authentication';
import type { IExecution, IExecutionStage } from '../../../../domain';
import { Markdown } from '../../../../presentation/Markdown';
import { ReactInjector } from '../../../../reactShims';
import { Spinner } from '../../../../widgets/spinners/Spinner';
=======
import { Application } from 'core/application/application.model';
import { ApplicationReader } from 'core/application/service/ApplicationReader';
import { AuthenticationService } from 'core/authentication';
import { IExecution, IExecutionStage } from 'core/domain';
import { Markdown } from 'core/presentation/Markdown';
import { NgReact, ReactInjector } from 'core/reactShims';
import { ApplicationReader } from 'core/application/service/ApplicationReader';
import { AuthenticationService } from 'core/authentication';
>>>>>>> 5f3031cd7 (Added Manual Judgment Feature):app/scripts/modules/core/src/pipeline/config/stages/manualJudgment/ManualJudgmentApproval.tsx

export interface IManualJudgmentApprovalProps {
execution: IExecution;
Expand Down Expand Up @@ -53,7 +42,6 @@ export class ManualJudgmentApproval extends React.Component<
}

public componentDidMount() {
<<<<<<< HEAD
const applicationName = this.props.execution.application;
ApplicationReader.getApplicationPermissions(applicationName).then((result) => {
if (result) {
Expand All @@ -65,19 +53,6 @@ export class ManualJudgmentApproval extends React.Component<
this.setState({
userRoles: AuthenticationService.getAuthenticatedUser().roles,
});
=======
const applicationName = this.props.execution.application;
ApplicationReader.getApplicationPermissions(applicationName).then(result => {
if (result) {
this.setState({
applicationRoles: result,
});
}
});
this.setState({
userRoles: AuthenticationService.getAuthenticatedUser().roles,
});
>>>>>>> 24dbe8d0e (Added manual judgment feature.)
}

private provideJudgment(judgmentDecision: string): void {
Expand All @@ -88,7 +63,6 @@ export class ManualJudgmentApproval extends React.Component<
}

private isManualJudgmentStageNotAuthorized(): boolean {
<<<<<<< HEAD
let isStageNotAuthorized = true;
let returnOnceFalse = true;
const { applicationRoles, userRoles } = this.state;
Expand All @@ -113,40 +87,6 @@ export class ManualJudgmentApproval extends React.Component<
}
});
return isStageNotAuthorized;
=======
let isStageNotAuthorized = true;
let returnOnceFalse = true;
const {
applicationRoles,
userRoles
} = this.state;
const stageRoles = this.props.stage?.context?.selectedStageRoles || [];
if (!stageRoles.length) {
isStageNotAuthorized = false;
return isStageNotAuthorized;
}
const {
CREATE,
EXECUTE,
WRITE
} = applicationRoles;
userRoles.forEach(userRole => {
if (returnOnceFalse) {
if (stageRoles.includes(userRole)) {
isStageNotAuthorized = (WRITE || []).includes(userRole) ||
(EXECUTE || []).includes(userRole) ||
(CREATE || []).includes(userRole);
if (isStageNotAuthorized) {
isStageNotAuthorized = false;
returnOnceFalse = false;
} else {
isStageNotAuthorized = true;
}
}
}
})
return isStageNotAuthorized;
>>>>>>> 24dbe8d0e (Added manual judgment feature.)
}

private isSubmitting(decision: string): boolean {
Expand Down
36 changes: 0 additions & 36 deletions packages/core/src/pipeline/config/stages/stage.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,10 @@ import { CORE_PIPELINE_CONFIG_STAGES_FAILONFAILEDEXPRESSIONS_FAILONFAILEDEXPRESS
import { CORE_PIPELINE_CONFIG_STAGES_OPTIONALSTAGE_OPTIONALSTAGE_DIRECTIVE } from './optionalStage/optionalStage.directive';
import { OVERRRIDE_FAILURE } from './overrideFailure/overrideFailure.module';
import { OVERRIDE_TIMEOUT_COMPONENT } from './overrideTimeout/overrideTimeout.module';
<<<<<<< HEAD:packages/core/src/pipeline/config/stages/stage.module.js
import { ReactModal } from '../../../presentation';
=======
<<<<<<< HEAD
>>>>>>> 5f3031cd7 (Added Manual Judgment Feature):app/scripts/modules/core/src/pipeline/config/stages/stage.module.js
import { PRODUCES_ARTIFACTS_REACT } from './producesArtifacts/ProducesArtifacts';
import { Registry } from '../../../registry';
import { PipelineConfigService } from '../services/PipelineConfigService';
=======
import { ApplicationReader } from 'core/application/service/ApplicationReader';
import { CORE_PIPELINE_CONFIG_STAGES_OPTIONALSTAGE_OPTIONALSTAGE_DIRECTIVE } from './optionalStage/optionalStage.directive';
import { CORE_PIPELINE_CONFIG_STAGES_FAILONFAILEDEXPRESSIONS_FAILONFAILEDEXPRESSIONS_DIRECTIVE } from './failOnFailedExpressions/failOnFailedExpressions.directive';
import { CORE_PIPELINE_CONFIG_STAGES_COMMON_STAGECONFIGFIELD_STAGECONFIGFIELD_DIRECTIVE } from './common/stageConfigField/stageConfigField.directive';
>>>>>>> 24dbe8d0e (Added manual judgment feature.)

export const CORE_PIPELINE_CONFIG_STAGES_STAGE_MODULE = 'spinnaker.core.pipeline.config.stage';
export const name = CORE_PIPELINE_CONFIG_STAGES_STAGE_MODULE; // for backwards compatibility
Expand Down Expand Up @@ -145,7 +135,6 @@ module(CORE_PIPELINE_CONFIG_STAGES_STAGE_MODULE, [
});
};

<<<<<<< HEAD
$scope.getApplicationPermissions = function () {
ApplicationReader.getApplicationPermissions($scope.application.name).then((result) => {
appPermissions = result;
Expand All @@ -169,31 +158,6 @@ module(CORE_PIPELINE_CONFIG_STAGES_STAGE_MODULE, [
available: true,
};
});
=======
$scope.getApplicationPermissions = function() {
ApplicationReader.getApplicationPermissions($scope.application.name).then(result => {
appPermissions = result;
if (appPermissions) {
const readArray = appPermissions.READ || [];
const writeArray = appPermissions.WRITE || [];
const executeArray = appPermissions.EXECUTE || [];
appRoles = _.union(readArray, writeArray, executeArray);
appRoles = Array.from(new Set(appRoles));
$scope.updateAvailableStageRoles();
}
});
};

$scope.updateAvailableStageRoles = function() {
$scope.options.stageRoles = appRoles.map(function(value, index) {
return {
name: value,
roleId: value,
id: index,
available: true,
};
});
>>>>>>> 24dbe8d0e (Added manual judgment feature.)
};

this.editStageJson = () => {
Expand Down
Loading

0 comments on commit 26d0829

Please sign in to comment.