Skip to content

Commit

Permalink
chore: update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ChaiWithJai committed May 11, 2023
1 parent 3646f9f commit 9b1870f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
18 changes: 3 additions & 15 deletions ui/app/components/job-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ export default class JobEditor extends Component {
return ['new', 'edit'].includes(this.args.context);
}

/**
* Set the definition on the Job model.
*/
@action
setDefinitionOnModel() {
this.args.job.set('_newDefinition', this.definition);
Expand All @@ -79,17 +76,14 @@ export default class JobEditor extends Component {
/**
* Determine the current stage of the component based on the plan output and editing state.
*
* @returns {string} The current stage, either 'review', 'edit', or 'read'.
* @returns {"review"|"edit"|"read"} The current stage, either 'review', 'edit', or 'read'.
*/
get stage() {
if (this.planOutput) return 'review';
if (this.isEditing) return 'edit';
else return 'read';
}

/**
* A local storage property that determines whether the plan message should be shown.
*/
@localStorageProperty('nomadMessageJobPlan', true) shouldShowPlanMessage;

@action
Expand Down Expand Up @@ -150,7 +144,7 @@ export default class JobEditor extends Component {
* Handle errors, setting the error object and scrolling to the error message.
*
* @param {Error} err - The error object.
* @param {string} type - The type of error (e.g., 'parse', 'plan', 'run').
* @param {"parse"|"plan"|"run"} type - The type of error (e.g., 'parse', 'plan', 'run').
* @param {string} actionMsg - A message describing the action that caused the error.
*/
onError(err, type, actionMsg) {
Expand All @@ -159,18 +153,12 @@ export default class JobEditor extends Component {
this.scrollToError();
}

/**
* Reset the planOutput and error properties to their initial state.
*/
@action
reset() {
this.planOutput = null;
this.error = null;
}

/**
* Scroll to the top of the page if not in a test environment.
*/
scrollToError() {
if (!this.config.get('isTest')) {
window.scrollTo(0, 0);
Expand All @@ -182,7 +170,7 @@ export default class JobEditor extends Component {
*
* @param {string} value - The new value for the job's definition or definition variables.
* @param {_codemirror} _codemirror - The CodeMirror instance (not used in this action).
* @param {string} [type='job'] - The type of code being updated ('job' or 'hclVariables').
* @param {"hclVariables"|"job"} [type='job'] - The type of code being updated ('job' or 'hclVariables').
*/
@action
updateCode(value, _codemirror, type = 'job') {
Expand Down
4 changes: 2 additions & 2 deletions ui/app/controllers/jobs/job/definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class DefinitionController extends Controller.extend(

/**
* Get the context of the controller based on the editing state.
* @returns {string} The context, either 'edit' or 'read'.
* @returns {"edit"|"read"} The context, either 'edit' or 'read'.
*/
get context() {
return this.isEditing ? 'edit' : 'read';
Expand All @@ -52,7 +52,7 @@ export default class DefinitionController extends Controller.extend(

/**
* Update the view based on the selected view.
* @param {string} selectedView - The selected view, either 'job-spec' or 'full-definition'.
* @param {"job-spec" | "full-definition"} selectedView - The selected view, either 'job-spec' or 'full-definition'.
*/
@action
selectView(selectedView) {
Expand Down

0 comments on commit 9b1870f

Please sign in to comment.