Skip to content

Commit 00cdf5d

Browse files
Merge pull request #611 from getodk/projects-empty-message
Update message shown when there are no projects
2 parents cb17057 + 936f78d commit 00cdf5d

File tree

3 files changed

+52
-9
lines changed

3 files changed

+52
-9
lines changed

src/components/project/list.vue

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,17 @@ except according to the terms contained in the LICENSE file.
2828
:max-forms="maxForms"/>
2929
</div>
3030
<loading :state="$store.getters.initiallyLoading(['projects'])"/>
31-
<p v-if="projects != null && projects.length === 0"
31+
<p v-if="projects != null && activeProjects.length === 0"
3232
class="empty-table-message">
33-
{{ $t('emptyTable') }}
33+
<template v-if="currentUser.can('project.create')">
34+
{{ $t('emptyTable.canCreate') }}<sentence-separator/>
35+
<i18n-t keypath="moreInfo.clickHere.full">
36+
<template #clickHere>
37+
<doc-link to="central-projects/">{{ $t('moreInfo.clickHere.clickHere') }}</doc-link>
38+
</template>
39+
</i18n-t>
40+
</template>
41+
<template v-else>{{ $t('emptyTable.cannotCreate') }}</template>
3442
</p>
3543
</template>
3644
</page-section>
@@ -56,11 +64,13 @@ except according to the terms contained in the LICENSE file.
5664
<script>
5765
import { sum } from 'ramda';
5866
67+
import DocLink from '../doc-link.vue';
5968
import Loading from '../loading.vue';
6069
import PageSection from '../page/section.vue';
6170
import ProjectNew from './new.vue';
6271
import ProjectHomeBlock from './home-block.vue';
6372
import ProjectSort from './sort.vue';
73+
import SentenceSeparator from '../sentence-separator.vue';
6474
6575
import modal from '../../mixins/modal';
6676
import routes from '../../mixins/routes';
@@ -70,11 +80,13 @@ import sortFunctions from '../../util/sort';
7080
export default {
7181
name: 'ProjectList',
7282
components: {
83+
DocLink,
7384
Loading,
7485
PageSection,
7586
ProjectNew,
7687
ProjectHomeBlock,
77-
ProjectSort
88+
ProjectSort,
89+
SentenceSeparator
7890
},
7991
mixins: [modal(), routes()],
8092
inject: ['alert'],
@@ -166,7 +178,10 @@ export default {
166178
// This is the text of a button that is used to create a new Project.
167179
"create": "New"
168180
},
169-
"emptyTable": "There are no Projects for you to see.",
181+
"emptyTable": {
182+
"canCreate": "To get started, create a Project. Projects help you organize your data by grouping related Forms and Users.",
183+
"cannotCreate": "There are no Projects to show. If you expect to see Projects here, talk to the person who gave you this account. They may need to assign a Project Role for Projects you’re supposed to see."
184+
},
170185
"alert": {
171186
"create": "Your new Project has been successfully created."
172187
}

test/components/project/list.spec.js

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,30 @@ const createProjectsWithForms = (projects, forms) => {
3131
};
3232

3333
describe('ProjectList', () => {
34-
beforeEach(mockLogin);
34+
describe('no projects', () => {
35+
it('shows the correct message if the user can project.create', () => {
36+
mockLogin();
37+
const message = mountComponent().get('.empty-table-message');
38+
message.should.be.visible();
39+
message.text().should.startWith('To get started, create a Project.');
40+
});
41+
42+
it('shows the correct message if the user cannot project.create', () => {
43+
mockLogin({ role: 'none' });
44+
const message = mountComponent().get('.empty-table-message');
45+
message.should.be.visible();
46+
message.text().should.startWith('There are no Projects to show.');
47+
});
3548

36-
it('shows a message if there are no projects', () => {
37-
// TODO: show something fancier when there are no projects and update test
38-
mountComponent().get('.empty-table-message').should.be.visible();
49+
it('shows the message if there are only archived projects', () => {
50+
mockLogin();
51+
testData.extendedProjects.createPast(1, { archived: true });
52+
mountComponent().get('.empty-table-message').should.be.visible();
53+
});
3954
});
4055

4156
it('renders a row for each project', () => {
57+
mockLogin();
4258
createProjectsWithForms(
4359
[{ name: 'Alpha Project' }, { name: 'Bravo Project' }],
4460
[[{}, {}], [{}, {}, {}, {}, {}]]
@@ -49,17 +65,20 @@ describe('ProjectList', () => {
4965
});
5066

5167
it('shows archived projects at the bottom of the page', () => {
68+
mockLogin();
5269
testData.extendedProjects.createPast(2);
5370
testData.extendedProjects.createPast(3, { archived: true });
5471
mountComponent().findAll('#project-list-archived .project-title').length.should.equal(3);
5572
});
5673

5774
it('does not show archived header if no archived projects exist', () => {
75+
mockLogin();
5876
mountComponent().find('#project-list-archived').exists().should.be.false();
5977
});
6078

6179
describe('sorting', () => {
6280
beforeEach(() => {
81+
mockLogin();
6382
createProjectsWithForms(
6483
[
6584
{ name: 'A', lastSubmission: ago({ days: 15 }).toISO() },
@@ -125,6 +144,8 @@ describe('ProjectList', () => {
125144
});
126145

127146
describe('sorting with ties', () => {
147+
beforeEach(mockLogin);
148+
128149
it('sorts projects alphabetically when last submission is null', async () => {
129150
createProjectsWithForms(
130151
[
@@ -158,6 +179,8 @@ describe('ProjectList', () => {
158179
});
159180

160181
describe('dynamic numbers of forms', () => {
182+
beforeEach(mockLogin);
183+
161184
it('renders correctly when there is one project with many forms', () => {
162185
createProjectsWithForms(
163186
[{ name: 'Project 1' }, { name: 'Project 2' }],

transifex/strings_en.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2881,7 +2881,12 @@
28812881
}
28822882
},
28832883
"emptyTable": {
2884-
"string": "There are no Projects for you to see."
2884+
"canCreate": {
2885+
"string": "To get started, create a Project. Projects help you organize your data by grouping related Forms and Users."
2886+
},
2887+
"cannotCreate": {
2888+
"string": "There are no Projects to show. If you expect to see Projects here, talk to the person who gave you this account. They may need to assign a Project Role for Projects you’re supposed to see."
2889+
}
28852890
},
28862891
"alert": {
28872892
"create": {

0 commit comments

Comments
 (0)