-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
207 additions
and
67 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
.../packages/design-system/ads/src/Templates/EntityContextMenu/EntityContextMenu.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* eslint-disable no-console */ | ||
import React from "react"; | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
|
||
import { MenuItem } from "../../Menu"; | ||
import { EntityContextMenu } from "./EntityContextMenu"; | ||
|
||
const meta: Meta<typeof EntityContextMenu> = { | ||
title: "ADS/Templates/Entity Context Menu", | ||
component: EntityContextMenu, | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof EntityContextMenu>; | ||
|
||
export const Basic: Story = { | ||
args: { | ||
tooltipContent: "More actions", | ||
children: ( | ||
<> | ||
<MenuItem onClick={console.log} startIcon="edit-line"> | ||
Rename | ||
</MenuItem> | ||
<MenuItem onClick={console.log} startIcon="copy-control"> | ||
Copy | ||
</MenuItem> | ||
<MenuItem onClick={console.log} startIcon="delete"> | ||
Delete | ||
</MenuItem> | ||
</> | ||
), | ||
}, | ||
}; |
12 changes: 12 additions & 0 deletions
12
...nt/packages/design-system/ads/src/Templates/EntityContextMenu/EntityContextMenu.styles.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import styled from "styled-components"; | ||
|
||
import { MenuContent as ADSMenuContent } from "../../Menu"; | ||
|
||
export const MenuContent = styled(ADSMenuContent)` | ||
width: 220px; | ||
max-height: unset; | ||
`; | ||
|
||
export const ButtonContainer = styled.div` | ||
position: relative; | ||
`; |
60 changes: 60 additions & 0 deletions
60
app/client/packages/design-system/ads/src/Templates/EntityContextMenu/EntityContextMenu.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import React from "react"; | ||
import { useToggle } from "usehooks-ts"; | ||
|
||
import { Button } from "../../Button"; | ||
import { Menu, MenuTrigger } from "../../Menu"; | ||
import { Tooltip } from "../../Tooltip"; | ||
|
||
import { | ||
EntityClassNames, | ||
DEFAULT_DATA_TEST_ID, | ||
DEFAULT_TOOLTIP_CONTENT, | ||
} from "./constants"; | ||
|
||
import * as Styled from "./EntityContextMenu.styles"; | ||
|
||
interface Props { | ||
dataTestid?: string; | ||
children?: React.ReactNode[] | React.ReactNode; | ||
tooltipContent?: React.ReactNode; | ||
} | ||
|
||
export const EntityContextMenu = (props: Props) => { | ||
const { | ||
children, | ||
dataTestid = DEFAULT_DATA_TEST_ID, | ||
tooltipContent = DEFAULT_TOOLTIP_CONTENT, | ||
} = props; | ||
|
||
const [isMenuOpen, toggleMenuOpen] = useToggle(); | ||
|
||
return ( | ||
<Menu onOpenChange={toggleMenuOpen} open={isMenuOpen}> | ||
<MenuTrigger className="t--context-menu"> | ||
<Styled.ButtonContainer> | ||
<Tooltip | ||
content={tooltipContent} | ||
isDisabled={isMenuOpen} | ||
mouseLeaveDelay={0} | ||
placement="right" | ||
> | ||
<Button | ||
className={EntityClassNames.CONTEXT_MENU} | ||
data-testid={dataTestid} | ||
isIconButton | ||
kind="tertiary" | ||
startIcon="more-2-fill" | ||
/> | ||
</Tooltip> | ||
</Styled.ButtonContainer> | ||
</MenuTrigger> | ||
<Styled.MenuContent | ||
align="start" | ||
className={`t--entity-context-menu ${EntityClassNames.CONTEXT_MENU_CONTENT}`} | ||
side="right" | ||
> | ||
{children} | ||
</Styled.MenuContent> | ||
</Menu> | ||
); | ||
}; |
7 changes: 7 additions & 0 deletions
7
app/client/packages/design-system/ads/src/Templates/EntityContextMenu/constants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export enum EntityClassNames { | ||
CONTEXT_MENU = "entity-context-menu", | ||
CONTEXT_MENU_CONTENT = "entity-context-menu-content", | ||
} | ||
|
||
export const DEFAULT_DATA_TEST_ID = "t--more-action-trigger"; | ||
export const DEFAULT_TOOLTIP_CONTENT = "More actions"; |
1 change: 1 addition & 0 deletions
1
app/client/packages/design-system/ads/src/Templates/EntityContextMenu/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { EntityContextMenu } from "./EntityContextMenu"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
app/client/src/git-artifact-helpers/application/sagas/applicationImportFromGitSaga.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { toast } from "@appsmith/ads"; | ||
import { createMessage, IMPORT_APP_SUCCESSFUL } from "ee/constants/messages"; | ||
import { builderURL } from "ee/RouteBuilder"; | ||
import { showReconnectDatasourceModal } from "ee/actions/applicationActions"; | ||
import type { ApplicationResponsePayload } from "ee/api/ApplicationApi"; | ||
import type { GitImportSuccessPayload } from "git/store/actions/gitImportActions"; | ||
import type { GitArtifactPayloadAction } from "git/store/types"; | ||
import { put } from "redux-saga/effects"; | ||
import history from "utils/history"; | ||
|
||
export default function* applicationImportFromGitSaga( | ||
action: GitArtifactPayloadAction<GitImportSuccessPayload>, | ||
) { | ||
const { responseData } = action.payload; | ||
const { isPartialImport, unConfiguredDatasourceList } = responseData; | ||
|
||
const application = | ||
(responseData.application as ApplicationResponsePayload) ?? null; | ||
|
||
if (!application) return; | ||
|
||
// there is configuration-missing datasources | ||
if (isPartialImport) { | ||
yield put( | ||
showReconnectDatasourceModal({ | ||
application: application as ApplicationResponsePayload, | ||
unConfiguredDatasourceList: unConfiguredDatasourceList ?? [], | ||
workspaceId: application?.workspaceId ?? "", | ||
}), | ||
); | ||
} else { | ||
let basePageId = ""; | ||
|
||
if (application.pages && application.pages.length > 0) { | ||
const defaultPage = application.pages.find( | ||
(eachPage) => !!eachPage.isDefault, | ||
); | ||
|
||
basePageId = defaultPage ? defaultPage.baseId : ""; | ||
} | ||
|
||
const branch = application?.gitApplicationMetadata?.branchName; | ||
|
||
const pageURL = builderURL({ | ||
basePageId, | ||
branch, | ||
}); | ||
|
||
history.push(pageURL); | ||
toast.show(createMessage(IMPORT_APP_SUCCESSFUL), { | ||
kind: "success", | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.