From 10bd990ca87eed0359c7eae35d1d367bcaed4ba0 Mon Sep 17 00:00:00 2001 From: Aaron Date: Thu, 1 Mar 2018 09:47:47 +0800 Subject: [PATCH 1/3] Fix bug https://github.com/rancher/rancher/issues/11745 https://github.com/rancher/rancher/issues/11744 --- lib/pipeline/addon/components/pipeline-jobs-table/component.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/pipeline/addon/components/pipeline-jobs-table/component.js b/lib/pipeline/addon/components/pipeline-jobs-table/component.js index 42dbdf0ab..3791b2a56 100644 --- a/lib/pipeline/addon/components/pipeline-jobs-table/component.js +++ b/lib/pipeline/addon/components/pipeline-jobs-table/component.js @@ -51,7 +51,6 @@ export default Component.extend({ filtered: function() { const data = this.get('body') || []; const projectId = this.get('projectId') - console.log(projectId) return data.filterBy('projectId', projectId); - }.property('model.@each.{projectId}', 'projectId'), + }.property('body.@each.{projectId}', 'projectId'), }); From fd114a7d3a84483111f56c27dca0cdacaf9d17a6 Mon Sep 17 00:00:00 2001 From: Aaron Date: Thu, 1 Mar 2018 14:48:46 +0800 Subject: [PATCH 2/3] Fix bug https://github.com/rancher/rancher/issues/11700 --- .../pipeline-jobs-table/template.hbs | 144 +++++++++--------- .../components/pipeline-steps/component.js | 1 - lib/pipeline/addon/pipelines/controller.js | 10 ++ lib/pipeline/addon/pipelines/route.js | 16 +- lib/pipeline/addon/pipelines/template.hbs | 34 +++-- lib/pipeline/addon/services/pipeline.js | 11 +- lib/pipeline/translations/en-us.yaml | 1 + .../components/containers-header/component.js | 2 - .../components/containers-header/template.hbs | 4 +- 9 files changed, 131 insertions(+), 92 deletions(-) diff --git a/lib/pipeline/addon/components/pipeline-jobs-table/template.hbs b/lib/pipeline/addon/components/pipeline-jobs-table/template.hbs index b8a1f4328..eaa3c7217 100644 --- a/lib/pipeline/addon/components/pipeline-jobs-table/template.hbs +++ b/lib/pipeline/addon/components/pipeline-jobs-table/template.hbs @@ -1,71 +1,75 @@ -{{#sortable-table - tableClassNames="double-rows" - bulkActions=bulkActions - body=filtered - sortBy=sortBy - stickyHeader=stickyHeader - fullRows=true - search=search - groupByKey=groupByKey - groupByRef=groupByRef - headers=headers as |sortable kind inst dt| - }} - {{#if (eq kind "row")}} - - {{#if filtered.length}} - - {{check-box nodeId=inst.id}} - - {{/if}} - - - {{#if inst.isActive}} - {{t 'pipelinesPage.active'}} - {{else}} - {{t 'pipelinesPage.inactive'}} - {{/if}} - - - - {{#link-to "pipeline" inst.id (query-params mode="review")}} - {{inst.name}} - {{/link-to}} - - -

{{inst.repository}}

-

{{inst.branchConditionLabel}} {{inst.branch}}

