Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: app redesign #1833

Merged
merged 139 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
139 commits
Select commit Hold shift + click to select a range
d49c9c3
initial commit with icons
jimniels Sep 3, 2024
3f62b07
scaffolding UI
jimniels Sep 3, 2024
e42c63a
initial commit towards centralized actions
jimniels Sep 4, 2024
b1b5581
tweaks
jimniels Sep 4, 2024
49488a9
Merge branch 'qa' into redesign
jimniels Sep 4, 2024
6be828e
more tweaks
jimniels Sep 4, 2024
52d7922
redo keyboard shortcuts, switch to TS from zod
AyushAgrawal-A2 Sep 5, 2024
96eb447
shortcut display
AyushAgrawal-A2 Sep 5, 2024
81b89c6
prettier
AyushAgrawal-A2 Sep 5, 2024
2db9123
zoom menu
AyushAgrawal-A2 Sep 5, 2024
bd09036
cleanup
AyushAgrawal-A2 Sep 5, 2024
b36a772
Update SyncState.tsx
jimniels Sep 5, 2024
925242b
organize menus
jimniels Sep 5, 2024
31b41f5
more menus
jimniels Sep 5, 2024
b5c4812
more icons
jimniels Sep 5, 2024
6ab0245
formatting bar and more
jimniels Sep 6, 2024
ee29392
Merge branch 'redesign' into ayush/actions_refactor
AyushAgrawal-A2 Sep 6, 2024
66449b1
Merge pull request #1845 from quadratichq/ayush/actions_refactor
AyushAgrawal-A2 Sep 6, 2024
b5decd8
Merge branch 'qa' into redesign
AyushAgrawal-A2 Sep 6, 2024
0285574
use partials for default shortcuts
AyushAgrawal-A2 Sep 6, 2024
83b1a7a
remove empty shortcuts
AyushAgrawal-A2 Sep 6, 2024
58c155e
updated actions
jimniels Sep 6, 2024
7ceeff3
Merge branch 'redesign' of github.com:quadratichq/quadratic into rede…
jimniels Sep 6, 2024
e169f9c
properly deprecate icons
jimniels Sep 6, 2024
0392af6
a bunch of fixes
jimniels Sep 6, 2024
31dd060
use pixiappsettings for setEditorInteractionState
AyushAgrawal-A2 Sep 7, 2024
218eb00
fix test
AyushAgrawal-A2 Sep 7, 2024
a055528
Edit menu actions
jimniels Sep 9, 2024
844ac31
more menus
jimniels Sep 9, 2024
fafe7aa
fix ui bug
jimniels Sep 9, 2024
4d6e93d
insert menu
jimniels Sep 9, 2024
3155046
better types for actionSpecs
AyushAgrawal-A2 Sep 10, 2024
da0b94b
text color and fill color
AyushAgrawal-A2 Sep 10, 2024
d5fc9a0
fix a bunch of focus issues
jimniels Sep 10, 2024
790ebcd
use specific actions in props
AyushAgrawal-A2 Sep 10, 2024
ddd8ce9
Merge branch 'redesign' of github.com:quadratichq/quadratic into rede…
AyushAgrawal-A2 Sep 10, 2024
47f271d
wire up more actions
jimniels Sep 10, 2024
7efdf2e
merge bugs
AyushAgrawal-A2 Sep 10, 2024
2094e4b
Merge branch 'redesign' of github.com:quadratichq/quadratic into rede…
AyushAgrawal-A2 Sep 10, 2024
c9f0dad
more merge bugs
AyushAgrawal-A2 Sep 10, 2024
df6a58f
permissions & other fixes
jimniels Sep 10, 2024
c51c922
initial isAvailable implementation for FileMenu
jimniels Sep 10, 2024
c2d8ec1
revert removing actionSpecs
AyushAgrawal-A2 Sep 10, 2024
6f16cd1
Merge branch 'redesign' of github.com:quadratichq/quadratic into rede…
AyushAgrawal-A2 Sep 10, 2024
bc36401
ts generics
AyushAgrawal-A2 Sep 11, 2024
34a6888
start borders
AyushAgrawal-A2 Sep 11, 2024
03ad239
Merge branch 'qa' of github.com:quadratichq/quadratic into redesign
AyushAgrawal-A2 Sep 11, 2024
736276d
insert checkbox and dropdown
AyushAgrawal-A2 Sep 11, 2024
7e50ee7
fix bug
AyushAgrawal-A2 Sep 11, 2024
9d62b29
use action specs for borders
AyushAgrawal-A2 Sep 11, 2024
8978160
border line style and color
AyushAgrawal-A2 Sep 11, 2024
fb7b7f5
color picker styles
AyushAgrawal-A2 Sep 11, 2024
0686530
add permissions
jimniels Sep 11, 2024
73c8c4a
Update TopBarUsers.tsx
jimniels Sep 11, 2024
c5c4824
add action specs for all actions, remove partial type
AyushAgrawal-A2 Sep 11, 2024
36987a8
fix bug
AyushAgrawal-A2 Sep 11, 2024
bb1ff7d
layout fixes and sheet bar fixes
jimniels Sep 11, 2024
1e7aa27
more fixes and code removal
jimniels Sep 12, 2024
34fb53a
rename and move
jimniels Sep 12, 2024
e3d8930
Merge branch 'qa' of github.com:quadratichq/quadratic into redesign
AyushAgrawal-A2 Sep 12, 2024
d70032a
lint
AyushAgrawal-A2 Sep 12, 2024
54d51f8
color picker fixes
jimniels Sep 12, 2024
7adbd80
context menu
jimniels Sep 12, 2024
0ea132f
Merge branch 'redesign' of github.com:quadratichq/quadratic into rede…
jimniels Sep 12, 2024
cac52e3
Update gridHeadingAtom.ts
jimniels Sep 12, 2024
65458ba
sidebar fixes
jimniels Sep 12, 2024
0c94849
Update Borders.tsx
jimniels Sep 12, 2024
47716bb
move sheetbar back
jimniels Sep 12, 2024
a289a8f
fix positioning of context menu
davidfig Sep 13, 2024
e00b215
minor tweak
davidfig Sep 13, 2024
6471c85
get rid of warning
davidfig Sep 13, 2024
50a0d10
ensure the cursor changes position
davidfig Sep 13, 2024
80d1c0f
initial commit for bordermenu
jimniels Sep 13, 2024
ff598ec
Update BorderMenu.tsx
jimniels Sep 13, 2024
7aad917
fix zoom menu
jimniels Sep 13, 2024
c0f02a1
Update FormattingBar.tsx
jimniels Sep 13, 2024
1807919
Update FormattingBar.tsx
jimniels Sep 13, 2024
58472a1
remove dead code
jimniels Sep 13, 2024
510384f
fixes
jimniels Sep 13, 2024
c598fd1
focus grid after file menu closes
jimniels Sep 13, 2024
3d6fbc0
Update MenubarItemAction.tsx
jimniels Sep 13, 2024
d1abfc0
Update QuadraticSidebar.tsx
jimniels Sep 13, 2024
7932ea1
update help command palette
jimniels Sep 13, 2024
df4adb6
remove code comments
jimniels Sep 13, 2024
e83038a
remove deprecated icon
jimniels Sep 13, 2024
4fc0a3b
Update execute_formats.rs
jimniels Sep 13, 2024
0cdee24
Update execute_formats.rs
jimniels Sep 13, 2024
8826734
logout button
jimniels Sep 13, 2024
e7db743
Merge branch 'qa' of github.com:quadratichq/quadratic into redesign
AyushAgrawal-A2 Sep 15, 2024
0238af3
add types to action spec sub files
AyushAgrawal-A2 Sep 15, 2024
c9a70f1
Update GridContextMenu.tsx
jimniels Sep 16, 2024
fdf7aad
fix todos and the embed view
jimniels Sep 16, 2024
309b530
Merge branch 'qa' of github.com:quadratichq/quadratic into redesign
AyushAgrawal-A2 Sep 16, 2024
2ae370c
move date and time picker
jimniels Sep 16, 2024
aff5f80
Merge branch 'redesign' of github.com:quadratichq/quadratic into rede…
jimniels Sep 16, 2024
6bc577c
Update FormattingBar.tsx
jimniels Sep 16, 2024
e262fd8
responsiveness
jimniels Sep 16, 2024
9cc719a
responsiveness
jimniels Sep 16, 2024
2cd8954
more action fixes and focusGrid
jimniels Sep 16, 2024
81ce258
fix initial icon display
jimniels Sep 17, 2024
2a6f940
update GoTo UI widget
jimniels Sep 17, 2024
f67180a
Update CursorPosition.tsx
jimniels Sep 17, 2024
4746053
Update QuadraticSidebar.tsx
jimniels Sep 17, 2024
45f780f
Update BorderMenu.tsx
jimniels Sep 17, 2024
2419df4
use isAvailable hook
jimniels Sep 17, 2024
7eedd8e
fix font display on load
jimniels Sep 17, 2024
b900c90
centralize all TooltipProviders to the root of the dashboard and app
jimniels Sep 17, 2024
a301bdc
initial swap out of radix icons on dashboard
jimniels Sep 17, 2024
c405a83
initial commit
jimniels Sep 17, 2024
59019ac
fix zoomed placement of context menu
davidfig Sep 18, 2024
b70f5f9
fix sizes of zoomed HTML elements
davidfig Sep 18, 2024
3fd8e31
context menu has pointer events again
davidfig Sep 18, 2024
42474a5
Merge branches 'redesign' and 'qa' of github.com:quadratichq/quadrati…
AyushAgrawal-A2 Sep 18, 2024
6b2d7f5
fix positioning
jimniels Sep 18, 2024
edc5319
Merge pull request #1875 from quadratichq/redesign-cmd-palette-transi…
jimniels Sep 18, 2024
ca92de4
Update keyboardShortcutsDisplay.ts
jimniels Sep 18, 2024
e0fdc0a
centralized edit actions in command palette
jimniels Sep 18, 2024
181c90f
fix kernel menu notifier
jimniels Sep 18, 2024
dcd9e27
fix bug
jimniels Sep 18, 2024
6c23c36
remove unused icons
jimniels Sep 18, 2024
5c3b127
move data validation out of sidebar and into menubar
jimniels Sep 18, 2024
67fdcb3
fix tests
jimniels Sep 18, 2024
ceaade5
fix kernel
jimniels Sep 18, 2024
3886db5
ensure that pointerMove is over the canvas
davidfig Sep 19, 2024
df3ea79
ensure the pointerMove doesn't work over the top menu
davidfig Sep 19, 2024
83103c3
add the view menu to exclusions
davidfig Sep 19, 2024
c41e348
Merge branch 'qa' into redesign
AyushAgrawal-A2 Sep 19, 2024
15b58d9
pointer-move-ignore
AyushAgrawal-A2 Sep 19, 2024
74b034d
Merge pull request #1888 from quadratichq/fix-non-canvas-hover
jimniels Sep 19, 2024
c177615
Update SheetBarTab.tsx
jimniels Sep 19, 2024
6afcb62
fix bug
jimniels Sep 19, 2024
437c49e
responsive fixes
jimniels Sep 19, 2024
3dce3f3
Update SyncState.tsx
jimniels Sep 19, 2024
f6615cf
get rid of old blues
jimniels Sep 19, 2024
920c199
Update insertActionsSpec.ts
jimniels Sep 19, 2024
a09d65f
Update SyncState.tsx
jimniels Sep 19, 2024
c5d9567
fix typo and client dependency
AyushAgrawal-A2 Sep 19, 2024
a964938
Merge branch 'qa' into redesign
AyushAgrawal-A2 Sep 19, 2024
65659c4
remove duplicate PermissionOverlay
AyushAgrawal-A2 Sep 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,11 @@
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[css]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[scss]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
1,223 changes: 1,043 additions & 180 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions quadratic-client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
<meta name="twitter:description" content="Modern spreadsheet software." />
<meta name="twitter:image" content="https://app.quadratichq.com/images/social.png" />

