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

Issue #255 Add open capability to connectors #227

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions packages/connector-google-drive-v2/src/capabilities/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import download from './download';
import upload from './upload';
import rename from './rename';
import sort from './sort';
import open from './open';

const capabilities = [
open,
createFolder,
rename,
download,
Expand Down
36 changes: 36 additions & 0 deletions packages/connector-google-drive-v2/src/capabilities/open.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import api from '../api';
import sanitizeFilename from 'sanitize-filename';
import icons from '../icons-svg';
import getMess from '../translations';

let label = 'open';

function handler(apiOptions, actions) {
const {
navigateToDir,
getSelectedResources
} = actions;

const selectedResources = getSelectedResources();
const selectedResourceId = selectedResources[0].id;
navigateToDir(selectedResourceId)
}

export default (apiOptions, actions) => {
const localeLabel = getMess(apiOptions.locale, label);
const { getSelectedResources } = actions;
return {
id: label,
icon: { svg: icons.open },
label: localeLabel,
shouldBeAvailable: (apiOptions) => {
let selectedResources = getSelectedResources();
return (
selectedResources.length === 1 &&
selectedResources[0].type === 'dir'
);
},
availableInContexts: ['row', 'toolbar'],
handler: () => handler(apiOptions, actions)
};
}
2 changes: 2 additions & 0 deletions packages/connector-node-v1/src/capabilities/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import download from './download';
import upload from './upload';
import rename from './rename';
import sort from './sort';
import open from './open';

const capabilities = [
open,
createFolder,
rename,
download,
Expand Down
36 changes: 36 additions & 0 deletions packages/connector-node-v1/src/capabilities/open.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import api from '../api';
import sanitizeFilename from 'sanitize-filename';
import icons from '../icons-svg';
import getMess from '../translations';

let label = 'open';

function handler(apiOptions, actions) {
const {
navigateToDir,
getSelectedResources
} = actions;

const selectedResources = getSelectedResources();
const selectedResourceId = selectedResources[0].id;
navigateToDir(selectedResourceId)
}

export default (apiOptions, actions) => {
const localeLabel = getMess(apiOptions.locale, label);
const { getSelectedResources } = actions;
return {
id: label,
icon: { svg: icons.open },
label: localeLabel,
shouldBeAvailable: (apiOptions) => {
let selectedResources = getSelectedResources();
return (
selectedResources.length === 1 &&
selectedResources[0].type === 'dir'
);
},
availableInContexts: ['row', 'toolbar'],
handler: () => handler(apiOptions, actions)
};
}
1 change: 1 addition & 0 deletions packages/connector-node-v1/src/icons-svg.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions packages/connector-node-v1/src/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const translations = {
remove: 'Remove',
download: 'Download',
rename: 'Rename',
open: 'Open',
creating: 'Creating',
creatingName: 'Creating {name}...',
create: 'Create',
Expand Down Expand Up @@ -40,6 +41,7 @@ const translations = {
remove: 'Löschen',
download: 'Herunterladen',
rename: 'Umbenennen',
open: 'Öffnen',
creating: 'Wird erstellt',
creatingName: '{name} wird angelegt...',
create: 'Erstellen',
Expand Down Expand Up @@ -71,6 +73,7 @@ const translations = {
remove: 'Poista',
download: 'Lataa',
rename: 'Nimeä uudelleen',
open: 'Avata',
creating: 'Luodaan',
creatingName: 'Luodaan {name}...',
create: 'Luo',
Expand Down Expand Up @@ -104,6 +107,7 @@ const translations = {
remove: 'Fjern',
download: 'Last ned',
rename: 'Gi nytt navn',
open: 'Åpen',
creating: 'Opprette',
creatingName: 'Opprette {name}...',
create: 'Opprett',
Expand Down Expand Up @@ -137,6 +141,7 @@ const translations = {
remove: 'Remove',
download: 'Загрузить',
rename: 'Переименовать',
open: 'Открытый',
creating: 'Создание',
creatingName: 'Создание {name}...',
create: 'Создать',
Expand Down Expand Up @@ -170,6 +175,7 @@ const translations = {
remove: 'Ta bort',
download: 'Hämta',
rename: 'Ändra namn',
open: 'Öppen',
creating: 'Skapar',
creatingName: 'Skapar {name}...',
create: 'Skapa',
Expand Down