Skip to content

Commit

Permalink
Merge branch 'main' into fix/timeseries
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwin-pc authored Sep 22, 2022
2 parents 17b6ee0 + 08d0504 commit ddbc454
Show file tree
Hide file tree
Showing 18 changed files with 317 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_and_test_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ jobs:
working-directory: ./artifacts
strategy:
matrix:
version: [ osd-2.0.0, osd-2.1.0, osd-2.2.0 ]
version: [ osd-2.0.0, osd-2.1.0, osd-2.2.0, osd-2.3.0 ]
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion bwctest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

set -e

DEFAULT_VERSIONS="osd-2.0.0,osd-2.1.0,osd-2.2.0"
DEFAULT_VERSIONS="osd-2.0.0,osd-2.1.0,osd-2.2.0,osd-2.3.0"

function usage() {
echo ""
Expand Down
Binary file added cypress/test-data/with-security/osd-2.3.0.tar.gz
Binary file not shown.
Binary file not shown.
6 changes: 4 additions & 2 deletions src/core/public/saved_objects/saved_objects_client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ import { SimpleSavedObject } from './simple_saved_object';
import { httpServiceMock } from '../http/http_service.mock';

describe('SavedObjectsClient', () => {
const updatedAt = new Date().toISOString();
const doc = {
id: 'AVwSwFxtcMV38qjDZoQg',
type: 'config',
attributes: { title: 'Example title' },
version: 'foo',
updated_at: updatedAt,
};

const http = httpServiceMock.createStartContract();
Expand Down Expand Up @@ -356,7 +358,7 @@ describe('SavedObjectsClient', () => {
Array [
"/api/saved_objects/_bulk_create",
Object {
"body": "[{\\"id\\":\\"AVwSwFxtcMV38qjDZoQg\\",\\"type\\":\\"config\\",\\"attributes\\":{\\"title\\":\\"Example title\\"},\\"version\\":\\"foo\\"}]",
"body": "[{\\"id\\":\\"AVwSwFxtcMV38qjDZoQg\\",\\"type\\":\\"config\\",\\"attributes\\":{\\"title\\":\\"Example title\\"},\\"version\\":\\"foo\\",\\"updated_at\\":\\"${updatedAt}\\"}]",
"method": "POST",
"query": Object {
"overwrite": false,
Expand All @@ -374,7 +376,7 @@ describe('SavedObjectsClient', () => {
Array [
"/api/saved_objects/_bulk_create",
Object {
"body": "[{\\"id\\":\\"AVwSwFxtcMV38qjDZoQg\\",\\"type\\":\\"config\\",\\"attributes\\":{\\"title\\":\\"Example title\\"},\\"version\\":\\"foo\\"}]",
"body": "[{\\"id\\":\\"AVwSwFxtcMV38qjDZoQg\\",\\"type\\":\\"config\\",\\"attributes\\":{\\"title\\":\\"Example title\\"},\\"version\\":\\"foo\\",\\"updated_at\\":\\"${updatedAt}\\"}]",
"method": "POST",
"query": Object {
"overwrite": true,
Expand Down
7 changes: 7 additions & 0 deletions src/core/public/saved_objects/simple_saved_object.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,11 @@ describe('SimpleSavedObject', () => {
const savedObject = new SimpleSavedObject(client, { version } as SavedObject);
expect(savedObject._version).toEqual(version);
});

it('persists updated_at', () => {
const updatedAt = new Date().toString();

const savedObject = new SimpleSavedObject(client, { updated_at: updatedAt } as SavedObject);
expect(savedObject.updated_at).toEqual(updatedAt);
});
});
14 changes: 13 additions & 1 deletion src/core/public/saved_objects/simple_saved_object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,29 @@ export class SimpleSavedObject<T = unknown> {
public migrationVersion: SavedObjectType<T>['migrationVersion'];
public error: SavedObjectType<T>['error'];
public references: SavedObjectType<T>['references'];
public updated_at: SavedObjectType<T>['updated_at'];

constructor(
private client: SavedObjectsClientContract,
{ id, type, version, attributes, error, references, migrationVersion }: SavedObjectType<T>
{
id,
type,
version,
attributes,
error,
references,
migrationVersion,
// eslint-disable-next-line @typescript-eslint/naming-convention
updated_at,
}: SavedObjectType<T>
) {
this.id = id;
this.type = type;
this.attributes = attributes || ({} as T);
this.references = references || [];
this._version = version;
this.migrationVersion = migrationVersion;
this.updated_at = updated_at;
if (error) {
this.error = error;
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import React, { Fragment } from 'react';
import PropTypes from 'prop-types';
import moment from 'moment';

import { FormattedMessage, I18nProvider } from '@osd/i18n/react';
import { i18n } from '@osd/i18n';
Expand Down Expand Up @@ -161,6 +162,7 @@ export class DashboardListing extends React.Component {
}

getTableColumns() {
const dateFormat = this.props.core.uiSettings.get('dateFormat');
const tableColumns = [
{
field: 'title',
Expand All @@ -185,6 +187,19 @@ export class DashboardListing extends React.Component {
dataType: 'string',
sortable: true,
},
{
field: `updated_at`,
name: i18n.translate('dashboard.listing.table.columnUpdatedAtName', {
defaultMessage: 'Last updated',
}),
dataType: 'date',
sortable: true,
description: i18n.translate('dashboard.listing.table.columnUpdatedAtDescription', {
defaultMessage: 'Last update of the saved object',
}),
['data-test-subj']: 'updated-at',
render: (updatedAt) => updatedAt && moment(updatedAt).format(dateFormat),
},
];
return tableColumns;
}
Expand Down
Loading

0 comments on commit ddbc454

Please sign in to comment.