Apply new eslint rules; default to prettier for styling
This commit is contained in:
parent
f22cce8881
commit
dc84af9937
218 changed files with 3876 additions and 3564 deletions
|
@ -35,17 +35,19 @@ const flashes: FlashStore = {
|
|||
} else {
|
||||
console.error(payload.error);
|
||||
|
||||
state.items = [ {
|
||||
type: 'error',
|
||||
title: 'Error',
|
||||
key: payload.key,
|
||||
message: httpErrorToHuman(payload.error),
|
||||
} ];
|
||||
state.items = [
|
||||
{
|
||||
type: 'error',
|
||||
title: 'Error',
|
||||
key: payload.key,
|
||||
message: httpErrorToHuman(payload.error),
|
||||
},
|
||||
];
|
||||
}
|
||||
}),
|
||||
|
||||
clearFlashes: action((state, payload) => {
|
||||
state.items = payload ? state.items.filter(flashes => flashes.key !== payload) : [];
|
||||
state.items = payload ? state.items.filter((flashes) => flashes.key !== payload) : [];
|
||||
}),
|
||||
};
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ const progress: ProgressStore = {
|
|||
continuous: false,
|
||||
progress: undefined,
|
||||
|
||||
startContinuous: action(state => {
|
||||
startContinuous: action((state) => {
|
||||
state.continuous = true;
|
||||
}),
|
||||
|
||||
|
@ -21,7 +21,7 @@ const progress: ProgressStore = {
|
|||
state.progress = payload;
|
||||
}),
|
||||
|
||||
setComplete: action(state => {
|
||||
setComplete: action((state) => {
|
||||
if (state.progress) {
|
||||
state.progress = 100;
|
||||
}
|
||||
|
|
|
@ -16,15 +16,15 @@ const databases: ServerDatabaseStore = {
|
|||
}),
|
||||
|
||||
appendDatabase: action((state, payload) => {
|
||||
if (state.data.find(database => database.id === payload.id)) {
|
||||
state.data = state.data.map(database => database.id === payload.id ? payload : database);
|
||||
if (state.data.find((database) => database.id === payload.id)) {
|
||||
state.data = state.data.map((database) => (database.id === payload.id ? payload : database));
|
||||
} else {
|
||||
state.data = [ ...state.data, payload ];
|
||||
state.data = [...state.data, payload];
|
||||
}
|
||||
}),
|
||||
|
||||
removeDatabase: action((state, payload) => {
|
||||
state.data = [ ...state.data.filter(database => database.id !== payload) ];
|
||||
state.data = [...state.data.filter((database) => database.id !== payload)];
|
||||
}),
|
||||
};
|
||||
|
||||
|
|
|
@ -24,11 +24,11 @@ const files: ServerFileStore = {
|
|||
}),
|
||||
|
||||
appendSelectedFile: action((state, payload) => {
|
||||
state.selectedFiles = state.selectedFiles.filter(f => f !== payload).concat(payload);
|
||||
state.selectedFiles = state.selectedFiles.filter((f) => f !== payload).concat(payload);
|
||||
}),
|
||||
|
||||
removeSelectedFile: action((state, payload) => {
|
||||
state.selectedFiles = state.selectedFiles.filter(f => f !== payload);
|
||||
state.selectedFiles = state.selectedFiles.filter((f) => f !== payload);
|
||||
}),
|
||||
};
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ interface ServerDataStore {
|
|||
const server: ServerDataStore = {
|
||||
permissions: [],
|
||||
|
||||
inConflictState: computed(state => {
|
||||
inConflictState: computed((state) => {
|
||||
if (!state.data) {
|
||||
return false;
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ const server: ServerDataStore = {
|
|||
}),
|
||||
|
||||
getServer: thunk(async (actions, payload) => {
|
||||
const [ server, permissions ] = await getServer(payload);
|
||||
const [server, permissions] = await getServer(payload);
|
||||
|
||||
actions.setServer(server);
|
||||
actions.setPermissions(permissions);
|
||||
|
@ -82,34 +82,37 @@ export interface ServerStore {
|
|||
clearServerState: Action<ServerStore>;
|
||||
}
|
||||
|
||||
export const ServerContext = createContextStore<ServerStore>({
|
||||
server,
|
||||
socket,
|
||||
status,
|
||||
databases,
|
||||
files,
|
||||
subusers,
|
||||
schedules,
|
||||
clearServerState: action(state => {
|
||||
state.server.data = undefined;
|
||||
state.server.permissions = [];
|
||||
state.databases.data = [];
|
||||
state.subusers.data = [];
|
||||
state.files.directory = '/';
|
||||
state.files.selectedFiles = [];
|
||||
state.schedules.data = [];
|
||||
export const ServerContext = createContextStore<ServerStore>(
|
||||
{
|
||||
server,
|
||||
socket,
|
||||
status,
|
||||
databases,
|
||||
files,
|
||||
subusers,
|
||||
schedules,
|
||||
clearServerState: action((state) => {
|
||||
state.server.data = undefined;
|
||||
state.server.permissions = [];
|
||||
state.databases.data = [];
|
||||
state.subusers.data = [];
|
||||
state.files.directory = '/';
|
||||
state.files.selectedFiles = [];
|
||||
state.schedules.data = [];
|
||||
|
||||
if (state.socket.instance) {
|
||||
state.socket.instance.removeAllListeners();
|
||||
state.socket.instance.close();
|
||||
}
|
||||
if (state.socket.instance) {
|
||||
state.socket.instance.removeAllListeners();
|
||||
state.socket.instance.close();
|
||||
}
|
||||
|
||||
state.socket.instance = null;
|
||||
state.socket.connected = false;
|
||||
}),
|
||||
}, {
|
||||
compose: composeWithDevTools({
|
||||
name: 'ServerStore',
|
||||
trace: true,
|
||||
}),
|
||||
});
|
||||
state.socket.instance = null;
|
||||
state.socket.connected = false;
|
||||
}),
|
||||
},
|
||||
{
|
||||
compose: composeWithDevTools({
|
||||
name: 'ServerStore',
|
||||
trace: true,
|
||||
}),
|
||||
}
|
||||
);
|
||||
|
|
|
@ -16,15 +16,15 @@ const schedules: ServerScheduleStore = {
|
|||
}),
|
||||
|
||||
appendSchedule: action((state, payload) => {
|
||||
if (state.data.find(schedule => schedule.id === payload.id)) {
|
||||
state.data = state.data.map(schedule => schedule.id === payload.id ? payload : schedule);
|
||||
if (state.data.find((schedule) => schedule.id === payload.id)) {
|
||||
state.data = state.data.map((schedule) => (schedule.id === payload.id ? payload : schedule));
|
||||
} else {
|
||||
state.data = [ ...state.data, payload ];
|
||||
state.data = [...state.data, payload];
|
||||
}
|
||||
}),
|
||||
|
||||
removeSchedule: action((state, payload) => {
|
||||
state.data = [ ...state.data.filter(schedule => schedule.id !== payload) ];
|
||||
state.data = [...state.data.filter((schedule) => schedule.id !== payload)];
|
||||
}),
|
||||
};
|
||||
|
||||
|
|
|
@ -1,15 +1,34 @@
|
|||
import { action, Action } from 'easy-peasy';
|
||||
|
||||
export type SubuserPermission =
|
||||
'websocket.connect' |
|
||||
'control.console' | 'control.start' | 'control.stop' | 'control.restart' |
|
||||
'user.create' | 'user.read' | 'user.update' | 'user.delete' |
|
||||
'file.create' | 'file.read' | 'file.update' | 'file.delete' | 'file.archive' | 'file.sftp' |
|
||||
'allocation.read' | 'allocation.update' |
|
||||
'startup.read' | 'startup.update' |
|
||||
'database.create' | 'database.read' | 'database.update' | 'database.delete' | 'database.view_password' |
|
||||
'schedule.create' | 'schedule.read' | 'schedule.update' | 'schedule.delete'
|
||||
;
|
||||
| 'websocket.connect'
|
||||
| 'control.console'
|
||||
| 'control.start'
|
||||
| 'control.stop'
|
||||
| 'control.restart'
|
||||
| 'user.create'
|
||||
| 'user.read'
|
||||
| 'user.update'
|
||||
| 'user.delete'
|
||||
| 'file.create'
|
||||
| 'file.read'
|
||||
| 'file.update'
|
||||
| 'file.delete'
|
||||
| 'file.archive'
|
||||
| 'file.sftp'
|
||||
| 'allocation.read'
|
||||
| 'allocation.update'
|
||||
| 'startup.read'
|
||||
| 'startup.update'
|
||||
| 'database.create'
|
||||
| 'database.read'
|
||||
| 'database.update'
|
||||
| 'database.delete'
|
||||
| 'database.view_password'
|
||||
| 'schedule.create'
|
||||
| 'schedule.read'
|
||||
| 'schedule.update'
|
||||
| 'schedule.delete';
|
||||
|
||||
export interface Subuser {
|
||||
uuid: string;
|
||||
|
@ -20,7 +39,7 @@ export interface Subuser {
|
|||
createdAt: Date;
|
||||
permissions: SubuserPermission[];
|
||||
|
||||
can (permission: SubuserPermission): boolean;
|
||||
can(permission: SubuserPermission): boolean;
|
||||
}
|
||||
|
||||
export interface ServerSubuserStore {
|
||||
|
@ -41,7 +60,7 @@ const subusers: ServerSubuserStore = {
|
|||
let matched = false;
|
||||
state.data = [
|
||||
...state.data
|
||||
.map(user => {
|
||||
.map((user) => {
|
||||
if (user.uuid === payload.uuid) {
|
||||
matched = true;
|
||||
|
||||
|
@ -50,12 +69,12 @@ const subusers: ServerSubuserStore = {
|
|||
|
||||
return user;
|
||||
})
|
||||
.concat(matched ? [] : [ payload ]),
|
||||
.concat(matched ? [] : [payload]),
|
||||
];
|
||||
}),
|
||||
|
||||
removeSubuser: action((state, payload) => {
|
||||
state.data = [ ...state.data.filter(user => user.uuid !== payload) ];
|
||||
state.data = [...state.data.filter((user) => user.uuid !== payload)];
|
||||
}),
|
||||
};
|
||||
|
||||
|
|
Reference in a new issue