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 {
await signOut(false)
await clearWorkspaces()
// No need as all stores are cleared on signout
// await clearWorkspaces()
await navigateTo('/signin')
} catch (e) {

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

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

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

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

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

@ -20,6 +20,7 @@ const { getMeta, removeMeta } = useMetas()
const { loadTables, projectUrl, isXcdbBase } = useProject()
const { refreshCommandPalette } = useCommandPalette()
const { removeFromRecentViews } = useViewsStore()
const { projectTables, activeTable } = storeToRefs(useTablesStore())
const { openTable } = useTablesStore()
@ -69,6 +70,9 @@ const onDelete = async () => {
await loadTables()
// Remove from recent views
removeFromRecentViews({ projectId: props.projectId, tableId: toBeDeletedTable.id as string })
removeMeta(toBeDeletedTable.id as string)
refreshCommandPalette()
// 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 type { ViewPageType } from '~/lib'
@ -6,6 +6,7 @@ export const useViewsStore = defineStore('viewsStore', () => {
const { $api } = useNuxtApp()
const router = useRouter()
const recentViews = ref<any>([])
const route = router.currentRoute
const tablesStore = useTablesStore()
@ -20,6 +21,7 @@ export const useViewsStore = defineStore('viewsStore', () => {
viewsByTable.value.set(tablesStore.activeTableId, value)
},
})
const isViewsLoading = ref(true)
const isViewDataLoading = ref(true)
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(
() => tablesStore.activeTableId,
async (newId, oldId) => {
@ -203,6 +209,7 @@ export const useViewsStore = defineStore('viewsStore', () => {
isViewDataLoading,
isPaginationLoading,
loadViews,
recentViews,
views,
activeView,
openedViewsTab,
@ -211,6 +218,8 @@ export const useViewsStore = defineStore('viewsStore', () => {
viewsByTable,
activeViewTitleOrId,
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 { DetailsPage } from './Details';
import { WorkspaceSettingsObject } from './WorkspaceSettings';
import { CmdJ } from './Command/CmdJPage';
import { CmdK } from './Command/CmdKPage';
import { CmdL } from './Command/CmdLPage';
export class DashboardPage extends BasePage {
readonly project: any;
@ -55,6 +58,9 @@ export class DashboardPage extends BasePage {
readonly shareProjectButton: ShareProjectButtonPage;
readonly details: DetailsPage;
readonly workspaceSettings: WorkspaceSettingsObject;
readonly cmdJ: CmdJ;
readonly cmdK: CmdK;
readonly cmdL: CmdL;
constructor(rootPage: Page, project: any) {
super(rootPage);
@ -88,6 +94,9 @@ export class DashboardPage extends BasePage {
this.shareProjectButton = new ShareProjectButtonPage(this);
this.details = new DetailsPage(this);
this.workspaceSettings = new WorkspaceSettingsObject(this);
this.cmdJ = new CmdJ(this);
this.cmdK = new CmdK(this);
this.cmdL = new CmdL(this);
}
get() {

Loading…
Cancel
Save