mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-04-01 02:41:39 -05:00
Changed "index" collection name to "latest"
https://github.com/TryGhost/Arch/issues/25 - This naming matches how the collection will be visible in the cards and how it's marketed. Naming it "index" even for internal purposes will get confusing.
This commit is contained in:
parent
acbe3a250e
commit
ed91412cd5
4 changed files with 21 additions and 21 deletions
|
@ -49,7 +49,7 @@ export class Collection {
|
|||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
get deletable() {
|
||||
return this.slug !== 'index' && this.slug !== 'featured';
|
||||
return this.slug !== 'latest' && this.slug !== 'featured';
|
||||
}
|
||||
private _deleted: boolean = false;
|
||||
|
||||
|
@ -69,7 +69,7 @@ export class Collection {
|
|||
}
|
||||
|
||||
public async edit(data: Partial<Collection>, uniqueChecker: UniqueChecker) {
|
||||
if (this.type === 'automatic' && this.slug !== 'index' && (data.filter === null || data.filter === '')) {
|
||||
if (this.type === 'automatic' && this.slug !== 'latest' && (data.filter === null || data.filter === '')) {
|
||||
throw new ValidationError({
|
||||
message: tpl(messages.invalidFilterProvided.message),
|
||||
context: tpl(messages.invalidFilterProvided.context)
|
||||
|
@ -201,7 +201,7 @@ export class Collection {
|
|||
});
|
||||
}
|
||||
|
||||
if (data.type === 'automatic' && (data.slug !== 'index') && !data.filter) {
|
||||
if (data.type === 'automatic' && (data.slug !== 'latest') && !data.filter) {
|
||||
// @NOTE: add filter validation here
|
||||
throw new ValidationError({
|
||||
message: tpl(messages.invalidFilterProvided.message),
|
||||
|
|
|
@ -210,20 +210,20 @@ describe('Collection', function () {
|
|||
});
|
||||
});
|
||||
|
||||
it('Does not throw when collection filter is empty for automatic "index" collection', async function (){
|
||||
it('Does not throw when collection filter is empty for automatic "latest" collection', async function (){
|
||||
const collection = await Collection.create({
|
||||
title: 'Index',
|
||||
slug: 'index',
|
||||
title: 'Latest',
|
||||
slug: 'latest',
|
||||
type: 'automatic',
|
||||
filter: ''
|
||||
});
|
||||
|
||||
const editedCollection = await collection.edit({
|
||||
title: 'Edited index',
|
||||
title: 'Edited latest',
|
||||
filter: ''
|
||||
}, uniqueChecker);
|
||||
|
||||
assert.equal(editedCollection.title, 'Edited index');
|
||||
assert.equal(editedCollection.title, 'Edited latest');
|
||||
assert.equal(editedCollection.filter, '');
|
||||
});
|
||||
});
|
||||
|
@ -303,10 +303,10 @@ describe('Collection', function () {
|
|||
assert.equal(collection.posts.length, 0);
|
||||
});
|
||||
|
||||
it('Cannot set index collection to deleted', async function () {
|
||||
it('Cannot set "latest" collection to deleted', async function () {
|
||||
const collection = await Collection.create({
|
||||
title: 'Testing adding posts',
|
||||
slug: 'index'
|
||||
slug: 'latest'
|
||||
});
|
||||
|
||||
assert.equal(collection.deleted, false);
|
||||
|
|
|
@ -6,19 +6,19 @@ module.exports = createTransactionalMigration(
|
|||
async function up(knex) {
|
||||
logging.info('Creating built in collections');
|
||||
|
||||
const existingIndexCollection = await knex('collections')
|
||||
const existingLatestCollection = await knex('collections')
|
||||
.where({
|
||||
slug: 'index'
|
||||
slug: 'latest'
|
||||
})
|
||||
.first();
|
||||
|
||||
if (existingIndexCollection) {
|
||||
logging.warn('Index collection already exists, skipping');
|
||||
if (existingLatestCollection) {
|
||||
logging.warn('Latest collection already exists, skipping');
|
||||
} else {
|
||||
await knex('collections').insert({
|
||||
id: (new ObjectID()).toHexString(),
|
||||
name: 'Index',
|
||||
slug: 'index',
|
||||
title: 'Latest',
|
||||
slug: 'latest',
|
||||
description: 'Collection with all posts',
|
||||
type: 'automatic',
|
||||
filter: '',
|
||||
|
@ -33,11 +33,11 @@ module.exports = createTransactionalMigration(
|
|||
.first();
|
||||
|
||||
if (existingFeaturedCollection) {
|
||||
logging.warn('Index collection already exists, skipping');
|
||||
logging.warn('Featured collection already exists, skipping');
|
||||
} else {
|
||||
await knex('collections').insert({
|
||||
id: (new ObjectID()).toHexString(),
|
||||
name: 'Featured',
|
||||
title: 'Featured',
|
||||
slug: 'featured',
|
||||
description: 'Collection of featured posts',
|
||||
type: 'automatic',
|
||||
|
@ -50,7 +50,7 @@ module.exports = createTransactionalMigration(
|
|||
logging.info('Deleting built in collections');
|
||||
|
||||
await knex('collections').where({
|
||||
slug: 'index'
|
||||
slug: 'latest'
|
||||
}).del();
|
||||
|
||||
await knex('collections').where({
|
|
@ -4,8 +4,8 @@
|
|||
"name": "Collection",
|
||||
"entries": [
|
||||
{
|
||||
"title": "Index",
|
||||
"slug": "index",
|
||||
"title": "Latest",
|
||||
"slug": "latest",
|
||||
"description": "Collection with all posts",
|
||||
"type": "automatic",
|
||||
"filter": ""
|
||||
|
|
Loading…
Add table
Reference in a new issue