-
Notifications
You must be signed in to change notification settings - Fork 2k
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
ui: job templates manager view #15815
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import Controller from '@ember/controller'; | ||
import { tracked } from '@glimmer/tracking'; | ||
|
||
export default class JobsRunTemplatesController extends Controller { | ||
@tracked selectedTemplate = null; | ||
|
||
columns = ['name', 'namespace', 'description'].map((column) => { | ||
return { | ||
key: column, | ||
label: `${column.charAt(0).toUpperCase()}${column.substring(1)}`, | ||
}; | ||
}); | ||
|
||
formatTemplateLabel(path) { | ||
return path.split('nomad/job-templates/')[1]; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { helper } from '@ember/component/helper'; | ||
|
||
function invokeFn([scope, fn]) { | ||
let args = arguments[0].slice(2); | ||
return fn.apply(scope, args); | ||
} | ||
|
||
export default helper(invokeFn); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import Route from '@ember/routing/route'; | ||
import { inject as service } from '@ember/service'; | ||
|
||
export default class RunTemplatesRoute extends Route { | ||
@service can; | ||
@service router; | ||
@service store; | ||
|
||
beforeModel() { | ||
const hasPermissions = this.can.can('write variable', null, { | ||
namespace: '*', | ||
path: '*', | ||
}); | ||
|
||
if (!hasPermissions) { | ||
this.router.transitionTo('jobs'); | ||
} | ||
} | ||
|
||
async model() { | ||
const jobTemplateVariables = await this.store.query('variable', { | ||
prefix: 'nomad/job-templates', | ||
namespace: '*', | ||
}); | ||
const recordsToQuery = jobTemplateVariables.map((template) => | ||
this.store.findRecord('variable', template.id) | ||
); | ||
|
||
return Promise.all(recordsToQuery); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{{page-title "Manage templates"}} | ||
<section class="section"> | ||
<header class="run-job-header"> | ||
<h1 class="title is-3">Choose from a template</h1> | ||
<p>A plan will be requested before the job is submitted. You can pick a template or write your own job spec.</p> | ||
</header> | ||
{{#if (eq this.model.length 0)}} | ||
<h3 data-test-empty-templates-list-headline class="empty-message-headline"> | ||
You have no templates to choose from. Would you like to <Hds::Link::Inline @route="jobs.run.templates.new" data-test-create-inline>create</Hds::Link::Inline> one? | ||
</h3> | ||
<Hds::Button class="button-group" @text="Back to editor" @route="jobs.run" @icon="arrow-left" data-test-cancel /> | ||
{{else}} | ||
<main class="radio-group" data-test-template-list> | ||
<Hds::Table @model={{this.model}} @columns={{this.columns}}> | ||
<:body as |B|> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we change There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't a template. Rather it's a contextual components that is yielding out Changing this to Your call. I'm open to suggestions! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This makes a ton of sense. Thanks for clearing it up for me! |
||
<B.Tr> | ||
<B.Td> | ||
<LinkTo @route="jobs.run.templates.template" @model={{concat B.data.path "@" B.data.namespace}} data-test-edit-template={{B.data.path}}> | ||
{{invoke-fn this this.formatTemplateLabel B.data.path}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice and reminds me of svelte attributes! |
||
</LinkTo> | ||
</B.Td> | ||
<B.Td>{{B.data.namespace}}</B.Td> | ||
<B.Td>{{B.data.items.description}}</B.Td> | ||
</B.Tr> | ||
</:body> | ||
</Hds::Table> | ||
</main> | ||
<footer class="buttonset"> | ||
<Hds::ButtonSet class="button-group"> | ||
<Hds::Button @icon="arrow-left" @text="Done" @route="jobs.run.templates" data-test-done /> | ||
</Hds::ButtonSet> | ||
</footer> | ||
{{/if}} | ||
</section> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seeing all variables here in the Mirage mocks:
- is
prefix
the correct property, or ispath
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: also seeing more variables than expected on the non-management list page (templates index)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In
mirage
mocks you will see all the variables here because we're using the/vars
endpoint which does not have any logic for accounting for theprefix
. Touching ourMirage
setup would spill over into thevariables
view so I'm not going to touch it until after all the work is complete and we don't have more feature requests or updates on the feature.Its annoying but we'll have to rely on a Nomad server here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood! Let's definitely tackle this at some point in the process, if not in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey! Get back to being on vacation and recharge your batteries!!!