From 555d41d8919720398fac6a25f0a37d38a1741c34 Mon Sep 17 00:00:00 2001 From: leiyre Date: Fri, 25 Mar 2022 11:20:13 +0100 Subject: [PATCH] feat(#1119): users without personal datasets (#1282) (cherry picked from commit 068e4be596e4f1a8dcd18bb5195d80cb6d24e2ea) chore(#1119): fix user dropdown styles (#1318) Closes #1317 This PR fixes alignment and width (cherry picked from commit eb704596bbe09b203e95e65f4fe61360e71d7236) fix(#1323): align text and icon in dataset name (#1324) Closes #1323 (cherry picked from commit 158fcad0507d3b2c12fb13345bc6ba1e9e1899e4) --- frontend/assets/icons/docs.js | 27 +++ frontend/assets/icons/filtrable-column.js | 27 +++ frontend/assets/icons/index.js | 20 +- frontend/assets/icons/logout.js | 8 +- frontend/assets/icons/sort-table.js | 27 +++ .../commons/datasets-list/DatasetsEmpty.vue | 9 +- .../components/commons/header/appHeader.vue | 6 +- .../components/commons/header/user/user.vue | 156 ++++--------- .../core/{ => table}/ReTableInfo.vue | 109 +++++---- .../core/table/TableFiltrableColumn.vue | 208 ++++++++++++++++++ .../results/EntityHighlight.vue | 4 +- frontend/database/modules/datasets.js | 3 + frontend/models/Workspace.js | 15 +- .../_workspace/_dataset/index.vue | 13 +- .../{ws/_workspace => datasets}/index.vue | 49 ++++- frontend/pages/index.vue | 2 +- frontend/pages/ws/_id/_dataset/index.vue | 28 +++ frontend/pages/ws/_id/index.vue | 26 +++ frontend/pages/ws/index.vue | 11 +- .../components/core/table/ReTableInfo.spec.js | 65 ++++++ .../core/table/TableFiltrableColumn.spec.js | 36 +++ .../__snapshots__/ReTableInfo.spec.js.snap | 58 +++++ .../TableFiltrableColumn.spec.js.snap | 11 + frontend/static/icons/docs.svg | 13 ++ frontend/static/icons/filtrable-column.svg | 10 + frontend/static/icons/logout.svg | 16 +- frontend/static/icons/sort-table.svg | 8 + 27 files changed, 734 insertions(+), 231 deletions(-) create mode 100644 frontend/assets/icons/docs.js create mode 100644 frontend/assets/icons/filtrable-column.js create mode 100644 frontend/assets/icons/sort-table.js rename frontend/components/core/{ => table}/ReTableInfo.vue (91%) create mode 100644 frontend/components/core/table/TableFiltrableColumn.vue rename frontend/pages/{ws => datasets}/_workspace/_dataset/index.vue (89%) rename frontend/pages/{ws/_workspace => datasets}/index.vue (84%) create mode 100644 frontend/pages/ws/_id/_dataset/index.vue create mode 100644 frontend/pages/ws/_id/index.vue create mode 100644 frontend/specs/components/core/table/ReTableInfo.spec.js create mode 100644 frontend/specs/components/core/table/TableFiltrableColumn.spec.js create mode 100644 frontend/specs/components/core/table/__snapshots__/ReTableInfo.spec.js.snap create mode 100644 frontend/specs/components/core/table/__snapshots__/TableFiltrableColumn.spec.js.snap create mode 100644 frontend/static/icons/docs.svg create mode 100644 frontend/static/icons/filtrable-column.svg create mode 100644 frontend/static/icons/sort-table.svg diff --git a/frontend/assets/icons/docs.js b/frontend/assets/icons/docs.js new file mode 100644 index 0000000000..4145af4ad9 --- /dev/null +++ b/frontend/assets/icons/docs.js @@ -0,0 +1,27 @@ +/* + * coding=utf-8 + * Copyright 2021-present, the Recognai S.L. team. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* eslint-disable */ +var icon = require('vue-svgicon') +icon.register({ + 'docs': { + width: 12, + height: 16, + viewBox: '0 0 12 16', + data: '' + } +}) \ No newline at end of file diff --git a/frontend/assets/icons/filtrable-column.js b/frontend/assets/icons/filtrable-column.js new file mode 100644 index 0000000000..e4921eac99 --- /dev/null +++ b/frontend/assets/icons/filtrable-column.js @@ -0,0 +1,27 @@ +/* + * coding=utf-8 + * Copyright 2021-present, the Recognai S.L. team. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* eslint-disable */ +var icon = require('vue-svgicon') +icon.register({ + 'filtrable-column': { + width: 15, + height: 11, + viewBox: '0 0 15 11', + data: '' + } +}) \ No newline at end of file diff --git a/frontend/assets/icons/index.js b/frontend/assets/icons/index.js index a2edd67811..a6dc7d4054 100644 --- a/frontend/assets/icons/index.js +++ b/frontend/assets/icons/index.js @@ -1,20 +1,3 @@ -/* - * coding=utf-8 - * Copyright 2021-present, the Recognai S.L. team. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - /* eslint-disable */ require('./annotate-view') require('./arrow-bottom') @@ -41,6 +24,7 @@ require('./datasets-empty') require('./datasource') require('./datasources') require('./delete') +require('./docs') require('./double-chev') require('./drop-down') require('./drop-up') @@ -56,6 +40,7 @@ require('./external-link') require('./external') require('./feather') require('./filter') +require('./filtrable-column') require('./forbidden') require('./go-back') require('./help') @@ -82,6 +67,7 @@ require('./progress') require('./refresh') require('./reject') require('./search') +require('./sort-table') require('./sort') require('./unlock') require('./zoomin') diff --git a/frontend/assets/icons/logout.js b/frontend/assets/icons/logout.js index a794741ee7..e8295806af 100644 --- a/frontend/assets/icons/logout.js +++ b/frontend/assets/icons/logout.js @@ -19,9 +19,9 @@ var icon = require('vue-svgicon') icon.register({ 'logout': { - width: 17, - height: 22, - viewBox: '0 0 17 22', - data: '' + width: 12, + height: 15, + viewBox: '0 0 12 15', + data: '' } }) \ No newline at end of file diff --git a/frontend/assets/icons/sort-table.js b/frontend/assets/icons/sort-table.js new file mode 100644 index 0000000000..8e16ce1ca5 --- /dev/null +++ b/frontend/assets/icons/sort-table.js @@ -0,0 +1,27 @@ +/* + * coding=utf-8 + * Copyright 2021-present, the Recognai S.L. team. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* eslint-disable */ +var icon = require('vue-svgicon') +icon.register({ + 'sort-table': { + width: 13, + height: 14, + viewBox: '0 0 13 14', + data: '' + } +}) \ No newline at end of file diff --git a/frontend/components/commons/datasets-list/DatasetsEmpty.vue b/frontend/components/commons/datasets-list/DatasetsEmpty.vue index 87b9218041..ce8585f4ca 100644 --- a/frontend/components/commons/datasets-list/DatasetsEmpty.vue +++ b/frontend/components/commons/datasets-list/DatasetsEmpty.vue @@ -13,7 +13,7 @@ see the docs for more information.

- + @@ -28,14 +28,11 @@ export default { }, methods: { - generateCodeSnippet(ws) { + generateCodeSnippet() { return `import rubrix as rb -# If you are using the default installation you can skip this line -rb.set_workspace("${ws}") - rb.log( - rb.TextClassificationRecord(inputs="my first rubrix example"), + rb.TextClassificationRecord(text="my first rubrix example"), name='example-dataset' )`; }, diff --git a/frontend/components/commons/header/appHeader.vue b/frontend/components/commons/header/appHeader.vue index a19d0690a0..2cb7bb9dc5 100644 --- a/frontend/components/commons/header/appHeader.vue +++ b/frontend/components/commons/header/appHeader.vue @@ -22,7 +22,7 @@ :class="['header', sticky && dataset ? 'sticky' : null]" > - + @@ -49,6 +49,10 @@ export default { type: Boolean, default: true, }, + copyButton: { + type: Boolean, + default: true, + }, }, computed: { currentTask() { diff --git a/frontend/components/commons/header/user/user.vue b/frontend/components/commons/header/user/user.vue index f4aa75a3e7..347ca6eefd 100644 --- a/frontend/components/commons/header/user/user.vue +++ b/frontend/components/commons/header/user/user.vue @@ -1,51 +1,21 @@ diff --git a/frontend/specs/components/core/table/ReTableInfo.spec.js b/frontend/specs/components/core/table/ReTableInfo.spec.js new file mode 100644 index 0000000000..4443697de2 --- /dev/null +++ b/frontend/specs/components/core/table/ReTableInfo.spec.js @@ -0,0 +1,65 @@ +import { mount } from "@vue/test-utils"; +import ReTableInfo from "@/components/core/table/ReTableInfo"; + +const $route = { + query: {}, +}; + +function mountReTableInfo() { + return mount(ReTableInfo, { + propsData: { + actions: [], + columns: [ + { + class: "text", + field: "owner", + filtrable: "true", + name: "Workspace", + type: "text", + }, + ], + data: [ + { + name: "dataset_1", + owner: "recognai", + task: "TokenClassification", + }, + { + name: "dataset_2", + owner: "recognai", + task: "TokenClassification", + }, + ], + deleteModalContent: { + text: "You are about to delete: undefined. This action cannot be undone", + title: "Delete confirmation", + }, + emptySearchInfo: { + title: "0 datasets found", + }, + globalActions: false, + groupBy: undefined, + hideButton: false, + noDataInfo: undefined, + querySearch: undefined, + filterFromRoute: "owner", + searchOn: "name", + sortedByField: "last_updated", + sortedOrder: "desc", + visibleModalId: undefined, + }, + mocks: { + $route, + }, + }); +} + +describe("ReTableInfo", () => { + let spy = jest.spyOn(console, "error"); + afterEach(() => spy.mockReset()); + + test("renders properly", () => { + const wrapper = mountReTableInfo(); + expect(wrapper.html()).toMatchSnapshot(); + }); +}); diff --git a/frontend/specs/components/core/table/TableFiltrableColumn.spec.js b/frontend/specs/components/core/table/TableFiltrableColumn.spec.js new file mode 100644 index 0000000000..5648cd1cca --- /dev/null +++ b/frontend/specs/components/core/table/TableFiltrableColumn.spec.js @@ -0,0 +1,36 @@ +import { mount } from "@vue/test-utils"; +import TableFiltrableColumn from "@/components/core/table/TableFiltrableColumn"; + +function mountTableFiltrableColumn() { + return mount(TableFiltrableColumn, { + propsData: { + filters: { + owner: ["recognai"], + }, + column: { + class: "text", + field: "owner", + filtrable: "true", + name: "Workspace", + type: "text", + }, + data: [ + { + name: "dataset_1", + owner: "recognai", + task: "TokenClassification", + }, + ], + }, + }); +} + +describe("TableFiltrableColumn", () => { + let spy = jest.spyOn(console, "error"); + afterEach(() => spy.mockReset()); + + test("renders properly", () => { + const wrapper = mountTableFiltrableColumn(); + expect(wrapper.html()).toMatchSnapshot(); + }); +}); diff --git a/frontend/specs/components/core/table/__snapshots__/ReTableInfo.spec.js.snap b/frontend/specs/components/core/table/__snapshots__/ReTableInfo.spec.js.snap new file mode 100644 index 0000000000..3a24b007d9 --- /dev/null +++ b/frontend/specs/components/core/table/__snapshots__/ReTableInfo.spec.js.snap @@ -0,0 +1,58 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ReTableInfo renders properly 1`] = ` + +
+
+
+
+ +
+
+
+
+ +
    +
  • +
    recognai +
    + +
    + +

    You are about to delete: undefined. This action cannot be undone

    + +
    +
    +
    +
  • +
  • +
    recognai +
    + +
    + +

    You are about to delete: undefined. This action cannot be undone

    + +
    +
    +
    +
  • +
+
+
+
+`; diff --git a/frontend/specs/components/core/table/__snapshots__/TableFiltrableColumn.spec.js.snap b/frontend/specs/components/core/table/__snapshots__/TableFiltrableColumn.spec.js.snap new file mode 100644 index 0000000000..566e215d2a --- /dev/null +++ b/frontend/specs/components/core/table/__snapshots__/TableFiltrableColumn.spec.js.snap @@ -0,0 +1,11 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`TableFiltrableColumn renders properly 1`] = ` +
+ +
+`; diff --git a/frontend/static/icons/docs.svg b/frontend/static/icons/docs.svg new file mode 100644 index 0000000000..9619643429 --- /dev/null +++ b/frontend/static/icons/docs.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/frontend/static/icons/filtrable-column.svg b/frontend/static/icons/filtrable-column.svg new file mode 100644 index 0000000000..8f6e9142e2 --- /dev/null +++ b/frontend/static/icons/filtrable-column.svg @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/frontend/static/icons/logout.svg b/frontend/static/icons/logout.svg index 10e5250e56..a511cba9ff 100644 --- a/frontend/static/icons/logout.svg +++ b/frontend/static/icons/logout.svg @@ -1,12 +1,12 @@ - - - - - - - - + + + + + + + + diff --git a/frontend/static/icons/sort-table.svg b/frontend/static/icons/sort-table.svg new file mode 100644 index 0000000000..c83a8ce340 --- /dev/null +++ b/frontend/static/icons/sort-table.svg @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file