Browse Source

Merge pull request #6542 from nocodb/feat/sync-changes

feat: sync
pull/6543/head
Anbarasu 1 year ago committed by GitHub
parent
commit
2bc196ae74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      packages/nc-gui/assets/nc-icons/project.svg
  2. 3
      packages/nc-gui/components/dashboard/Sidebar/UserInfo.vue
  3. 12
      packages/nc-gui/components/dashboard/TreeView/ViewsList.vue
  4. 3
      packages/nc-gui/components/dlg/ProjectDelete.vue
  5. 4
      packages/nc-gui/components/dlg/TableDelete.vue
  6. 11
      packages/nc-gui/store/views.ts
  7. 39
      tests/playwright/pages/Dashboard/Command/CmdJPage.ts
  8. 35
      tests/playwright/pages/Dashboard/Command/CmdKPage.ts
  9. 49
      tests/playwright/pages/Dashboard/Command/CmdLPage.ts
  10. 9
      tests/playwright/pages/Dashboard/index.ts

9
packages/nc-gui/assets/nc-icons/project.svg

@ -0,0 +1,9 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M8.99294 14.8095L14.548 12.28C14.8177 12.1572 14.9569 11.9975 14.9659 11.8367H1C1.00896 11.9975 1.14826 12.1572 1.4179 12.28L6.97294 14.8095C7.53075 15.0635 8.43514 15.0635 8.99294 14.8095Z" fill="#142966"/>
<path d="M14.9999 9.27893H1.00513V11.8367H14.9999V9.27893Z" fill="#142966"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M8.99294 12.2518L14.548 9.72223C14.8177 9.59946 14.9569 9.4398 14.9659 9.27893H1C1.00896 9.4398 1.14826 9.59946 1.4179 9.72223L6.97294 12.2518C7.53075 12.5058 8.43514 12.5058 8.99294 12.2518Z" fill="#142966"/>
<path d="M14.9999 6.72107H1.00513V9.27885H14.9999V6.72107Z" fill="#142966"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M8.99294 10.9729L14.548 8.44332C14.8177 8.32054 14.9569 8.16088 14.9659 8H1C1.00896 8.16088 1.14826 8.32054 1.4179 8.44332L6.97294 10.9729C7.53075 11.2269 8.43514 11.2269 8.99294 10.9729Z" fill="#36BFFF"/>
<path d="M14.9997 4.16309H1.00491V8.00309H14.9997V4.16309Z" fill="#36BFFF"/>
<path d="M14.5484 4.63991L8.99337 7.16947C8.43561 7.42348 7.53121 7.42348 6.9734 7.16947L1.41836 4.63991C0.860546 4.3859 0.860546 3.97408 1.41836 3.72007L6.9734 1.19051C7.53121 0.936498 8.43561 0.936498 8.99337 1.19051L14.5484 3.72007C15.1063 3.97408 15.1063 4.3859 14.5484 4.63991Z" fill="#36BFFF"/>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

3
packages/nc-gui/components/dashboard/Sidebar/UserInfo.vue

