Skip to content

Commit

Permalink
task tabs.js file seperated
Browse files Browse the repository at this point in the history
  • Loading branch information
Pratiyushkumar committed Nov 3, 2023
1 parent fbb29a4 commit 367a304
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 46 deletions.
59 changes: 14 additions & 45 deletions app/components/task-tabs.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,20 @@
class='task-tabs__dropdown-container
{{if @showTasks "task-tabs__dropdown-active"}}'
>
{{#each @taskStatusList as |status|}}
{{#if @dev}}

{{#if
(and
(not-eq status.key 'VERIFIED')
(not-eq status.key 'RELEASED')
(not-eq status.key 'REGRESSION_CHECK')
(not-eq status.key 'SANITY_CHECK')
(not-eq status.key 'APPROVED')
(not-eq status.key 'SMOKE_TESTING')
(not-eq status.key 'NEEDS_REVIEW')
)
}}
<button
data-test-task-tabs-button
href='#'
class='task-tabs__dropdown-container__button
{{if
(eq @userSelectedTaskText status.displayLabel)
"task-tabs__dropdown-container__button-active"
}}'
{{on 'click' (fn @changeUserSelectedTask status)}}
type='button'
>
{{status.displayLabel}}
</button>
{{/if}}

{{else}}
<button
data-test-task-tabs-button
href='#'
class='task-tabs__dropdown-container__button
{{if
(eq @userSelectedTaskText status.displayLabel)
"task-tabs__dropdown-container__button-active"
}}'
{{on 'click' (fn @changeUserSelectedTask status)}}
type='button'
>
{{status.displayLabel}}
</button>
{{/if}}

{{#each this.removedTaskTabs as |status|}}
<button
data-test-task-tabs-button
href='#'
class='task-tabs__dropdown-container__button
{{if
(eq @userSelectedTaskText status.displayLabel)
"task-tabs__dropdown-container__button-active"
}}'
{{on 'click' (fn @changeUserSelectedTask status)}}
type='button'
>
{{status.displayLabel}}
</button>
{{/each}}
</div>
{{#unless @showTasks}}
Expand Down
28 changes: 28 additions & 0 deletions app/components/task-tabs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import Component from '@glimmer/component';
import { TASK_KEYS } from 'website-my/constants/tasks';

export default class TaskTabsComponent extends Component {
TASK_KEYS = TASK_KEYS;
availabletaskTabsList = this.args.taskStatusList;

get removedTaskTabs() {
const statusToDisplay = this.availabletaskTabsList.filter((taskStatus) => {
if (this.args.dev === true) {
if (
taskStatus.key !== TASK_KEYS.VERIFIED &&
taskStatus.key !== TASK_KEYS.RELEASED &&
taskStatus.key !== TASK_KEYS.APPROVED &&
taskStatus.key !== TASK_KEYS.COMPLETED &&
taskStatus.key !== TASK_KEYS.NEEDS_REVIEW
) {
return true;
} else {
return false;
}
} else {
return taskStatus;
}
});
return statusToDisplay;
}
}
4 changes: 3 additions & 1 deletion tests/integration/components/task-tabs-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ module('Integration | Component | task-tabs', function (hooks) {
userSelectedTaskText: DEFAULT_TASK_TYPE.displayLabel,
showTasks: false,
toggleTasks: () => {},
dev: true,
});

await render(hbs` <TaskTabs
@taskStatusList={{this.tabsTaskStatusList}}
@showDropDown={{this.showDropDown}}
Expand All @@ -61,6 +61,7 @@ module('Integration | Component | task-tabs', function (hooks) {
@userSelectedTaskText={{this.userSelectedTaskText}}
@showTasks={{this.showTasks}}
@toggleTasks={{this.toggleTasks}}
@dev={{this.dev}}
/>`);

assert
Expand All @@ -77,6 +78,7 @@ module('Integration | Component | task-tabs', function (hooks) {
@userSelectedTaskText={{this.userSelectedTaskText}}
@showTasks={{this.showTasks}}
@toggleTasks={{this.toggleTasks}}
@dev={{this.dev}}
/>`);

assert
Expand Down

0 comments on commit 367a304

Please sign in to comment.