<!-- Material symbols font -->
<link
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,[email protected],400,0,0&display=block"
rel="stylesheet"
/>

<!-- Google Tag Manager -->
<script>
(function (w, d, s, l, i) {
Expand All @@ -44,6 +50,7 @@
</head>
<body>
<!-- Google Tag Manager (noscript) -->
<!-- prettier-ignore -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-WVC2XPB3" crossorigin="anonymous"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
Expand Down
3 changes: 3 additions & 0 deletions quadratic-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-menubar": "^1.1.1",
"@radix-ui/react-popover": "^1.0.7",
"@radix-ui/react-progress": "^1.0.3",
"@radix-ui/react-radio-group": "^1.1.3",
Expand All @@ -38,6 +39,8 @@
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-switch": "^1.0.3",
"@radix-ui/react-tabs": "^1.0.4",
"@radix-ui/react-toggle": "^1.1.0",
"@radix-ui/react-toggle-group": "^1.1.0",
"@radix-ui/react-tooltip": "^1.0.7",
"@sentry/react": "^7.108.0",
"@sentry/vite-plugin": "^2.15.0",
Expand Down
75 changes: 1 addition & 74 deletions quadratic-client/src/app/actions.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import { EditorInteractionState } from '@/app/atoms/editorInteractionStateAtom';
import { sheets } from '@/app/grid/controller/Sheets';
import { downloadFile, downloadQuadraticFile } from '@/app/helpers/downloadFileInBrowser';
import { FileContextType } from '@/app/ui/components/FileProvider';
import { quadraticCore } from '@/app/web-workers/quadraticCore/quadraticCore';
import { getActionFileDuplicate } from '@/routes/api.files.$uuid';
import { apiClient } from '@/shared/api/apiClient';
import { GlobalSnackbar } from '@/shared/components/GlobalSnackbarProvider';
import { ROUTES } from '@/shared/constants/routes';
import { DOCUMENTATION_URL } from '@/shared/constants/urls';
import { ApiTypes, FilePermission, FilePermissionSchema, TeamPermission } from 'quadratic-shared/typesAndSchemas';
import { SubmitFunction } from 'react-router-dom';
import { SetterOrUpdater } from 'recoil';
Expand Down Expand Up @@ -63,7 +58,7 @@ export const hasPermissionToEditFile = (filePermissions: FilePermission[]) => fi
// They are shared between actions here and command palette actions
export const isAvailableBecauseCanEditFile = ({ filePermissions }: IsAvailableArgs) =>
hasPermissionToEditFile(filePermissions);
const isAvailableBecauseLoggedIn = ({ isAuthenticated }: IsAvailableArgs) => isAuthenticated;
export const isAvailableBecauseLoggedIn = ({ isAuthenticated }: IsAvailableArgs) => isAuthenticated;
export const isAvailableBecauseFileLocationIsAccessibleAndWriteable = ({
fileTeamPrivacy,
teamPermissions,
Expand All @@ -77,11 +72,6 @@ export const createNewFileAction = {
},
};

export const renameFileAction = {
label: 'Rename',
isAvailable: isAvailableBecauseCanEditFile,
};

export const duplicateFileAction = {
label: 'Duplicate',
isAvailable: isAvailableBecauseFileLocationIsAccessibleAndWriteable,
Expand All @@ -91,14 +81,6 @@ export const duplicateFileAction = {
},
};

export const downloadFileAction = {
label: 'Download',
isAvailable: isAvailableBecauseLoggedIn,
async run({ name }: { name: FileContextType['name'] }) {
downloadQuadraticFile(name, await quadraticCore.export());
},
};

export const deleteFile = {
label: 'Delete',
isAvailable: ({ filePermissions }: IsAvailableArgs) => filePermissions.includes(FILE_DELETE),
Expand All @@ -123,47 +105,6 @@ export const provideFeedbackAction = {
},
};

export const viewDocsAction = {
label: 'Docs',
run() {
window.open(DOCUMENTATION_URL, '_blank')?.focus();
},
};

export const cutAction = {
label: 'Cut',
isAvailable: isAvailableBecauseCanEditFile,
};

export const pasteAction = {
label: 'Paste',
isAvailable: isAvailableBecauseCanEditFile,
};

export const pasteActionValues = {
label: 'Paste values only',
isAvailable: isAvailableBecauseCanEditFile,
};

export const pasteActionFormats = {
label: 'Paste formats only',
isAvailable: isAvailableBecauseCanEditFile,
};

export const undoAction = {
label: 'Undo',
isAvailable: isAvailableBecauseCanEditFile,
};

export const redoAction = {
label: 'Redo',
isAvailable: isAvailableBecauseCanEditFile,
};

export const copyAction = {
label: 'Copy',
};

export const rerunCellAction = {
label: 'Run this code cell',
isAvailable: isAvailableBecauseCanEditFile,
Expand All @@ -179,25 +120,11 @@ export const rerunSheetAction = {
isAvailable: isAvailableBecauseCanEditFile,
};

export const downloadSelectionAsCsvAction = {
label: 'Download selection as CSV',
async run({ fileName }: { fileName: string }) {
downloadFile(fileName, await quadraticCore.exportCsvSelection(sheets.getRustSelection()), 'text/plain', 'csv');
},
};

export const dataValidations = {
label: 'Data Validations',
isAvailable: isAvailableBecauseCanEditFile,
};

export const findInSheet = {
label: 'Find in current sheet',
};
export const findInSheets = {
label: 'Find in all sheets',
};

export const resizeColumnAction = {
label: 'Resize column to fit data',
isAvailable: isAvailableBecauseCanEditFile,
Expand Down
128 changes: 128 additions & 0 deletions quadratic-client/src/app/actions/actions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
export enum Action {
FileDownload = 'file_download',
FileShare = 'file_share',
FileRename = 'file_rename',
InsertCodePython = 'insert_code_python',
InsertCodeJavascript = 'insert_code_javascript',
InsertCodeFormula = 'insert_code_formula',
InsertSheet = 'insert_sheet',
InsertChartPython = 'insert_chart_python',
InsertChartJavascript = 'insert_chart_javascript',
InsertApiRequestJavascript = 'insert_api_request_javascript',
InsertApiRequestPython = 'insert_api_request_python',
InsertCheckbox = 'insert_checkbox',
InsertDropdown = 'insert_dropdown',
ToggleDataValidation = 'toggle_data_validation',
Copy = 'copy',
Cut = 'cut',
Paste = 'paste',
PasteValuesOnly = 'paste_values_only',
PasteFormattingOnly = 'paste_formatting_only',
FindInCurrentSheet = 'find_in_current_sheet',
FindInAllSheets = 'find_in_all_sheets',
HelpContactUs = 'help_contact_us',
HelpDocs = 'help_docs',
HelpFeedback = 'help_feedback',
FormatAlignHorizontalCenter = 'format_align_horizontal_center',
FormatAlignHorizontalLeft = 'format_align_horizontal_left',
FormatAlignHorizontalRight = 'format_align_horizontal_right',
FormatAlignVerticalBottom = 'format_align_vertical_bottom',
FormatAlignVerticalMiddle = 'format_align_vertical_middle',
FormatAlignVerticalTop = 'format_align_vertical_top',
FormatNumberAutomatic = 'format_number_automatic',
FormatNumberCurrency = 'format_number_currency',
FormatNumberDecimalDecrease = 'format_number_decimal_decrease',
FormatNumberDecimalIncrease = 'format_number_decimal_increase',
FormatNumberPercent = 'format_number_percent',
FormatNumberScientific = 'format_number_scientific',
FormatNumberToggleCommas = 'format_number_toggle_commas',
FormatDateTime = 'format_date_time',
FormatTextWrapClip = 'format_text_wrap_clip',
FormatTextWrapOverflow = 'format_text_wrap_overflow',
FormatTextWrapWrap = 'format_text_wrap_wrap',
FormatTextColor = 'format_text_color',
FormatFillColor = 'format_fill_color',
FormatBorderAll = 'format_border_all',
FormatBorderOuter = 'format_border_outer',
FormatBorderInner = 'format_border_inner',
FormatBorderVertical = 'format_border_vertical',
FormatBorderHorizontal = 'format_border_horizontal',
FormatBorderLeft = 'format_border_left',
FormatBorderRight = 'format_border_right',
FormatBorderTop = 'format_border_top',
FormatBorderBottom = 'format_border_bottom',
FormatBorderClear = 'format_border_clear',
FormatBorderLine1 = 'format_border_line1',
FormatBorderLine2 = 'format_border_line2',
FormatBorderLine3 = 'format_border_line3',
FormatBorderDashed = 'format_border_dashed',
FormatBorderDotted = 'format_border_dotted',
FormatBorderDouble = 'format_border_double',
FormatBorderColor = 'format_border_color',
GridPanMode = 'grid_pan_mode',
ShowCommandPalette = 'show_command_palette',
TogglePresentationMode = 'toggle_presentation_mode',
CloseOverlay = 'close_overlay',
ShowGoToMenu = 'show_go_to_menu',
ZoomIn = 'zoom_in',
ZoomOut = 'zoom_out',
ZoomToSelection = 'zoom_to_selection',
ZoomToFit = 'zoom_to_fit',
ZoomTo50 = 'zoom_to_50',
ZoomTo100 = 'zoom_to_100',
ZoomTo200 = 'zoom_to_200',
Save = 'save',
SwitchSheetNext = 'switch_sheet_next',
SwitchSheetPrevious = 'switch_sheet_previous',
ClearFormattingBorders = 'clear_formatting_borders',
ToggleBold = 'toggle_bold',
ToggleItalic = 'toggle_italic',
FillRight = 'fill_right',
FillDown = 'fill_down',
CancelExecution = 'cancel_execution',
CopyAsPng = 'copy_as_png',
DownloadAsCsv = 'download_as_csv',
Undo = 'undo',
Redo = 'redo',
SelectAll = 'select_all',
SelectColumn = 'select_column',
SelectRow = 'select_row',
ExecuteCode = 'execute_code',
RerunSheetCode = 'rerun_sheet_code',
RerunAllCode = 'rerun_all_code',
InsertCellReference = 'insert_cell_reference',
MoveCursorUp = 'move_cursor_up',
JumpCursorContentTop = 'jump_cursor_content_top',
ExpandSelectionUp = 'expand_selection_up',
ExpandSelectionContentTop = 'expand_selection_content_top',
MoveCursorDown = 'move_cursor_down',
JumpCursorContentBottom = 'jump_cursor_content_bottom',
ExpandSelectionDown = 'expand_selection_down',
ExpandSelectionContentBottom = 'expand_selection_content_bottom',
MoveCursorLeft = 'move_cursor_left',
JumpCursorContentLeft = 'jump_cursor_content_left',
ExpandSelectionLeft = 'expand_selection_left',
ExpandSelectionContentLeft = 'expand_selection_content_left',
MoveCursorRight = 'move_cursor_right',
JumpCursorContentRight = 'jump_cursor_content_right',
ExpandSelectionRight = 'expand_selection_right',
ExpandSelectionContentRight = 'expand_selection_content_right',
GotoA0 = 'goto_A0',
GotoBottomRight = 'goto_bottom_right',
GotoRowStart = 'goto_row_start',
GotoRowEnd = 'goto_row_end',
PageUp = 'page_up',
PageDown = 'page_down',
MoveCursorRightWithSelection = 'move_cursor_right_with_selection',
MoveCursorLeftWithSelection = 'move_cursor_left_with_selection',
EditCell = 'edit_cell',
DeleteCell = 'delete_cell',
ShowCellTypeMenu = 'show_cell_type_menu',
CloseInlineEditor = 'close_inline_editor',
SaveInlineEditor = 'save_inline_editor',
SaveInlineEditorMoveUp = 'save_inline_editor_move_up',
SaveInlineEditorMoveRight = 'save_inline_editor_move_right',
SaveInlineEditorMoveLeft = 'save_inline_editor_move_left',
RemoveInsertedCells = 'remove_inserted_cells',
TriggerCell = 'trigger_cell',
}
53 changes: 53 additions & 0 deletions quadratic-client/src/app/actions/actionsSpec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Note: this is a new pattern that should replace the old `actions.ts` file
import { Action } from '@/app/actions/actions';
import { FileActionArgs } from '@/app/actions/fileActionsSpec';
import { FormatActionArgs } from '@/app/actions/formatActionsSpec';
import { IconComponent } from '@/shared/components/Icons';
import { ApiTypes, FilePermission, TeamPermission } from 'quadratic-shared/typesAndSchemas';

/**
* Every action _may_ have an `isAvailable` key.
*
* If it doesn’t have that key, that means the action is available to any user.
*
* If it does have that key, that means that function _must_ be run to determine
* whether that action (and its associated shortcuts) should be available to the
* current user.
*/
export type ActionAvailabilityArgs = {
filePermissions: FilePermission[];
isAuthenticated: boolean;
teamPermissions: TeamPermission[] | undefined;
fileTeamPrivacy: ApiTypes['/v0/files/:uuid.GET.response']['userMakingRequest']['fileTeamPrivacy'];
};

/**
* Shared types for actions in the app that can be used across multiple locations,
* e.g. the sidebar, command palette, file menu, and formatting bar.
*/
export type ActionSpec<ActionArgsType> = {
label: string;
run: (args: ActionArgsType) => void;

// Used for contexts where we want to show a longer label
labelVerbose?: string;

// We make this a reference to a component, so it must be called where it's used
// allow us to pass additional props depending on context, e.g.
//
// ```
// const { Icon } = action;
// return `<Icon className="custom-style-class" />`
// ```
Icon?: IconComponent;
isAvailable?: (args: ActionAvailabilityArgs) => boolean;
// Used for command palette search
keywords?: string[];
};

export type ActionSpecRecord = {
[K in Action]: ActionSpec<K extends keyof ActionArgs ? ActionArgs[K] : void>;
};

// Define the possible argument types for each action
export type ActionArgs = FileActionArgs & FormatActionArgs;
Loading
Loading