- - - {{#if inst.lastExecutionId}} - {{#tooltip-element style="100%;" inlineBlock=true type="tooltip-basic" tooltipTemplate="tooltip-static" model=(date-str inst.lastStarted) tagName="span" tooltipFor="tooltip-basic"}} -

#{{inst.lastRun}} {{inst.lastRunState}}

-

{{date-from-now inst.lastStarted}}

- {{/tooltip-element}} - {{else}} - N/A +{{#if filtered.length}} + {{#sortable-table + tableClassNames="double-rows" + bulkActions=bulkActions + body=filtered + sortBy=sortBy + stickyHeader=stickyHeader + fullRows=true + search=search + groupByKey=groupByKey + groupByRef=groupByRef + headers=headers as |sortable kind inst dt| + }} + {{#if (eq kind "row")}} + + {{#if filtered.length}} + + {{check-box nodeId=inst.id}} + {{/if}} - - - {{#if inst.nextStart}} - {{#tooltip-element style="100%;" inlineBlock=true type="tooltip-basic" tooltipTemplate="tooltip-static" model=(date-str inst.nextStart) tagName="span" tooltipFor="tooltip-basic"}} - {{date-from-now inst.nextStart}} - {{/tooltip-element}} - {{/if}} - {{#if inst.triggerWebhook}} -

{{t 'pipelinesPage.awaitingWebhook'}}

- {{/if}} - {{#unless (or inst.triggerWebhook inst.nextStart)}} - {{t 'pipelinesPage.triggerManually'}} - {{/unless}} - - - - {{action-menu model=inst showPrimary=true}} - - - {{else if (eq kind "nomatch")}} - {{t 'pipelinesPage.table.noMatch'}} - {{else if (eq kind "norows")}} - {{t 'pipelinesPage.table.noData'}} - {{/if}} -{{/sortable-table}} + + + {{#if inst.isActive}} + {{t 'pipelinesPage.active'}} + {{else}} + {{t 'pipelinesPage.inactive'}} + {{/if}} + + + + {{#link-to "pipeline" inst.id (query-params mode="review")}} + {{inst.name}} + {{/link-to}} + + +

{{inst.repository}}

+

{{inst.branchConditionLabel}} {{inst.branch}}

+ + + {{#if inst.lastExecutionId}} + {{#tooltip-element style="100%;" inlineBlock=true type="tooltip-basic" tooltipTemplate="tooltip-static" model=(date-str inst.lastStarted) tagName="span" tooltipFor="tooltip-basic"}} +

#{{inst.lastRun}} {{inst.lastRunState}}

+

{{date-from-now inst.lastStarted}}

+ {{/tooltip-element}} + {{else}} + N/A + {{/if}} + + + {{#if inst.nextStart}} + {{#tooltip-element style="100%;" inlineBlock=true type="tooltip-basic" tooltipTemplate="tooltip-static" model=(date-str inst.nextStart) tagName="span" tooltipFor="tooltip-basic"}} + {{date-from-now inst.nextStart}} + {{/tooltip-element}} + {{/if}} + {{#if inst.triggerWebhook}} +

{{t 'pipelinesPage.awaitingWebhook'}}

+ {{/if}} + {{#unless (or inst.triggerWebhook inst.nextStart)}} + {{t 'pipelinesPage.triggerManually'}} + {{/unless}} + + + + {{action-menu model=inst showPrimary=true}} + + + {{else if (eq kind "nomatch")}} + {{t 'pipelinesPage.table.noMatch'}} + {{else if (eq kind "norows")}} + {{t 'pipelinesPage.table.noData'}} + {{/if}} + {{/sortable-table}} +{{else}} + {{empty-table resource="container" newRoute="authenticated.project.pipeline.new-pipeline" newTranslationKey="pipelinesPage.add"}} +{{/if}} \ No newline at end of file diff --git a/lib/pipeline/addon/components/pipeline-steps/component.js b/lib/pipeline/addon/components/pipeline-steps/component.js index 468d3400e..72c8a0dba 100644 --- a/lib/pipeline/addon/components/pipeline-steps/component.js +++ b/lib/pipeline/addon/components/pipeline-steps/component.js @@ -13,7 +13,6 @@ export default Component.extend({ this._super(...arguments); setTimeout(()=>{ let route = this.get('route'); - debugger this.showStepAdd(); },0); }, diff --git a/lib/pipeline/addon/pipelines/controller.js b/lib/pipeline/addon/pipelines/controller.js index a439f31e0..96e95ac82 100644 --- a/lib/pipeline/addon/pipelines/controller.js +++ b/lib/pipeline/addon/pipelines/controller.js @@ -1,5 +1,15 @@ import Controller from '@ember/controller'; +import { inject as service } from '@ember/service'; +import { htmlSafe } from '@ember/string'; export default Controller.extend({ sortBy: 'Name', + router: service(), + linkToDeploy: function(){ + let projectModel = window.l('route:application').modelFor('authenticated.project'); + let clusterId = projectModel.project.clusterId; + let route = this.get('router').urlFor('authenticated.cluster.pipeline', clusterId); + // return htmlSafe(`Pipeline is not enabled, click here to enable Pipline`) + return route + }.property(), }); diff --git a/lib/pipeline/addon/pipelines/route.js b/lib/pipeline/addon/pipelines/route.js index 1e2396b5a..b13d548db 100644 --- a/lib/pipeline/addon/pipelines/route.js +++ b/lib/pipeline/addon/pipelines/route.js @@ -2,17 +2,31 @@ import { inject as service } from '@ember/service'; import Route from '@ember/routing/route'; import { on } from '@ember/object/evented'; import C from 'ui/utils/constants'; +import { hash } from 'rsvp'; export default Route.extend({ globalStore: service(), session: service(), + pipeline: service(), model: function() { var globalStore = this.get('globalStore'); let projectModel = window.l('route:application').modelFor('authenticated.project'); let projectId = projectModel.project.id; var model = globalStore.findAll('pipeline', { filter: { projectId }}); - return model + return this.get('pipeline').isReady(projectModel.project.clusterId).then((deployed)=>{ + if(!deployed){ + return { + deployed, + } + } + return model.then((pipelines)=>{ + return { + deployed, + pipelines + } + }) + }) }, setDefaultRoute: on('activate', function() { this.set(`session.${C.SESSION.CONTAINER_ROUTE}`,'authenticated.project.pipeline.pipelines'); diff --git a/lib/pipeline/addon/pipelines/template.hbs b/lib/pipeline/addon/pipelines/template.hbs index 13c7fe6dc..cd183c279 100644 --- a/lib/pipeline/addon/pipelines/template.hbs +++ b/lib/pipeline/addon/pipelines/template.hbs @@ -1,16 +1,26 @@ {{#containers-header tags=tags simpleMode=true showGroup=false}} - {{#link-to "new-pipeline" class="btn bg-primary btn-sm"}} - {{t 'pipelinesPage.add'}} - {{/link-to}} + {{#if model.deployed}} + {{!-- {{#link-to "pipelines.project.import" classNames="btn btn-sm bg-default mr-10"}}{{t 'pipelinesPage.import'}}{{/link-to}} --}} + + {{/if}} {{/containers-header}}
-
- {{pipeline-jobs-table - body=model - sortBy=sortBy - bulkActions=true - search=true - paging=true - }} -
+{{#if model.deployed}} +
+ {{pipeline-jobs-table + body=model.pipelines + sortBy=sortBy + bulkActions=true + search=true + paging=true + }} +
+{{else}} + {{banner-message color='bg-warning mb-0 mt-10' message=(t 'pipelinesPage.notDeployed' route=linkToDeploy htmlSafe=true)}} +{{/if}} diff --git a/lib/pipeline/addon/services/pipeline.js b/lib/pipeline/addon/services/pipeline.js index 36d9f47ad..90c3b5632 100644 --- a/lib/pipeline/addon/services/pipeline.js +++ b/lib/pipeline/addon/services/pipeline.js @@ -6,11 +6,16 @@ export default Service.extend({ globalStore: service(), scope: service(), deploy: false, - isReady() { - let clusterId = this.get('scope').currentCluster.id; - this.get('globalStore').find('clusterPipeline', `${clusterId}:${clusterId}`) + isReady(clusterId) { + let requestClusterId = clusterId||this.get('scope').currentCluster.id; + this.set('deploy', false); + return this.get('globalStore').find('clusterPipeline', `${requestClusterId}:${requestClusterId}`) .then((res)=>{ this.set('deploy', res.deploy); + return res.deploy; + }).catch(()=>{ + this.set('deploy', false); + return false; }) }, }); diff --git a/lib/pipeline/translations/en-us.yaml b/lib/pipeline/translations/en-us.yaml index be6931d92..c2faecfa4 100644 --- a/lib/pipeline/translations/en-us.yaml +++ b/lib/pipeline/translations/en-us.yaml @@ -41,6 +41,7 @@ pipelinesPage: nextRun: NextRun awaitingWebhook: Awaiting Webhook triggerManually: Trigger Manually + notDeployed: Pipeline is not enabled, click here to enable Pipline pipelinesSetting: gitAuthentication: Git Authentication authenticateWithGit: Authenticate with git repository diff --git a/lib/shared/addon/components/containers-header/component.js b/lib/shared/addon/components/containers-header/component.js index 85a458430..ea4555610 100644 --- a/lib/shared/addon/components/containers-header/component.js +++ b/lib/shared/addon/components/containers-header/component.js @@ -14,12 +14,10 @@ export default Component.extend({ showGroup: true, tagName: '', - pipelineDeploy: alias('pipeline.deploy'), allStacks: null, init() { this._super(...arguments); this.set('allStacks', this.get('store').all('stack')); - this.get('pipeline').isReady(); }, actions: { diff --git a/lib/shared/addon/components/containers-header/template.hbs b/lib/shared/addon/components/containers-header/template.hbs index fa535f135..1399f2e63 100644 --- a/lib/shared/addon/components/containers-header/template.hbs +++ b/lib/shared/addon/components/containers-header/template.hbs @@ -10,9 +10,7 @@
  • {{#link-to-external "authenticated.project.dns.index" scope.currentProject.id}}{{t 'nav.containers.dns'}}{{/link-to-external}}
  • {{/if}}
  • {{#link-to-external "volumes.index" scope.currentProject.id}}{{t 'nav.containers.volumes'}}{{/link-to-external}}
  • - {{#if pipelineDeploy}} -
  • {{#link-to-external "authenticated.project.pipeline.pipelines" scope.currentProject.id}}Pipeline{{/link-to-external}}
  • - {{/if}} +
  • {{#link-to-external "authenticated.project.pipeline.pipelines" scope.currentProject.id}}Pipeline{{/link-to-external}}
  • From 4882f8d5def643b8974f97d9ffad09480320d1ed Mon Sep 17 00:00:00 2001 From: Aaron Date: Thu, 1 Mar 2018 14:54:12 +0800 Subject: [PATCH 3/3] Fix bug https://github.com/rancher/rancher/issues/11733 --- app/app.js | 1 + lib/pipeline/addon/engine.js | 1 + lib/pipeline/addon/settings/route.js | 3 +-- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/app.js b/app/app.js index 27287206a..8694829f4 100644 --- a/app/app.js +++ b/app/app.js @@ -128,6 +128,7 @@ const App = Application.extend({ failWhale: 'failWhale', authenticated: 'authenticated', 'authenticated.cluster': 'authenticated.cluster', + 'authenticated.cluster.index': 'authenticated.cluster.index', 'authenticated.cluster.projects': 'authenticated.cluster.projects', 'authenticated.project': 'authenticated.project', 'authenticated.prefs': 'authenticated.prefs', diff --git a/lib/pipeline/addon/engine.js b/lib/pipeline/addon/engine.js index 813485db1..2fd29c674 100644 --- a/lib/pipeline/addon/engine.js +++ b/lib/pipeline/addon/engine.js @@ -28,6 +28,7 @@ const Eng = Engine.extend({ 'failWhale', 'authenticated', 'authenticated.cluster', + 'authenticated.cluster.index', 'authenticated.cluster.projects', 'authenticated.project', 'authenticated.prefs', diff --git a/lib/pipeline/addon/settings/route.js b/lib/pipeline/addon/settings/route.js index 4a74a4295..b23f887cf 100644 --- a/lib/pipeline/addon/settings/route.js +++ b/lib/pipeline/addon/settings/route.js @@ -9,11 +9,10 @@ export default Route.extend({ const cluster = window.l('route:application').modelFor('authenticated.cluster') const cluster_id = cluster.id; if ( get(cluster,'state') !== 'active' ) { - this.transitionTo('authenticated.cluster.index'); + this.transitionToExternal('authenticated.cluster.index'); } let model = globalStore.find('clusterPipeline',`${cluster_id}:${cluster_id}`,{forceReload: true}); - // return model return model } });