Skip to content
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

feat(SFINT-4388) no results text when no user actions #106

Merged
merged 7 commits into from
Feb 4, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/components/UserActions/Strings.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { Translation, Language } from '../../utils/translation';

Translation.register(Language.English, {
UserActions_no_actions: 'No actions available for this user',
UserActions: 'User Actions',
UserActions_no_actions_title: 'No actions available for this user',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
UserActions_no_actions_title: 'No actions available for this user',
UserActions_no_actions_title: 'No actions available for this user.',

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should've specified :D the . is added but elsewhere hehe thanks for confirming I need a . though!

UserActions_no_actions_causes_title: 'Potential causes',
UserActions_no_actions_cause_not_enabled: 'User actions are not enabled for your organization',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
UserActions_no_actions_cause_not_enabled: 'User actions are not enabled for your organization',
UserActions_no_actions_cause_not_enabled: 'User actions are not enabled for your organization.',

UserActions_no_actions_cause_not_associated: 'There are no user actions associated with the user',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
UserActions_no_actions_cause_not_associated: 'There are no user actions associated with the user',
UserActions_no_actions_cause_not_associated: 'There are no user actions associated with the user.',

UserActions_no_actions_cause_case_too_old: 'The case is too old to detect related actions',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
UserActions_no_actions_cause_case_too_old: 'The case is too old to detect related actions',
UserActions_no_actions_cause_case_too_old: 'The case is too old to detect related actions.',

UserActions_no_actions_contact_admin: 'Contact your administrator for help',
Comment on lines +4 to +10
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@acarpentier01 These are the strings. you can check on the screenshots where they are used.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
UserActions_no_actions_contact_admin: 'Contact your administrator for help',
UserActions_no_actions_contact_admin: 'Contact your administrator for help.',

UserActions_enable_prompt: 'The User Action feature is not activated for your organization.\nTo activate it, contact Coveo Support.',

QueryList_more: 'Show More',
Expand Down
20 changes: 18 additions & 2 deletions src/components/UserActions/UserActions.scss
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,24 @@ $clickable-blue: #004990;
}

.coveo-no-actions {
padding: 3em;
text-align: center;
padding: 1em;
border: 1px solid $heather;
border-radius: 2px;
background-color: $background-color-grey;
height: 15rem;
text-align: left;

.coveo-user-actions-title {
font-size: 1.2em;
font-weight: bold;
text-align: left;
width: auto;
margin-bottom: 1em;
}

.coveo-no-actions-causes {
margin: 0.5em 0;
}
}

.coveo-enable-prompt {
Expand Down
34 changes: 25 additions & 9 deletions src/components/UserActions/UserActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ export class UserActions extends Component {
this.element.dispatchEvent(new CustomEvent(UserActions.Events.Show));
this.bindings.usageAnalytics.logCustomEvent(UserActionEvents.open, {}, this.element);
this.root.classList.add(UserActions.USER_ACTION_OPENED);

try {
const userActions = await (get(this.root, UserProfileModel) as UserProfileModel).getActions(this.options.userId);
if (userActions.length > 0) {
Expand Down Expand Up @@ -316,21 +315,38 @@ export class UserActions extends Component {
}

private renderNoActions() {
const element = document.createElement('div');
element.classList.add('coveo-no-actions');
element.innerText = l(`${UserActions.ID}_no_actions`);
const messageContainer = document.createElement('div');
messageContainer.classList.add('coveo-no-actions');
messageContainer.innerHTML = `
<div class="coveo-user-actions-title">${l(UserActions.ID)}</div>
<div>${l(UserActions.ID + '_no_actions_title')}.</div>
<br/>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of adding <br /> tags like this, you could add a class like coveo-no-actions-section to add the top margin you want.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote a comment but it disappeared :(

Basically the thing we are displaying I consider more as a 1 paragraph than multiple HTML elements. What do you think? It felt more like a line break, than a margin between elements.

<div>${l(UserActions.ID + '_no_actions_causes_title')}
<ul class="coveo-no-actions-causes">
<li>${l(UserActions.ID + '_no_actions_cause_not_associated')}</li>
<li>${l(UserActions.ID + '_no_actions_cause_case_too_old')}</li>
</ul>
</div>
<br/>
<div>${l(UserActions.ID + '_no_actions_contact_admin')}.</div>
`;

this.element.innerHTML = '';
this.element.appendChild(element);
this.element.appendChild(messageContainer);
}

private renderEnablePrompt() {
const element = document.createElement('div');
element.classList.add('coveo-enable-prompt');
element.innerText = l(`${UserActions.ID}_enable_prompt`);
const messageContainer = document.createElement('div');
messageContainer.classList.add('coveo-no-actions');
messageContainer.innerHTML = `
<div class="coveo-user-actions-title">${l(UserActions.ID)}</div>
<div>${l(UserActions.ID + '_no_actions_cause_not_enabled')}.</div>
<br/>
<div>${l(UserActions.ID + '_no_actions_contact_admin')}.</div>
`;

this.element.innerHTML = '';
this.element.appendChild(element);
this.element.appendChild(messageContainer);
}

private showViewedByCustomer() {
Expand Down
17 changes: 11 additions & 6 deletions tests/components/UserActions/UserActions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,9 @@ describe('UserActions', () => {
);
await mock.cmp.show();

expect(mock.cmp.element.querySelector<HTMLElement>('.coveo-enable-prompt')).not.toBeNull();
expect(mock.cmp.element.querySelector<HTMLElement>('.coveo-enable-prompt').innerText).toBe(
l(`${UserActions.ID}_enable_prompt`).replace('\n', '')
expect(mock.cmp.element.querySelector<HTMLElement>('.coveo-no-actions')).not.toBeNull();
expect(mock.cmp.element.querySelector<HTMLElement>('.coveo-no-actions').innerText).toContain(
l(`${UserActions.ID}_no_actions_cause_not_enabled`)
);
});

Expand All @@ -294,8 +294,12 @@ describe('UserActions', () => {
);
await mock.cmp.show();

expect(mock.cmp.element.querySelector<HTMLElement>('.coveo-no-actions')).not.toBeNull();
expect(mock.cmp.element.querySelector<HTMLElement>('.coveo-no-actions').innerText).toBe(l(`${UserActions.ID}_no_actions`));
const noActions = mock.cmp.element.querySelector<HTMLElement>('.coveo-no-actions');

expect(noActions).not.toBeNull();
expect(noActions.innerText).toContain(l(`${UserActions.ID}_no_actions_title`));
erocheleau marked this conversation as resolved.
Show resolved Hide resolved
expect(noActions.innerText).toContain(l(`${UserActions.ID}_no_actions_cause_not_associated`));
expect(noActions.innerText).toContain(l(`${UserActions.ID}_no_actions_cause_case_too_old`));
});

it('should show a message when actions cannot be gathered', async () => {
Expand All @@ -310,7 +314,8 @@ describe('UserActions', () => {
);
await mock.cmp.show();

expect(mock.cmp.element.querySelector<HTMLElement>('.coveo-no-actions').innerText).toBe(l(`${UserActions.ID}_no_actions`));
const messageEl = mock.cmp.element.querySelector<HTMLElement>('.coveo-no-actions');
expect(messageEl.innerText).toContain(l(`${UserActions.ID}_no_actions_title`));
});

describe('when the accordion header is clicked', () => {
Expand Down