@ -26,7 +26,8 @@ const logout = async () => {
try { try {
await signOut(false) await signOut(false)
await clearWorkspaces() // No need as all stores are cleared on signout
// await clearWorkspaces()
await navigateTo('/signin') await navigateTo('/signin')
} catch (e) { } catch (e) {

12
packages/nc-gui/components/dashboard/TreeView/ViewsList.vue

@ -45,7 +45,7 @@ const isDefaultBase = computed(() => {
return _isDefaultBase(base) return _isDefaultBase(base)
}) })
const { viewsByTable, activeView } = storeToRefs(useViewsStore()) const { viewsByTable, activeView, recentViews } = storeToRefs(useViewsStore())
const { navigateToTable } = useTablesStore() const { navigateToTable } = useTablesStore()
@ -57,7 +57,7 @@ const { refreshCommandPalette } = useCommandPalette()
const { addUndo, defineModelScope } = useUndoRedo() const { addUndo, defineModelScope } = useUndoRedo()
const { navigateToView, loadViews } = useViewsStore() const { navigateToView, loadViews, removeFromRecentViews } = useViewsStore()
/** Selected view(s) for menu */ /** Selected view(s) for menu */
const selected = ref<string[]>([]) const selected = ref<string[]>([])
@ -244,6 +244,13 @@ async function onRename(view: ViewType, originalTitle?: string, undo = false) {
scope: defineModelScope({ view: activeView.value }), scope: defineModelScope({ view: activeView.value }),
}) })
} }
// update view name in recent views
recentViews.value = recentViews.value.map((rv) => {
if (rv.viewId === view.id && rv.tableID === view.fk_model_id) {
rv.viewName = view.title
}
return rv
})
// View renamed successfully // View renamed successfully
// message.success(t('msg.success.viewRenamed')) // message.success(t('msg.success.viewRenamed'))
@ -265,6 +272,7 @@ function openDeleteDialog(view: ViewType) {
emits('deleted') emits('deleted')
removeFromRecentViews({ viewId: view.id, tableId: view.fk_model_id, projectId: project.value.id })
refreshCommandPalette() refreshCommandPalette()
if (activeView.value?.id === view.id) { if (activeView.value?.id === view.id) {
navigateToTable({ navigateToTable({

3
packages/nc-gui/components/dlg/ProjectDelete.vue

@ -14,6 +14,8 @@ const projectsStore = useProjects()
const { deleteProject, navigateToFirstProjectOrHome } = projectsStore const { deleteProject, navigateToFirstProjectOrHome } = projectsStore
const { projects } = storeToRefs(projectsStore) const { projects } = storeToRefs(projectsStore)
const { removeFromRecentViews } = useViewsStore()
const { refreshCommandPalette } = useCommandPalette() const { refreshCommandPalette } = useCommandPalette()
const project = computed(() => projects.value.get(props.projectId)) const project = computed(() => projects.value.get(props.projectId))
@ -41,6 +43,7 @@ const onDelete = async () => {
message.error(await extractSdkResponseErrorMsg(e)) message.error(await extractSdkResponseErrorMsg(e))
} finally { } finally {
isLoading.value = false isLoading.value = false
removeFromRecentViews({ projectId: toBeDeletedProject.id! })
} }
} }
</script> </script>

4
packages/nc-gui/components/dlg/TableDelete.vue

@ -20,6 +20,7 @@ const { getMeta, removeMeta } = useMetas()
const { loadTables, projectUrl, isXcdbBase } = useProject() const { loadTables, projectUrl, isXcdbBase } = useProject()
const { refreshCommandPalette } = useCommandPalette() const { refreshCommandPalette } = useCommandPalette()
const { removeFromRecentViews } = useViewsStore()
const { projectTables, activeTable } = storeToRefs(useTablesStore()) const { projectTables, activeTable } = storeToRefs(useTablesStore())
const { openTable } = useTablesStore() const { openTable } = useTablesStore()
@ -69,6 +70,9 @@ const onDelete = async () => {
await loadTables() await loadTables()
// Remove from recent views
removeFromRecentViews({ projectId: props.projectId, tableId: toBeDeletedTable.id as string })
removeMeta(toBeDeletedTable.id as string) removeMeta(toBeDeletedTable.id as string)
refreshCommandPalette() refreshCommandPalette()
// Deleted table successfully // Deleted table successfully

11
packages/nc-gui/store/views.ts

@ -1,4 +1,4 @@
import { type ViewType } from 'nocodb-sdk' import type { ViewType } from 'nocodb-sdk'
import { acceptHMRUpdate, defineStore } from 'pinia' import { acceptHMRUpdate, defineStore } from 'pinia'
import type { ViewPageType } from '~/lib' import type { ViewPageType } from '~/lib'
@ -6,6 +6,7 @@ export const useViewsStore = defineStore('viewsStore', () => {
const { $api } = useNuxtApp() const { $api } = useNuxtApp()
const router = useRouter() const router = useRouter()
const recentViews = ref<any>([])
const route = router.currentRoute const route = router.currentRoute
const tablesStore = useTablesStore() const tablesStore = useTablesStore()
@ -20,6 +21,7 @@ export const useViewsStore = defineStore('viewsStore', () => {
viewsByTable.value.set(tablesStore.activeTableId, value) viewsByTable.value.set(tablesStore.activeTableId, value)
}, },
}) })
const isViewsLoading = ref(true) const isViewsLoading = ref(true)
const isViewDataLoading = ref(true) const isViewDataLoading = ref(true)
const isPublic = computed(() => route.value.meta?.public) const isPublic = computed(() => route.value.meta?.public)
@ -118,6 +120,10 @@ export const useViewsStore = defineStore('viewsStore', () => {
}) })
} }
const changeView = async (..._args: any) => {}
const removeFromRecentViews = (..._args: any) => {}
watch( watch(
() => tablesStore.activeTableId, () => tablesStore.activeTableId,
async (newId, oldId) => { async (newId, oldId) => {
@ -203,6 +209,7 @@ export const useViewsStore = defineStore('viewsStore', () => {
isViewDataLoading, isViewDataLoading,
isPaginationLoading, isPaginationLoading,
loadViews, loadViews,
recentViews,
views, views,
activeView, activeView,
openedViewsTab, openedViewsTab,
@ -211,6 +218,8 @@ export const useViewsStore = defineStore('viewsStore', () => {
viewsByTable, viewsByTable,
activeViewTitleOrId, activeViewTitleOrId,
navigateToView, navigateToView,
changeView,
removeFromRecentViews,
} }
}) })

39
tests/playwright/pages/Dashboard/Command/CmdJPage.ts

@ -0,0 +1,39 @@
import BasePage from '../../Base';
import { DashboardPage } from '..';
export class CmdJ extends BasePage {
readonly dashboardPage: DashboardPage;
constructor(dashboard: DashboardPage) {
super(dashboard.rootPage);
this.dashboardPage = dashboard;
}
get() {
return this.dashboardPage.get().locator('.DocSearch');
}
async openCmdJ() {
await this.dashboardPage.rootPage.keyboard.press(this.isMacOs() ? 'Meta+J' : 'Control+J');
// await this.dashboardPage.rootPage.waitForSelector('.DocSearch-Input');
}
async searchText(text: string) {
await this.dashboardPage.rootPage.fill('.DocSearch-Input', text);
}
async isCmdJVisible() {
const isVisible = this.get();
return await isVisible.count();
}
async isCmdJNotVisible() {
const isNotVisible = this.get();
return await isNotVisible.count();
}
async getPlaceholderText() {
const placeholderText = this.get().locator('.DocSearch-Input');
return await placeholderText.innerText();
}
}

35
tests/playwright/pages/Dashboard/Command/CmdKPage.ts

@ -0,0 +1,35 @@
import BasePage from '../../Base';
import { DashboardPage } from '..';
export class CmdK extends BasePage {
readonly dashboardPage: DashboardPage;
constructor(dashboard: DashboardPage) {
super(dashboard.rootPage);
this.dashboardPage = dashboard;
}
get() {
return this.dashboardPage.get().locator('.cmdk-modal.cmdk-modal-active');
}
async openCmdK() {
await this.dashboardPage.rootPage.keyboard.press(this.isMacOs() ? 'Meta+K' : 'Control+K');
// await this.dashboardPage.rootPage.waitForSelector('.DocSearch-Input');
}
async searchText(text: string) {
await this.dashboardPage.rootPage.fill('.cmdk-input', text);
await this.rootPage.keyboard.press('Enter');
}
async isCmdKVisible() {
const isVisible = this.get();
return await isVisible.count();
}
async isCmdKNotVisible() {
const isNotVisible = this.get();
return await isNotVisible.count();
}
}

49
tests/playwright/pages/Dashboard/Command/CmdLPage.ts

@ -0,0 +1,49 @@
import BasePage from '../../Base';
import { DashboardPage } from '..';
export class CmdL extends BasePage {
readonly dashboardPage: DashboardPage;
constructor(dashboard: DashboardPage) {
super(dashboard.rootPage);
this.dashboardPage = dashboard;
}
get() {
return this.dashboardPage.get().locator('.cmdl-modal.cmdl-modal-active');
}
async openCmdL() {
await this.dashboardPage.rootPage.keyboard.press(this.isMacOs() ? 'Meta+L' : 'Control+L');
}
async isCmdLVisible() {
const isVisible = this.get();
return await isVisible.count();
}
async isCmdLNotVisible() {
const isNotVisible = this.get();
return await isNotVisible.count();
}
async moveDown() {
await this.dashboardPage.rootPage.keyboard.press('ArrowDown');
}
async moveUp() {
await this.dashboardPage.rootPage.keyboard.press('ArrowUp');
}
async openRecent() {
await this.dashboardPage.rootPage.keyboard.press('Enter');
}
async getActiveViewTitle() {
return await this.dashboardPage.get().locator('.nc-active-view-title').innerText();
}
async getActiveTableTitle() {
return await this.dashboardPage.get().locator('.nc-active-table-title').innerText();
}
}

9
tests/playwright/pages/Dashboard/index.ts

@ -25,6 +25,9 @@ import { ProjectTypes } from 'nocodb-sdk';
import { WorkspacePage } from '../WorkspacePage'; import { WorkspacePage } from '../WorkspacePage';
import { DetailsPage } from './Details'; import { DetailsPage } from './Details';
import { WorkspaceSettingsObject } from './WorkspaceSettings'; import { WorkspaceSettingsObject } from './WorkspaceSettings';
import { CmdJ } from './Command/CmdJPage';
import { CmdK } from './Command/CmdKPage';
import { CmdL } from './Command/CmdLPage';
export class DashboardPage extends BasePage { export class DashboardPage extends BasePage {
readonly project: any; readonly project: any;
@ -55,6 +58,9 @@ export class DashboardPage extends BasePage {
readonly shareProjectButton: ShareProjectButtonPage; readonly shareProjectButton: ShareProjectButtonPage;
readonly details: DetailsPage; readonly details: DetailsPage;
readonly workspaceSettings: WorkspaceSettingsObject; readonly workspaceSettings: WorkspaceSettingsObject;
readonly cmdJ: CmdJ;
readonly cmdK: CmdK;
readonly cmdL: CmdL;
constructor(rootPage: Page, project: any) { constructor(rootPage: Page, project: any) {
super(rootPage); super(rootPage);
@ -88,6 +94,9 @@ export class DashboardPage extends BasePage {
this.shareProjectButton = new ShareProjectButtonPage(this); this.shareProjectButton = new ShareProjectButtonPage(this);
this.details = new DetailsPage(this); this.details = new DetailsPage(this);
this.workspaceSettings = new WorkspaceSettingsObject(this); this.workspaceSettings = new WorkspaceSettingsObject(this);
this.cmdJ = new CmdJ(this);
this.cmdK = new CmdK(this);
this.cmdL = new CmdL(this);
} }
get() { get() {

Loading…
Cancel
Save